From a4f8a88022f89ffd83452e8fb55744356dfb20b0 Mon Sep 17 00:00:00 2001 From: Andrew Innes Date: Tue, 31 Oct 2023 15:35:27 +0800 Subject: [PATCH 1/7] Macos: Zprop changes Signed-off-by: Andrew Innes Co-Authored-By: Jorgen Lundman --- include/sys/fs/zfs.h | 20 ++++++++++++++++++++ module/zcommon/zfs_prop.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/include/sys/fs/zfs.h b/include/sys/fs/zfs.h index c6f7dcca78..bc376af405 100644 --- a/include/sys/fs/zfs.h +++ b/include/sys/fs/zfs.h @@ -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; @@ -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 @@ -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; diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c index 764993b45e..00bad9bb88 100644 --- a/module/zcommon/zfs_prop.c +++ b/module/zcommon/zfs_prop.c @@ -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, @@ -609,6 +626,26 @@ zfs_prop_init(void) ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "[,...]", "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, "", "USED", B_FALSE, sfeatures); From 956be9ab0356f3348f3a4aa89fadeee339de009a Mon Sep 17 00:00:00 2001 From: Andrew Innes Date: Tue, 31 Oct 2023 16:16:22 +0800 Subject: [PATCH 2/7] Macos: libabigail changes Signed-off-by: Andrew Innes Co-Authored-By: Jorgen Lundman --- lib/libzfs/libzfs.abi | 11 +++++++++-- lib/libzfs_core/libzfs_core.abi | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index 7c39b134d1..93741585e3 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -1824,7 +1824,12 @@ - + + + + + + @@ -5826,7 +5831,9 @@ - + + + diff --git a/lib/libzfs_core/libzfs_core.abi b/lib/libzfs_core/libzfs_core.abi index 5b95c8f779..f3893d287d 100644 --- a/lib/libzfs_core/libzfs_core.abi +++ b/lib/libzfs_core/libzfs_core.abi @@ -1365,7 +1365,9 @@ - + + + From d3acfe1ab4734e623fb38c0b144531a33766fd40 Mon Sep 17 00:00:00 2001 From: Andrew Innes Date: Thu, 18 Jan 2024 14:01:30 +0800 Subject: [PATCH 3/7] Macos: remove namespace from zprops Remove prefix to avoid conflict with user-defined properties Signed-off-by: Andrew Innes --- module/zcommon/zfs_prop.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c index 00bad9bb88..417c148d17 100644 --- a/module/zcommon/zfs_prop.c +++ b/module/zcommon/zfs_prop.c @@ -630,19 +630,19 @@ zfs_prop_init(void) * These props are needed for compatability with pools created * using openzfsonosx */ - zprop_register_index(ZFS_PROP_BROWSE, "com.apple.browse", 1, + zprop_register_index(ZFS_PROP_BROWSE, "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, + zprop_register_index(ZFS_PROP_IGNOREOWNER, "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, + zprop_register_index(ZFS_PROP_MIMIC, "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, + zprop_register_index(ZFS_PROP_DEVDISK, "devdisk", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "poolonly | on | off", "COM.APPLE.DEVDISK", devdisk_table, sfeatures); From 12a59b201ac46ce469588b49085b233530b8a49b Mon Sep 17 00:00:00 2001 From: Andrew Innes Date: Thu, 18 Jan 2024 14:20:03 +0800 Subject: [PATCH 4/7] Macos: zprop documentation Add a new manpage that describes the zprops used on macos Signed-off-by: Andrew Innes Co-Authored-By: Jorgen Lundman --- man/Makefile.am | 1 + man/man7/zfsprops-macos.7 | 95 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 man/man7/zfsprops-macos.7 diff --git a/man/Makefile.am b/man/Makefile.am index 45156571ee..1fe24e8226 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -21,6 +21,7 @@ dist_man_MANS = \ %D%/man7/zpool-features.7 \ %D%/man7/zpoolconcepts.7 \ %D%/man7/zpoolprops.7 \ + %D%/man7/zfsprops-macos.7 \ \ %D%/man8/fsck.zfs.8 \ %D%/man8/mount.zfs.8 \ diff --git a/man/man7/zfsprops-macos.7 b/man/man7/zfsprops-macos.7 new file mode 100644 index 0000000000..f4df8071ea --- /dev/null +++ b/man/man7/zfsprops-macos.7 @@ -0,0 +1,95 @@ +.\" +.\" CDDL HEADER START +.\" +.\" The contents of this file are subject to the terms of the +.\" Common Development and Distribution License (the "License"). +.\" You may not use this file except in compliance with the License. +.\" +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +.\" or http://www.opensolaris.org/os/licensing. +.\" See the License for the specific language governing permissions +.\" and limitations under the License. +.\" +.\" When distributing Covered Code, include this CDDL HEADER in each +.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. +.\" If applicable, add the following below this CDDL HEADER, with the +.\" fields enclosed by brackets "[]" replaced with your own identifying +.\" information: Portions Copyright [yyyy] [name of copyright owner] +.\" +.\" CDDL HEADER END +.\" +.\" +.\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved. +.\" Copyright 2011 Joshua M. Clulow +.\" Copyright (c) 2011, 2019 by Delphix. All rights reserved. +.\" Copyright (c) 2011, Pawel Jakub Dawidek +.\" Copyright (c) 2012, Glen Barber +.\" Copyright (c) 2012, Bryan Drewery +.\" Copyright (c) 2013, Steven Hartland +.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved. +.\" Copyright (c) 2014, Joyent, Inc. All rights reserved. +.\" Copyright (c) 2014 by Adam Stevko. All rights reserved. +.\" Copyright (c) 2014 Integros [integros.com] +.\" Copyright (c) 2016 Nexenta Systems, Inc. All Rights Reserved. +.\" Copyright (c) 2014, Xin LI +.\" Copyright (c) 2014-2015, The FreeBSD Foundation, All Rights Reserved. +.\" Copyright 2019 Richard Laager. All rights reserved. +.\" Copyright 2018 Nexenta Systems, Inc. +.\" Copyright 2019 Joyent, Inc. +.\" Copyright (c) 2019, Kjeld Schouten-Lebbing +.\" +.Dd April 29, 2021 +.Dt ZFSPROPS-MACOS 7 +.Os +. +.Sh NAME +.Nm zfsprops-macos +.Nd native properties of ZFS datasets specific to macOS +. +.Sh DESCRIPTION +These properties are like the native properties described in +.Xr zfsprops 7 +but they are specific to macOS. +.Pp +The following native properties can be used to change the behavior of a ZFS +dataset. +.Bl -tag -width "" +.It Xo +.Sy browse Ns = Ns Sy on Ns | Ns Sy off +.Xc +Equivalent to mount option +.Sy browse/nobrowse . +This option indicates +that the mount point should not be visible via the GUI (i.e., appear +on the Desktop as a separate volume). Setting it to off will result +in Spotlight being unavailable for the specified mount point. +The default value is +.Sy off . +.It Xo +.Sy ignoreowner Ns = Ns Sy on Ns | Ns Sy off +.Xc +Equivalent to mount option +.Sy noowners . +Ignore the ownership field for the entire volume. +The default value is +.Sy off . +.It Xo +.Sy mimic Ns = Ns Sy hfs Ns | Ns Sy off +.Xc +Some applications check if the filesystem type is "hfs" and refuse to work with +ZFS. +In this situation, this property can be enabled and the filesystem type will be +reported as "hfs". +The default value is +.Sy off . +.It Xo +.Sy devdisk Ns = Ns Sy poolonly Ns | Ns Sy on Ns | Ns Sy off +.Xc +Create a /dev/diskX pseudo-disk for the mount, which has better compatibility +with macOS UI. +Due to the cost of creating a /dev/disk entry, the default value is set to +.Sy poolonly +as to only create an entry for the pool's root dataset. +For lower datasets, set to +.Sy on . +.El From 13146ca00a50325b0aa20a0f2663893c75650abc Mon Sep 17 00:00:00 2001 From: Andrew Innes Date: Thu, 18 Jan 2024 14:37:51 +0800 Subject: [PATCH 5/7] Macos: add ntfs to zprop options Signed-off-by: Andrew Innes --- module/zcommon/zfs_prop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c index 417c148d17..8b20f617c5 100644 --- a/module/zcommon/zfs_prop.c +++ b/module/zcommon/zfs_prop.c @@ -640,7 +640,7 @@ zfs_prop_init(void) PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "LASTUNMOUNT", B_FALSE, sfeatures); zprop_register_index(ZFS_PROP_MIMIC, "mimic", 0, - PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "off | hfs | apfs", + PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "off | hfs | apfs | ntfs", "COM.APPLE.MIMIC_HFS", mimic_table, sfeatures); zprop_register_index(ZFS_PROP_DEVDISK, "devdisk", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "poolonly | on | off", From da0d2a966f5eac67404e05f892d70fcb62e93ddb Mon Sep 17 00:00:00 2001 From: Andrew Innes Date: Thu, 18 Jan 2024 14:45:34 +0800 Subject: [PATCH 6/7] Macos: add apfs ntfs to zprop man page Signed-off-by: Andrew Innes --- man/man7/zfsprops-macos.7 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/man/man7/zfsprops-macos.7 b/man/man7/zfsprops-macos.7 index f4df8071ea..f04c340bdb 100644 --- a/man/man7/zfsprops-macos.7 +++ b/man/man7/zfsprops-macos.7 @@ -74,12 +74,11 @@ Ignore the ownership field for the entire volume. The default value is .Sy off . .It Xo -.Sy mimic Ns = Ns Sy hfs Ns | Ns Sy off +.Sy mimic Ns = Ns Sy hfs Ns | Ns Sy apfs Ns | Ns Sy ntfs Ns | Ns Sy off .Xc -Some applications check if the filesystem type is "hfs" and refuse to work with -ZFS. -In this situation, this property can be enabled and the filesystem type will be -reported as "hfs". +Some applications check if the filesystem type is and refuse to work with ZFS. +In this situation, this property can be enabled and the chosen filesystem type +will be reported. The default value is .Sy off . .It Xo From 8d73dab71f3b5eb729ac76037a6ede6ce89253a2 Mon Sep 17 00:00:00 2001 From: Andrew Innes Date: Thu, 18 Jan 2024 15:05:09 +0800 Subject: [PATCH 7/7] Macos: zprop documentation to debian package Signed-off-by: Andrew Innes --- contrib/debian/openzfs-zfsutils.install | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/debian/openzfs-zfsutils.install b/contrib/debian/openzfs-zfsutils.install index 741014398a..96aaaa05f3 100644 --- a/contrib/debian/openzfs-zfsutils.install +++ b/contrib/debian/openzfs-zfsutils.install @@ -91,6 +91,7 @@ usr/share/man/man8/zfs_ids_to_path.8 usr/share/man/man8/zfs_prepare_disk.8 usr/share/man/man7/zfsconcepts.7 usr/share/man/man7/zfsprops.7 +usr/share/man/man7/zfsprops-macos.7 usr/share/man/man8/zgenhostid.8 usr/share/man/man8/zinject.8 usr/share/man/man8/zpool-add.8