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_share_006_pos.ksh 1.3 07/02/06 SMI" 30# 31 32. $STF_SUITE/include/libtest.kshlib 33 34################################################################################# 35# 36# __stc_assertion_start 37# 38# ID: zfs_share_006_pos 39# 40# DESCRIPTION: 41# Verify that a dataset could not be shared but filesystems are shared. 42# 43# STRATEGY: 44# 1. Create a dataset and file system 45# 2. Set the sharenfs property on the dataset 46# 3. Verify that the dataset is unable be shared. 47# 4. Add a new file system to the dataset. 48# 5. Verify that the newly added file system be shared. 49# 50# TESTABILITY: explicit 51# 52# TEST_AUTOMATION_LEVEL: automated 53# 54# CODING_STATUS: COMPLETED (2005-07-04) 55# 56# __stc_assertion_end 57# 58################################################################################ 59 60verify_runnable "global" 61 62function cleanup 63{ 64 log_must $ZFS set sharenfs=off $TESTPOOL/$TESTCTR 65 if mounted $TESTDIR2; then 66 log_must $ZFS unmount $TESTDIR2 67 fi 68 69 datasetexists $TESTPOOL/$TESTCTR/$TESTFS2 && \ 70 log_must $ZFS destroy $TESTPOOL/$TESTCTR/$TESTFS2 71 72 typeset fs="" 73 for fs in $mntp $TESTDIR1 $TESTDIR2 74 do 75 log_must unshare_fs $fs 76 done 77} 78 79# 80# Main test routine. 81# 82# Given a mountpoint and a dataset, this routine will set the 83# sharenfs property on the dataset and verify that dataset 84# is unable to be shared but the existing contained file systems 85# could be shared. 86# 87function test_ctr_share # mntp ctr 88{ 89 typeset mntp=$1 90 typeset ctr=$2 91 92 not_shared $mntp || \ 93 log_fail "Mountpoint: $mntp is already shared." 94 95 log_must $ZFS set sharenfs=on $ctr 96 97 not_shared $mntp || \ 98 log_fail "File system $mntp is shared (set sharenfs)." 99 100 # 101 # Add a new file system to the dataset and verify it is shared. 102 # 103 typeset mntp2=$TESTDIR2 104 log_must $ZFS create $ctr/$TESTFS2 105 log_must $ZFS set mountpoint=$mntp2 $ctr/$TESTFS2 106 107 is_shared $mntp2 || \ 108 log_fail "File system $mntp2 was not shared (set sharenfs)." 109} 110 111log_assert "Verify that a dataset could not be shared, " \ 112 "but its sub-filesystems could be shared." 113log_onexit cleanup 114 115typeset mntp=$(get_prop mountpoint $TESTPOOL/$TESTCTR) 116test_ctr_share $mntp $TESTPOOL/$TESTCTR 117 118log_pass "A dataset could not be shared, " \ 119 "but its sub-filesystems could be shared as expect." 120