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. $STF_SUITE/include/libtest.kshlib 27 28################################################################################ 29# 30# __stc_assertion_start 31# 32# ID: zfs_unmount_001_pos 33# 34# DESCRIPTION: 35# Creates a file system and verifies that it can be unmounted 36# using each of the various unmount options and sub-command 37# variants. 38# 39# STRATEGY: 40# 1. Create and mount a file system as necessary. 41# 2. Umount the file system using the various combinations. 42# - With force option. 43# - Without force option. 44# - Using the unmount sub-command. 45# - Using the umount sub-command. 46# 47# TESTABILITY: explicit 48# 49# TEST_AUTOMATION_LEVEL: automated 50# 51# CODING_STATUS: COMPLETED (2005-07-04) 52# 53# __stc_assertion_end 54# 55################################################################################ 56 57verify_runnable "both" 58 59 60function cleanup 61{ 62 mounted $TESTDIR2 && \ 63 log_must $ZFS umount -f $TESTDIR2 64 65 datasetexists $TESTPOOL/$TESTFS2 && \ 66 log_must $ZFS destroy $TESTPOOL/$TESTFS2 67 68 [[ -d $TESTDIR2 ]] && \ 69 log_must $RM -rf $TESTDIR2 70} 71function do_unmount 72{ 73 typeset cmd=$1 74 typeset opt=$2 75 typeset mnt=$3 76 77 [[ ! -d $TESTDIR2 ]] && \ 78 log_must $MKDIR $TESTDIR2 79 80 if ! datasetexists $TESTPOOL/$TESTFS2 ; then 81 log_must $ZFS create $TESTPOOL/$TESTFS2 82 log_must $ZFS set mountpoint=$TESTDIR2 \ 83 $TESTPOOL/$TESTFS2 84 fi 85 86 unmounted $TESTPOOL/$TESTFS2 && \ 87 log_must $ZFS mount $TESTPOOL/$TESTFS2 88 89 log_must $ZFS $cmd $options $mnt 90 91 unmounted "$mnt" || \ 92 log_fail "Unable to unmount $options $mnt" 93 94 log_note "Successfully unmounted $options $mnt" 95} 96 97log_onexit cleanup 98 99set -A cmd "umount" "unmount" 100set -A options "" "-f" 101set -A dev "$TESTPOOL/$TESTFS2" "$TESTDIR2" 102 103log_assert "Verify the u[n]mount [-f] sub-command." 104 105typeset -i i=0 106typeset -i j=0 107typeset -i k=0 108while [[ $i -lt ${#cmd[*]} ]]; do 109 j=0 110 while [[ $j -lt ${#options[*]} ]]; do 111 k=0 112 while [[ $k -lt ${#dev[*]} ]]; do 113 do_unmount "${cmd[i]}" "${options[j]}" \ 114 "${dev[k]}" 115 116 ((k = k + 1)) 117 done 118 119 ((j = j + 1)) 120 done 121 122 ((i = i + 1)) 123done 124 125log_pass "zfs u[n]mount [-f] completed successfully." 126