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 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27. $STF_SUITE/include/libtest.kshlib 28 29################################################################################# 30# 31# __stc_assertion_start 32# 33# ID: zfs_share_009_pos 34# 35# DESCRIPTION: 36# Verify that umount/rollback/destroy fails does not unshare the shared 37# file system 38# 39# STRATEGY: 40# 1. Share the filesystem via 'zfs set sharenfs'. 41# 2. Try umount failure, and verify that the file system is still shared. 42# 3. Try rollback failure, and verify that the file system is still shared. 43# 4. Try destroy failure, and verify that the file system is still shared. 44# 45# TESTABILITY: explicit 46# 47# TEST_AUTOMATION_LEVEL: automated 48# 49# CODING_STATUS: COMPLETED (2006-04-28) 50# 51# __stc_assertion_end 52# 53################################################################################ 54 55verify_runnable "global" 56 57function cleanup 58{ 59 log_must cd $origdir 60 61 log_must $ZFS set sharenfs=off $TESTPOOL/$TESTFS 62 unshare_fs $TESTPOOL/$TESTFS 63 64 if snapexists "$TESTPOOL/$TESTFS@snapshot"; then 65 log_must $ZFS destroy -f $TESTPOOL/$TESTFS@snapshot 66 fi 67 68 if datasetexists $TESTPOOL/$TESTFS/fs2 ; then 69 log_must $ZFS destroy -f $TESTPOOL/$TESTFS/fs2 70 fi 71} 72 73log_assert "Verify umount/rollback/destroy fails does not unshare the shared" \ 74 "file system" 75log_onexit cleanup 76 77typeset origdir=$PWD 78 79# unmount fails will not unshare the shared filesystem 80log_must $ZFS set sharenfs=on $TESTPOOL/$TESTFS 81log_must is_shared $TESTDIR 82if cd $TESTDIR ; then 83 log_mustnot $ZFS umount $TESTPOOL/$TESTFS 84else 85 log_fail "cd $TESTDIR fails" 86fi 87log_must is_shared $TESTDIR 88 89# rollback fails will not unshare the shared filesystem 90log_must $ZFS snapshot $TESTPOOL/$TESTFS@snapshot 91if cd $TESTDIR ; then 92 log_mustnot $ZFS rollback $TESTPOOL/$TESTFS@snapshot 93else 94 log_fail "cd $TESTDIR fails" 95fi 96log_must is_shared $TESTDIR 97 98# destroy fails will not unshare the shared filesystem 99log_must $ZFS create $TESTPOOL/$TESTFS/fs2 100if cd $TESTDIR/fs2 ; then 101 log_mustnot $ZFS destroy $TESTPOOL/$TESTFS/fs2 102else 103 log_fail "cd $TESTDIR/fs2 fails" 104fi 105log_must is_shared $TESTDIR/fs2 106 107log_pass "Verify umount/rollback/destroy fails does not unshare the shared" \ 108 "file system" 109