diff sbin/fjail @ 161:57b9b899bf77

Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 20 Nov 2019 09:11:48 +0100
parents 3f9cae8f5862
children 9bd38c55a75c
line wrap: on
line diff
--- a/sbin/fjail	Thu Nov 07 09:42:44 2019 +0100
+++ b/sbin/fjail	Wed Nov 20 09:11:48 2019 +0100
@@ -66,6 +66,47 @@
 umask 0022
 
 
+_get_dataset_for_mountpoint() {
+    : 'Use `zfs mount` to determine the ZFS dataset for a given mountpoint.
+
+    '
+    local _mountpoint
+    local _ds _mount
+
+    _mountpoint="$1"
+
+    while read -r _ds _mount; do
+        if [ "$_mount" = "$_mountpoint" ]; then
+            echo $_ds
+            return 0
+        fi
+    done <<EOF__GDSFM
+$(zfs mount)
+EOF__GDSFM
+    return 1
+}
+
+
+_get_dataset_for_varempty() {
+    : 'Allow special handling for <mountpoint>/var/empty which may be
+    mounted read-only.
+
+    '
+    local _mountpoint
+    local _ve_mount
+
+    _mountpoint="$1"
+
+    if [ "$_mountpoint" = '/' ]; then
+        _ve_mount='/var/empty'
+    else
+        _ve_mount="${_mountpoint}/var/empty"
+    fi
+
+    _get_dataset_for_mountpoint "${_ve_mount}"
+}
+
+
 #
 # "datasets" -- create the ZFS dataset tree
 #