]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_001_pos.ksh
084b18d1f17281907a251087606b14455ab8fe80
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.
28 .
$STF_SUITE/include
/libtest.shlib
32 # Verify that 'zfs set sharenfs' and 'zfs share' shares a given dataset.
35 # 1. Invoke 'zfs set sharenfs'.
36 # 2. Verify that the file system is shared.
37 # 3. Invoke 'zfs share'.
38 # 4. Verify that the file system is shared.
39 # 5. Verify that a shared filesystem cannot be shared again.
40 # 6. Verify that share -a succeeds.
43 verify_runnable
"global"
46 "$TESTDIR" "$TESTPOOL/$TESTFS" \
47 "$TESTDIR1" "$TESTPOOL/$TESTCTR/$TESTFS1" \
48 "$TESTDIR2" "$TESTPOOL/$TESTFS-clone"
53 while (( i
< ${#fs[*]} )); do
54 log_must
$ZFS set sharenfs
=off
${fs[((i+1))]}
60 if mounted
$TESTPOOL/$TESTFS-clone; then
61 log_must
$ZFS unmount
$TESTDIR2
64 datasetexists
$TESTPOOL/$TESTFS-clone && \
65 log_must
$ZFS destroy
-f $TESTPOOL/$TESTFS-clone
67 if snapexists
"$TESTPOOL/$TESTFS@snapshot"; then
68 log_must
$ZFS destroy
-f $TESTPOOL/$TESTFS@snapshot
76 # Given a mountpoint and file system this routine will attempt
77 # share the mountpoint and then verify it has been shared.
79 function test_share
# mntp filesystem
85 log_fail
"File system $filesystem is already shared."
87 log_must
$ZFS set sharenfs
=on
$filesystem
89 log_fail
"File system $filesystem is not shared (set sharenfs)."
92 # Verify 'zfs share' works as well.
94 log_must
$ZFS unshare
$filesystem
96 log_fail
"File system $filesystem is still shared."
98 log_must
$ZFS share
$filesystem
100 log_fail
"file system $filesystem is not shared (zfs share)."
102 log_note
"Sharing a shared file system fails."
103 log_mustnot
$ZFS share
$filesystem
106 log_assert
"Verify that 'zfs share' succeeds as root."
109 log_must
$ZFS snapshot
$TESTPOOL/$TESTFS@snapshot
110 log_must
$ZFS clone
$TESTPOOL/$TESTFS@snapshot
$TESTPOOL/$TESTFS-clone
111 log_must
$ZFS set mountpoint
=$TESTDIR2 $TESTPOOL/$TESTFS-clone
114 while (( i
< ${#fs[*]} )); do
115 test_share
${fs[i]} ${fs[((i + 1))]}
120 log_note
"Verify 'zfs share -a' succeeds."
123 # Unshare each of the file systems.
126 while (( i
< ${#fs[*]} )); do
133 # Try a zfs share -a and verify all file systems are shared.
135 log_must
$ZFS share
-a
138 while (( i
< ${#fs[*]} )); do
139 is_shared
${fs[i]} || \
140 log_fail
"File system ${fs[i]} is not shared (share -a)"
145 log_pass
"'$ZFS share [ -a ] <filesystem>' succeeds as root."