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 27. $STF_SUITE/include/libtest.kshlib 28 29################################################################################# 30# 31# __stc_assertion_start 32# 33# ID: zfs_share_003_pos 34# 35# DESCRIPTION: 36# Invoking "zfs share <file system>" with a file system 37# whose sharenfs property is 'off' , will fail with a 38# return code of 1 and issue an error message. 39# 40# STRATEGY: 41# 1. Make sure that the ZFS file system is unshared. 42# 2. Mount the file system using the various combinations 43# - zfs set sharenfs=off <file system> 44# - zfs set sharenfs=none <file system> 45# 3. Verify that share failed with return code of 1. 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 59set -A fs \ 60 "$TESTDIR" "$TESTPOOL/$TESTFS" \ 61 "$TESTDIR1" "$TESTPOOL/$TESTCTR/$TESTFS1" 62 63function cleanup 64{ 65 typeset -i i=0 66 while (( i < ${#fs[*]} )); do 67 log_must $ZFS inherit -r sharenfs ${fs[((i + 1))]} 68 log_must unshare_fs ${fs[i]} 69 70 ((i = i + 2)) 71 done 72} 73 74 75# 76# Main test routine. 77# 78# Given a mountpoint and file system this routine will attempt 79# to share a legacy mountpoint and then verify the share fails as 80# expected. 81# 82function test_legacy_share # mntp filesystem 83{ 84 typeset mntp=$1 85 typeset filesystem=$2 86 87 not_shared $mntp || \ 88 log_fail "File system $filesystem is already shared." 89 90 if is_global_zone ; then 91 log_must $ZFS set sharenfs=off $filesystem 92 not_shared $mntp || \ 93 log_fail "File system $filesystem is still shared (set sharenfs)." 94 fi 95 96 $ZFS share $filesystem 97 ret=$? 98 (( ret == 1)) || \ 99 log_fail "'$ZFS share $filesystem' " \ 100 "unexpected return code of $ret." 101 102 not_shared $mntp || \ 103 log_fail "file system $filesystem is shared (zfs share)." 104} 105 106log_assert "Verify that '$ZFS share' with a file system " \ 107 "whose sharenfs property is 'off' " \ 108 "will fail with return code 1." 109log_onexit cleanup 110 111typeset -i i=0 112while (( i < ${#fs[*]} )); do 113 test_legacy_share ${fs[i]} ${fs[((i + 1))]} 114 115 ((i = i + 2)) 116done 117 118log_pass "Verify that '$ZFS share' with a file system " \ 119 "whose sharenfs property is 'off' fails." 120