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# 29# Copyright (c) 2012 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/include/libtest.shlib 33. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib 34 35# 36# DESCRIPTION: 37# If ZFS is currently managing the file system but it is currently unmoutned, 38# and the mountpoint property is changed, the file system remains unmounted. 39# 40# STRATEGY: 41# 1. Setup a pool and create fs, ctr within it. 42# 2. Unmount that dataset 43# 2. Change the mountpoint to the valid mountpoint value. 44# 3. Check the file system remains unmounted. 45# 46 47verify_runnable "both" 48 49export TESTDIR_NOTEXISTING=${TEST_BASE_DIR%%/}/testdir_notexisting$$ 50 51set -A dataset "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTCTR" 52 53set -A values "$TESTDIR2" "$TESTDIR_NOTEXISTING" 54 55function cleanup 56{ 57 log_must $ZFS set mountpoint=$old_ctr_mpt $TESTPOOL/$TESTCTR 58 log_must $ZFS set mountpoint=$old_fs_mpt $TESTPOOL/$TESTFS 59 log_must $ZFS mount -a 60 [[ -d $TESTDIR2 ]] && log_must $RM -r $TESTDIR2 61 [[ -d $TESTDIR_NOTEXISTING ]] && log_must $RM -r $TESTDIR_NOTEXISTING 62} 63 64log_assert "Setting a valid mountpoint for an unmounted file system, \ 65 it remains unmounted." 66log_onexit cleanup 67 68old_fs_mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS) 69[[ $? != 0 ]] && \ 70 log_fail "Unable to get the mountpoint property for $TESTPOOL/$TESTFS" 71old_ctr_mpt=$(get_prop mountpoint $TESTPOOL/$TESTCTR) 72[[ $? != 0 ]] && \ 73 log_fail "Unable to get the mountpoint property for $TESTPOOL/$TESTCTR" 74 75if [[ ! -d $TESTDIR2 ]]; then 76 log_must $MKDIR $TESTDIR2 77fi 78 79typeset -i i=0 80typeset -i j=0 81while (( i < ${#dataset[@]} )); do 82 j=0 83 if ismounted ${dataset[i]} ; then 84 log_must $ZFS unmount ${dataset[i]} 85 fi 86 log_mustnot ismounted ${dataset[i]} 87 while (( j < ${#values[@]} )); do 88 set_n_check_prop "${values[j]}" "mountpoint" \ 89 "${dataset[i]}" 90 log_mustnot ismounted ${dataset[i]} 91 (( j += 1 )) 92 done 93 cleanup 94 (( i += 1 )) 95done 96 97log_pass "Setting a valid mountpoint for an unmounted file system, \ 98 it remains unmounted." 99