annotate sbin/fzfs @ 484:5d43c68bd1e9

Style
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 29 Aug 2024 15:11:29 +0200
parents a2011285f054
children 312aebce590c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
276
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
1 #!/bin/sh
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
2 # -*- indent-tabs-mode: nil; -*-
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
3 #:
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
4 #: A ZFS management helper tool.
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
5 #:
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
6 #: :Author: Franz Glasner
438
9c3b1966ba91 Extend copyright to 2024
Franz Glasner <fzglas.hg@dom66.de>
parents: 429
diff changeset
7 #: :Copyright: (c) 2022-2024 Franz Glasner.
276
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
8 #: All rights reserved.
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
9 #: :License: BSD 3-Clause "New" or "Revised" License.
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
10 #: See LICENSE for details.
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
11 #: If you cannot find LICENSE see
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
12 #: <https://opensource.org/licenses/BSD-3-Clause>
386
84d2735fe7f6 Simplified version tagging a lot: it is also faster now.
Franz Glasner <fzglas.hg@dom66.de>
parents: 380
diff changeset
13 #: :ID: @(#)@@SIMPLEVERSIONTAG@@
276
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
14 #:
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
15
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
16 set -eu
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
17
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
18 VERSION="@@VERSION@@"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
19
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
20 USAGE='
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
21 USAGE: fzfs [ OPTIONS ] COMMAND [ COMMAND OPTIONS ] [ ARG ... ]
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
22
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
23 OPTIONS:
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
24
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
25 -V Print the program name and version number to stdout and exit
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
26
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
27 -h Print this help message to stdout and exit
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
28
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
29 COMMANDS:
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
30
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
31 copy-tree [-A] [-M MOUNTPOINT] [-n] [-u] SOURCE-DATASET DEST-DATASET
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
32
380
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
33 create-tree [-A] [-M MOUNTPOINT] [-n] [-p] [-u] SOURCE-DATASET DEST-DATASET
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
34
283
1fc3b04b39fa Build and package manual pages for fzfs, fzfs-mount and fzfs-umount.
Franz Glasner <fzglas.hg@dom66.de>
parents: 276
diff changeset
35 mount [-O] [-N] [-P] [-u] [-n] DATASET [MOUNTPOINT]
276
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
36
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
37 umount DATASET
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
38
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
39 unmount
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
40
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
41 '
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
42
380
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
43
442
a2011285f054 Move "_get_local_zfs_properties_for_create()" into common.subr
Franz Glasner <fzglas.hg@dom66.de>
parents: 441
diff changeset
44 _p_datadir="$(dirname "$0")"/../share/local-bsdtools
a2011285f054 Move "_get_local_zfs_properties_for_create()" into common.subr
Franz Glasner <fzglas.hg@dom66.de>
parents: 441
diff changeset
45 . "${_p_datadir}/common.subr"
380
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
46
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
47
276
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
48 #
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
49 #: Implementation of the "mount" command.
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
50 #:
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
51 #: Mount a dataset and recursively all its children datasets.
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
52 #:
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
53 command_mount() {
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
54 local _dsname _mountpoint
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
55 local _opt_dry_run _opt_mount_outside _opt_mount_natural
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
56 local _opt_mount_children_only
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
57
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
58 local _name _mp _canmount _mounted _rootds_mountpoint _relative_mp _real_mp
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
59
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
60 _opt_dry_run=""
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
61 _opt_mount_outside=""
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
62 _opt_mount_natural=""
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
63 _opt_mount_children_only=""
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
64 while getopts "ONPnu" _opt ; do
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
65 case ${_opt} in
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
66 O)
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
67 _opt_mount_outside="yes"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
68 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
69 N)
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
70 _opt_mount_natural="yes"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
71 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
72 P)
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
73 _opt_mount_children_only="yes"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
74 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
75 n|u)
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
76 _opt_dry_run="yes"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
77 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
78 \?|:)
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
79 return 2;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
80 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
81 esac
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
82 done
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
83 shift $((OPTIND-1))
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
84 OPTIND=1
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
85
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
86 _dsname="${1-}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
87 _mountpoint="${2-}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
88
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
89 if [ -z "${_dsname}" ]; then
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
90 echo "ERROR: no dataset given" >&2
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
91 return 2
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
92 fi
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
93
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
94 _rootds_mountpoint="$(zfs list -H -o mountpoint -t filesystem "${_dsname}")" || \
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
95 { echo "ERROR: root dataset does not exist" >&2; return 1; }
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
96
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
97 if [ -z "${_mountpoint}" ]; then
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
98 if [ "${_opt_mount_natural}" = "yes" ]; then
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
99 _mountpoint="${_rootds_mountpoint}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
100 else
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
101 echo "ERROR: no mountpoint given" >&2
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
102 return 2
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
103 fi
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
104 else
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
105 if [ "${_opt_mount_natural}" = "yes" ]; then
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
106 echo "ERROR: Cannot have a custom mountpoint when \"-O\" is given" >&2
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
107 return 2
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
108 fi
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
109 fi
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
110
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
111 # Eventually remove a trailing slash
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
112 _mountpoint="${_mountpoint%/}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
113 if [ -z "${_mountpoint}" ]; then
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
114 echo "ERROR: would mount over the root filesystem" >&2
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
115 return 1
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
116 fi
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
117
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
118 zfs list -H -o name,mountpoint,canmount,mounted -s mountpoint -t filesystem -r "${_dsname}" \
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
119 | {
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
120 while IFS=$'\t' read -r _name _mp _canmount _mounted ; do
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
121 # Skip filesystems that are already mounted
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
122 [ "${_mounted}" = "yes" ] && continue
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
123 # Skip filesystems that must not be mounted
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
124 [ "${_canmount}" = "off" ] && continue
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
125 #
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
126 # Mount only the children and skip the given parent dataset
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
127 # if required
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
128 #
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
129 [ \( "${_opt_mount_children_only}" = "yes" \) -a \( "${_name}" = "${_dsname}" \) ] && continue
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
130 case "${_mp}" in
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
131 "none"|"legacy")
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
132 # Do nothing for filesystem with unset or legacy mountpoints
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
133 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
134 "${_rootds_mountpoint}"|"${_rootds_mountpoint}/"*)
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
135 #
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
136 # Handle only mountpoints that have a mountpoint below
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
137 # the parent datasets mountpoint
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
138 #
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
139
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
140 # Determine the mountpoint relative to the parent mountpoint
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
141 _relative_mp="${_mp#${_rootds_mountpoint}}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
142 # Eventually remove a trailing slash
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
143 _relative_mp="${_relative_mp%/}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
144 # The real effective full mountpoint
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
145 _real_mp="${_mountpoint}${_relative_mp}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
146
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
147 #
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
148 # Consistency and sanity check: computed real mountpoint must
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
149 # be equal to the configured mountpoint when no custom mountpoint
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
150 # is given.
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
151 #
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
152 if [ "${_opt_mount_natural}" = "yes" ]; then
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
153 if [ "${_real_mp}" != "${_mp}" ]; then
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
154 echo "ERROR: mountpoint mismatch" >&2
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
155 return 1
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
156 fi
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
157 fi
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
158
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
159 if [ "${_opt_dry_run}" = "yes" ]; then
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
160 echo "Would mount ${_name} on ${_real_mp}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
161 else
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
162 mkdir -p "${_real_mp}" 1> /dev/null 2> /dev/null || \
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
163 { echo "ERROR: cannot create mountpoint ${_real_mp}" >&2; return 1; }
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
164 echo "Mounting ${_name} on ${_real_mp}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
165 mount -t zfs "${_name}" "${_real_mp}" || return 1
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
166 fi
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
167 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
168 *)
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
169 if [ "${_opt_mount_outside}" = "yes" ]; then
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
170 if [ "${_opt_dry_run}" = "yes" ]; then
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
171 echo "Would mount ${_name} on configured ZFS dataset mountpoint ${_mp}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
172 else
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
173 echo "Mounting ${_name} on configured ZFS dataset mountpoint ${_mp}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
174 zfs mount "${_name}" || return 1
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
175 fi
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
176 else
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
177 echo "Skipping ${_name} because its configured ZFS mountpoint is not relative to given root dataset" 2>&1
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
178 fi
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
179 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
180 esac
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
181 done
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
182
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
183 return 0
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
184 }
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
185 }
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
186
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
187
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
188 #:
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
189 #: Implement the "umount" command.
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
190 #:
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
191 #: Umount a datasets and recursively all its children datasets.
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
192 #:
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
193 command_umount() {
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
194 local _dsname
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
195
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
196 local _name _mp _rest _rootds_mountpoint
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
197
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
198 _dsname="${1-}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
199 [ -z "${_dsname}" ] && { echo "ERROR: no dataset given" 1>&2; return 2; }
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
200
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
201 # Just determine whether the given dataset name exists
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
202 _rootds_mountpoint="$(zfs list -H -o mountpoint -t filesystem "${_dsname}")" || { echo "ERROR: dataset not found" 1>&2; return 1; }
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
203
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
204 mount -t zfs -p \
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
205 | grep -E "^${_dsname}(/|\s)" \
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
206 | sort -n -r \
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
207 | {
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
208 while IFS=' '$'\t' read -r _name _mp _rest ; do
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
209 echo "Umounting ${_name} on ${_mp}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
210 umount "${_mp}" || return 1
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
211 done
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
212 }
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
213 return 0
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
214 }
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
215
380
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
216
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
217 #:
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
218 #: Implementation of "copy-tree"
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
219 #:
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
220 command_copy_tree() {
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
221 local _ds_source _ds_target
429
bbdb1ab0ea00 Implement "-k" option for "fzfs copy-tree" to keep received snapshots
Franz Glasner <fzglas.hg@dom66.de>
parents: 428
diff changeset
222 local _opt_mountpoint _opt_mount_noauto _opt_nomount _opt_keep _opt_dry_run
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
223
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
224 local _ds_source_base _ds_source_snapshot _snapshot_suffix
426
2cd4777821fc More work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 424
diff changeset
225 local _ds_tree _ds _ds_relname _ds_canmount
428
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
226 local _arg_canmount _arg_mp1 _arg_mp2
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
227
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
228 _opt_mountpoint=""
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
229 _opt_mount_noauto=""
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
230 _opt_nomount=""
429
bbdb1ab0ea00 Implement "-k" option for "fzfs copy-tree" to keep received snapshots
Franz Glasner <fzglas.hg@dom66.de>
parents: 428
diff changeset
231 _opt_keep=""
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
232 _opt_dry_run=""
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
233
429
bbdb1ab0ea00 Implement "-k" option for "fzfs copy-tree" to keep received snapshots
Franz Glasner <fzglas.hg@dom66.de>
parents: 428
diff changeset
234 while getopts "AM:knu" _opt ; do
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
235 case ${_opt} in
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
236 A)
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
237 _opt_mount_noauto="-o canmount=noauto"
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
238 ;;
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
239 M)
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
240 _opt_mountpoint="${OPTARG}"
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
241 ;;
429
bbdb1ab0ea00 Implement "-k" option for "fzfs copy-tree" to keep received snapshots
Franz Glasner <fzglas.hg@dom66.de>
parents: 428
diff changeset
242 k)
bbdb1ab0ea00 Implement "-k" option for "fzfs copy-tree" to keep received snapshots
Franz Glasner <fzglas.hg@dom66.de>
parents: 428
diff changeset
243 _opt_keep="yes"
bbdb1ab0ea00 Implement "-k" option for "fzfs copy-tree" to keep received snapshots
Franz Glasner <fzglas.hg@dom66.de>
parents: 428
diff changeset
244 ;;
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
245 n)
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
246 _opt_dry_run="-n"
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
247 ;;
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
248 u)
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
249 _opt_nomount="-u"
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
250 ;;
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
251 \?)
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
252 return 2;
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
253 ;;
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
254 esac
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
255 done
422
4363929b0a3e FIX: Typo in variable name "OPTID" -> "OPTIND"
Franz Glasner <fzglas.hg@dom66.de>
parents: 421
diff changeset
256 shift $((OPTIND-1))
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
257 OPTIND=1
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
258
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
259 _ds_source="${1-}"
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
260 _ds_target="${2-}"
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
261
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
262 [ -z "${_ds_source}" ] && { echo "ERROR: no source given" 1>&2; return 2; }
423
1d6ee78f06ef FIX: Another typo in variable name (COPY-PASTE)
Franz Glasner <fzglas.hg@dom66.de>
parents: 422
diff changeset
263 [ -z "${_ds_target}" ] && { echo "ERROR: no target name given" 1>&2; return 2; }
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
264
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
265 if ! zfs get -H name "${_ds_source}" >/dev/null 2>&1; then
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
266 echo "ERROR: source dataset does not exist: ${_ds_source}" 1>&2;
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
267 return 1;
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
268 fi
428
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
269 if zfs get -H name "${_ds_target}" >/dev/null 2>&1; then
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
270 echo "ERROR: target dataset already exists: ${_ds_target}" 1>&2;
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
271 return 1;
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
272 fi
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
273
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
274 _ds_source_base="${_ds_source%@*}"
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
275 _ds_source_snapshot="${_ds_source##*@}"
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
276 _snapshot_suffix="@${_ds_source_snapshot}"
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
277
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
278 if [ "${_ds_source_snapshot}" = "${_ds_source_base}" ]; then
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
279 # No snapshot given
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
280 [ "${_ds_source_base}" = "${_ds_source}" ] || { echo "ERROR:" 1>&2; return 1; }
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
281 _ds_source_snapshot=""
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
282 _snapshot_suffix=""
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
283 fi
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
284
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
285 _ds_tree=""
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
286
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
287 while IFS=$'\n' read -r _ds; do
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
288 if [ -z "${_ds_tree}" ]; then
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
289 _ds_tree="${_ds}"
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
290 else
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
291 _ds_tree="${_ds_tree}"$'\n'"${_ds}"
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
292 fi
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
293 done <<EOF20ee7ea0781414fab8c305d3875d15e
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
294 $(zfs list -H -r -t filesystem -o name -s name "${_ds_source_base}")
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
295 EOF20ee7ea0781414fab8c305d3875d15e
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
296 # Check the existence of all intermediate datasets and their shapshots
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
297 IFS=$'\n'
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
298 for _ds in ${_ds_tree}; do
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
299 if ! zfs get -H name "${_ds}${_snapshot_suffix}" >/dev/null 2>&1; then
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
300 echo "ERROR: child dataset does not exist: ${_ds}${_snapshot_suffix}" 1>&2
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
301 return 1
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
302 fi
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
303 done
428
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
304 IFS=$'\n'
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
305 for _ds in ${_ds_tree}; do
428
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
306 # Reset IFS
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
307 IFS=$' \t\n'
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
308
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
309 # Determine the relative name of the dataset
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
310 _ds_relname="${_ds#${_ds_source_base}}"
426
2cd4777821fc More work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 424
diff changeset
311
2cd4777821fc More work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 424
diff changeset
312 _ds_canmount=$(zfs get -H -o value canmount "${_ds}")
2cd4777821fc More work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 424
diff changeset
313
2cd4777821fc More work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 424
diff changeset
314 if [ "${_ds_canmount}" = "off" ]; then
428
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
315 _arg_canmount="-o canmount=off"
426
2cd4777821fc More work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 424
diff changeset
316 else
428
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
317 _arg_canmount="${_opt_mount_noauto}"
426
2cd4777821fc More work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 424
diff changeset
318 fi
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
319
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
320 if [ -z "${_ds_relname}" ]; then
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
321 #
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
322 # Source root to target root
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
323 #
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
324 if [ -z "${_opt_mountpoint}" ]; then
428
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
325 _arg_mp1=-x
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
326 _arg_mp2=mountpoint
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
327 else
428
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
328 _arg_mp1=-o
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
329 _arg_mp2="mountpoint=${_opt_mountpoint}"
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
330 fi
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
331 else
428
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
332 _arg_mp1=-x
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
333 _arg_mp2=mountpoint
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
334 fi
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
335 if [ -z "${_opt_dry_run}" ]; then
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
336 zfs send -Lec -p -v "${_ds}${_snapshot_suffix}" | zfs receive -v ${_opt_nomount} ${_arg_canmount} ${_arg_mp1} "${_arg_mp2}" "${_ds_target}${_ds_relname}"
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
337 else
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
338 echo "Would execute: zfs send -Lec -p -v '${_ds}${_snapshot_suffix}' | zfs receive -v ${_opt_nomount} ${_arg_canmount} ${_arg_mp1} '${_arg_mp2}' '${_ds_target}${_ds_relname}'"
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
339 fi
428
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
340 # for the loop
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
341 IFS=$'\n'
424
a200c18603c9 Further work on "fzfs copy-tree"
Franz Glasner <fzglas.hg@dom66.de>
parents: 423
diff changeset
342 done
428
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
343 # Reset to default
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
344 IFS=$' \t\n'
429
bbdb1ab0ea00 Implement "-k" option for "fzfs copy-tree" to keep received snapshots
Franz Glasner <fzglas.hg@dom66.de>
parents: 428
diff changeset
345 # Remove received snapshots by default
428
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
346 if [ -n "${_ds_source_snapshot}" ]; then
429
bbdb1ab0ea00 Implement "-k" option for "fzfs copy-tree" to keep received snapshots
Franz Glasner <fzglas.hg@dom66.de>
parents: 428
diff changeset
347 if [ -z "${_opt_keep}" ]; then
bbdb1ab0ea00 Implement "-k" option for "fzfs copy-tree" to keep received snapshots
Franz Glasner <fzglas.hg@dom66.de>
parents: 428
diff changeset
348 if [ -z "${_opt_dry_run}" ]; then
bbdb1ab0ea00 Implement "-k" option for "fzfs copy-tree" to keep received snapshots
Franz Glasner <fzglas.hg@dom66.de>
parents: 428
diff changeset
349 zfs destroy -rv "${_ds_target}${_snapshot_suffix}"
bbdb1ab0ea00 Implement "-k" option for "fzfs copy-tree" to keep received snapshots
Franz Glasner <fzglas.hg@dom66.de>
parents: 428
diff changeset
350 else
bbdb1ab0ea00 Implement "-k" option for "fzfs copy-tree" to keep received snapshots
Franz Glasner <fzglas.hg@dom66.de>
parents: 428
diff changeset
351 echo "Would execute: zfs destroy -rv '${_ds_target}${_snapshot_suffix}'"
bbdb1ab0ea00 Implement "-k" option for "fzfs copy-tree" to keep received snapshots
Franz Glasner <fzglas.hg@dom66.de>
parents: 428
diff changeset
352 fi
428
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
353 fi
824e88618376 The first version of "fzfs copy-tree" completed
Franz Glasner <hg@dom66.de>
parents: 427
diff changeset
354 fi
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
355 }
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
356
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
357
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
358 #:
380
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
359 #: Implement the "create-tree" command
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
360 #:
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
361 #: Create a ZFS dataset tree from a source tree tree including important properties
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
362 #:
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
363 command_create_tree() {
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
364 local _source_ds _target_ds
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
365 local _opt_dry_run _opt_mountpoint _opt_noauto _opt_nomount _opt_canmount_parent_only
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
366
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
367 local _opt _source_name _snapshot_name _current_name _current_type _relative_name _zfs_opts _zfs_canmount _zfs_mountpoint
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
368
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
369 _opt_noauto=""
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
370 _opt_dry_run=""
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
371 _opt_mountpoint=""
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
372 _opt_nomount=""
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
373 _opt_canmount_parent_only=""
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
374
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
375 while getopts "AM:npu" _opt ; do
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
376 case ${_opt} in
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
377 A)
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
378 _opt_noauto="-o canmount=noauto"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
379 ;;
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
380 M)
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
381 _opt_mountpoint="${OPTARG}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
382 ;;
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
383 n)
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
384 _opt_dry_run="yes"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
385 ;;
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
386 p)
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
387 _opt_canmount_parent_only="yes"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
388 ;;
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
389 u)
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
390 _opt_nomount="-u"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
391 ;;
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
392 \?|:)
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
393 return 2;
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
394 ;;
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
395 esac
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
396 done
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
397 shift $((OPTIND-1))
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
398 OPTIND=1
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
399
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
400 _source_ds="${1-}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
401 _target_ds="${2-}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
402
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
403 [ -z "${_source_ds}" ] && { echo "ERROR: no source dataset given" 1>&2; return 2; }
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
404 [ -z "${_target_ds}" ] && { echo "ERROR: no destination dataset given" 1>&2; return 2; }
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
405
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
406 _source_name="${_source_ds%@*}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
407 if [ "${_source_name}" != "${_source_ds}" ]; then
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
408 _snapshot_name="${_source_ds##*@}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
409 else
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
410 _snapshot_name=""
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
411 fi
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
412
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
413 [ -n "${_snapshot_name}" ] && { echo "ERROR: No snapshot sources are supported yet" 1>&2; return 2; }
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
414
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
415 zfs list -H -r -t filesystem -o name,type "${_source_ds}" \
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
416 | {
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
417 while IFS=$'\t' read -r _current_name _current_type ; do
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
418 # Determine the relative name of the dataset
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
419 _relative_name="${_current_name#${_source_name}}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
420 _relative_name="${_relative_name%@*}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
421 if [ "${_current_type}" != "filesystem" ]; then
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
422 echo "ERROR: Got a snapshot but expected a filesystem" 1>&2
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
423 return 1
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
424 fi
441
f06998866c01 Renamed local helper function
Franz Glasner <fzglas.hg@dom66.de>
parents: 438
diff changeset
425 _zfs_opts="$(_get_local_zfs_properties_for_create "${_current_name}" atime exec setuid compression primarycache sync readonly)"
380
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
426 if [ -z "${_relative_name}" ]; then
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
427 #
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
428 # Root
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
429 #
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
430 if [ -z "${_opt_noauto}" ]; then
441
f06998866c01 Renamed local helper function
Franz Glasner <fzglas.hg@dom66.de>
parents: 438
diff changeset
431 _zfs_canmount="$(_get_local_zfs_properties_for_create "${_current_name}" canmount)"
380
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
432 else
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
433 _zfs_canmount="${_opt_noauto}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
434 fi
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
435 if [ -n "${_opt_mountpoint}" ]; then
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
436 _zfs_mountpoint="${_opt_mountpoint}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
437 else
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
438 _zfs_mountpoint=""
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
439 fi
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
440
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
441 if [ "${_opt_dry_run}" = "yes" ]; then
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
442 if [ -z "${_zfs_mountpoint}" ]; then
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
443 echo "Would call: zfs create ${_opt_nomount} ${_zfs_opts} ${_zfs_canmount} ${_target_ds}${_relative_name}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
444 else
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
445 echo "Would call: zfs create ${_opt_nomount} ${_zfs_opts} ${_zfs_canmount} -o mountpoint=${_zfs_mountpoint} ${_target_ds}${_relative_name}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
446 fi
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
447 else
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
448 if [ -z "${_zfs_mountpoint}" ]; then
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
449 zfs create -v ${_opt_nomount} ${_zfs_opts} ${_zfs_canmount} "${_target_ds}${_relative_name}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
450 else
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
451 zfs create -v ${_opt_nomount} ${_zfs_opts} ${_zfs_canmount} -o "mountpoint=${_zfs_mountpoint}" "${_target_ds}${_relative_name}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
452 fi
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
453 fi
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
454 else
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
455 #
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
456 # Children
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
457 #
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
458 if [ -z "${_opt_noauto}" ]; then
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
459 if [ "${_opt_canmount_parent_only}" = "yes" ]; then
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
460 _zfs_canmount=""
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
461 else
441
f06998866c01 Renamed local helper function
Franz Glasner <fzglas.hg@dom66.de>
parents: 438
diff changeset
462 _zfs_canmount="$(_get_local_zfs_properties_for_create "${_current_name}" canmount)"
380
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
463 fi
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
464 else
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
465 _zfs_canmount="${_opt_noauto}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
466 fi
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
467 if [ "${_opt_dry_run}" = "yes" ]; then
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
468 echo "Would call: zfs create ${_opt_nomount} ${_zfs_opts} ${_zfs_canmount} ${_target_ds}${_relative_name}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
469 else
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
470 zfs create -v ${_opt_nomount} ${_zfs_opts} ${_zfs_canmount} "${_target_ds}${_relative_name}"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
471 fi
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
472 fi
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
473 done
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
474 }
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
475 return 0
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
476 }
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
477
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
478
276
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
479 #
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
480 # Global option handling
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
481 #
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
482 while getopts "Vh" _opt ; do
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
483 case ${_opt} in
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
484 V)
408
bb0a0384b5da FIX: Program name in fzfs's version string
Franz Glasner <f.glasner@feldmann-mg.com>
parents: 386
diff changeset
485 printf 'fzfs %s\n' '@@SIMPLEVERSIONSTR@@'
276
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
486 exit 0
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
487 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
488 h)
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
489 echo "${USAGE}"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
490 exit 0
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
491 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
492 \?)
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
493 exit 2;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
494 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
495 *)
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
496 echo "ERROR: option handling failed" 1>&2
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
497 exit 2
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
498 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
499 esac
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
500 done
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
501 #
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
502 # Reset the Shell's option handling system to prepare for handling
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
503 # command-local options.
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
504 #
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
505 shift $((OPTIND-1))
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
506 OPTIND=1
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
507
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
508 test $# -gt 0 || { echo "ERROR: no command given" 1>&2; exit 2; }
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
509
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
510 command="$1"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
511 shift
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
512
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
513 case "${command}" in
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
514 mount)
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
515 command_mount "$@"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
516 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
517 umount|unmount)
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
518 command_umount "$@"
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
519 ;;
421
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
520 copy-tree)
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
521 command_copy_tree "$@"
a571a30bcf8a Begin the implementation of "fzfs copy-tree"
Franz Glasner <hg@dom66.de>
parents: 408
diff changeset
522 ;;
380
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
523 create-tree)
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
524 command_create_tree "$@"
6be930eb7490 Implement the "fzfs create-tree" command
Franz Glasner <fzglas.hg@dom66.de>
parents: 283
diff changeset
525 ;;
276
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
526 *)
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
527 echo "ERROR: unknown command \`${command}'" 1>&2
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
528 exit 2
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
529 ;;
3c24b07240f2 Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
530 esac