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