mount: use the mount syscall directly

Allow zfs datasets to be mounted on Linux without relying on the
invocation of an external processes.  This is the same behavior
which is implemented for FreeBSD.

Use of the libmount library was originally considered because it 
provides functionality to properly lock and update the /etc/mtab 
file.  However, these days /etc/mtab is typically a symlink to 
/proc/self/mounts so there's nothing to updated.  Therefore, we
call mount(2) directly and avoid any additional dependencies. 

If required the legacy behavior can be enabled by setting the 
ZFS_MOUNT_HELPER environment variable.  This may be needed in
environments where SELinux in enabled and the zfs binary does  
not have mount permission.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Felix Dörre <felix@dogcraft.de>
#10294
This commit is contained in:
felixdoerre
2020-05-21 04:02:41 +03:00
committed by GitHub
parent 57434abae6
commit 501a1511ae
9 changed files with 334 additions and 276 deletions
+9
View File
@@ -710,6 +710,15 @@ Do note that any changes done with the
.Xr net 8
command will be undone if the share is ever unshared (such as at a reboot etc).
.El
.Sh ENVIRONMENT VARIABLES
.Bl -tag -width "ZFS_MOUNT_HELPER"
.It Ev ZFS_MOUNT_HELPER
Cause
.Nm zfs mount
to use
.Em /bin/mount
to mount zfs datasets. This option is provided for backwards compatibility with older zfs versions.
.El
.Sh INTERFACE STABILITY
.Sy Committed .
.Sh SEE ALSO