Skip to content

Commit

Permalink
Make mount.zfs(8) calling zfs_mount_at for legacy mounts as well
Browse files Browse the repository at this point in the history
Commit 329e2ff has made mount.zfs(8) to
call libzfs function 'zfs_mount_at', in order to propagate dataset
properties into mount options. This fix however, is limited to a special
use case where mount.zfs(8) is used in initrd with option '-o zfsutil'.
If either initrd or the user need to use mount.zfs(8) to mount a file
system with 'mountpoint' set to 'legacy', '-o zfsutil' can't be used and
the original issue openzfs#7947 will still happen.

Since the existing code already excluded the possibility of calling
'zfs_mount_at' when it was invoked as a helper program from zfs(8), by
checking 'ZFS_MOUNT_HELPER' environment variable, it makes no sense to
avoid calling 'zfs_mount_at' without '-o zfsutil'.

An exception however, is when mount.zfs(8) was invoked with '-o remount'
to update the mount options for an existing mount point. In this case
call mount(2) directly without modifying the mount options passed from
command line.

Signed-off-by: WHR <whr@rivoreo.one>
  • Loading branch information
Low-power committed Aug 22, 2024
1 parent 816d2b2 commit b50ae96
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cmd/mount_zfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ main(int argc, char **argv)
return (MOUNT_USAGE);
}

if (!zfsutil || sloppy ||
libzfs_envvar_is_set("ZFS_MOUNT_HELPER")) {
if (sloppy || libzfs_envvar_is_set("ZFS_MOUNT_HELPER")) {
zfs_adjust_mount_options(zhp, mntpoint, mntopts, mtabopt);
}

Expand Down Expand Up @@ -337,7 +336,7 @@ main(int argc, char **argv)
dataset, mntpoint, mntflags, zfsflags, mntopts, mtabopt);

if (!fake) {
if (zfsutil && !sloppy &&
if (!remount && !sloppy &&
!libzfs_envvar_is_set("ZFS_MOUNT_HELPER")) {
error = zfs_mount_at(zhp, mntopts, mntflags, mntpoint);
if (error) {
Expand Down

0 comments on commit b50ae96

Please sign in to comment.