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, 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/include/libtest.shlib 33. $STF_SUITE/tests/functional/cli_root/zfs_create/zfs_create.cfg 34. $STF_SUITE/tests/functional/cli_root/zfs_create/properties.kshlib 35 36# 37# DESCRIPTION: 38# 'zfs create <filesystem>' fails with bad <filesystem> arguments, including: 39# *Invalid character against the ZFS namespace 40# *Incomplete component 41# *Too many arguments 42# *Filesystem already exists 43# *Beyond maximal name length. 44# *Same property set multiple times via '-o property=value' 45# *Volume's property set on filesystem 46# 47# STRATEGY: 48# 1. Create an array of <filesystem> arguments 49# 2. Execute 'zfs create <filesystem>' with each argument 50# 3. Verify an error is returned. 51# 52 53verify_runnable "both" 54 55function cleanup 56{ 57 typeset -i i 58 typeset found 59 60 # 61 # check to see if there is any new fs created during the test 62 # if so destroy it. 63 # 64 for dset in $(zfs list -H | \ 65 awk '{print $1}' | grep / ); do 66 found=false 67 i=0 68 while (( $i < ${#existed_fs[*]} )); do 69 if [[ $dset == ${existed_fs[i]} ]]; then 70 found=true 71 break 72 fi 73 (( i = i + 1 )) 74 done 75 76 # 77 # new fs created during the test, cleanup it 78 # 79 if [[ $found == "false" ]]; then 80 log_must zfs destroy -f $dset 81 fi 82 done 83} 84 85log_onexit cleanup 86 87set -A args "$TESTPOOL/" "$TESTPOOL//blah" "$TESTPOOL/@blah" \ 88 "$TESTPOOL/blah@blah" "$TESTPOOL/blah^blah" "$TESTPOOL/blah%blah" \ 89 "$TESTPOOL/blah*blah" "$TESTPOOL/blah blah" \ 90 "-s $TESTPOOL/$TESTFS1" "-b 1092 $TESTPOOL/$TESTFS1" \ 91 "-b 64k $TESTPOOL/$TESTFS1" "-s -b 32k $TESTPOOL/$TESTFS1" \ 92 "$TESTPOOL/$BYND_MAX_NAME" 93 94log_assert "Verify 'zfs create <filesystem>' fails with bad <filesystem> argument." 95 96datasetexists $TESTPOOL/$TESTFS || \ 97 log_must zfs create $TESTPOOL/$TESTFS 98 99set -A existed_fs $(zfs list -H | awk '{print $1}' | grep / ) 100 101log_mustnot zfs create $TESTPOOL 102log_mustnot zfs create $TESTPOOL/$TESTFS 103 104typeset -i i=0 105while (( $i < ${#args[*]} )); do 106 log_mustnot zfs create ${args[$i]} 107 log_mustnot zfs create -p ${args[$i]} 108 ((i = i + 1)) 109done 110 111i=0 112while (( $i < ${#RW_FS_PROP[*]} )); do 113 log_mustnot zfs create -o ${RW_FS_PROP[i]} -o ${RW_FS_PROP[i]} \ 114 $TESTPOOL/$TESTFS1 115 log_mustnot zfs create -p -o ${RW_FS_PROP[i]} -o ${RW_FS_PROP[i]} \ 116 $TESTPOOL/$TESTFS1 117 ((i = i + 1)) 118done 119 120i=0 121while (( $i < ${#VOL_ONLY_PROP[*]} )); do 122 log_mustnot zfs create -o ${VOL_ONLY_PROP[i]} $TESTPOOL/$TESTFS1 123 log_mustnot zfs create -p -o ${VOL_ONLY_PROP[i]} $TESTPOOL/$TESTFS1 124 ((i = i + 1)) 125done 126 127log_pass "'zfs create <filesystem>' fails as expected with bad <filesystem> argument." 128