d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER START
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# The contents of this file are subject to the terms of the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Common Development and Distribution License (the "License").
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You may not use this file except in compliance with the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# See the License for the specific language governing permissions
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# and limitations under the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER END
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Use is subject to license terms.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2016 by Delphix. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Verify that 'zfs unshare [-a] <filesystem|mountpoint>' is aware of legacy share.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 1. Set 'zfs set sharenfs=off'
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 2. Use 'share' to share given filesystem
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 3. Verify that 'zfs unshare <filesystem|mountpoint>' is aware of legacy share
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 4. Verify that 'zfs unshare -a' is aware of legacy share.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy typeset -i i=0
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if datasetexists "$TESTPOOL/$TESTCLONE"; then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zfs destroy -f $TESTPOOL/$TESTCLONE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if snapexists "$TESTPOOL/$TESTFS2@snapshot"; then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zfs destroy -f $TESTPOOL/$TESTFS2@snapshot
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if datasetexists "$TESTPOOL/$TESTFS2"; then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zfs destroy -f $TESTPOOL/$TESTFS2
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Main test routine.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Given a mountpoint and file system this routine will attempt
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# to verify 'zfs unshare' is aware of legacy share.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyfunction test_legacy_unshare # <mntp> <filesystem>
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_fail "'zfs set sharenfs=off' fails to make ZFS " \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_fail "'share' command fails to share ZFS file system."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # Verify 'zfs unshare <filesystem>' is aware of legacy share.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_fail "'zfs unshare <filesystem>' fails to be aware" \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # Verify 'zfs unshare <filesystem>' is aware of legacy share.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_fail "'zfs unshare <mountpoint>' fails to be aware" \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "$TESTDIR1" "$TESTPOOL/$TESTCTR/$TESTFS1" \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_assert "Verify that 'zfs unshare [-a]' is aware of legacy share."
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs snapshot $TESTPOOL/$TESTFS2@snapshot
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs clone $TESTPOOL/$TESTFS2@snapshot $TESTPOOL/$TESTCLONE
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs set mountpoint=$TESTDIR2 $TESTPOOL/$TESTCLONE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Invoke 'test_legacy_unshare' routine to verify.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy test_legacy_unshare ${mntp_fs[i]} ${mntp_fs[((i + 1 ))]}
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_note "Verify 'zfs unshare -a' is aware of legacy share."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# set the 'sharenfs' property to 'off' for each filesystem
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zfs set sharenfs=off ${mntp_fs[((i + 1))]}
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_fail "'zfs set sharenfs=off' unshares file system failed."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Share each of the file systems via legacy share.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_fail "'share' shares ZFS filesystem failed."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Verify that 'zfs unshare -a' is aware of legacy share
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# verify ZFS filesystems are still shared
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_fail "'zfs unshare -a' fails to be aware of legacy share."
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_pass "'zfs unshare [-a]' succeeds to be aware of legacy share."