changeset 453:5194d87e0b4b

Move "_get_mounts_at_directory()" into common.subr
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 14 May 2024 09:46:54 +0200
parents d5591ebc303d
children 263b4d382155
files sbin/ftjail share/local-bsdtools/common.subr
diffstat 2 files changed, 46 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/sbin/ftjail	Fri May 10 13:42:10 2024 +0200
+++ b/sbin/ftjail	Tue May 14 09:46:54 2024 +0200
@@ -65,52 +65,6 @@
 umask 0022
 
 
-#:
-#: Search for mounts and sub-mounts at a given directory.
-#:
-#: The output is sorted by the mountpoint.
-#:
-#: Args:
-#:   $1: the directory where to start for mounts and sub-mounts
-#:
-#: Output (stdout):
-#:   The sorted list (lines) of mounts in :manpage:`fstab(5)` format.
-#:   This list may be empty.
-#:
-#: Exit:
-#:   1: on fatal errors (usage et al.)
-#:
-#: Important:
-#:   The input directory **must** be an absolute path.
-#:
-_get_mounts_at_directory() {
-    local _directory
-
-    local _fstab
-
-    _directory=${1-}
-    case "${_directory}" in
-        */)
-            echo "ERROR: a trailing slash in directory name given" 1>&2;
-            exit 1;
-            ;;
-        /*)
-            :
-            ;;
-        '')
-            echo "ERROR: no directory given" 1>&2;
-            exit 1;
-            ;;
-        *)
-            echo "ERROR: directory must be an absolute path" 1>&2;
-            exit 1;
-            ;;
-    esac
-    _fstab="$(mount -p | awk -v pa1="^${_directory}\$" -v pa2="^${_directory}/" '($2 ~ pa1) || ($2 ~ pa2 ) { print; }' | sort -k3)"
-    echo "${_fstab}"
-}
-
-
 #
 # PARENT-BASE NAME DRY-RUN
 #
--- a/share/local-bsdtools/common.subr	Fri May 10 13:42:10 2024 +0200
+++ b/share/local-bsdtools/common.subr	Tue May 14 09:46:54 2024 +0200
@@ -184,3 +184,49 @@
       return 3
   }
 }
+
+
+#:
+#: Search for mounts and sub-mounts at a given directory.
+#:
+#: The output is sorted by the mountpoint.
+#:
+#: Args:
+#:   $1: the directory where to start for mounts and sub-mounts
+#:
+#: Output (stdout):
+#:   The sorted list (lines) of mounts in :manpage:`fstab(5)` format.
+#:   This list may be empty.
+#:
+#: Exit:
+#:   1: on fatal errors (usage et al.)
+#:
+#: Important:
+#:   The input directory **must** be an absolute path.
+#:
+_get_mounts_at_directory() {
+    local _directory
+
+    local _fstab
+
+    _directory=${1-}
+    case "${_directory}" in
+        */)
+            echo "ERROR: a trailing slash in directory name given" 1>&2;
+            exit 1;
+            ;;
+        /*)
+            :
+            ;;
+        '')
+            echo "ERROR: no directory given" 1>&2;
+            exit 1;
+            ;;
+        *)
+            echo "ERROR: directory must be an absolute path" 1>&2;
+            exit 1;
+            ;;
+    esac
+    _fstab="$(mount -p | awk -v pa1="^${_directory}\$" -v pa2="^${_directory}/" '($2 ~ pa1) || ($2 ~ pa2 ) { print; }' | sort -k3)"
+    echo "${_fstab}"
+}