Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
comparison sbin/fzfs @ 528:93b98803219b
fzfs umount: implemented option "-k" (dry-run)
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 04 Sep 2024 18:48:10 +0200 |
| parents | b7d60802b25f |
| children | 703e9f357339 |
comparison
equal
deleted
inserted
replaced
| 527:b7d60802b25f | 528:93b98803219b |
|---|---|
| 34 | 34 |
| 35 create-tree [-A] [-M MOUNTPOINT] [-n] [-p] [-u] SOURCE-DATASET DEST-DATASET | 35 create-tree [-A] [-M MOUNTPOINT] [-n] [-p] [-u] SOURCE-DATASET DEST-DATASET |
| 36 | 36 |
| 37 mount [-O] [-N] [-P] [-k] [-u] [-n] DATASET [MOUNTPOINT] | 37 mount [-O] [-N] [-P] [-k] [-u] [-n] DATASET [MOUNTPOINT] |
| 38 | 38 |
| 39 umount DATASET | 39 umount [-k] DATASET |
| 40 | 40 |
| 41 unmount | 41 unmount |
| 42 | 42 |
| 43 ' | 43 ' |
| 44 | 44 |
| 280 #: | 280 #: |
| 281 #: Umount a datasets and recursively all its children datasets. | 281 #: Umount a datasets and recursively all its children datasets. |
| 282 #: | 282 #: |
| 283 command_umount() { | 283 command_umount() { |
| 284 local _dsname | 284 local _dsname |
| 285 | 285 local _opt_dry_run |
| 286 local _name _mp _rest _rootds_mountpoint | 286 |
| 287 local _opt _name _mp _rest _rootds_mountpoint | |
| 288 | |
| 289 _opt_dry_run="" | |
| 290 | |
| 291 while getopts "k" _opt ; do | |
| 292 case ${_opt} in | |
| 293 k) | |
| 294 _opt_dry_run="yes" | |
| 295 ;; | |
| 296 \?) | |
| 297 return 2; | |
| 298 ;; | |
| 299 esac | |
| 300 done | |
| 301 shift $((OPTIND-1)) | |
| 302 OPTIND=1 | |
| 287 | 303 |
| 288 _dsname="${1-}" | 304 _dsname="${1-}" |
| 289 [ -z "${_dsname}" ] && { echo "ERROR: no dataset given" 1>&2; return 2; } | 305 [ -z "${_dsname}" ] && { echo "ERROR: no dataset given" 1>&2; return 2; } |
| 290 | 306 |
| 291 # Just determine whether the given dataset name exists | 307 # Just determine whether the given dataset name exists |
| 294 /sbin/mount -t zfs -p \ | 310 /sbin/mount -t zfs -p \ |
| 295 | LC_ALL=C GREP_OPTIONS="" /usr/bin/egrep "^${_dsname}(/|\s)" \ | 311 | LC_ALL=C GREP_OPTIONS="" /usr/bin/egrep "^${_dsname}(/|\s)" \ |
| 296 | /usr/bin/sort -n -r \ | 312 | /usr/bin/sort -n -r \ |
| 297 | { | 313 | { |
| 298 while IFS=' '$'\t' read -r _name _mp _rest ; do | 314 while IFS=' '$'\t' read -r _name _mp _rest ; do |
| 299 echo "Umounting ${_name} on ${_mp}" | 315 if checkyes _opt_dry_run ; then |
| 300 /sbin/umount "${_mp}" || return 1 | 316 echo "Would umount ${_name} from ${_mp}" |
| 317 else | |
| 318 echo "Umounting ${_name} on ${_mp}" | |
| 319 /sbin/umount "${_mp}" || return 1 | |
| 320 fi | |
| 301 done | 321 done |
| 302 } | 322 } |
| 303 return 0 | 323 return 0 |
| 304 } | 324 } |
| 305 | 325 |
