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 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
33 . $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
37 # While canmount=noauto and the dataset is mounted,
38 # zfs must not attempt to unmount it.
41 # 1. Setup a pool and create fs, volume, snapshot clone within it.
42 # 2. Set canmount=noauto for each dataset and check the return value
43 # and check if it still can not be unmounted when the dataset is mounted
46 verify_runnable "both"
48 set -A dataset_pos "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTCLONE"
54 while (( i < ${#dataset_pos[*]} )); do
56 if datasetexists $ds; then
57 log_must zfs set mountpoint=${old_mnt[i]} $ds
58 log_must zfs set canmount=${old_canmount[i]} $ds
63 ds=$TESTPOOL/$TESTCLONE
64 if datasetexists $ds; then
65 mntp=$(get_prop mountpoint $ds)
66 log_must zfs destroy $ds
67 if [[ -d $mntp ]]; then
72 if snapexists $TESTPOOL/$TESTFS@$TESTSNAP ; then
73 log_must zfs destroy -R $TESTPOOL/$TESTFS@$TESTSNAP
76 zfs unmount -a > /dev/null 2>&1
80 log_assert "While canmount=noauto and the dataset is mounted,"\
81 " zfs must not attempt to unmount it"
89 log_must zfs snapshot $TESTPOOL/$TESTFS@$TESTSNAP
90 log_must zfs clone $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTCLONE
93 while (( i < ${#dataset_pos[*]} )); do
95 old_mnt[i]=$(get_prop mountpoint $ds)
96 old_canmount[i]=$(get_prop canmount $ds)
101 while (( i < ${#dataset_pos[*]} )) ; do
102 dataset=${dataset_pos[i]}
103 if ismounted $dataset; then
104 log_must cd ${old_mnt[i]}
105 set_n_check_prop "noauto" "canmount" "$dataset"
106 log_must mounted $dataset
111 log_pass "Setting canmount=noauto to filesystem while dataset busy pass."