⬢ DragonFlyBSD Kernel Audit
DF-3241 / getfh.c
← back to finding ↓ download raw
/*
 * DF-3241 helper: capture an fhandle_t for a path (root).
 * Usage: ./getfh /mnt > fh.bin
 */
#include <sys/param.h>
#include <sys/mount.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <err.h>

int
main(int argc, char **argv)
{
	fhandle_t fh;

	if (argc != 2)
		errx(1, "usage: getfh path");
	if (getfh(argv[1], &fh) < 0)
		err(1, "getfh(%s)", argv[1]);
	if (fwrite(&fh, sizeof(fh), 1, stdout) != 1)
		err(1, "fwrite");
	return (0);
}