1#!/bin/ksh -p 2# SPDX-License-Identifier: CDDL-1.0 3# 4# CDDL HEADER START 5# 6# The contents of this file are subject to the terms of the 7# Common Development and Distribution License (the "License"). 8# You may not use this file except in compliance with the License. 9# 10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11# or https://opensource.org/licenses/CDDL-1.0. 12# See the License for the specific language governing permissions 13# and limitations under the License. 14# 15# When distributing Covered Code, include this CDDL HEADER in each 16# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17# If applicable, add the following below this CDDL HEADER, with the 18# fields enclosed by brackets "[]" replaced with your own identifying 19# information: Portions Copyright [yyyy] [name of copyright owner] 20# 21# CDDL HEADER END 22# 23 24# 25# Copyright 2016, loli10K. All rights reserved. 26# 27 28. $STF_SUITE/include/libtest.shlib 29 30# 31# DESCRIPTION: 32# Verify that 'zfs unshare [nfs|smb] -a' unshares only filesystems shared by the 33# specified protocol. 34# 35# STRATEGY: 36# 1. Share filesystems with different protocols. 37# 2. Invoke 'zfs unshare nfs -a' to unshare filesystems. 38# 3. Verify that only nfs filesystems are unshared. 39# 4. Share all filesystems again. 40# 5. Invoke 'zfs unshare smb -a' and verify only smb filesystems are unshared. 41# 42 43verify_runnable "global" 44 45[ -d "/var/lib/samba/usershares" ] || log_unsupported "Samba usershares disabled" 46 47function cleanup 48{ 49 log_must zfs unshare -a 50 log_must zfs destroy -f $TESTPOOL/$TESTFS/shared1 51 log_must zfs destroy -f $TESTPOOL/$TESTFS/shared2 52 log_must zfs destroy -f $TESTPOOL/$TESTFS/shared3 53 log_must rm -f /var/lib/samba/usershares/testpool_testfs_shared{2,3} 54} 55 56log_assert "Verify 'zfs unshare [nfs|smb] -a' only works on the specified" \ 57 "protocol." 58log_onexit cleanup 59 60# 1. Share filesystems with different protocols. 61log_must zfs create $TESTPOOL/$TESTFS/shared1 62log_must zfs create $TESTPOOL/$TESTFS/shared2 63log_must zfs create $TESTPOOL/$TESTFS/shared3 64log_must zfs set mountpoint=$TESTDIR/1 $TESTPOOL/$TESTFS/shared1 65log_must zfs set mountpoint=$TESTDIR/2 $TESTPOOL/$TESTFS/shared2 66log_must zfs set mountpoint=$TESTDIR/3 $TESTPOOL/$TESTFS/shared3 67log_must zfs set sharenfs=on $TESTPOOL/$TESTFS/shared1 68log_must zfs set sharenfs=on $TESTPOOL/$TESTFS/shared2 69log_must zfs set sharesmb=on $TESTPOOL/$TESTFS/shared2 70log_must zfs set sharesmb=on $TESTPOOL/$TESTFS/shared3 71log_must zfs share -a 72 73# 2. Invoke 'zfs unshare nfs -a' to unshare filesystems. 74log_must zfs unshare nfs -a 75 76# 3. Verify that only nfs filesystems are unshared. 77log_must not_shared $TESTPOOL/$TESTFS/shared1 78log_must not_shared $TESTPOOL/$TESTFS/shared2 79log_must is_shared_smb $TESTPOOL/$TESTFS/shared2 80log_must is_shared_smb $TESTPOOL/$TESTFS/shared3 81 82# 4. Share all filesystems again. 83log_must zfs share -a 84 85# 5. Invoke 'zfs unshare smb -a' and verify only smb filesystems are unshared. 86log_must zfs unshare smb -a 87log_must is_shared $TESTPOOL/$TESTFS/shared1 88log_must is_shared $TESTPOOL/$TESTFS/shared2 89log_must not_shared_smb $TESTPOOL/$TESTFS/shared2 90log_must not_shared_smb $TESTPOOL/$TESTFS/shared3 91 92log_pass "'zfs unshare [nfs|smb] -a' only works on the specified protocol." 93