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. $STF_SUITE/include/libtest.shlib 28. $STF_SUITE/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib 29 30# DESCRIPTION: 31# Verify that 'zfs mount -a' succeeds as root. 32# 33# STRATEGY: 34# 1. Create a group of pools with specified vdev. 35# 2. Create zfs filesystems within the given pools. 36# 3. Unmount all the filesystems. 37# 4. Verify that 'zfs mount -a' command succeed, 38# and all available ZFS filesystems are mounted. 39# 5. Verify that 'zfs mount' is identical with 'df -F zfs' 40# 41 42verify_runnable "both" 43 44set -A fs "$TESTFS" "$TESTFS1" 45set -A ctr "" "$TESTCTR" "$TESTCTR/$TESTCTR1" "$TESTCTR1" 46set -A vol "$TESTVOL" "$TESTVOL1" 47 48function setup_all 49{ 50 typeset -i i=0 51 typeset -i j=0 52 typeset path 53 54 while (( i < ${#ctr[*]} )); do 55 56 path=${TEST_BASE_DIR%%/}/testroot$$/$TESTPOOL 57 if [[ -n ${ctr[i]} ]]; then 58 path=$path/${ctr[i]} 59 60 setup_filesystem "$DISKS" "$TESTPOOL" \ 61 "${ctr[i]}" "$path" \ 62 "ctr" 63 fi 64 65 if is_global_zone ; then 66 j=0 67 while (( j < ${#vol[*]} )); do 68 setup_filesystem "$DISKS" "$TESTPOOL" \ 69 "${ctr[i]}/${vol[j]}" \ 70 "$path/${vol[j]}" \ 71 "vol" 72 ((j = j + 1)) 73 done 74 fi 75 76 j=0 77 while (( j < ${#fs[*]} )); do 78 setup_filesystem "$DISKS" "$TESTPOOL" \ 79 "${ctr[i]}/${fs[j]}" \ 80 "$path/${fs[j]}" 81 ((j = j + 1)) 82 done 83 84 ((i = i + 1)) 85 done 86 87 return 0 88} 89 90function cleanup_all 91{ 92 typeset -i i=0 93 typeset -i j=0 94 typeset path 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 125# 126# This function takes a single true/false argument. If true it will verify that 127# all file systems are mounted. If false it will verify that they are not 128# mounted. 129# 130function verify_all 131{ 132 typeset -i i=0 133 typeset -i j=0 134 typeset path 135 typeset logfunc 136 137 if $1; then 138 logfunc=log_must 139 else 140 logfunc=log_mustnot 141 fi 142 143 while (( i < ${#ctr[*]} )); do 144 145 path=$TESTPOOL 146 [[ -n ${ctr[i]} ]] && \ 147 path=$path/${ctr[i]} 148 149 if is_global_zone ; then 150 j=0 151 while (( j < ${#vol[*]} )); do 152 log_mustnot mounted "$path/${vol[j]}" 153 ((j = j + 1)) 154 done 155 fi 156 157 j=0 158 while (( j < ${#fs[*]} )); do 159 $logfunc mounted "$path/${fs[j]}" 160 ((j = j + 1)) 161 done 162 163 $logfunc mounted "$path" 164 165 ((i = i + 1)) 166 done 167 168 return 0 169} 170 171 172log_assert "Verify that 'zfs $mountall' succeeds as root, " \ 173 "and all available ZFS filesystems are mounted." 174 175log_onexit cleanup_all 176 177log_must setup_all 178 179export __ZFS_POOL_RESTRICT="$TESTPOOL" 180log_must $ZFS $unmountall 181unset __ZFS_POOL_RESTRICT 182 183verify_all false 184 185export __ZFS_POOL_RESTRICT="$TESTPOOL" 186log_must $ZFS $mountall 187unset __ZFS_POOL_RESTRICT 188 189verify_all true 190 191log_note "Verify that 'zfs $mountcmd' will display " \ 192 "all ZFS filesystems currently mounted." 193 194verify_mount_display 195 196log_pass "'zfs $mountall' succeeds as root, " \ 197 "and all available ZFS filesystems are mounted." 198