aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatthew Macy <[email protected]>2020-08-11 13:49:50 -0700
committerGitHub <[email protected]>2020-08-11 13:49:50 -0700
commit6f763d408530c5dd22e4e8616235871524e55529 (patch)
tree2cce1d67fbf637996e429079d062945ad584f67b /lib
parentd817c17100183b266aa6bf8b868e016805d51d16 (diff)
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 <[email protected]> Co-authored-by: Ryan Moeller <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #10699
Diffstat (limited to 'lib')
-rw-r--r--lib/libzfs/os/freebsd/libzfs_compat.c14
1 files 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 <sys/stat.h>
#include <sys/param.h>
+#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);
}
}