changeset 662:bc418b122fc9

fzfs: Implement option "-f" for the "umount" command: try to forcefully umount a dataset tree
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 29 Sep 2024 16:27:22 +0200
parents 1e6c86f0a850
children 83ec66c64f47
files docs/man/man8/ftjail.rst docs/man/man8/fzfs-umount.rst sbin/fzfs
diffstat 3 files changed, 25 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/docs/man/man8/ftjail.rst	Sun Sep 29 16:22:45 2024 +0200
+++ b/docs/man/man8/ftjail.rst	Sun Sep 29 16:27:22 2024 +0200
@@ -14,7 +14,7 @@
 Description
 -----------
 
-Management tool for Thin Jails: creation of base and skeleton datasets,
+Management tool for Thin Jails: creation of base and skeleton ZFS datasets,
 mount and population helpers.
 
 The following global options are implemented:
--- a/docs/man/man8/fzfs-umount.rst	Sun Sep 29 16:22:45 2024 +0200
+++ b/docs/man/man8/fzfs-umount.rst	Sun Sep 29 16:27:22 2024 +0200
@@ -3,12 +3,15 @@
 fzfs-umount
 ===========
 
+.. program:: fzfs umount
+
+
 Synopsis
 --------
 
-**fzfs umount** [**-k**] `dataset`
+**fzfs umount** [**-f**] [**-k**] `dataset`
 
-**fzfs unmount** [**-k**] `dataset`
+**fzfs unmount** [**-f**] [**-k**] `dataset`
 
 
 Description
@@ -20,7 +23,10 @@
 Options
 -------
 
-.. program:: fzfs umount
+.. option:: -f
+
+   Forcefully unmount all the file systems, even if they are currently
+   in use.
 
 .. option:: -k
 
--- a/sbin/fzfs	Sun Sep 29 16:22:45 2024 +0200
+++ b/sbin/fzfs	Sun Sep 29 16:27:22 2024 +0200
@@ -37,9 +37,9 @@
 
   mount [-O] [-N] [-P] [-k] [-u] [-n] DATASET [MOUNTPOINT]
 
-  umount [-k] DATASET
+  umount [-f] [-k] DATASET
 
-  unmount
+  unmount [-f] [-k] DATASET
 
 '
 
@@ -285,14 +285,18 @@
 #:
 command_umount() {
     local _dsname
-    local _opt_dry_run
+    local _opt_force _opt_dry_run
 
     local _opt _name _mp _rest _rootds_mountpoint
 
+    _opt_force=""
     _opt_dry_run=""
 
-    while getopts "k" _opt ; do
+    while getopts "fk" _opt ; do
         case ${_opt} in
+            f)
+                _opt_force="-f"
+                ;;
             k)
                 _opt_dry_run="yes"
                 ;;
@@ -314,10 +318,15 @@
     | {
         while IFS=$'\t' read -r _name _mp ; do
             if checkyes _opt_dry_run ; then
-                echo "Would umount ${_name} from ${_mp}"
+                if [ -z "${_opt_force}" ]; then
+                    echo "Would umount ${_name} from ${_mp}"
+                else
+
+                    echo "Would forcefully umount ${_name} from ${_mp}"
+                fi
             else
                 echo "Umounting ${_name} on ${_mp}"
-                /sbin/umount "${_mp}" || return 1
+                /sbin/umount ${_opt_force} "${_mp}" || return 1
             fi
         done
         return 0