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 <behlendorf1@llnl.gov>
Co-authored-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10699
This commit is contained in:
Matthew Macy 2020-08-11 13:49:50 -07:00 committed by GitHub
parent d817c17100
commit 6f763d4085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,12 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/param.h> #include <sys/param.h>
#ifdef IN_BASE
#define ZFS_KMOD "zfs"
#else
#define ZFS_KMOD "openzfs"
#endif
void void
libzfs_set_pipe_max(int infd) libzfs_set_pipe_max(int infd)
{ {
@ -195,10 +201,14 @@ zfs_ioctl(libzfs_handle_t *hdl, int request, zfs_cmd_t *zc)
int int
libzfs_load_module(void) 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) { if (modfind("zfs") < 0) {
/* Not present in kernel, try loading it. */ /* Not present in kernel, try loading it. */
if (kldload("openzfs") < 0 && errno != EEXIST) { if (kldload(ZFS_KMOD) < 0 && errno != EEXIST) {
return (errno); return (errno);
} }
} }