https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=289655
--- Comment #2 from [email protected] --- Just the Makefile: ``` PROG= libzfs_demo MAN= SRCS= main.c CFLAGS+= -O0 -g -pipe -DRACONIC ZFS_INCDIRS+= contrib/openzfs/include ZFS_INCDIRS+= contrib/openzfs/lib/libspl/include/ ZFS_INCDIRS+= contrib/openzfs/lib/libspl/include/os/freebsd ZFS_INCDIRS+= contrib/cddl/compat/opensolaris/include ZFS_INCDIRS+= contrib/openzfs/module/icp/include .for zfs_incdir in ${ZFS_INCDIRS} CFLAGS+= -I$(.CURDIR)/$(zfs_incdir) .endfor LDFLAGS+= -lzfs .include <bsd.prog.mk> ``` The main.c: ``` #include <sys/dtrace.h> #include <vm/vm.h> typedef long long hrtime_t; #include <libzfs_core.h> #include <libzfs.h> #include <err.h> #include <errno.h> static libzfs_handle_t *lib_handle = NULL; static void close_libzfs(void) { if (lib_handle != NULL) { libzfs_fini(lib_handle); } } static libzfs_handle_t * open_libzfs(void) { if (lib_handle != NULL) { return lib_handle; } lib_handle = libzfs_init(); if (lib_handle == NULL) { errx(1, "%s:%d %s(): Failed to init libzfs: %s", __FILE__, __LINE__, __func__, libzfs_error_init(errno)); } if (atexit(close_libzfs) != 0) { err(1, "%s:%d %s(): Failed to register atexit handler", __FILE__, __LINE__, __func__); } return lib_handle; } int main(int argc, char **argv) { libzfs_handle_t *lib = open_libzfs(); for (int i = 1; i < argc; i++) { const char *name = argv[i]; boolean_t exists = zfs_dataset_exists(lib, name, ZFS_TYPE_FILESYSTEM); printf("name = %s, exists = %s\n", name, exists ? "true" : "false"); } return 0; } ``` To make it work I copied the following files into the contrib directory: - contrib/openzfs/include/sys/avl.h - contrib/openzfs/include/sys/avl_impl.h - contrib/openzfs/include/sys/fs/zfs.h - contrib/openzfs/include/sys/zio_priority.h - contrib/openzfs/lib/libspl/include/libshare.h - contrib/openzfs/lib/libspl/include/os/freebsd/sys/mnttab.h -- You are receiving this mail because: You are the assignee for the bug.
