changeset 265:95a81116471a

Implement a mount option to allow only the mount of children whem mounting a dataset tree
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 13 Sep 2022 09:18:21 +0200
parents 947ccf0a99fd
children a23e952580f8
files sbin/fjail
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sbin/fjail	Tue Sep 13 00:13:05 2022 +0200
+++ b/sbin/fjail	Tue Sep 13 09:18:21 2022 +0200
@@ -49,6 +49,7 @@
     -O        Also mount datasets at mountpoints outside of their "natural"
               and inherited mountpoints
     -N        Mount at their "natural" configured ZFS mountpoints (MOUNTPOINT is not required)
+    -P        Do not mount the given prent DATASET but only its children
     -n        Do not really mount but show what would be mounted where
     -u        Alias of -n
 
@@ -497,12 +498,13 @@
     local _dsname _mountpoint
     local _name _mp _canmount _mounted
     local _rootds_mountpoint _relative_mp _real_mp
-    local _dry_run _mount_outside _mount_natural
+    local _dry_run _mount_outside _mount_natural _mount_children_only
 
     _dry_run=""
     _mount_outside=""
     _mount_natural=""
-    while getopts "ONnu" _opt ; do
+    _mount_children_only=""
+    while getopts "ONPnu" _opt ; do
         case ${_opt} in
             O)
                 _mount_outside="yes"
@@ -510,6 +512,9 @@
             N)
                 _mount_natural="yes"
                 ;;
+            P)
+                _mount_children_only="yes"
+                ;;
             n|u)
                 _dry_run="yes"
                 ;;
@@ -560,6 +565,8 @@
             [ "${_mounted}" = "yes" ] && continue
             # Skip filesystems that must not be mounted
             [ "${_canmount}" = "off" ] && continue
+            # Mount only the children and skip the given dataset it required
+            [ \( "${_mount_children_only}" = "yes" \) -a \( "${_name}" = "${_dsname}" \) ] && continue
             case "${_mp}" in
                 "none"|"legacy")
                     # Do nothing for filesystem with unset or legacy mountpoints