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.
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.
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]
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
36 # Verify that 'zfs unshare [-a] <filesystem|mountpoint>' is aware of legacy share.
39 # 1. Set 'zfs set sharenfs=off'
40 # 2. Use 'share' to share given filesystem
41 # 3. Verify that 'zfs unshare <filesystem|mountpoint>' is aware of legacy share
42 # 4. Verify that 'zfs unshare -a' is aware of legacy share.
45 verify_runnable "global"
48 log_unsupported "zfs set sharenfs=off won't unshare if already off"
54 while (( i < ${#mntp_fs[*]} )); do
55 is_shared ${mntp_fs[i]} && \
56 log_must eval "unshare_nfs ${mntp_fs[i]}"
61 if mounted $TESTPOOL/$TESTCLONE; then
62 log_must zfs unmount $TESTDIR2
65 [[ -d $TESTDIR2 ]] && \
66 log_must rm -rf $TESTDIR2
68 if datasetexists "$TESTPOOL/$TESTCLONE"; then
69 log_must zfs destroy -f $TESTPOOL/$TESTCLONE
72 if snapexists "$TESTPOOL/$TESTFS2@snapshot"; then
73 log_must zfs destroy -f $TESTPOOL/$TESTFS2@snapshot
76 if datasetexists "$TESTPOOL/$TESTFS2"; then
77 log_must zfs destroy -f $TESTPOOL/$TESTFS2
84 # Given a mountpoint and file system this routine will attempt
85 # to verify 'zfs unshare' is aware of legacy share.
87 function test_legacy_unshare # <mntp> <filesystem>
92 log_must zfs set sharenfs=off $filesystem
94 log_fail "'zfs set sharenfs=off' fails to make ZFS " \
95 "filesystem $filesystem unshared."
97 log_must eval "share_nfs $mntp"
99 log_fail "'share' command fails to share ZFS file system."
101 # Verify 'zfs unshare <filesystem>' is aware of legacy share.
103 log_mustnot zfs unshare $filesystem
105 log_fail "'zfs unshare <filesystem>' fails to be aware" \
109 # Verify 'zfs unshare <filesystem>' is aware of legacy share.
111 log_mustnot zfs unshare $mntp
113 log_fail "'zfs unshare <mountpoint>' fails to be aware" \
119 "$TESTDIR" "$TESTPOOL/$TESTFS" \
120 "$TESTDIR1" "$TESTPOOL/$TESTCTR/$TESTFS1" \
121 "$TESTDIR2" "$TESTPOOL/$TESTCLONE"
123 log_assert "Verify that 'zfs unshare [-a]' is aware of legacy share."
126 log_must zfs create $TESTPOOL/$TESTFS2
127 log_must zfs snapshot $TESTPOOL/$TESTFS2@snapshot
128 log_must zfs clone $TESTPOOL/$TESTFS2@snapshot $TESTPOOL/$TESTCLONE
129 log_must zfs set mountpoint=$TESTDIR2 $TESTPOOL/$TESTCLONE
132 # Invoke 'test_legacy_unshare' routine to verify.
135 while (( i < ${#mntp_fs[*]} )); do
136 test_legacy_unshare ${mntp_fs[i]} ${mntp_fs[((i + 1 ))]}
142 log_note "Verify 'zfs unshare -a' is aware of legacy share."
145 # set the 'sharenfs' property to 'off' for each filesystem
148 while (( i < ${#mntp_fs[*]} )); do
149 log_must zfs set sharenfs=off ${mntp_fs[((i + 1))]}
150 not_shared ${mntp_fs[i]} || \
151 log_fail "'zfs set sharenfs=off' unshares file system failed."
157 # Share each of the file systems via legacy share.
160 while (( i < ${#mntp_fs[*]} )); do
161 share_nfs ${mntp_fs[i]}
162 is_shared ${mntp_fs[i]} || \
163 log_fail "'share' shares ZFS filesystem failed."
169 # Verify that 'zfs unshare -a' is aware of legacy share
171 log_must zfs unshare -a
174 # verify ZFS filesystems are still shared
177 while (( i < ${#mntp_fs[*]} )); do
178 is_shared ${mntp_fs[i]} || \
179 log_fail "'zfs unshare -a' fails to be aware of legacy share."
184 log_pass "'zfs unshare [-a]' succeeds to be aware of legacy share."