diff --git a/include/os/freebsd/spl/sys/ccompile.h b/include/os/freebsd/spl/sys/ccompile.h index f9b09d4304..4dda0756f3 100644 --- a/include/os/freebsd/spl/sys/ccompile.h +++ b/include/os/freebsd/spl/sys/ccompile.h @@ -160,11 +160,13 @@ extern "C" { #define KMALLOC_MAX_SIZE MAXPHYS #ifdef _KERNEL +#if !defined(LOCORE) && !defined(_ASM) typedef unsigned long long u_longlong_t; typedef long long longlong_t; -#include + typedef void zfs_kernel_param_t; +#endif #define param_set_charp(a, b) (0) #define ATTR_UID AT_UID #define ATTR_GID AT_GID @@ -179,6 +181,9 @@ typedef void zfs_kernel_param_t; #define MUTEX_NOLOCKDEP 0 #define RW_NOLOCKDEP 0 +#if !defined(LOCORE) && !defined(_ASM) +#include +#include #if __FreeBSD_version < 1300051 #define vm_page_valid(m) (m)->valid = VM_PAGE_BITS_ALL @@ -207,7 +212,6 @@ typedef void zfs_kernel_param_t; #else #define getnewvnode_reserve_() getnewvnode_reserve(1) #endif - struct hlist_node { struct hlist_node *next, **pprev; }; @@ -288,7 +292,7 @@ atomic_dec(atomic_t *v) { return (atomic_fetchadd_int(&v->counter, -1) - 1); } - +#endif #else typedef long loff_t; typedef long rlim64_t; diff --git a/include/os/freebsd/spl/sys/condvar.h b/include/os/freebsd/spl/sys/condvar.h index 4375bd6a31..2e99a1a34e 100644 --- a/include/os/freebsd/spl/sys/condvar.h +++ b/include/os/freebsd/spl/sys/condvar.h @@ -35,7 +35,6 @@ #include #include #include -#include /* * cv_timedwait() is similar to cv_wait() except that it additionally expects diff --git a/include/os/freebsd/spl/sys/file.h b/include/os/freebsd/spl/sys/file.h index 10a82c2048..0d0be44f8a 100644 --- a/include/os/freebsd/spl/sys/file.h +++ b/include/os/freebsd/spl/sys/file.h @@ -29,6 +29,8 @@ #ifndef _OPENSOLARIS_SYS_FILE_H_ #define _OPENSOLARIS_SYS_FILE_H_ +#include +#include_next #include_next #define FKIOCTL 0x80000000 /* ioctl addresses are from kernel */ diff --git a/include/os/freebsd/spl/sys/mount.h b/include/os/freebsd/spl/sys/mount.h index 4732d283bb..42614e4739 100644 --- a/include/os/freebsd/spl/sys/mount.h +++ b/include/os/freebsd/spl/sys/mount.h @@ -31,8 +31,9 @@ #include #include_next +#ifdef BUILDING_ZFS #include - +#endif #define MS_FORCE MNT_FORCE #define MS_REMOUNT MNT_UPDATE diff --git a/include/os/freebsd/spl/sys/sunddi.h b/include/os/freebsd/spl/sys/sunddi.h index bb76cd9641..41d0f45129 100644 --- a/include/os/freebsd/spl/sys/sunddi.h +++ b/include/os/freebsd/spl/sys/sunddi.h @@ -29,7 +29,9 @@ #include #include #include +#ifdef BUILDING_ZFS #include +#endif typedef int ddi_devid_t; diff --git a/module/Makefile.bsd b/module/Makefile.bsd index a46b920513..7c83113ac8 100644 --- a/module/Makefile.bsd +++ b/module/Makefile.bsd @@ -331,6 +331,7 @@ CFLAGS.fm.c= -Wno-cast-qual CFLAGS.lz4.c= -Wno-cast-qual CFLAGS.spa.c= -Wno-cast-qual CFLAGS.spa_misc.c= -Wno-cast-qual +CFLAGS.sysctl_os.c= -include ../zfs_config.h CFLAGS.vdev_raidz.c= -Wno-cast-qual CFLAGS.vdev_raidz_math.c= -Wno-cast-qual CFLAGS.vdev_raidz_math_scalar.c= -Wno-cast-qual diff --git a/module/os/freebsd/spl/spl_misc.c b/module/os/freebsd/spl/spl_misc.c index ab4702574b..8d33916d85 100644 --- a/module/os/freebsd/spl/spl_misc.c +++ b/module/os/freebsd/spl/spl_misc.c @@ -34,15 +34,24 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include -char hw_serial[11] = "0"; - static struct opensolaris_utsname hw_utsname = { .machine = MACHINE }; +#ifndef KERNEL_STATIC +char hw_serial[11] = "0"; + +utsname_t * +utsname(void) +{ + return (&hw_utsname); +} +#endif + static void opensolaris_utsname_init(void *arg) { @@ -98,10 +107,6 @@ spl_panic(const char *file, const char *func, int line, const char *fmt, ...) va_end(ap); } -utsname_t * -utsname(void) -{ - return (&hw_utsname); -} + SYSINIT(opensolaris_utsname_init, SI_SUB_TUNABLES, SI_ORDER_ANY, opensolaris_utsname_init, NULL); diff --git a/module/os/freebsd/spl/spl_sysevent.c b/module/os/freebsd/spl/spl_sysevent.c index d3748276a7..4bb0658c87 100644 --- a/module/os/freebsd/spl/spl_sysevent.c +++ b/module/os/freebsd/spl/spl_sysevent.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/module/os/freebsd/zfs/arc_os.c b/module/os/freebsd/zfs/arc_os.c index 23b580c437..87e517b58b 100644 --- a/module/os/freebsd/zfs/arc_os.c +++ b/module/os/freebsd/zfs/arc_os.c @@ -44,6 +44,7 @@ #include #include #include +#include #include extern struct vfsops zfs_vfsops; diff --git a/module/os/freebsd/zfs/sysctl_os.c b/module/os/freebsd/zfs/sysctl_os.c index 6d5c88e21c..54b62f2485 100644 --- a/module/os/freebsd/zfs/sysctl_os.c +++ b/module/os/freebsd/zfs/sysctl_os.c @@ -90,7 +90,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include <../zfs_config.h> /* BEGIN CSTYLED */ SYSCTL_DECL(_vfs_zfs); @@ -124,10 +123,11 @@ SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, cache, CTLFLAG_RW, 0, "ZFS VDEV Cache"); SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, mirror, CTLFLAG_RD, 0, "ZFS VDEV mirror"); +#ifdef ZFS_META_VERSION SYSCTL_DECL(_vfs_zfs_version); SYSCTL_CONST_STRING(_vfs_zfs_version, OID_AUTO, module, CTLFLAG_RD, (ZFS_META_VERSION "-" ZFS_META_RELEASE), "OpenZFS module version"); - +#endif extern arc_state_t ARC_anon; extern arc_state_t ARC_mru; extern arc_state_t ARC_mru_ghost; diff --git a/module/os/freebsd/zfs/vdev_file.c b/module/os/freebsd/zfs/vdev_file.c index 01851378e7..cca6bffd92 100644 --- a/module/os/freebsd/zfs/vdev_file.c +++ b/module/os/freebsd/zfs/vdev_file.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/module/os/freebsd/zfs/vdev_geom.c b/module/os/freebsd/zfs/vdev_geom.c index 69a73103c4..8462755f82 100644 --- a/module/os/freebsd/zfs/vdev_geom.c +++ b/module/os/freebsd/zfs/vdev_geom.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/module/zfs/spa_config.c b/module/zfs/spa_config.c index 3a65b0bb43..b30c65e71e 100644 --- a/module/zfs/spa_config.c +++ b/module/zfs/spa_config.c @@ -27,6 +27,7 @@ */ #include +#include #include #include #include