⬢ DragonFlyBSD Kernel Audit
DF-5755 / mountdbg.c
← back to finding ↓ download raw
/* debug helper: mount kiconv, leave mounted; print statfs proof */
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/iconv.h>
#include <sys/stat.h>
#include <vfs/msdosfs/msdosfsmount.h>
#include <err.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int
main(int argc, char **argv)
{
	struct msdosfs_args args;
	struct statfs st;

	if (argc != 3)
		errx(1, "usage: %s <dev> <dir>", argv[0]);
	memset(&args, 0, sizeof(args));
	args.fspec = argv[1];
	args.uid = 0;
	args.gid = 0;
	args.mask = 0777 & ALLPERMS;
	args.dirmask = 0777 & ALLPERMS;
	args.flags = MSDOSFSMNT_KICONV | MSDOSFSMNT_LONGNAME;
	strlcpy(args.cs_local, "UTF-8", sizeof(args.cs_local));
	strlcpy(args.cs_dos, "UTF-8", sizeof(args.cs_dos));
	if (mount("msdos", argv[2], 0, &args) < 0)
		err(1, "mount");
	if (statfs(argv[2], &st) == 0)
		printf("[+] mounted, f_mntfromname=%s\n", st.f_mntfromname);
	return 0;
}