1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 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. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or https://opensource.org/licenses/CDDL-1.0. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 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] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib 33 34# 35# DESCRIPTION: 36# 'zfs snapshot -o' cannot set properties other than user property 37# 38# STRATEGY: 39# 1. Create snapshot and give '-o property=value' with regular property. 40# 2. Verify the snapshot creation failed. 41# 42 43verify_runnable "both" 44 45function cleanup 46{ 47 for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do 48 typeset fssnap=$fs@snap 49 datasetexists $fssnap && destroy_dataset $fssnap -rf 50 done 51 cleanup_user_prop $TESTPOOL 52} 53 54function nonexist_user_prop 55{ 56 typeset user_prop=$1 57 typeset dtst=$2 58 59 typeset source=$(get_source $user_prop $dtst) 60 typeset value=$(get_prop $user_prop $dtst) 61 if [[ $source == '-' && $value == '-' ]]; then 62 return 0 63 else 64 return 1 65 fi 66} 67 68log_assert "'zfs snapshot -o' cannot set properties other than user property." 69log_onexit cleanup 70 71typeset ro_props="type used available avail creation referenced refer compressratio \ 72 mounted origin" 73typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \ 74 sharenfs checksum compression compress atime devices exec readonly rdonly \ 75 setuid version" 76if is_freebsd; then 77 snap_ro_props+=" jailed" 78else 79 snap_ro_props+=" zoned" 80fi 81 82 83for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do 84 typeset fssnap=$fs@snap 85 prop_name=$(valid_user_property 10) 86 value=$(user_property_value 16) 87 88 log_must eval "zfs snapshot -o $prop_name='$value' $fssnap" 89 log_must snapexists $fssnap 90 log_mustnot nonexist_user_prop $prop_name $fssnap 91 92 log_must zfs destroy -f $fssnap 93 94 prop_name2=$(valid_user_property 10) 95 value2=$(user_property_value 16) 96 97 log_must eval "zfs snapshot -o $prop_name='$value' -o $prop_name2='$value2' $fssnap" 98 log_must snapexists $fssnap 99 log_mustnot nonexist_user_prop $prop_name $fssnap 100 log_mustnot nonexist_user_prop $prop_name2 $fssnap 101 102 log_must zfs destroy -f $fssnap 103done 104 105cleanup 106 107prop_name=$(valid_user_property 10) 108value=$(user_property_value 16) 109 110log_must eval "zfs snapshot -r -o $prop_name='$value' $TESTPOOL@snap" 111for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do 112 typeset fssnap=$fs@snap 113 log_must snapexists $fssnap 114 log_mustnot nonexist_user_prop $prop_name $fssnap 115done 116 117cleanup 118 119prop_name2=$(valid_user_property 10) 120value2=$(user_property_value 16) 121 122log_must eval "zfs snapshot -r -o $prop_name='$value' -o $prop_name2='$value2' $TESTPOOL@snap" 123for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do 124 typeset fssnap=$fs@snap 125 log_must snapexists $fssnap 126 log_mustnot nonexist_user_prop $prop_name $fssnap 127 log_mustnot nonexist_user_prop $prop_name2 $fssnap 128done 129 130log_pass "'zfs snapshot -o' cannot set properties other than user property." 131