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.
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.
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]
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib
33 . $STF_SUITE/tests/functional/cli_root/zfs_unmount/zfs_unmount.kshlib
37 # Verify that 'zfs unmount -a[f]' succeeds as root.
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'
48 verify_runnable "both"
50 set -A fs "$TESTFS" "$TESTFS1"
51 set -A ctr "" "$TESTCTR" "$TESTCTR1" "$TESTCTR/$TESTCTR1"
52 set -A vol "$TESTVOL" "$TESTVOL1"
60 while (( i < ${#ctr[*]} )); do
62 path=${TEST_BASE_DIR%%/}/testroot$$/$TESTPOOL
63 if [[ -n ${ctr[i]} ]]; then
66 setup_filesystem "$DISKS" "$TESTPOOL" \
71 if is_global_zone ; then
73 while (( j < ${#vol[*]} )); do
74 setup_filesystem "$DISKS" "$TESTPOOL" \
75 "${ctr[i]}/${vol[j]}" \
82 while (( j < ${#fs[*]} )); do
83 setup_filesystem "$DISKS" "$TESTPOOL" \
84 "${ctr[i]}/${fs[j]}" \
100 ((i = ${#ctr[*]} - 1))
102 while (( i >= 0 )); do
103 if is_global_zone ; then
105 while (( j < ${#vol[*]} )); do
106 cleanup_filesystem "$TESTPOOL" \
107 "${ctr[i]}/${vol[j]}"
113 while (( j < ${#fs[*]} )); do
114 cleanup_filesystem "$TESTPOOL" \
119 [[ -n ${ctr[i]} ]] && \
120 cleanup_filesystem "$TESTPOOL" "${ctr[i]}"
125 [[ -d ${TEST_BASE_DIR%%/}/testroot$$ ]] && \
126 rm -rf ${TEST_BASE_DIR%%/}/testroot$$
135 while (( i < ${#ctr[*]} )); do
138 [[ -n ${ctr[i]} ]] && \
141 if is_global_zone ; then
143 while (( j < ${#vol[*]} )); do
144 log_must unmounted "$path/${vol[j]}"
150 while (( j < ${#fs[*]} )); do
151 log_must unmounted "$path/${fs[j]}"
155 log_must unmounted "$path"
164 log_assert "Verify that 'zfs $unmountall' succeeds as root, " \
165 "and all available ZFS filesystems are unmounted."
167 log_onexit cleanup_all
172 for opt in "-a" "-fa"; do
173 export __ZFS_POOL_RESTRICT="$TESTPOOL"
174 log_must zfs $mountall
175 unset __ZFS_POOL_RESTRICT
177 if [[ $opt == "-fa" ]]; then
178 mntpnt=$(get_prop mountpoint ${TESTPOOL}/${TESTCTR}/${TESTFS})
180 log_mustnot zfs unmount -a
183 export __ZFS_POOL_RESTRICT="$TESTPOOL"
184 if [[ $opt == "-fa" ]] && is_linux; then
185 log_mustnot zfs unmount $opt
188 log_must zfs unmount $opt
189 unset __ZFS_POOL_RESTRICT
191 if [[ $opt == "-fa" ]]; then
196 log_note "Verify that 'zfs $mountcmd' will display " \
197 "all ZFS filesystems currently mounted."
198 log_must verify_mount_display
202 log_pass "'zfs mount -[f]a' succeeds as root, " \
203 "and all available ZFS filesystems are unmounted."