diff --git a/include/os/macos/zfs/sys/zfs_mount.h b/include/os/macos/zfs/sys/zfs_mount.h index 7a3abc93e..23993d2dd 100644 --- a/include/os/macos/zfs/sys/zfs_mount.h +++ b/include/os/macos/zfs/sys/zfs_mount.h @@ -54,6 +54,8 @@ struct zfs_mount_args { #define MS_DETACH MNT_DETACH #define MS_OVERLAY MNT_UNION #define MS_CRYPT MNT_CPROTECT +#define MS_NOATIME MNT_NOATIME +#define MS_STRICTATIME MNT_STRICTATIME #endif #endif /* _SYS_ZFS_IOCTL_H */ diff --git a/include/sys/mntent.h b/include/sys/mntent.h index be62c5397..11e20312f 100644 --- a/include/sys/mntent.h +++ b/include/sys/mntent.h @@ -80,8 +80,8 @@ #define MNTOPT_SETUID "setuid" /* Set uid allowed */ #define MNTOPT_NOSETUID "nosetuid" /* Set uid not allowed */ #elif defined(__APPLE__) -#define MNTOPT_SETUID "setuid" /* Set uid allowed */ -#define MNTOPT_NOSETUID "nosetuid" /* Set uid not allowed */ +#define MNTOPT_SETUID "suid" /* Set uid allowed */ +#define MNTOPT_NOSETUID "nosuid" /* Set uid not allowed */ #define MNTOPT_BROWSE "browse" /* browsable autofs mount */ #define MNTOPT_NOBROWSE "nobrowse" /* non-browsable autofs mount */ #define MNTOPT_OWNERS "owners" /* use ownership */ diff --git a/lib/libspl/include/os/macos/mntent.h b/lib/libspl/include/os/macos/mntent.h index 8183dda00..5d411016a 100644 --- a/lib/libspl/include/os/macos/mntent.h +++ b/lib/libspl/include/os/macos/mntent.h @@ -123,8 +123,8 @@ extern "C" { #define MNTOPT_NOGLOBAL "noglobal" /* Mount local to single node */ #define MNTOPT_DFRATIME "dfratime" /* Deferred access time updates */ #define MNTOPT_NODFRATIME "nodfratime" /* No Deferred access time updates */ -#define MNTOPT_NBMAND "nbmand" /* allow non-blocking mandatory locks */ -#define MNTOPT_NONBMAND "nonbmand" /* deny non-blocking mandatory locks */ +#define MNTOPT_NBMAND "mand" /* allow non-blocking mandatory locks */ +#define MNTOPT_NONBMAND "nomand" /* deny non-blocking mandatory locks */ #define MNTOPT_XATTR "xattr" /* enable extended attributes */ #define MNTOPT_NOXATTR "noxattr" /* disable extended attributes */ #define MNTOPT_EXEC "exec" /* enable executables */ diff --git a/lib/libspl/include/os/macos/sys/mnttab.h b/lib/libspl/include/os/macos/sys/mnttab.h index 9ba5d08b2..201f2c1f3 100644 --- a/lib/libspl/include/os/macos/sys/mnttab.h +++ b/lib/libspl/include/os/macos/sys/mnttab.h @@ -43,7 +43,6 @@ #include #define MNTTAB _PATH_DEVNULL #define MS_NOMNTTAB 0x0 -#define MS_RDONLY 0x1 #define umount2(p, f) unmount(p, f) #define MNT_LINE_MAX 4096 diff --git a/lib/libspl/include/os/macos/sys/mount.h b/lib/libspl/include/os/macos/sys/mount.h index 0153b7f53..7081dd365 100644 --- a/lib/libspl/include/os/macos/sys/mount.h +++ b/lib/libspl/include/os/macos/sys/mount.h @@ -67,6 +67,7 @@ #define MS_POSIXACL (1<<16) #endif +#define MS_RDONLY MNT_RDONLY #define MS_NOSUID MNT_NOSUID #define MS_NOEXEC MNT_NOEXEC #define MS_NODEV MNT_NODEV @@ -83,5 +84,8 @@ #define MS_DETACH MNT_DETACH #define MS_OVERLAY MNT_UNION #define MS_CRYPT MNT_CPROTECT +#define MS_NOATIME MNT_NOATIME +#define MS_STRICTATIME MNT_STRICTATIME +#define MS_MANDLOCK 0 #endif /* _LIBSPL_SYS_MOUNT_H */ diff --git a/lib/libzfs/os/macos/libzfs_mount_os.c b/lib/libzfs/os/macos/libzfs_mount_os.c index 920153570..0076961ad 100644 --- a/lib/libzfs/os/macos/libzfs_mount_os.c +++ b/lib/libzfs/os/macos/libzfs_mount_os.c @@ -262,8 +262,12 @@ static const option_map_t option_map[] = { #endif /* Custom zfs options */ { MNTOPT_XATTR, MS_COMMENT, ZS_COMMENT }, - { MNTOPT_NOXATTR, MS_COMMENT, ZS_COMMENT }, + { MNTOPT_NOXATTR, MNT_NOUSERXATTR, ZS_COMMENT }, { MNTOPT_ZFSUTIL, MS_COMMENT, ZS_ZFSUTIL }, + { MNTOPT_BROWSE, MS_COMMENT, ZS_COMMENT }, + { MNTOPT_NOBROWSE, MNT_DONTBROWSE, ZS_COMMENT }, + { MNTOPT_OWNERS, MS_COMMENT, ZS_COMMENT }, + { MNTOPT_NOOWNERS, MNT_IGNORE_OWNERSHIP, ZS_COMMENT }, { NULL, 0, 0 } }; /* @@ -502,16 +506,20 @@ do_mount(zfs_handle_t *zhp, const char *dir, char *optptr, int mflag) } } - // We don't pass flags to XNU, we use optstr - mflag = 0; + char badopt[MNT_LINE_MAX] = {0}; + unsigned long mntflags = mflag, zfsflags; + char myopts[MNT_LINE_MAX] = {0}; - // Some arguments need to be told to XNU - if (strstr(optptr, "remount") != NULL) - mflag |= MNT_UPDATE; + if (zfs_parse_mount_options(optptr, &mntflags, + &zfsflags, 0, badopt, NULL)) { + return (EINVAL); + } + strlcat(myopts, optptr, MNT_LINE_MAX); + zfs_adjust_mount_options(zhp, dir, myopts, NULL); - mnt_args.mflag = mflag; - mnt_args.optptr = optptr; - mnt_args.optlen = optlen; + mnt_args.mflag = mntflags; + mnt_args.optptr = myopts; + mnt_args.optlen = MNT_LINE_MAX; mnt_args.struct_size = sizeof (mnt_args); /* @@ -523,13 +531,13 @@ do_mount(zfs_handle_t *zhp, const char *dir, char *optptr, int mflag) rpath = realpath(dir, NULL); #ifdef ZFS_DEBUG - printf("%s calling mount with fstype %s, %s %s, fspec %s, mflag %d," + printf("%s calling mount with fstype %s, %s %s, fspec %s, mntflags %lu," " optptr %s, optlen %d, devdisk %d, ispool %d\n", __func__, fstype, (rpath ? "rpath" : "dir"), - (rpath ? rpath : dir), mnt_args.fspec, mflag, optptr, optlen, + (rpath ? rpath : dir), mnt_args.fspec, mntflags, optptr, optlen, devdisk, ispool); #endif - rv = mount(fstype, rpath ? rpath : dir, mflag, &mnt_args); + rv = mount(fstype, rpath ? rpath : dir, mntflags, &mnt_args); /* Check if we need to create/update icon */ if (rv == 0) diff --git a/module/os/macos/zfs/zfs_vfsops.c b/module/os/macos/zfs/zfs_vfsops.c index 72583b6c4..842709cf5 100644 --- a/module/os/macos/zfs/zfs_vfsops.c +++ b/module/os/macos/zfs/zfs_vfsops.c @@ -1387,6 +1387,70 @@ zfs_vfs_mount(struct mount *vfsp, vnode_t *mvp /* devvp */, cmdflags |= MNT_UPDATE; } + // MS_NODEV + if (mflag & MNT_NODEV) { + dprintf("%s: adding MNT_NODEV\n", __func__); + cmdflags |= MNT_NODEV; + } + + // MS_NOSUID + if (mflag & MNT_NOSUID) { + dprintf("%s: adding MNT_NOSUID\n", __func__); + cmdflags |= MNT_NOSUID; + } + + // MS_NOEXEC + if (mflag & MNT_NOEXEC) { + dprintf("%s: adding MNT_NOEXEC\n", __func__); + cmdflags |= MNT_NOEXEC; + } + +#if 0 + // zfsvfs->z_xattr needs to be set instead of MNT_NOUSERXATTR + if (mflag & MNT_NOUSERXATTR) { + dprintf("%s: adding MNT_NOUSERXATTR\n", __func__); + cmdflags |= MNT_NOUSERXATTR; + } +#endif + + // MS_NOATIME + if (mflag & MNT_NOATIME) { + dprintf("%s: adding MNT_NOATIME\n", __func__); + cmdflags |= MNT_NOATIME; + } + + // nobrowse + if (mflag & MNT_DONTBROWSE) { + dprintf("%s: adding MNT_DONTBROWSE\n", __func__); + cmdflags |= MNT_DONTBROWSE; + } + + // noowners + if (mflag & MNT_IGNORE_OWNERSHIP) { + dprintf("%s: adding MNT_IGNORE_OWNERSHIP\n", __func__); + cmdflags |= MNT_IGNORE_OWNERSHIP; + } + +// These aren't handled by zfs_register_callbacks yet. +#if 0 + if (mflag & MNT_ASYNC) { + dprintf("%s: adding MNT_ASYNC\n", __func__); + cmdflags |= MNT_ASYNC; + } + + // MS_SYNCHRONOUS + if (mflag & MNT_SYNCHRONOUS) { + dprintf("%s: adding MNT_SYNCHRONOUS\n", __func__); + cmdflags |= MNT_SYNCHRONOUS; + } + + // MS_STRICTATIME + if (mflag & MNT_STRICTATIME) { + dprintf("%s: adding MNT_STRICTATIME\n", __func__); + cmdflags |= MNT_STRICTATIME; + } +#endif + vfs_setflags(vfsp, (uint64_t)cmdflags); /*