# HG changeset patch # User Franz Glasner # Date 1727457441 -7200 # Node ID b0e8b5cf5d3396e836590998e6a74a425acb5986 # Parent 1d5f87e68078520df69d6c56e4c9ae57d5e73c52 Implement "_check_no_open_files_on_filesystem()" as common function and use it in ftjail. It checks for open files and memory mapping on a given file system. It uses the standard command "fstat -m -f ". diff -r 1d5f87e68078 -r b0e8b5cf5d33 sbin/ftjail --- a/sbin/ftjail Fri Sep 27 17:28:49 2024 +0200 +++ b/sbin/ftjail Fri Sep 27 19:17:21 2024 +0200 @@ -870,6 +870,7 @@ local _res _jailname _dir_mounts _dir_fn_fstab _dir_fn_fstab2 local _dir_basename _dir_fn_tldir local _root_dataset _root_mountpoint _root_type _root_options + local _mnt_device _mnt_mountpoint _mnt_type _mnt_options local _clone_extra_props _canmount_prop local _line _opt local _root_readonly _root_origin @@ -947,9 +948,9 @@ # mountpoint in ZFS. # Also check that it is a clone proper. # - IFS=$'\t' read -r _root_dataset _root_mountpoint _root_type _root_options _line <&2; return 1; } [ "${_root_type}" != "zfs" ] && { echo "ERROR: root mountpoint is not from a ZFS dataset" 1>&2; return 1; } _root_readonly="$(zfs list -H -o readonly "${_root_dataset}")" @@ -960,6 +961,17 @@ else [ "${_root_origin}" = '-' ] && { echo "ERROR: the root dataset is not a ZFS clone" 1>&2; return 1; } fi + # + # Check for open files on all the mounted filesystems + # + while IFS=$'\t' read -r _mnt_device _mnt_mountpoint _mnt_type _mnt_options _line; do + if ! _check_no_open_files_on_filesystem "${_mnt_mountpoint}" ; then + err "There are open files or memory mapping on file system \`${_mnt_mountpoint}'" + return 1 + fi + done <