Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
comparison sbin/fjail @ 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 |
comparison
equal
deleted
inserted
replaced
| 200:8f739dd15d7f | 201:687210f46b8f |
|---|---|
| 393 fi | 393 fi |
| 394 | 394 |
| 395 _rootds_mountpoint="$(zfs list -H -o mountpoint -t filesystem "${_dsname}")" || \ | 395 _rootds_mountpoint="$(zfs list -H -o mountpoint -t filesystem "${_dsname}")" || \ |
| 396 { echo "ERROR: root dataset does not exist" >&2; return 1; } | 396 { echo "ERROR: root dataset does not exist" >&2; return 1; } |
| 397 | 397 |
| 398 zfs list -H -o name,mountpoint,canmount,mounted -s mountpoint -t filesystem -r "${_dsname}" | \ | 398 zfs list -H -o name,mountpoint,canmount,mounted -s mountpoint -t filesystem -r "${_dsname}" \ |
| 399 | { | |
| 399 while IFS=$'\t' read -r _name _mp _canmount _mounted ; do | 400 while IFS=$'\t' read -r _name _mp _canmount _mounted ; do |
| 400 # Skip filesystems that are already mounted | 401 # Skip filesystems that are already mounted |
| 401 [ "${_mounted}" = "yes" ] && continue | 402 [ "${_mounted}" = "yes" ] && continue |
| 402 # Skip filesystems that must not be mounted | 403 # Skip filesystems that must not be mounted |
| 403 [ "${_canmount}" = "off" ] && continue | 404 [ "${_canmount}" = "off" ] && continue |
| 430 echo "Skipping ${_name} because its configured mountpoint is not relative to given root dataset" 2>&1 | 431 echo "Skipping ${_name} because its configured mountpoint is not relative to given root dataset" 2>&1 |
| 431 ;; | 432 ;; |
| 432 esac | 433 esac |
| 433 done | 434 done |
| 434 | 435 |
| 435 return 0 | 436 return 0 |
| 437 } | |
| 436 } | 438 } |
| 437 | 439 |
| 438 | 440 |
| 439 # | 441 # |
| 440 # "umount" -- Recursively unmount ZFS datasets | 442 # "umount" -- Recursively unmount ZFS datasets |
| 451 { echo "ERROR: no dataset given" >&2; return 2; } | 453 { echo "ERROR: no dataset given" >&2; return 2; } |
| 452 | 454 |
| 453 # Just determine whether the given dataset name exists | 455 # Just determine whether the given dataset name exists |
| 454 _rootds_mountpoint="$(zfs list -H -o mountpoint -t filesystem "${_dsname}")" || { echo "ERROR: dataset not found" >&2; return 1; } | 456 _rootds_mountpoint="$(zfs list -H -o mountpoint -t filesystem "${_dsname}")" || { echo "ERROR: dataset not found" >&2; return 1; } |
| 455 | 457 |
| 456 mount -t zfs -p | \ | 458 mount -t zfs -p \ |
| 457 grep -E "^${_dsname}(/|\s)" | \ | 459 | grep -E "^${_dsname}(/|\s)" \ |
| 458 sort -n -r | \ | 460 | sort -n -r \ |
| 461 | { | |
| 459 while IFS=' '$'\t' read -r _name _mp _rest ; do | 462 while IFS=' '$'\t' read -r _name _mp _rest ; do |
| 460 echo "Umounting ${_name} on ${_mp}" | 463 echo "Umounting ${_name} on ${_mp}" |
| 461 umount "${_mp}" || return 1 | 464 umount "${_mp}" || return 1 |
| 462 done | 465 done |
| 463 return 0 | 466 return 0 |
| 467 } | |
| 464 } | 468 } |
| 465 | 469 |
| 466 | 470 |
| 467 # | 471 # |
| 468 # "privs" -- adjust privileges | 472 # "privs" -- adjust privileges |
