Skip to content

Commit

Permalink
Macos: Zprop changes
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Innes <[email protected]>
Co-Authored-By: Jorgen Lundman <[email protected]>
  • Loading branch information
andrewc12 and lundman committed Jan 17, 2024
1 parent a0b2a93 commit a4f8a88
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
20 changes: 20 additions & 0 deletions include/sys/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ typedef enum {
ZFS_PROP_SNAPSHOTS_CHANGED,
ZFS_PROP_PREFETCH,
ZFS_PROP_VOLTHREADING,
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 @@ -552,6 +557,19 @@ typedef enum {
ZFS_PREFETCH_ALL = 2
} zfs_prefetch_type_t;

typedef enum zfs_mimic {
ZFS_MIMIC_OFF = 0,
ZFS_MIMIC_HFS,
ZFS_MIMIC_APFS,
ZFS_MIMIC_NTFS
} 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 @@ -1519,6 +1537,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
37 changes: 37 additions & 0 deletions module/zcommon/zfs_prop.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,23 @@ zfs_prop_init(void)
struct zfs_mod_supported_features *sfeatures =
zfs_mod_list_supported(ZFS_SYSFS_DATASET_PROPERTIES);

/* __APPLE__ */
static zprop_index_t devdisk_table[] = {
{ "poolonly", ZFS_DEVDISK_POOLONLY },
{ "off", ZFS_DEVDISK_OFF },
{ "on", ZFS_DEVDISK_ON },
{ NULL }
};

static zprop_index_t mimic_table[] = {
{ "off", ZFS_MIMIC_OFF },
{ "hfs", ZFS_MIMIC_HFS },
{ "apfs", ZFS_MIMIC_APFS },
{ "ntfs", ZFS_MIMIC_NTFS },
{ NULL }
};
/* __APPLE__ */

/* inherit index properties */
zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata",
ZFS_REDUNDANT_METADATA_ALL,
Expand Down Expand Up @@ -609,6 +626,26 @@ zfs_prop_init(void)
ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<snapshot>[,...]",
"RSNAPS", sfeatures);

/*
* These props are needed for compatability with pools created
* using openzfsonosx
*/
zprop_register_index(ZFS_PROP_BROWSE, "com.apple.browse", 1,
PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off",
"COM.APPLE.BROWSE", boolean_table, sfeatures);
zprop_register_index(ZFS_PROP_IGNOREOWNER, "com.apple.ignoreowner", 0,
PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off",
"COM.APPLE.IGNOREOWNER", boolean_table, sfeatures);
zprop_register_hidden(ZFS_PROP_LASTUNMOUNT, "COM.APPLE.LASTUNMOUNT",
PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "LASTUNMOUNT",
B_FALSE, sfeatures);
zprop_register_index(ZFS_PROP_MIMIC, "com.apple.mimic", 0,
PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "off | hfs | apfs",
"COM.APPLE.MIMIC_HFS", mimic_table, sfeatures);
zprop_register_index(ZFS_PROP_DEVDISK, "com.apple.devdisk", 0,
PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "poolonly | on | off",
"COM.APPLE.DEVDISK", devdisk_table, sfeatures);

/* readonly number properties */
zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
ZFS_TYPE_DATASET, "<size>", "USED", B_FALSE, sfeatures);
Expand Down

0 comments on commit a4f8a88

Please sign in to comment.