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