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) 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/tests
/functional
/cli_root
/zfs_set
/zfs_set_common.kshlib
36 # 'zfs snapshot -o' cannot set properties other than user property
39 # 1. Create snapshot and give '-o property=value' with regular property.
40 # 2. Verify the snapshot creation failed.
43 verify_runnable
"both"
47 for fs
in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do
48 typeset fssnap
=$fs@snap
49 if datasetexists
$fssnap ; then
50 log_must zfs destroy
-rf $fssnap
53 cleanup_user_prop
$TESTPOOL
56 function nonexist_user_prop
61 typeset
source=$
(get_source
$user_prop $dtst)
62 typeset value
=$
(get_prop
$user_prop $dtst)
63 if [[ $source == '-' && $value == '-' ]]; then
70 log_assert
"'zfs snapshot -o' cannot set properties other than user property."
73 typeset ro_props
="type used available avail creation referenced refer compressratio \
75 typeset snap_ro_props
="volsize recordsize recsize quota reservation reserv mountpoint \
76 sharenfs checksum compression compress atime devices exec readonly rdonly \
79 zfs upgrade
-v > /dev
/null
2>&1
80 if [[ $?
-eq 0 ]]; then
81 snap_ro_props
="$snap_ro_props version"
85 for fs
in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do
86 typeset fssnap
=$fs@snap
87 prop_name
=$
(valid_user_property
10)
88 value
=$
(user_property_value
16)
90 log_must
eval "zfs snapshot -o $prop_name='$value' $fssnap"
91 log_must snapexists
$fssnap
92 log_mustnot nonexist_user_prop
$prop_name $fssnap
94 log_must zfs destroy
-f $fssnap
96 prop_name2
=$
(valid_user_property
10)
97 value2
=$
(user_property_value
16)
99 log_must
eval "zfs snapshot -o $prop_name='$value' -o $prop_name2='$value2' $fssnap"
100 log_must snapexists
$fssnap
101 log_mustnot nonexist_user_prop
$prop_name $fssnap
102 log_mustnot nonexist_user_prop
$prop_name2 $fssnap
104 log_must zfs destroy
-f $fssnap
109 prop_name
=$
(valid_user_property
10)
110 value
=$
(user_property_value
16)
112 log_must
eval "zfs snapshot -r -o $prop_name='$value' $TESTPOOL@snap"
113 for fs
in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do
114 typeset fssnap
=$fs@snap
115 log_must snapexists
$fssnap
116 log_mustnot nonexist_user_prop
$prop_name $fssnap
121 prop_name2
=$
(valid_user_property
10)
122 value2
=$
(user_property_value
16)
124 log_must
eval "zfs snapshot -r -o $prop_name='$value' -o $prop_name2='$value2' $TESTPOOL@snap"
125 for fs
in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do
126 typeset fssnap
=$fs@snap
127 log_must snapexists
$fssnap
128 log_mustnot nonexist_user_prop
$prop_name $fssnap
129 log_mustnot nonexist_user_prop
$prop_name2 $fssnap
132 log_pass
"'zfs snapshot -o' cannot set properties other than user property."