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 2009 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# Setting valid canmount to filesystem, it is successful. 34# Whatever is set to volume or snapshot, it is failed. 35# 'zfs set canmount=on|off <fs>' 36# 37# STRATEGY: 38# 1. Setup a pool and create fs, volume, snapshot clone within it. 39# 2. Loop all the valid mountpoint value. 40# 3. Check the return value. 41# 42 43verify_runnable "both" 44 45set -A dataset_pos \ 46 "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTCTR" "$TESTPOOL/$TESTCLONE" 47 48if is_global_zone ; then 49 set -A dataset_neg \ 50 "$TESTPOOL/$TESTVOL" "$TESTPOOL/$TESTFS@$TESTSNAP" \ 51 "$TESTPOOL/$TESTVOL@$TESTSNAP" "$TESTPOOL/$TESTCLONE1" 52else 53 set -A dataset_neg \ 54 "$TESTPOOL/$TESTFS@$TESTSNAP" "$TESTPOOL/$TESTVOL@$TESTSNAP" 55fi 56 57 58set -A values "on" "off" 59 60function cleanup 61{ 62 if snapexists $TESTPOOL/$TESTFS@$TESTSNAP ; then 63 log_must $ZFS destroy -R $TESTPOOL/$TESTFS@$TESTSNAP 64 fi 65 if snapexists $TESTPOOL/$TESTVOL@$TESTSNAP ; then 66 log_must $ZFS destroy -R $TESTPOOL/$TESTVOL@$TESTSNAP 67 fi 68 69 [[ -n $old_ctr_canmount ]] && \ 70 log_must $ZFS set canmount=$old_ctr_canmount $TESTPOOL/$TESTCTR 71 [[ -n $old_fs_canmount ]] && \ 72 log_must $ZFS set canmount=$old_fs_canmount $TESTPOOL/$TESTFS 73 74 $ZFS unmount -a > /dev/null 2>&1 75 log_must $ZFS mount -a 76} 77 78log_assert "Setting a valid property of canmount to file system, it must be successful." 79log_onexit cleanup 80 81typeset old_fs_canmount="" old_ctr_canmount="" 82 83old_fs_canmount=$(get_prop canmount $TESTPOOL/$TESTFS) 84[[ $? != 0 ]] && \ 85 log_fail "Get the $TESTPOOL/$TESTFS canmount error." 86old_ctr_canmount=$(get_prop canmount $TESTPOOL/$TESTCTR) 87[[ $? != 0 ]] && \ 88 log_fail "Get the $TESTPOOL/$TESTCTR canmount error." 89 90log_must $ZFS snapshot $TESTPOOL/$TESTFS@$TESTSNAP 91log_must $ZFS snapshot $TESTPOOL/$TESTVOL@$TESTSNAP 92log_must $ZFS clone $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTCLONE 93log_must $ZFS clone $TESTPOOL/$TESTVOL@$TESTSNAP $TESTPOOL/$TESTCLONE1 94 95for dataset in "${dataset_pos[@]}" ; do 96 for value in "${values[@]}" ; do 97 set_n_check_prop "$value" "canmount" "$dataset" 98 if [[ $value == "off" ]]; then 99 log_mustnot ismounted $dataset 100 log_mustnot $ZFS mount $dataset 101 log_mustnot ismounted $dataset 102 else 103 if ! ismounted $dataset ; then 104 log_must $ZFS mount $dataset 105 fi 106 log_must ismounted $dataset 107 fi 108 done 109done 110 111for dataset in "${dataset_neg[@]}" ; do 112 for value in "${values[@]}" ; do 113 set_n_check_prop "$value" "canmount" \ 114 "$dataset" "false" 115 log_mustnot ismounted $dataset 116 done 117done 118 119log_pass "Setting canmount to filesystem pass." 120