⬢ DragonFlyBSD Kernel Audit
DF-3218 / vkmount.c
← back to finding ↓ download raw
#include <sys/mount.h>
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

/*
 * vkmount: call mount(2) directly for dirfs, bypassing mount(8)'s
 * helper-binary lookup.  Usage: vkmount <hostpath> <guestdir>
 *   mount("dirfs", dir, 0, hostpath)  -> dirfs_mount copyinstr(data)
 */
int
main(int ac, char **av)
{
	if (ac != 3) {
		fprintf(stderr, "usage: %s hostpath guestdir\n", av[0]);
		exit(1);
	}
	if (mount("dirfs", av[2], 0, av[1]) < 0) {
		fprintf(stderr, "mount failed: %s\n", strerror(errno));
		exit(1);
	}
	printf("dirfs mounted: %s -> %s\n", av[1], av[2]);
	return (0);
}