]>
Commit | Line | Data |
---|---|---|
6bb24f4d BB |
1 | #!/bin/ksh -p |
2 | # | |
3 | # CDDL HEADER START | |
4 | # | |
5 | # The contents of this file are subject to the terms of the | |
6 | # Common Development and Distribution License (the "License"). | |
7 | # You may not use this file except in compliance with the License. | |
8 | # | |
9 | # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
10 | # or http://www.opensolaris.org/os/licensing. | |
11 | # See the License for the specific language governing permissions | |
12 | # and limitations under the License. | |
13 | # | |
14 | # When distributing Covered Code, include this CDDL HEADER in each | |
15 | # file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
16 | # If applicable, add the following below this CDDL HEADER, with the | |
17 | # fields enclosed by brackets "[]" replaced with your own identifying | |
18 | # information: Portions Copyright [yyyy] [name of copyright owner] | |
19 | # | |
20 | # CDDL HEADER END | |
21 | # | |
22 | ||
23 | # | |
24 | # Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
25 | # Use is subject to license terms. | |
26 | # | |
27 | ||
c1d9abf9 JWK |
28 | # |
29 | # Copyright (c) 2016 by Delphix. All rights reserved. | |
30 | # | |
31 | ||
6bb24f4d BB |
32 | . $STF_SUITE/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib |
33 | . $STF_SUITE/tests/functional/cli_root/zfs_unmount/zfs_unmount.kshlib | |
34 | ||
35 | # | |
36 | # DESCRIPTION: | |
37 | # Verify that 'zfs unmount -a[f]' succeeds as root. | |
38 | # | |
39 | # STRATEGY: | |
40 | # 1. Create a group of pools with specified vdev. | |
41 | # 2. Create zfs filesystems within the given pools. | |
42 | # 3. Mount all the filesystems. | |
43 | # 4. Verify that 'zfs unmount -a[f]' command succeed, | |
44 | # and all available ZFS filesystems are unmounted. | |
45 | # 5. Verify that 'zfs mount' is identical with 'df -F zfs' | |
46 | # | |
47 | ||
48 | verify_runnable "both" | |
49 | ||
50 | set -A fs "$TESTFS" "$TESTFS1" | |
51 | set -A ctr "" "$TESTCTR" "$TESTCTR1" "$TESTCTR/$TESTCTR1" | |
52 | set -A vol "$TESTVOL" "$TESTVOL1" | |
53 | ||
54 | function setup_all | |
55 | { | |
56 | typeset -i i=0 | |
57 | typeset -i j=0 | |
58 | typeset path | |
59 | ||
60 | while (( i < ${#ctr[*]} )); do | |
61 | ||
62 | path=${TEST_BASE_DIR%%/}/testroot$$/$TESTPOOL | |
63 | if [[ -n ${ctr[i]} ]]; then | |
64 | path=$path/${ctr[i]} | |
65 | ||
66 | setup_filesystem "$DISKS" "$TESTPOOL" \ | |
67 | "${ctr[i]}" "$path" \ | |
68 | "ctr" | |
69 | fi | |
70 | ||
71 | if is_global_zone ; then | |
72 | j=0 | |
73 | while (( j < ${#vol[*]} )); do | |
74 | setup_filesystem "$DISKS" "$TESTPOOL" \ | |
75 | "${ctr[i]}/${vol[j]}" \ | |
76 | "$path/${vol[j]}" \ | |
77 | "vol" | |
78 | ((j = j + 1)) | |
79 | done | |
80 | fi | |
81 | j=0 | |
82 | while (( j < ${#fs[*]} )); do | |
83 | setup_filesystem "$DISKS" "$TESTPOOL" \ | |
84 | "${ctr[i]}/${fs[j]}" \ | |
85 | "$path/${fs[j]}" | |
86 | ((j = j + 1)) | |
87 | done | |
88 | ||
89 | ((i = i + 1)) | |
90 | done | |
91 | ||
92 | return 0 | |
93 | } | |
94 | ||
95 | function cleanup_all | |
96 | { | |
97 | typeset -i i=0 | |
98 | typeset -i j=0 | |
99 | ||
100 | ((i = ${#ctr[*]} - 1)) | |
101 | ||
102 | while (( i >= 0 )); do | |
103 | if is_global_zone ; then | |
104 | j=0 | |
105 | while (( j < ${#vol[*]} )); do | |
106 | cleanup_filesystem "$TESTPOOL" \ | |
107 | "${ctr[i]}/${vol[j]}" | |
108 | ((j = j + 1)) | |
109 | done | |
110 | fi | |
111 | ||
112 | j=0 | |
113 | while (( j < ${#fs[*]} )); do | |
114 | cleanup_filesystem "$TESTPOOL" \ | |
115 | "${ctr[i]}/${fs[j]}" | |
116 | ((j = j + 1)) | |
117 | done | |
118 | ||
119 | [[ -n ${ctr[i]} ]] && \ | |
120 | cleanup_filesystem "$TESTPOOL" "${ctr[i]}" | |
121 | ||
122 | ((i = i - 1)) | |
123 | done | |
124 | ||
125 | [[ -d ${TEST_BASE_DIR%%/}/testroot$$ ]] && \ | |
c1d9abf9 | 126 | rm -rf ${TEST_BASE_DIR%%/}/testroot$$ |
6bb24f4d BB |
127 | } |
128 | ||
129 | function verify_all | |
130 | { | |
131 | typeset -i i=0 | |
132 | typeset -i j=0 | |
133 | typeset path | |
134 | ||
135 | while (( i < ${#ctr[*]} )); do | |
136 | ||
137 | path=$TESTPOOL | |
138 | [[ -n ${ctr[i]} ]] && \ | |
139 | path=$path/${ctr[i]} | |
140 | ||
141 | if is_global_zone ; then | |
142 | j=0 | |
143 | while (( j < ${#vol[*]} )); do | |
144 | log_must unmounted "$path/${vol[j]}" | |
145 | ((j = j + 1)) | |
146 | done | |
147 | fi | |
148 | ||
149 | j=0 | |
150 | while (( j < ${#fs[*]} )); do | |
151 | log_must unmounted "$path/${fs[j]}" | |
152 | ((j = j + 1)) | |
153 | done | |
154 | ||
155 | log_must unmounted "$path" | |
156 | ||
157 | ((i = i + 1)) | |
158 | done | |
159 | ||
160 | return 0 | |
161 | } | |
162 | ||
163 | ||
164 | log_assert "Verify that 'zfs $unmountall' succeeds as root, " \ | |
165 | "and all available ZFS filesystems are unmounted." | |
166 | ||
167 | log_onexit cleanup_all | |
168 | ||
169 | log_must setup_all | |
170 | ||
171 | typeset opt | |
172 | for opt in "-a" "-fa"; do | |
173 | export __ZFS_POOL_RESTRICT="$TESTPOOL" | |
c1d9abf9 | 174 | log_must zfs $mountall |
6bb24f4d BB |
175 | unset __ZFS_POOL_RESTRICT |
176 | ||
177 | if [[ $opt == "-fa" ]]; then | |
178 | mntpnt=$(get_prop mountpoint ${TESTPOOL}/${TESTCTR}/${TESTFS}) | |
179 | cd $mntpnt | |
c1d9abf9 | 180 | log_mustnot zfs unmount -a |
6bb24f4d BB |
181 | fi |
182 | ||
183 | export __ZFS_POOL_RESTRICT="$TESTPOOL" | |
95401cb6 BB |
184 | if [[ $opt == "-fa" ]] && is_linux; then |
185 | log_mustnot zfs unmount $opt | |
186 | cd /tmp | |
187 | fi | |
c1d9abf9 | 188 | log_must zfs unmount $opt |
6bb24f4d BB |
189 | unset __ZFS_POOL_RESTRICT |
190 | ||
191 | if [[ $opt == "-fa" ]]; then | |
192 | cd /tmp | |
193 | fi | |
194 | ||
195 | log_must verify_all | |
196 | log_note "Verify that 'zfs $mountcmd' will display " \ | |
197 | "all ZFS filesystems currently mounted." | |
198 | log_must verify_mount_display | |
199 | ||
200 | done | |
201 | ||
202 | log_pass "'zfs mount -[f]a' succeeds as root, " \ | |
203 | "and all available ZFS filesystems are unmounted." |