1#!/usr/local/bin/ksh93 -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# ident "@(#)zfs_unmount_all_001_pos.ksh 1.3 07/07/31 SMI" 28# 29 30. $STF_SUITE/tests/cli_root/zfs_mount/zfs_mount.kshlib 31. $STF_SUITE/tests/cli_root/zfs_unmount/zfs_unmount.kshlib 32 33################################################################################ 34# 35# __stc_assertion_start 36# 37# ID: zfs_unmount_all_001_pos 38# 39# DESCRIPTION: 40# Verify that 'zfs unmount -a[f]' succeeds as root. 41# 42# STRATEGY: 43# 1. Create a group of pools with specified vdev. 44# 2. Create zfs filesystems within the given pools. 45# 3. Mount all the filesystems. 46# 4. Verify that 'zfs unmount -a[f]' command succeed, 47# and all available ZFS filesystems are unmounted. 48# 5. Verify that 'zfs mount' is identical with 'df -F zfs' 49# 50# TESTABILITY: explicit 51# 52# TEST_AUTOMATION_LEVEL: automated 53# 54# CODING_STATUS: COMPLETED (2005-07-12) 55# 56# __stc_assertion_end 57# 58################################################################################ 59 60verify_runnable "both" 61 62set -A fs "$TESTFS" "$TESTFS1" 63set -A ctr "" "$TESTCTR" "$TESTCTR1" "$TESTCTR/$TESTCTR1" 64set -A vol "$TESTVOL" "$TESTVOL1" 65 66function setup_all 67{ 68 typeset -i i=0 69 typeset -i j=0 70 typeset path 71 72 while (( i < ${#ctr[*]} )); do 73 74 path=${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID}/$TESTPOOL 75 if [[ -n ${ctr[i]} ]]; then 76 path=$path/${ctr[i]} 77 78 setup_filesystem "$DISKS" "$TESTPOOL" \ 79 "${ctr[i]}" "$path" \ 80 "ctr" 81 fi 82 83 if is_global_zone ; then 84 j=0 85 while (( j < ${#vol[*]} )); do 86 setup_filesystem "$DISKS" "$TESTPOOL" \ 87 "${ctr[i]}/${vol[j]}" \ 88 "$path/${vol[j]}" \ 89 "vol" 90 ((j = j + 1)) 91 done 92 fi 93 j=0 94 while (( j < ${#fs[*]} )); do 95 setup_filesystem "$DISKS" "$TESTPOOL" \ 96 "${ctr[i]}/${fs[j]}" \ 97 "$path/${fs[j]}" 98 ((j = j + 1)) 99 done 100 101 ((i = i + 1)) 102 done 103 104 return 0 105} 106 107function cleanup_all 108{ 109 typeset -i i=0 110 typeset -i j=0 111 112 ((i = ${#ctr[*]} - 1)) 113 114 while (( i >= 0 )); do 115 if is_global_zone ; then 116 j=0 117 while (( j < ${#vol[*]} )); do 118 cleanup_filesystem "$TESTPOOL" \ 119 "${ctr[i]}/${vol[j]}" 120 ((j = j + 1)) 121 done 122 fi 123 124 j=0 125 while (( j < ${#fs[*]} )); do 126 cleanup_filesystem "$TESTPOOL" \ 127 "${ctr[i]}/${fs[j]}" 128 ((j = j + 1)) 129 done 130 131 [[ -n ${ctr[i]} ]] && \ 132 cleanup_filesystem "$TESTPOOL" "${ctr[i]}" 133 134 ((i = i - 1)) 135 done 136 137 [[ -d ${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID} ]] && \ 138 $RM -rf ${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID} 139} 140 141function verify_all 142{ 143 typeset -i i=0 144 typeset -i j=0 145 typeset path 146 147 while (( i < ${#ctr[*]} )); do 148 149 path=$TESTPOOL 150 [[ -n ${ctr[i]} ]] && \ 151 path=$path/${ctr[i]} 152 153 if is_global_zone ; then 154 j=0 155 while (( j < ${#vol[*]} )); do 156 log_must unmounted "$path/${vol[j]}" 157 ((j = j + 1)) 158 done 159 fi 160 161 j=0 162 while (( j < ${#fs[*]} )); do 163 log_must unmounted "$path/${fs[j]}" 164 ((j = j + 1)) 165 done 166 167 log_must unmounted "$path" 168 169 ((i = i + 1)) 170 done 171 172 return 0 173} 174 175 176log_assert "Verify that 'zfs $unmountall' succeeds as root, " \ 177 "and all available ZFS filesystems are unmounted." 178 179log_onexit cleanup_all 180 181log_must setup_all 182 183typeset opt 184for opt in "-a" "-fa"; do 185 log_must $ZFS $mountall 186 187 if [[ $opt == "-fa" ]]; then 188 mntpnt=$(get_prop mountpoint ${TESTPOOL}/${TESTCTR}/${TESTFS}) 189 cd $mntpnt 190 log_mustnot $ZFS unmount -a 191 fi 192 193 log_must $ZFS unmount $opt 194 195 if [[ $opt == "-fa" ]]; then 196 cd /tmp 197 fi 198 199 log_must verify_all 200 log_note "Verify that 'zfs $mountcmd' will display " \ 201 "all ZFS filesystems currently mounted." 202 log_must verify_mount_display 203 204done 205 206log_pass "'zfs mount -[f]a' succeeds as root, " \ 207 "and all available ZFS filesystems are unmounted." 208