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