Skip to content

Commit d68ad3b

Browse files
committed
5: include/* lib/* and top build
Bonus part5, the non-macos changes to include lib and the top level Makefiles Signed-off-by: Jorgen Lundman <[email protected]>
1 parent 553d903 commit d68ad3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+532
-35
lines changed

Makefile.am

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ if BUILD_LINUX
1818
include $(srcdir)/%D%/rpm/Makefile.am
1919
endif
2020

21+
if BUILD_MACOS
22+
bin_PROGRAMS=
23+
noinst_PROGRAMS=
24+
include $(srcdir)/%D%/module/os/macos/Makefile.am
25+
endif
26+
2127
if CONFIG_USER
2228
include $(srcdir)/%D%/cmd/Makefile.am
2329
include $(srcdir)/%D%/contrib/Makefile.am
@@ -194,11 +200,12 @@ cscopelist:
194200
PHONY += tags
195201
tags: ctags etags
196202

197-
PHONY += pkg pkg-dkms pkg-kmod pkg-utils
203+
PHONY += pkg pkg-dkms pkg-kmod pkg-utils pkg-macos
198204
pkg: @DEFAULT_PACKAGE@
199205
pkg-dkms: @DEFAULT_PACKAGE@-dkms
200206
pkg-kmod: @DEFAULT_PACKAGE@-kmod
201207
pkg-utils: @DEFAULT_PACKAGE@-utils
208+
pkg-macos: @DEFAULT_PACKAGE@-macos
202209

203210
include config/rpm.am
204211
include config/deb.am

configure.ac

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ AM_INIT_AUTOMAKE([subdir-objects foreign])
4444
# Remove default macros from config.h:
4545
# PACKAGE, PACKAGE_{BUGREPORT,NAME,STRING,TARNAME,VERSION}, STDC_HEADERS, VERSION
4646
AC_CONFIG_HEADERS([zfs_config.h], [
47-
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])
47+
$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])
4848

4949
LT_INIT
5050
AC_PROG_INSTALL
@@ -55,6 +55,9 @@ AM_PROG_AS
5555
AM_PROG_CC_C_O
5656
AX_CODE_COVERAGE
5757
_AM_PROG_TAR(pax)
58+
AC_PROG_CXX(clang++)
59+
AC_PROG_OBJC(clang)
60+
AC_PROG_OBJCXX(clang++)
5861

5962
ZFS_AC_LICENSE
6063
ZFS_AC_CONFIG

etc/Makefile.am

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,9 @@ dist_modulesload_DATA = \
9797
%D%/modules-load.d/zfs.conf
9898
endif
9999
endif
100+
101+
if BUILD_MACOS
102+
include $(srcdir)/%D%/launchd/Makefile.am
103+
include $(srcdir)/%D%/paths.d/Makefile.am
104+
include $(srcdir)/%D%/launchd.d/Makefile.am
105+
endif

include/libzfs.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ _LIBZFS_H int zpool_enable_datasets(zpool_handle_t *, const char *, int);
10031003
_LIBZFS_H int zpool_disable_datasets(zpool_handle_t *, boolean_t);
10041004
_LIBZFS_H void zpool_disable_datasets_os(zpool_handle_t *, boolean_t);
10051005
_LIBZFS_H void zpool_disable_volume_os(const char *);
1006+
_LIBZFS_H void zfs_rollback_os(struct zfs_handle *);
10061007

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

1045+
#ifdef __APPLE__
1046+
_LIBZFS_H int zfs_snapshot_mount(zfs_handle_t *, const char *, int);
1047+
_LIBZFS_H int zfs_snapshot_unmount(zfs_handle_t *, int);
1048+
/* We moved these from libspl to libzfs to be able to do more */
1049+
_LIBZFS_H int getmntent(FILE *, struct mnttab *);
1050+
_LIBZFS_H char *hasmntopt(struct mnttab *, const char *);
1051+
_LIBZFS_H int getextmntent(const char *, struct extmnttab *,
1052+
struct stat64 *);
1053+
_LIBZFS_H int do_mount(zfs_handle_t *, const char *, const char *, int);
10431054
#endif
10441055

1056+
/*
1057+
* Manual mounting of snapshots.
1058+
*/
1059+
extern int zfs_snapshot_mount(zfs_handle_t *, const char *, int);
1060+
extern int zfs_snapshot_unmount(zfs_handle_t *, int);
1061+
10451062
#ifdef __cplusplus
10461063
}
10471064
#endif

include/libzutil.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ _LIBZUTIL_H void update_vdev_config_dev_strs(nvlist_t *);
109109
* Default device paths
110110
*/
111111
#define DISK_ROOT "/dev"
112+
#ifdef __APPLE__
113+
#define UDISK_ROOT "/private/var/run/disk"
114+
#else
112115
#define UDISK_ROOT "/dev/disk"
116+
#endif
113117
#define ZVOL_ROOT "/dev/zvol"
114118

115119
_LIBZUTIL_H int zfs_append_partition(char *path, size_t max_len);

include/os/freebsd/spl/sys/simd_aarch64.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,13 @@ zfs_sha512_available(void)
9191
return (elf_hwcap & HWCAP_SHA512);
9292
}
9393

94+
/*
95+
* Check if AESV8 is available
96+
*/
97+
static inline boolean_t
98+
zfs_aesv8_available(void)
99+
{
100+
return (elf_hwcap & HWCAP_AES);
101+
}
102+
94103
#endif /* _FREEBSD_SIMD_AARCH64_H */

include/os/linux/kernel/linux/simd_aarch64.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,14 @@ zfs_sha512_available(void)
113113
return (ftr & 0x2);
114114
}
115115

116+
/*
117+
* Check if AESV8 is available
118+
*/
119+
static inline boolean_t
120+
zfs_aesv8_available(void)
121+
{
122+
unsigned long ftr = ((get_ftr(ID_AA64ISAR0_EL1)) >> 4) & 0x3;
123+
return (ftr);
124+
}
125+
116126
#endif /* _LINUX_SIMD_AARCH64_H */

include/os/linux/zfs/sys/zfs_context_os.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@
3737
#undef longjmp
3838
#endif
3939

40+
#ifndef MODULE_PARAM_MAX
41+
#define MODULE_PARAM_MAX 1024
42+
#endif
43+
4044
#endif

include/sys/abd.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ typedef struct abd {
6060
union {
6161
struct abd_scatter {
6262
uint_t abd_offset;
63-
#if defined(__FreeBSD__) && defined(_KERNEL)
63+
#if defined(_KERNEL) && (defined(__FreeBSD__) || defined(__APPLE__))
64+
uint_t abd_chunk_size;
6465
void *abd_chunks[1]; /* actually variable-length */
6566
#else
6667
uint_t abd_nents;
@@ -129,6 +130,7 @@ void abd_copy_off(abd_t *, abd_t *, size_t, size_t, size_t);
129130
void abd_copy_from_buf_off(abd_t *, const void *, size_t, size_t);
130131
void abd_copy_to_buf_off(void *, abd_t *, size_t, size_t);
131132
int abd_cmp(abd_t *, abd_t *);
133+
int abd_cmp_size(abd_t *, abd_t *, size_t);
132134
int abd_cmp_buf_off(abd_t *, const void *, size_t, size_t);
133135
void abd_zero_off(abd_t *, size_t, size_t);
134136
void abd_verify(abd_t *);
@@ -176,6 +178,11 @@ abd_zero(abd_t *abd, size_t size)
176178
abd_zero_off(abd, 0, size);
177179
}
178180

181+
#ifdef __APPLE__
182+
void abd_return_buf_off(abd_t *, void *, size_t, size_t, size_t);
183+
void abd_return_buf_copy_off(abd_t *, void *, size_t, size_t, size_t);
184+
#endif
185+
179186
/*
180187
* ABD type check functions
181188
*/

include/sys/abd_impl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ void abd_iter_unmap(struct abd_iter *);
9595
#if defined(__FreeBSD__)
9696
#define abd_enter_critical(flags) critical_enter()
9797
#define abd_exit_critical(flags) critical_exit()
98+
#elif defined(__APPLE__)
99+
#define abd_enter_critical(flags) (flags) = ml_set_interrupts_enabled(FALSE)
100+
#define abd_exit_critical(flags) ml_set_interrupts_enabled((flags))
98101
#else
99102
#define abd_enter_critical(flags) local_irq_save(flags)
100103
#define abd_exit_critical(flags) local_irq_restore(flags)

include/sys/asm_linkage.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333

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

36+
#elif defined(__aarch64__)
37+
38+
#include <sys/aarch64/asm_linkage.h>
39+
3640
#endif
3741

3842
#if defined(_KERNEL) && defined(HAVE_KERNEL_OBJTOOL)

include/sys/crypto/icp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ int icp_init(void);
3939
void icp_fini(void);
4040

4141
int aes_impl_set(const char *);
42+
int aes_impl_get(char *, size_t);
4243
int gcm_impl_set(const char *);
44+
int gcm_impl_get(char *, size_t);
45+
4346

4447
#endif /* _SYS_CRYPTO_ALGS_H */

include/sys/fs/zfs.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ typedef enum {
191191
ZFS_PROP_REDACTED,
192192
ZFS_PROP_REDACT_SNAPS,
193193
ZFS_PROP_SNAPSHOTS_CHANGED,
194+
ZFS_PROP_BROWSE, /* macOS: nobrowse/browse */
195+
ZFS_PROP_IGNOREOWNER, /* macOS: ignoreowner mount */
196+
ZFS_PROP_LASTUNMOUNT, /* macOS: Spotlight required */
197+
ZFS_PROP_MIMIC, /* macOS: mimic=hfs|apfs */
198+
ZFS_PROP_DEVDISK, /* macOS: create IOkit virtual disk */
194199
ZFS_NUM_PROPS
195200
} zfs_prop_t;
196201

@@ -543,6 +548,18 @@ typedef enum zfs_key_location {
543548
ZFS_KEYLOCATION_LOCATIONS
544549
} zfs_keylocation_t;
545550

551+
typedef enum zfs_mimic {
552+
ZFS_MIMIC_OFF = 0,
553+
ZFS_MIMIC_HFS,
554+
ZFS_MIMIC_APFS
555+
} zfs_mimic_t;
556+
557+
typedef enum zfs_devdisk {
558+
ZFS_DEVDISK_POOLONLY = 0,
559+
ZFS_DEVDISK_OFF,
560+
ZFS_DEVDISK_ON
561+
} zfs_devdisk_t;
562+
546563
#define DEFAULT_PBKDF2_ITERATIONS 350000
547564
#define MIN_PBKDF2_ITERATIONS 100000
548565

@@ -1379,7 +1396,7 @@ typedef enum zfs_ioc {
13791396
/*
13801397
* Core features - 88/128 numbers reserved.
13811398
*/
1382-
#ifdef __FreeBSD__
1399+
#if defined(__FreeBSD__) || defined(__APPLE__)
13831400
ZFS_IOC_FIRST = 0,
13841401
#else
13851402
ZFS_IOC_FIRST = ('Z' << 8),
@@ -1488,6 +1505,8 @@ typedef enum zfs_ioc {
14881505
ZFS_IOC_USERNS_DETACH = ZFS_IOC_UNJAIL, /* 0x86 (Linux) */
14891506
ZFS_IOC_SET_BOOTENV, /* 0x87 */
14901507
ZFS_IOC_GET_BOOTENV, /* 0x88 */
1508+
ZFS_IOC_PROXY_DATASET, /* 0x89 (macOS) */
1509+
ZFS_IOC_PROXY_REMOVE, /* 0x8a (macOS) */
14911510
ZFS_IOC_LAST
14921511
} zfs_ioc_t;
14931512

include/sys/mntent.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@
7979
#elif defined(__FreeBSD__)
8080
#define MNTOPT_SETUID "setuid" /* Set uid allowed */
8181
#define MNTOPT_NOSETUID "nosetuid" /* Set uid not allowed */
82+
#elif defined(__APPLE__)
83+
#define MNTOPT_SETUID "setuid" /* Set uid allowed */
84+
#define MNTOPT_NOSETUID "nosetuid" /* Set uid not allowed */
85+
#define MNTOPT_BROWSE "browse" /* browsable autofs mount */
86+
#define MNTOPT_NOBROWSE "nobrowse" /* non-browsable autofs mount */
87+
#define MNTOPT_OWNERS "owners" /* use ownership */
88+
#define MNTOPT_NOOWNERS "noowners" /* ignore ownership */
8289
#else
8390
#error "unknown OS"
8491
#endif

include/sys/spa.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,8 @@ extern boolean_t zfs_ereport_is_valid(const char *clazz, spa_t *spa, vdev_t *vd,
11441144
zio_t *zio);
11451145
extern void zfs_ereport_taskq_fini(void);
11461146
extern void zfs_ereport_clear(spa_t *spa, vdev_t *vd);
1147+
extern void zfs_ereport_zvol_post(const char *subclass, const char *name,
1148+
const char *bsd, const char *rbsd);
11471149
extern nvlist_t *zfs_event_create(spa_t *spa, vdev_t *vd, const char *type,
11481150
const char *name, nvlist_t *aux);
11491151
extern void zfs_post_remove(spa_t *spa, vdev_t *vd);

include/sys/spa_impl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,9 @@ struct spa {
441441
boolean_t spa_waiters_cancel; /* waiters should return */
442442

443443
char *spa_compatibility; /* compatibility file(s) */
444+
#ifdef __APPLE__
445+
spa_iokit_t *spa_iokit_proxy; /* IOKit pool proxy */
446+
#endif
444447

445448
/*
446449
* spa_refcount & spa_config_lock must be the last elements

include/sys/sysevent/dev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ extern "C" {
239239
#define DEV_INSTANCE "instance"
240240
#define DEV_PROP_PREFIX "prop-"
241241

242-
#ifdef __linux__
242+
#if defined(__linux__) || defined(__APPLE__)
243243
#define DEV_IDENTIFIER "devid"
244244
#define DEV_PATH "path"
245245
#define DEV_IS_PART "is_slice"

include/sys/vdev_raidz.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ int vdev_raidz_math_generate(struct raidz_map *, struct raidz_row *);
6464
int vdev_raidz_math_reconstruct(struct raidz_map *, struct raidz_row *,
6565
const int *, const int *, const int);
6666
int vdev_raidz_impl_set(const char *);
67+
int vdev_raidz_impl_get(char *buffer, size_t max);
6768

6869
typedef struct vdev_raidz {
6970
int vd_logical_width;

include/sys/xvattr.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ typedef struct xoptattr {
6767
uint8_t xoa_sparse;
6868
uint8_t xoa_projinherit;
6969
uint64_t xoa_projid;
70+
uint8_t xoa_tracked; /* macOS */;
71+
uint8_t xoa_sappendonly; /* macOS */;
72+
uint8_t xoa_simmutable; /* macOS */;
7073
} xoptattr_t;
7174

7275
/*
@@ -174,12 +177,16 @@ typedef struct xvattr {
174177
#define XAT0_SPARSE 0x00010000 /* sparse */
175178
#define XAT0_PROJINHERIT 0x00020000 /* Create with parent projid */
176179
#define XAT0_PROJID 0x00040000 /* Project ID */
180+
#define XAT0_TRACKED 0x00080000 /* macOS UF_TRACKED */
181+
#define XAT0_SAPPENDONLY 0x00100000 /* macOS SF_APPENDONLY */
182+
#define XAT0_SIMMUTABLE 0x00200000 /* macOS SF_IMMUTABLE */
177183

178184
#define XAT0_ALL_ATTRS (XAT0_CREATETIME|XAT0_ARCHIVE|XAT0_SYSTEM| \
179185
XAT0_READONLY|XAT0_HIDDEN|XAT0_NOUNLINK|XAT0_IMMUTABLE|XAT0_APPENDONLY| \
180186
XAT0_NODUMP|XAT0_OPAQUE|XAT0_AV_QUARANTINED| XAT0_AV_MODIFIED| \
181187
XAT0_AV_SCANSTAMP|XAT0_REPARSE|XATO_GEN|XAT0_OFFLINE|XAT0_SPARSE| \
182-
XAT0_PROJINHERIT | XAT0_PROJID)
188+
XAT0_PROJINHERIT | XAT0_PROJID|XAT0_TRACKED|XAT0_SAPPENDONLY| \
189+
XAT0_SIMMUTABLE)
183190

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

222232
/*
223233
* The returned attribute map array (xva_rtnattrmap[]) is located past the

include/sys/zfs_bootenv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extern "C" {
3030
#define BE_FREEBSD_VENDOR "freebsd"
3131
#define BE_GRUB_VENDOR "grub"
3232
#define BE_LINUX_VENDOR "linux"
33+
#define BE_MACOS_VENDOR "macos"
3334

3435
#include <sys/zfs_bootenv_os.h>
3536

include/sys/zfs_debug.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,36 @@ extern void __dprintf(boolean_t dprint, const char *file, const char *func,
8383
if (zfs_dbgmsg_enable) \
8484
__dprintf(B_FALSE, __FILE__, __func__, __LINE__, __VA_ARGS__)
8585

86-
#ifdef ZFS_DEBUG
86+
#ifdef __APPLE__
8787
/*
8888
* To enable this:
8989
*
90-
* $ echo 1 >/sys/module/zfs/parameters/zfs_flags
90+
* $ sysctl kstat.zfs.darwin.tunable.zfs_flags=1
9191
*/
92+
#ifdef _KERNEL
93+
#undef dprintf
94+
#define dprintf(...) \
95+
if (zfs_flags & ZFS_DEBUG_DPRINTF) \
96+
__dprintf(B_TRUE, __FILE__, __func__, __LINE__, __VA_ARGS__)
97+
#endif
98+
99+
#else /* !APPLE */
100+
101+
#ifdef ZFS_DEBUG
102+
/*
103+
* To enable this:
104+
*
105+
* $ echo 1 >/sys/module/zfs/parameters/zfs_flags
106+
*/
92107
#define dprintf(...) \
93108
if (zfs_flags & ZFS_DEBUG_DPRINTF) \
94109
__dprintf(B_TRUE, __FILE__, __func__, __LINE__, __VA_ARGS__)
95110
#else
96111
#define dprintf(...) ((void)0)
97112
#endif /* ZFS_DEBUG */
98113

114+
#endif /* !APPLE */
115+
99116
extern void zfs_panic_recover(const char *fmt, ...);
100117

101118
extern void zfs_dbgmsg_init(void);

include/sys/zfs_file.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ typedef struct zfs_file {
3131
} zfs_file_t;
3232
#elif defined(__linux__) || defined(__FreeBSD__)
3333
typedef struct file zfs_file_t;
34+
#elif defined(__APPLE__)
35+
typedef struct spl_fileproc zfs_file_t;
3436
#else
3537
#error "unknown OS"
3638
#endif

0 commit comments

Comments
 (0)