Skip to content

Commit

Permalink
5: include/* lib/* and top build
Browse files Browse the repository at this point in the history
Bonus part5, the non-macos changes to
include
lib
and the top level Makefiles

Signed-off-by: Jorgen Lundman <[email protected]>
  • Loading branch information
lundman committed Oct 23, 2023
1 parent 553d903 commit d68ad3b
Show file tree
Hide file tree
Showing 57 changed files with 532 additions and 35 deletions.
9 changes: 8 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ if BUILD_LINUX
include $(srcdir)/%D%/rpm/Makefile.am
endif

if BUILD_MACOS
bin_PROGRAMS=
noinst_PROGRAMS=
include $(srcdir)/%D%/module/os/macos/Makefile.am
endif

if CONFIG_USER
include $(srcdir)/%D%/cmd/Makefile.am
include $(srcdir)/%D%/contrib/Makefile.am
Expand Down Expand Up @@ -194,11 +200,12 @@ cscopelist:
PHONY += tags
tags: ctags etags

PHONY += pkg pkg-dkms pkg-kmod pkg-utils
PHONY += pkg pkg-dkms pkg-kmod pkg-utils pkg-macos
pkg: @DEFAULT_PACKAGE@
pkg-dkms: @DEFAULT_PACKAGE@-dkms
pkg-kmod: @DEFAULT_PACKAGE@-kmod
pkg-utils: @DEFAULT_PACKAGE@-utils
pkg-macos: @DEFAULT_PACKAGE@-macos

include config/rpm.am
include config/deb.am
Expand Down
5 changes: 4 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ AM_INIT_AUTOMAKE([subdir-objects foreign])
# Remove default macros from config.h:
# PACKAGE, PACKAGE_{BUGREPORT,NAME,STRING,TARNAME,VERSION}, STDC_HEADERS, VERSION
AC_CONFIG_HEADERS([zfs_config.h], [
sed -nri~ -e '/^$/be' -e 'N;N;/#define (PACKAGE|VERSION|STDC_HEADERS)/d' -e ':e' -e 'p' zfs_config.h && rm zfs_config.h~ || exit])
$SED -nri~ -e '/^$/be' -e 'N;N;/#define (PACKAGE|VERSION|STDC_HEADERS)/d' -e ':e' -e 'p' zfs_config.h && rm zfs_config.h~ || exit])

LT_INIT
AC_PROG_INSTALL
Expand All @@ -55,6 +55,9 @@ AM_PROG_AS
AM_PROG_CC_C_O
AX_CODE_COVERAGE
_AM_PROG_TAR(pax)
AC_PROG_CXX(clang++)
AC_PROG_OBJC(clang)
AC_PROG_OBJCXX(clang++)

ZFS_AC_LICENSE
ZFS_AC_CONFIG
Expand Down
6 changes: 6 additions & 0 deletions etc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,9 @@ dist_modulesload_DATA = \
%D%/modules-load.d/zfs.conf
endif
endif

if BUILD_MACOS
include $(srcdir)/%D%/launchd/Makefile.am
include $(srcdir)/%D%/paths.d/Makefile.am
include $(srcdir)/%D%/launchd.d/Makefile.am
endif
17 changes: 17 additions & 0 deletions include/libzfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ _LIBZFS_H int zpool_enable_datasets(zpool_handle_t *, const char *, int);
_LIBZFS_H int zpool_disable_datasets(zpool_handle_t *, boolean_t);
_LIBZFS_H void zpool_disable_datasets_os(zpool_handle_t *, boolean_t);
_LIBZFS_H void zpool_disable_volume_os(const char *);
_LIBZFS_H void zfs_rollback_os(struct zfs_handle *);

/*
* Parse a features file for -o compatibility
Expand Down Expand Up @@ -1039,9 +1040,25 @@ _LIBZFS_H int zpool_nextboot(libzfs_handle_t *, uint64_t, uint64_t,
* Add or delete the given filesystem to/from the given user namespace.
*/
_LIBZFS_H int zfs_userns(zfs_handle_t *zhp, const char *nspath, int attach);
#endif

#ifdef __APPLE__
_LIBZFS_H int zfs_snapshot_mount(zfs_handle_t *, const char *, int);
_LIBZFS_H int zfs_snapshot_unmount(zfs_handle_t *, int);
/* We moved these from libspl to libzfs to be able to do more */
_LIBZFS_H int getmntent(FILE *, struct mnttab *);
_LIBZFS_H char *hasmntopt(struct mnttab *, const char *);
_LIBZFS_H int getextmntent(const char *, struct extmnttab *,
struct stat64 *);
_LIBZFS_H int do_mount(zfs_handle_t *, const char *, const char *, int);
#endif

/*
* Manual mounting of snapshots.
*/
extern int zfs_snapshot_mount(zfs_handle_t *, const char *, int);
extern int zfs_snapshot_unmount(zfs_handle_t *, int);

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/libzutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ _LIBZUTIL_H void update_vdev_config_dev_strs(nvlist_t *);
* Default device paths
*/
#define DISK_ROOT "/dev"
#ifdef __APPLE__
#define UDISK_ROOT "/private/var/run/disk"
#else
#define UDISK_ROOT "/dev/disk"
#endif
#define ZVOL_ROOT "/dev/zvol"

_LIBZUTIL_H int zfs_append_partition(char *path, size_t max_len);
Expand Down
9 changes: 9 additions & 0 deletions include/os/freebsd/spl/sys/simd_aarch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,13 @@ zfs_sha512_available(void)
return (elf_hwcap & HWCAP_SHA512);
}

/*
* Check if AESV8 is available
*/
static inline boolean_t
zfs_aesv8_available(void)
{
return (elf_hwcap & HWCAP_AES);
}

#endif /* _FREEBSD_SIMD_AARCH64_H */
10 changes: 10 additions & 0 deletions include/os/linux/kernel/linux/simd_aarch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,14 @@ zfs_sha512_available(void)
return (ftr & 0x2);
}

/*
* Check if AESV8 is available
*/
static inline boolean_t
zfs_aesv8_available(void)
{
unsigned long ftr = ((get_ftr(ID_AA64ISAR0_EL1)) >> 4) & 0x3;
return (ftr);
}

#endif /* _LINUX_SIMD_AARCH64_H */
4 changes: 4 additions & 0 deletions include/os/linux/zfs/sys/zfs_context_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@
#undef longjmp
#endif

#ifndef MODULE_PARAM_MAX
#define MODULE_PARAM_MAX 1024
#endif

#endif
9 changes: 8 additions & 1 deletion include/sys/abd.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ typedef struct abd {
union {
struct abd_scatter {
uint_t abd_offset;
#if defined(__FreeBSD__) && defined(_KERNEL)
#if defined(_KERNEL) && (defined(__FreeBSD__) || defined(__APPLE__))
uint_t abd_chunk_size;
void *abd_chunks[1]; /* actually variable-length */
#else
uint_t abd_nents;
Expand Down Expand Up @@ -129,6 +130,7 @@ void abd_copy_off(abd_t *, abd_t *, size_t, size_t, size_t);
void abd_copy_from_buf_off(abd_t *, const void *, size_t, size_t);
void abd_copy_to_buf_off(void *, abd_t *, size_t, size_t);
int abd_cmp(abd_t *, abd_t *);
int abd_cmp_size(abd_t *, abd_t *, size_t);
int abd_cmp_buf_off(abd_t *, const void *, size_t, size_t);
void abd_zero_off(abd_t *, size_t, size_t);
void abd_verify(abd_t *);
Expand Down Expand Up @@ -176,6 +178,11 @@ abd_zero(abd_t *abd, size_t size)
abd_zero_off(abd, 0, size);
}

#ifdef __APPLE__
void abd_return_buf_off(abd_t *, void *, size_t, size_t, size_t);
void abd_return_buf_copy_off(abd_t *, void *, size_t, size_t, size_t);
#endif

/*
* ABD type check functions
*/
Expand Down
3 changes: 3 additions & 0 deletions include/sys/abd_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ void abd_iter_unmap(struct abd_iter *);
#if defined(__FreeBSD__)
#define abd_enter_critical(flags) critical_enter()
#define abd_exit_critical(flags) critical_exit()
#elif defined(__APPLE__)
#define abd_enter_critical(flags) (flags) = ml_set_interrupts_enabled(FALSE)
#define abd_exit_critical(flags) ml_set_interrupts_enabled((flags))
#else
#define abd_enter_critical(flags) local_irq_save(flags)
#define abd_exit_critical(flags) local_irq_restore(flags)
Expand Down
4 changes: 4 additions & 0 deletions include/sys/asm_linkage.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

#include <sys/ia32/asm_linkage.h> /* XX64 x86/sys/asm_linkage.h */

#elif defined(__aarch64__)

#include <sys/aarch64/asm_linkage.h>

#endif

#if defined(_KERNEL) && defined(HAVE_KERNEL_OBJTOOL)
Expand Down
3 changes: 3 additions & 0 deletions include/sys/crypto/icp.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ int icp_init(void);
void icp_fini(void);

int aes_impl_set(const char *);
int aes_impl_get(char *, size_t);
int gcm_impl_set(const char *);
int gcm_impl_get(char *, size_t);


#endif /* _SYS_CRYPTO_ALGS_H */
21 changes: 20 additions & 1 deletion include/sys/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ typedef enum {
ZFS_PROP_REDACTED,
ZFS_PROP_REDACT_SNAPS,
ZFS_PROP_SNAPSHOTS_CHANGED,
ZFS_PROP_BROWSE, /* macOS: nobrowse/browse */
ZFS_PROP_IGNOREOWNER, /* macOS: ignoreowner mount */
ZFS_PROP_LASTUNMOUNT, /* macOS: Spotlight required */
ZFS_PROP_MIMIC, /* macOS: mimic=hfs|apfs */
ZFS_PROP_DEVDISK, /* macOS: create IOkit virtual disk */
ZFS_NUM_PROPS
} zfs_prop_t;

Expand Down Expand Up @@ -543,6 +548,18 @@ typedef enum zfs_key_location {
ZFS_KEYLOCATION_LOCATIONS
} zfs_keylocation_t;

typedef enum zfs_mimic {
ZFS_MIMIC_OFF = 0,
ZFS_MIMIC_HFS,
ZFS_MIMIC_APFS
} zfs_mimic_t;

typedef enum zfs_devdisk {
ZFS_DEVDISK_POOLONLY = 0,
ZFS_DEVDISK_OFF,
ZFS_DEVDISK_ON
} zfs_devdisk_t;

#define DEFAULT_PBKDF2_ITERATIONS 350000
#define MIN_PBKDF2_ITERATIONS 100000

Expand Down Expand Up @@ -1379,7 +1396,7 @@ typedef enum zfs_ioc {
/*
* Core features - 88/128 numbers reserved.
*/
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__APPLE__)
ZFS_IOC_FIRST = 0,
#else
ZFS_IOC_FIRST = ('Z' << 8),
Expand Down Expand Up @@ -1488,6 +1505,8 @@ typedef enum zfs_ioc {
ZFS_IOC_USERNS_DETACH = ZFS_IOC_UNJAIL, /* 0x86 (Linux) */
ZFS_IOC_SET_BOOTENV, /* 0x87 */
ZFS_IOC_GET_BOOTENV, /* 0x88 */
ZFS_IOC_PROXY_DATASET, /* 0x89 (macOS) */
ZFS_IOC_PROXY_REMOVE, /* 0x8a (macOS) */
ZFS_IOC_LAST
} zfs_ioc_t;

Expand Down
7 changes: 7 additions & 0 deletions include/sys/mntent.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@
#elif defined(__FreeBSD__)
#define MNTOPT_SETUID "setuid" /* Set uid allowed */
#define MNTOPT_NOSETUID "nosetuid" /* Set uid not allowed */
#elif defined(__APPLE__)
#define MNTOPT_SETUID "setuid" /* Set uid allowed */
#define MNTOPT_NOSETUID "nosetuid" /* Set uid not allowed */
#define MNTOPT_BROWSE "browse" /* browsable autofs mount */
#define MNTOPT_NOBROWSE "nobrowse" /* non-browsable autofs mount */
#define MNTOPT_OWNERS "owners" /* use ownership */
#define MNTOPT_NOOWNERS "noowners" /* ignore ownership */
#else
#error "unknown OS"
#endif
Expand Down
2 changes: 2 additions & 0 deletions include/sys/spa.h
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,8 @@ extern boolean_t zfs_ereport_is_valid(const char *clazz, spa_t *spa, vdev_t *vd,
zio_t *zio);
extern void zfs_ereport_taskq_fini(void);
extern void zfs_ereport_clear(spa_t *spa, vdev_t *vd);
extern void zfs_ereport_zvol_post(const char *subclass, const char *name,
const char *bsd, const char *rbsd);
extern nvlist_t *zfs_event_create(spa_t *spa, vdev_t *vd, const char *type,
const char *name, nvlist_t *aux);
extern void zfs_post_remove(spa_t *spa, vdev_t *vd);
Expand Down
3 changes: 3 additions & 0 deletions include/sys/spa_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,9 @@ struct spa {
boolean_t spa_waiters_cancel; /* waiters should return */

char *spa_compatibility; /* compatibility file(s) */
#ifdef __APPLE__
spa_iokit_t *spa_iokit_proxy; /* IOKit pool proxy */
#endif

/*
* spa_refcount & spa_config_lock must be the last elements
Expand Down
2 changes: 1 addition & 1 deletion include/sys/sysevent/dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ extern "C" {
#define DEV_INSTANCE "instance"
#define DEV_PROP_PREFIX "prop-"

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
#define DEV_IDENTIFIER "devid"
#define DEV_PATH "path"
#define DEV_IS_PART "is_slice"
Expand Down
1 change: 1 addition & 0 deletions include/sys/vdev_raidz.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ int vdev_raidz_math_generate(struct raidz_map *, struct raidz_row *);
int vdev_raidz_math_reconstruct(struct raidz_map *, struct raidz_row *,
const int *, const int *, const int);
int vdev_raidz_impl_set(const char *);
int vdev_raidz_impl_get(char *buffer, size_t max);

typedef struct vdev_raidz {
int vd_logical_width;
Expand Down
12 changes: 11 additions & 1 deletion include/sys/xvattr.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ typedef struct xoptattr {
uint8_t xoa_sparse;
uint8_t xoa_projinherit;
uint64_t xoa_projid;
uint8_t xoa_tracked; /* macOS */;
uint8_t xoa_sappendonly; /* macOS */;
uint8_t xoa_simmutable; /* macOS */;
} xoptattr_t;

/*
Expand Down Expand Up @@ -174,12 +177,16 @@ typedef struct xvattr {
#define XAT0_SPARSE 0x00010000 /* sparse */
#define XAT0_PROJINHERIT 0x00020000 /* Create with parent projid */
#define XAT0_PROJID 0x00040000 /* Project ID */
#define XAT0_TRACKED 0x00080000 /* macOS UF_TRACKED */
#define XAT0_SAPPENDONLY 0x00100000 /* macOS SF_APPENDONLY */
#define XAT0_SIMMUTABLE 0x00200000 /* macOS SF_IMMUTABLE */

#define XAT0_ALL_ATTRS (XAT0_CREATETIME|XAT0_ARCHIVE|XAT0_SYSTEM| \
XAT0_READONLY|XAT0_HIDDEN|XAT0_NOUNLINK|XAT0_IMMUTABLE|XAT0_APPENDONLY| \
XAT0_NODUMP|XAT0_OPAQUE|XAT0_AV_QUARANTINED| XAT0_AV_MODIFIED| \
XAT0_AV_SCANSTAMP|XAT0_REPARSE|XATO_GEN|XAT0_OFFLINE|XAT0_SPARSE| \
XAT0_PROJINHERIT | XAT0_PROJID)
XAT0_PROJINHERIT | XAT0_PROJID|XAT0_TRACKED|XAT0_SAPPENDONLY| \
XAT0_SIMMUTABLE)

/* Support for XAT_* optional attributes */
#define XVA_MASK 0xffffffff /* Used to mask off 32 bits */
Expand Down Expand Up @@ -218,6 +225,9 @@ typedef struct xvattr {
#define XAT_SPARSE ((XAT0_INDEX << XVA_SHFT) | XAT0_SPARSE)
#define XAT_PROJINHERIT ((XAT0_INDEX << XVA_SHFT) | XAT0_PROJINHERIT)
#define XAT_PROJID ((XAT0_INDEX << XVA_SHFT) | XAT0_PROJID)
#define XAT_TRACKED ((XAT0_INDEX << XVA_SHFT) | XAT0_TRACKED)
#define XAT_SAPPENDONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_SAPPENDONLY)
#define XAT_SIMMUTABLE ((XAT0_INDEX << XVA_SHFT) | XAT0_SIMMUTABLE)

/*
* The returned attribute map array (xva_rtnattrmap[]) is located past the
Expand Down
1 change: 1 addition & 0 deletions include/sys/zfs_bootenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern "C" {
#define BE_FREEBSD_VENDOR "freebsd"
#define BE_GRUB_VENDOR "grub"
#define BE_LINUX_VENDOR "linux"
#define BE_MACOS_VENDOR "macos"

#include <sys/zfs_bootenv_os.h>

Expand Down
21 changes: 19 additions & 2 deletions include/sys/zfs_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,36 @@ extern void __dprintf(boolean_t dprint, const char *file, const char *func,
if (zfs_dbgmsg_enable) \
__dprintf(B_FALSE, __FILE__, __func__, __LINE__, __VA_ARGS__)

#ifdef ZFS_DEBUG
#ifdef __APPLE__
/*
* To enable this:
*
* $ echo 1 >/sys/module/zfs/parameters/zfs_flags
* $ sysctl kstat.zfs.darwin.tunable.zfs_flags=1
*/
#ifdef _KERNEL
#undef dprintf
#define dprintf(...) \
if (zfs_flags & ZFS_DEBUG_DPRINTF) \
__dprintf(B_TRUE, __FILE__, __func__, __LINE__, __VA_ARGS__)
#endif

#else /* !APPLE */

#ifdef ZFS_DEBUG
/*
* To enable this:
*
* $ echo 1 >/sys/module/zfs/parameters/zfs_flags
*/
#define dprintf(...) \
if (zfs_flags & ZFS_DEBUG_DPRINTF) \
__dprintf(B_TRUE, __FILE__, __func__, __LINE__, __VA_ARGS__)
#else
#define dprintf(...) ((void)0)
#endif /* ZFS_DEBUG */

#endif /* !APPLE */

extern void zfs_panic_recover(const char *fmt, ...);

extern void zfs_dbgmsg_init(void);
Expand Down
2 changes: 2 additions & 0 deletions include/sys/zfs_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ typedef struct zfs_file {
} zfs_file_t;
#elif defined(__linux__) || defined(__FreeBSD__)
typedef struct file zfs_file_t;
#elif defined(__APPLE__)
typedef struct spl_fileproc zfs_file_t;
#else
#error "unknown OS"
#endif
Expand Down
Loading

0 comments on commit d68ad3b

Please sign in to comment.