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 # Setting valid canmount to filesystem, it is successful.
38 # Whatever is set to volume or snapshot, it is failed.
39 # 'zfs set canmount=noauto <fs>'
42 # 1. Setup a pool and create fs, volume, snapshot clone within it.
43 # 2. Set canmount=noauto for each dataset and check the retuen value
44 # and check if it still can be mounted by mount -a.
45 # 3. mount each dataset(except volume) to see if it can be mounted.
48 verify_runnable
"both"
51 "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTCTR" "$TESTPOOL/$TESTCLONE"
53 if is_global_zone
; then
55 "$TESTPOOL/$TESTVOL" "$TESTPOOL/$TESTFS@$TESTSNAP" \
56 "$TESTPOOL/$TESTVOL@$TESTSNAP" "$TESTPOOL/$TESTCLONE1"
59 "$TESTPOOL/$TESTFS@$TESTSNAP" "$TESTPOOL/$TESTVOL@$TESTSNAP"
65 while (( i
< ${#dataset_pos[*]} )); do
67 if datasetexists
$ds; then
68 log_must zfs
set mountpoint
=${old_mnt[i]} $ds
69 log_must zfs
set canmount
=${old_canmount[i]} $ds
74 ds
=$TESTPOOL/$TESTCLONE
75 if datasetexists
$ds; then
76 mntp
=$
(get_prop mountpoint
$ds)
77 log_must zfs destroy
$ds
78 if [[ -d $mntp ]]; then
83 if snapexists
$TESTPOOL/$TESTFS@
$TESTSNAP ; then
84 log_must zfs destroy
-R $TESTPOOL/$TESTFS@
$TESTSNAP
86 if snapexists
$TESTPOOL/$TESTVOL@
$TESTSNAP ; then
87 log_must zfs destroy
-R $TESTPOOL/$TESTVOL@
$TESTSNAP
90 zfs unmount
-a > /dev
/null
2>&1
93 if [[ -d $tmpmnt ]]; then
98 log_assert
"Setting canmount=noauto to file system, it must be successful."
103 typeset tmpmnt
=/tmpmount$$
106 log_must zfs snapshot
$TESTPOOL/$TESTFS@
$TESTSNAP
107 log_must zfs snapshot
$TESTPOOL/$TESTVOL@
$TESTSNAP
108 log_must zfs clone
$TESTPOOL/$TESTFS@
$TESTSNAP $TESTPOOL/$TESTCLONE
109 log_must zfs clone
$TESTPOOL/$TESTVOL@
$TESTSNAP $TESTPOOL/$TESTCLONE1
112 while (( i
< ${#dataset_pos[*]} )); do
114 old_mnt
[i
]=$
(get_prop mountpoint
$ds)
115 old_canmount
[i
]=$
(get_prop canmount
$ds)
120 while (( i
< ${#dataset_pos[*]} )) ; do
121 dataset
=${dataset_pos[i]}
122 set_n_check_prop
"noauto" "canmount" "$dataset"
123 log_must zfs
set mountpoint
=$tmpmnt $dataset
124 if ismounted
$dataset; then
125 zfs unmount
-a > /dev
/null
2>&1
126 log_must mounted
$dataset
127 log_must zfs unmount
$dataset
128 log_must unmounted
$dataset
129 log_must zfs mount
-a
130 log_must unmounted
$dataset
132 log_must zfs mount
-a
133 log_must unmounted
$dataset
134 zfs unmount
-a > /dev
/null
2>&1
135 log_must unmounted
$dataset
138 log_must zfs mount
$dataset
139 log_must mounted
$dataset
140 log_must zfs
set canmount
="${old_canmount[i]}" $dataset
141 log_must zfs
set mountpoint
="${old_mnt[i]}" $dataset
145 for dataset
in "${dataset_neg[@]}" ; do
146 set_n_check_prop
"noauto" "canmount" "$dataset" "false"
147 log_mustnot ismounted
$dataset
150 log_pass
"Setting canmount=noauto to filesystem pass."