Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
comparison sbin/fzfs @ 421:a571a30bcf8a
Begin the implementation of "fzfs copy-tree"
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Tue, 19 Sep 2023 19:35:29 +0200 |
| parents | bb0a0384b5da |
| children | 4363929b0a3e |
comparison
equal
deleted
inserted
replaced
| 420:bf0d63c8e682 | 421:a571a30bcf8a |
|---|---|
| 25 -V Print the program name and version number to stdout and exit | 25 -V Print the program name and version number to stdout and exit |
| 26 | 26 |
| 27 -h Print this help message to stdout and exit | 27 -h Print this help message to stdout and exit |
| 28 | 28 |
| 29 COMMANDS: | 29 COMMANDS: |
| 30 | |
| 31 copy-tree [-A] [-M MOUNTPOINT] [-n] [-u] SOURCE-DATASET DEST-DATASET | |
| 30 | 32 |
| 31 create-tree [-A] [-M MOUNTPOINT] [-n] [-p] [-u] SOURCE-DATASET DEST-DATASET | 33 create-tree [-A] [-M MOUNTPOINT] [-n] [-p] [-u] SOURCE-DATASET DEST-DATASET |
| 32 | 34 |
| 33 mount [-O] [-N] [-P] [-u] [-n] DATASET [MOUNTPOINT] | 35 mount [-O] [-N] [-P] [-u] [-n] DATASET [MOUNTPOINT] |
| 34 | 36 |
| 244 echo "Umounting ${_name} on ${_mp}" | 246 echo "Umounting ${_name} on ${_mp}" |
| 245 umount "${_mp}" || return 1 | 247 umount "${_mp}" || return 1 |
| 246 done | 248 done |
| 247 } | 249 } |
| 248 return 0 | 250 return 0 |
| 251 } | |
| 252 | |
| 253 | |
| 254 #: | |
| 255 #: Implementation of "copy-tree" | |
| 256 #: | |
| 257 command_copy_tree() { | |
| 258 local _ds_source _ds_target | |
| 259 local _opt_mountpoint _opt_mount_noauto _opt_nomount _opt_dry_run | |
| 260 | |
| 261 local _ds_source_base _ds_source_snapshot | |
| 262 | |
| 263 while getopts "AM:nu" _opt ; do | |
| 264 case ${_opt} in | |
| 265 A) | |
| 266 _opt_mount_noauto="-o canmount=noauto" | |
| 267 ;; | |
| 268 M) | |
| 269 _opt_mountpoint="${OPTARG}" | |
| 270 ;; | |
| 271 n) | |
| 272 _opt_dry_run="-n" | |
| 273 ;; | |
| 274 u) | |
| 275 _opt_nomount="-u" | |
| 276 ;; | |
| 277 \?) | |
| 278 return 2; | |
| 279 ;; | |
| 280 esac | |
| 281 done | |
| 282 shift $((OPTID-1)) | |
| 283 OPTIND=1 | |
| 284 | |
| 285 _ds_source="${1-}" | |
| 286 _ds_target="${2-}" | |
| 287 | |
| 288 [ -z "${_ds_source}" ] && { echo "ERROR: no source given" 1>&2; return 2; } | |
| 289 [ -z "${_snapshot_name}" ] && { echo "ERROR: no snapshot name given" 1>&2; return 2; } | |
| 290 | |
| 291 _ds_source_base="${_ds_source%@*}" | |
| 292 _ds_source_snapshot="${_ds_source##*@}" | |
| 293 | |
| 294 if [ "${_ds_source_snapshot}" = "${_ds_source_base}" ]; then | |
| 295 # No snapshot given | |
| 296 _ds_source_snapshot="" | |
| 297 fi | |
| 249 } | 298 } |
| 250 | 299 |
| 251 | 300 |
| 252 #: | 301 #: |
| 253 #: Implement the "create-tree" command | 302 #: Implement the "create-tree" command |
| 409 command_mount "$@" | 458 command_mount "$@" |
| 410 ;; | 459 ;; |
| 411 umount|unmount) | 460 umount|unmount) |
| 412 command_umount "$@" | 461 command_umount "$@" |
| 413 ;; | 462 ;; |
| 463 copy-tree) | |
| 464 command_copy_tree "$@" | |
| 465 ;; | |
| 414 create-tree) | 466 create-tree) |
| 415 command_create_tree "$@" | 467 command_create_tree "$@" |
| 416 ;; | 468 ;; |
| 417 *) | 469 *) |
| 418 echo "ERROR: unknown command \`${command}'" 1>&2 | 470 echo "ERROR: unknown command \`${command}'" 1>&2 |
