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