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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27# Copyright (c) 2016 by Delphix. All rights reserved. 28# 29 30. $STF_SUITE/include/libtest.shlib 31. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib 32 33# 34# DESCRIPTION: 35# Verify that read-only properties are immutable. 36# Note that we can only check properties that have no possibility of 37# changing while we are running (which excludes e.g. "available"). 38# 39# STRATEGY: 40# 1. Create pool, fs, vol, fs@snap & vol@snap. 41# 2. Get the original property value and set value to those properties. 42# 3. Check return value. 43# 4. Compare the current property value with the original one. 44# 45 46verify_runnable "both" 47 48set -A values filesystem volume snapshot -3 0 1 50K 10G 80G \ 49 2005/06/17 30K 20x yes no \ 50 on off default pool/fs@snap $TESTDIR 51set -A dataset $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \ 52 $TESTPOOL/$TESTCTR/$TESTFS1 $TESTPOOL/$TESTFS@$TESTSNAP \ 53 $TESTPOOL/$TESTVOL@$TESTSNAP 54typeset ro_props="type used creation referenced refer compressratio \ 55 mounted origin" 56typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \ 57 sharenfs checksum compression compress atime devices exec readonly rdonly \ 58 setuid version" 59if is_freebsd; then 60 snap_ro_props+=" jailed" 61else 62 snap_ro_props+=" zoned" 63fi 64 65function cleanup 66{ 67 datasetexists $TESTPOOL/$TESTVOL@$TESTSNAP && \ 68 destroy_snapshot $TESTPOOL/$TESTVOL@$TESTSNAP 69 datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \ 70 destroy_snapshot $TESTPOOL/$TESTFS@$TESTSNAP 71} 72 73log_assert "Verify that read-only properties are immutable." 74log_onexit cleanup 75 76# Create filesystem and volume's snapshot 77create_snapshot $TESTPOOL/$TESTFS $TESTSNAP 78create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP 79sync_pool $TESTPOOL 80sleep 5 81 82typeset -i i=0 83typeset -i j=0 84typeset cur_value="" 85typeset props="" 86 87while (( i < ${#dataset[@]} )); do 88 props=$ro_props 89 90 dst_type=$(get_prop type ${dataset[i]}) 91 if [[ $dst_type == 'snapshot' ]]; then 92 props="$ro_props $snap_ro_props" 93 fi 94 95 for prop in $props; do 96 cur_value=$(get_prop $prop ${dataset[i]}) 97 98 j=0 99 while (( j < ${#values[@]} )); do 100 # 101 # If the current property value is equal to values[j], 102 # just expect it failed. Otherwise, set it to dataset, 103 # expecting it failed and the property value is not 104 # equal to values[j]. 105 # 106 if [[ $cur_value == ${values[j]} ]]; then 107 log_mustnot zfs set $prop=${values[j]} \ 108 ${dataset[i]} 109 else 110 set_n_check_prop ${values[j]} $prop \ 111 ${dataset[i]} false 112 fi 113 (( j += 1 )) 114 done 115 done 116 (( i += 1 )) 117done 118 119log_pass "Setting uneditable properties should failed. It passed." 120