diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 5017a0e7d5d9..261060280111 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -3629,6 +3629,9 @@ parse_object_range(char *range, zopt_object_range_t *zor, char **msg) *msg = "Invalid characters in object ID"; rc = 1; } +#ifdef __APPLE__ + zor->zor_obj_start = INO_XNUTOZFS(zor->zor_obj_start, 2); +#endif zor->zor_obj_end = zor->zor_obj_start; return (rc); } @@ -3707,6 +3710,11 @@ parse_object_range(char *range, zopt_object_range_t *zor, char **msg) } zor->zor_flags = flags; +#ifdef __APPLE__ + zor->zor_obj_start = INO_XNUTOZFS(zor->zor_obj_start, 2); + zor->zor_obj_end = INO_XNUTOZFS(zor->zor_obj_end, 2); +#endif + out: free(dup); return (rc); diff --git a/include/os/macos/spl/sys/vnode.h b/include/os/macos/spl/sys/vnode.h index 06f57918b1d2..1a12c339d97a 100644 --- a/include/os/macos/spl/sys/vnode.h +++ b/include/os/macos/spl/sys/vnode.h @@ -164,31 +164,6 @@ vn_lock(struct vnode *vp, int fl) return (0); } -/* - * XNU reserves fileID 1-15, so we remap them high. - * 2 is root-of-the-mount. - * If ID is same as root, return 2. Otherwise, if it is 0-15, return - * adjusted, otherwise, return as-is. - * See hfs_format.h: kHFSRootFolderID, kHFSExtentsFileID, ... - */ -#define INO_ROOT 2ULL -#define INO_RESERVED 16ULL /* [0-15] reserved. */ -#define INO_ISRESERVED(ID) ((ID) < (INO_RESERVED)) -/* 0xFFFFFFFFFFFFFFF0 */ -#define INO_MAP ((uint64_t)-INO_RESERVED) /* -16, -15, .., -1 */ - -#define INO_ZFSTOXNU(ID, ROOT) \ - ((ID) == (ROOT)?INO_ROOT:(INO_ISRESERVED(ID)?INO_MAP+(ID):(ID))) - -/* - * This macro relies on *unsigned*. - * If asking for 2, return rootID. If in special range, adjust to - * normal, otherwise, return as-is. - */ -#define INO_XNUTOZFS(ID, ROOT) \ - ((ID) == INO_ROOT)?(ROOT): \ - (INO_ISRESERVED((ID)-INO_MAP))?((ID)-INO_MAP):(ID) - #define VN_HOLD(vp) vnode_getwithref(vp) #define VN_RELE(vp) vnode_put(vp) diff --git a/include/os/macos/zfs/sys/zfs_context_os.h b/include/os/macos/zfs/sys/zfs_context_os.h index a88f5dae9e89..50230367b647 100644 --- a/include/os/macos/zfs/sys/zfs_context_os.h +++ b/include/os/macos/zfs/sys/zfs_context_os.h @@ -36,6 +36,31 @@ #define flock64_t struct flock +/* + * XNU reserves fileID 1-15, so we remap them high. + * 2 is root-of-the-mount. + * If ID is same as root, return 2. Otherwise, if it is 0-15, return + * adjusted, otherwise, return as-is. + * See hfs_format.h: kHFSRootFolderID, kHFSExtentsFileID, ... + */ +#define INO_ROOT 2ULL +#define INO_RESERVED 16ULL /* [0-15] reserved. */ +#define INO_ISRESERVED(ID) ((ID) < (INO_RESERVED)) +/* 0xFFFFFFFFFFFFFFF0 */ +#define INO_MAP ((uint64_t)-INO_RESERVED) /* -16, -15, .., -1 */ + +#define INO_ZFSTOXNU(ID, ROOT) \ + ((ID) == (ROOT)?INO_ROOT:(INO_ISRESERVED(ID)?INO_MAP+(ID):(ID))) + +/* + * This macro relies on *unsigned*. + * If asking for 2, return rootID. If in special range, adjust to + * normal, otherwise, return as-is. + */ +#define INO_XNUTOZFS(ID, ROOT) \ + ((ID) == INO_ROOT)?(ROOT): \ + (INO_ISRESERVED((ID)-INO_MAP))?((ID)-INO_MAP):(ID) + struct spa_iokit; typedef struct spa_iokit spa_iokit_t; diff --git a/lib/libspl/include/os/macos/sys/zfs_context_os.h b/lib/libspl/include/os/macos/sys/zfs_context_os.h index 524f7a61d213..e7df48f35696 100644 --- a/lib/libspl/include/os/macos/sys/zfs_context_os.h +++ b/lib/libspl/include/os/macos/sys/zfs_context_os.h @@ -28,6 +28,31 @@ #define ZFS_EXPORTS_PATH "/etc/exports" #define MNTTYPE_ZFS_SUBTYPE ('Z'<<24|'F'<<16|'S'<<8) +/* + * XNU reserves fileID 1-15, so we remap them high. + * 2 is root-of-the-mount. + * If ID is same as root, return 2. Otherwise, if it is 0-15, return + * adjusted, otherwise, return as-is. + * See hfs_format.h: kHFSRootFolderID, kHFSExtentsFileID, ... + */ +#define INO_ROOT 2ULL +#define INO_RESERVED 16ULL /* [0-15] reserved. */ +#define INO_ISRESERVED(ID) ((ID) < (INO_RESERVED)) +/* 0xFFFFFFFFFFFFFFF0 */ +#define INO_MAP ((uint64_t)-INO_RESERVED) /* -16, -15, .., -1 */ + +#define INO_ZFSTOXNU(ID, ROOT) \ + ((ID) == (ROOT)?INO_ROOT:(INO_ISRESERVED(ID)?INO_MAP+(ID):(ID))) + +/* + * This macro relies on *unsigned*. + * If asking for 2, return rootID. If in special range, adjust to + * normal, otherwise, return as-is. + */ +#define INO_XNUTOZFS(ID, ROOT) \ + ((ID) == INO_ROOT)?(ROOT): \ + (INO_ISRESERVED((ID)-INO_MAP))?((ID)-INO_MAP):(ID) + struct spa_iokit; typedef struct spa_iokit spa_iokit_t;