From 6f763d408530c5dd22e4e8616235871524e55529 Mon Sep 17 00:00:00 2001 From: Matthew Macy Date: Tue, 11 Aug 2020 13:49:50 -0700 Subject: FreeBSD: Fix module autoloading when built in base The KMOD name is "zfs" instead of "openzfs" when building in FreeBSD. Define a ZFS_KMOD symbol as "zfs" when IN_BASE is defined, otherwise "openzfs". Reviewed-by: Brian Behlendorf Co-authored-by: Ryan Moeller Signed-off-by: Ryan Moeller Closes #10699 --- lib/libzfs/os/freebsd/libzfs_compat.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/libzfs/os/freebsd/libzfs_compat.c b/lib/libzfs/os/freebsd/libzfs_compat.c index a4643ef08..037ba56ef 100644 --- a/lib/libzfs/os/freebsd/libzfs_compat.c +++ b/lib/libzfs/os/freebsd/libzfs_compat.c @@ -33,6 +33,12 @@ #include #include +#ifdef IN_BASE +#define ZFS_KMOD "zfs" +#else +#define ZFS_KMOD "openzfs" +#endif + void libzfs_set_pipe_max(int infd) { @@ -195,10 +201,14 @@ zfs_ioctl(libzfs_handle_t *hdl, int request, zfs_cmd_t *zc) int libzfs_load_module(void) { - /* XXX: modname is "zfs" but file is named "openzfs". */ + /* + * XXX: kldfind(ZFS_KMOD) would be nice here, but we retain + * modfind("zfs") so out-of-base openzfs userland works with the + * in-base module. + */ if (modfind("zfs") < 0) { /* Not present in kernel, try loading it. */ - if (kldload("openzfs") < 0 && errno != EEXIST) { + if (kldload(ZFS_KMOD) < 0 && errno != EEXIST) { return (errno); } } -- cgit v1.2.3