Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 201:687210f46b8f
FIX: In mount and unmount commands handle pipeline return values correctly now
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 21 Aug 2022 11:43:01 +0200 |
| parents | 8f739dd15d7f |
| children | 6b7a084ddf1d |
| files | sbin/fjail |
| diffstat | 1 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/sbin/fjail Sun Aug 21 11:19:47 2022 +0200 +++ b/sbin/fjail Sun Aug 21 11:43:01 2022 +0200 @@ -395,7 +395,8 @@ _rootds_mountpoint="$(zfs list -H -o mountpoint -t filesystem "${_dsname}")" || \ { echo "ERROR: root dataset does not exist" >&2; return 1; } - zfs list -H -o name,mountpoint,canmount,mounted -s mountpoint -t filesystem -r "${_dsname}" | \ + zfs list -H -o name,mountpoint,canmount,mounted -s mountpoint -t filesystem -r "${_dsname}" \ + | { while IFS=$'\t' read -r _name _mp _canmount _mounted ; do # Skip filesystems that are already mounted [ "${_mounted}" = "yes" ] && continue @@ -432,7 +433,8 @@ esac done - return 0 + return 0 + } } @@ -453,14 +455,16 @@ # Just determine whether the given dataset name exists _rootds_mountpoint="$(zfs list -H -o mountpoint -t filesystem "${_dsname}")" || { echo "ERROR: dataset not found" >&2; return 1; } - mount -t zfs -p | \ - grep -E "^${_dsname}(/|\s)" | \ - sort -n -r | \ + mount -t zfs -p \ + | grep -E "^${_dsname}(/|\s)" \ + | sort -n -r \ + | { while IFS=' '$'\t' read -r _name _mp _rest ; do echo "Umounting ${_name} on ${_mp}" umount "${_mp}" || return 1 done - return 0 + return 0 + } }
