Skip to content

Commit

Permalink
FreeBSD: Fix module autoloading when built in base
Browse files Browse the repository at this point in the history
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 openzfs#10699
  • Loading branch information
mattmacy authored and jsai20 committed Mar 30, 2021
1 parent 250bd22 commit 7595aa8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/libzfs/os/freebsd/libzfs_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 7595aa8

Please sign in to comment.