]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_set/readonly_001_pos.ksh
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) 2014 by Delphix. All rights reserved.
32 .
$STF_SUITE/tests
/functional
/cli_root
/zfs_set
/zfs_set_common.kshlib
36 # Setting readonly on a dataset, it should keep the dataset as readonly.
39 # 1. Create pool, then create filesystem and volume within it.
40 # 2. Setting readonly to each dataset.
41 # 3. Check the return value and make sure it is 0.
42 # 4. Verify the stuff under mountpoint is readonly.
45 verify_runnable
"both"
49 for dataset
in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL ; do
50 snapexists
${dataset}@
$TESTSNAP && \
51 log_must
$ZFS destroy
-R ${dataset}@
$TESTSNAP
55 function initial_dataset
# $1 dataset
59 typeset fstype
=$
(get_prop
type $dataset)
61 if [[ $fstype == "filesystem" ]] ; then
62 typeset mtpt
=$
(get_prop mountpoint
$dataset)
63 log_must
$TOUCH $mtpt/$TESTFILE0
64 log_must
$MKDIR -p $mtpt/$TESTDIR0
69 function cleanup_dataset
# $1 dataset
73 typeset fstype
=$
(get_prop
type $dataset)
75 if [[ $fstype == "filesystem" ]] ; then
76 typeset mtpt
=$
(get_prop mountpoint
$dataset)
77 log_must
$RM -f $mtpt/$TESTFILE0
78 log_must
$RM -rf $mtpt/$TESTDIR0
82 function verify_readonly
# $1 dataset, $2 on|off
87 if datasetnonexists
$dataset ; then
88 log_note
"$dataset does not exist!"
92 typeset fstype
=$
(get_prop
type $dataset)
96 if [[ $2 == "on" ]] ; then
102 typeset mtpt
=$
(get_prop mountpoint
$dataset)
103 $expect $TOUCH $mtpt/$TESTFILE1
104 $expect $MKDIR -p $mtpt/$TESTDIR1
105 $expect eval "$ECHO 'y' | $RM $mtpt/$TESTFILE0"
106 $expect $RMDIR $mtpt/$TESTDIR0
108 if [[ $expect == "log_must" ]] ; then
109 log_must
eval "$ECHO 'y' | $RM $mtpt/$TESTFILE1"
110 log_must
$RMDIR $mtpt/$TESTDIR1
111 log_must
$TOUCH $mtpt/$TESTFILE0
112 log_must
$MKDIR -p $mtpt/$TESTDIR0
116 $expect eval "$ECHO 'y' | $NEWFS \
117 ${ZVOL_DEVDIR}/$dataset > /dev/null 2>&1"
128 log_assert
"Setting a valid readonly property on a dataset succeeds."
132 log_must
$ZFS mount
-a
134 log_must
$ZFS snapshot
$TESTPOOL/$TESTFS@
$TESTSNAP
135 log_must
$ZFS clone
$TESTPOOL/$TESTFS@
$TESTSNAP $TESTPOOL/$TESTCLONE
137 if is_global_zone
; then
138 log_must
$ZFS snapshot
$TESTPOOL/$TESTVOL@
$TESTSNAP
139 log_must
$ZFS clone
$TESTPOOL/$TESTVOL@
$TESTSNAP $TESTPOOL/$TESTCLONE1
140 all_datasets
="$TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL "
141 all_datasets
+="$TESTPOOL/$TESTCLONE $TESTPOOL/$TESTCLONE1"
143 all_datasets
="$TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTCLONE"
147 for dataset
in $all_datasets; do
148 for value
in on off
; do
149 set_n_check_prop
"off" "readonly" "$dataset"
150 initial_dataset
$dataset
152 set_n_check_prop
"$value" "readonly" "$dataset"
153 verify_readonly
$dataset $value
155 set_n_check_prop
"off" "readonly" "$dataset"
156 cleanup_dataset
$dataset
160 log_pass
"Setting a valid readonly property on a dataset succeeds."