1#!/usr/local/bin/ksh93 -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# $FreeBSD$ 24 25# 26# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)ro_props_001_pos.ksh 1.4 07/10/09 SMI" 30# 31 32. $STF_SUITE/include/libtest.kshlib 33. $STF_SUITE/tests/cli_root/zfs_set/zfs_set_common.kshlib 34 35############################################################################### 36# 37# __stc_assertion_start 38# 39# ID: ro_props_001_pos 40# 41# DESCRIPTION: 42# Verify that read-only properties are immutable. 43# 44# STRATEGY: 45# 1. Create pool, fs, vol, fs@snap & vol@snap. 46# 2. Get the original property value and set value to those properties. 47# 3. Check return value. 48# 4. Compare the current property value with the original one. 49# 50# TESTABILITY: explicit 51# 52# TEST_AUTOMATION_LEVEL: automated 53# 54# CODING_STATUS: COMPLETED (2005-07-04) 55# 56# __stc_assertion_end 57# 58################################################################################ 59 60verify_runnable "both" 61 62set -A values filesystem volume snapshot -3 0 1 50K 10G 80G \ 63 2005/06/17 30K 20x yes no \ 64 on off default pool/fs@snap $TESTDIR 65set -A dataset $TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \ 66 $TESTPOOL/$TESTCTR/$TESTFS1 $TESTPOOL/$TESTFS@$TESTSNAP \ 67 $TESTPOOL/$TESTVOL@$TESTSNAP 68 69typeset ro_props="type" 70ro_props="$ro_props creation" 71ro_props="$ro_props compressratio" 72ro_props="$ro_props mounted" 73ro_props="$ro_props origin" 74# Uncomment these once the test ensures they can't be changed. 75#ro_props="$ro_props used" 76#ro_props="$ro_props available" 77#ro_props="$ro_props avail" 78#ro_props="$ro_props referenced" 79#ro_props="$ro_props refer" 80 81typeset snap_ro_props="volsize" 82snap_ro_props="$snap_ro_props recordsize" 83snap_ro_props="$snap_ro_props recsize" 84snap_ro_props="$snap_ro_props quota" 85snap_ro_props="$snap_ro_props reservation" 86snap_ro_props="$snap_ro_props reserv" 87snap_ro_props="$snap_ro_props mountpoint" 88snap_ro_props="$snap_ro_props sharenfs" 89snap_ro_props="$snap_ro_props checksum" 90snap_ro_props="$snap_ro_props compression" 91snap_ro_props="$snap_ro_props compress" 92snap_ro_props="$snap_ro_props atime" 93snap_ro_props="$snap_ro_props devices" 94snap_ro_props="$snap_ro_props exec" 95snap_ro_props="$snap_ro_props readonly" 96snap_ro_props="$snap_ro_props rdonly" 97snap_ro_props="$snap_ro_props setuid" 98 99$ZFS upgrade -v > /dev/null 2>&1 100if [[ $? -eq 0 ]]; then 101 snap_ro_props="$snap_ro_props version" 102fi 103 104function cleanup 105{ 106 poolexists $TESTPOOL && log_must $ZPOOL history $TESTPOOL 107 datasetexists $TESTPOOL/$TESTVOL@$TESTSNAP && \ 108 destroy_snapshot $TESTPOOL/$TESTVOL@$TESTSNAP 109 datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \ 110 destroy_snapshot $TESTPOOL/$TESTFS@$TESTSNAP 111} 112 113log_assert "Verify that read-only properties are immutable." 114log_onexit cleanup 115 116# Create filesystem and volume's snapshot 117create_snapshot $TESTPOOL/$TESTFS $TESTSNAP 118create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP 119 120# Make sure any history logs have been synced. They're asynchronously 121# pushed to the syncing context, and could influence the value of some 122# properties on $TESTPOOL, like 'used'. Fetching it here forces the sync, 123# per spa_history.c:spa_history_get(). 124log_must $ZPOOL history $TESTPOOL 125 126typeset -i i=0 127typeset -i j=0 128typeset cur_value="" 129typeset props="" 130 131while (( i < ${#dataset[@]} )); do 132 props=$ro_props 133 134 dst_type=$(get_prop type ${dataset[i]}) 135 if [[ $dst_type == 'snapshot' ]]; then 136 props="$ro_props $snap_ro_props" 137 fi 138 139 for prop in $props; do 140 cur_value=$(get_prop $prop ${dataset[i]}) 141 142 j=0 143 while (( j < ${#values[@]} )); do 144 # 145 # If the current property value is equal to values[j], 146 # just expect it failed. Otherwise, set it to dataset, 147 # expecting it failed and the property value is not 148 # equal to values[j]. 149 # 150 if [[ $cur_value == ${values[j]} ]]; then 151 log_mustnot $ZFS set $prop=${values[j]} \ 152 ${dataset[i]} 153 else 154 set_n_check_prop ${values[j]} $prop \ 155 ${dataset[i]} false 156 fi 157 (( j += 1 )) 158 done 159 done 160 (( i += 1 )) 161done 162 163log_pass "Setting uneditable properties fail, as required." 164