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