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 2008 Sun Microsystems, Inc. All rights reserved. 26# Use is subject to license terms. 27# 28 29# 30# Copyright (c) 2016 by Delphix. All rights reserved. 31# 32 33. $STF_SUITE/include/libtest.shlib 34 35# 36# DESCRIPTION: 37# Verify that umount and destroy fail, and do not unshare the shared 38# file system 39# 40# STRATEGY: 41# 1. Share the filesystem via 'zfs set sharenfs'. 42# 2. Try umount failure, and verify that the file system is still shared. 43# 3. Try destroy failure, and verify that the file system is still shared. 44# 45 46verify_runnable "global" 47 48function cleanup 49{ 50 log_must cd $origdir 51 52 log_must zfs set sharenfs=off $TESTPOOL/$TESTFS 53 unshare_fs $TESTPOOL/$TESTFS 54 55 snapexists "$TESTPOOL/$TESTFS@snapshot" && \ 56 destroy_dataset $TESTPOOL/$TESTFS@snapshot -f 57 58 datasetexists $TESTPOOL/$TESTFS/fs2 && \ 59 destroy_dataset $TESTPOOL/$TESTFS/fs2 -f 60} 61 62log_assert "Verify that umount and destroy fail, and do not unshare the shared" \ 63 "file system" 64log_onexit cleanup 65 66typeset origdir=$PWD 67 68# unmount fails will not unshare the shared filesystem 69log_must zfs set sharenfs=on $TESTPOOL/$TESTFS 70log_must is_shared $TESTDIR 71log_must cd $TESTDIR 72log_mustnot zfs umount $TESTPOOL/$TESTFS 73log_must is_shared $TESTDIR 74 75# destroy fails will not unshare the shared filesystem 76log_must zfs create $TESTPOOL/$TESTFS/fs2 77log_must cd $TESTDIR/fs2 78log_mustnot zfs destroy $TESTPOOL/$TESTFS/fs2 79log_must is_shared $TESTDIR/fs2 80 81log_pass "Verify that umount and destroy fail, and do not unshare the shared" \ 82 "file system" 83