From 49d8a99a4d6579a61b04c4b05f732fab26b09d30 Mon Sep 17 00:00:00 2001 From: Jorgen Lundman Date: Thu, 9 Sep 2021 05:56:04 +0900 Subject: [PATCH] Upstream: zdb inode mapping Unfortunately macOS reserves inode ID numbers 0-15, and we can not used them. In macOS port we simply map them really high IDs. Normally this is hidden inside the _os implementation, but this is the one place in the common source files. Reviewed-by: Brian Behlendorf Signed-off-by: Jorgen Lundman Closes #12530 --- cmd/zdb/zdb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index f9c3f9ea6b..d65cd3a233 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -94,6 +94,13 @@ (idx) == DMU_OTN_UINT64_DATA || (idx) == DMU_OTN_UINT64_METADATA ? \ DMU_OT_UINT64_OTHER : DMU_OT_NUMTYPES) +/* Some platforms require part of inode IDs to be remapped */ +#ifdef __APPLE__ +#define ZDB_MAP_OBJECT_ID(obj) INO_XNUTOZFS(obj, 2) +#else +#define ZDB_MAP_OBJECT_ID(obj) (obj) +#endif + static char * zdb_ot_name(dmu_object_type_t type) { @@ -3631,6 +3638,7 @@ parse_object_range(char *range, zopt_object_range_t *zor, char **msg) *msg = "Invalid characters in object ID"; rc = 1; } + zor->zor_obj_start = ZDB_MAP_OBJECT_ID(zor->zor_obj_start); zor->zor_obj_end = zor->zor_obj_start; return (rc); } @@ -3709,6 +3717,9 @@ parse_object_range(char *range, zopt_object_range_t *zor, char **msg) } zor->zor_flags = flags; + zor->zor_obj_start = ZDB_MAP_OBJECT_ID(zor->zor_obj_start); + zor->zor_obj_end = ZDB_MAP_OBJECT_ID(zor->zor_obj_end); + out: free(dup); return (rc);