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 2009 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zfs_rename_005_neg.ksh 1.3 09/06/22 SMI" 30# 31. $STF_SUITE/include/libtest.kshlib 32. $STF_SUITE/tests/cli_root/zfs_rename/zfs_rename.kshlib 33 34################################################################################ 35# 36# __stc_assertion_start 37# 38# ID: zfs_rename_005_neg 39# 40# DESCRIPTION: 41# 'zfs rename' should fail when the dataset are not within the same pool 42# 43# STRATEGY: 44# 1. Given a file system, snapshot and volume. 45# 2. Rename each dataset object to a different pool. 46# 3. Verify the operation fails, and only the original name 47# is displayed by zfs list. 48# 49# TESTABILITY: explicit 50# 51# TEST_AUTOMATION_LEVEL: automated 52# 53# CODING_STATUS: COMPLETED (2005-09-13) 54# 55# __stc_assertion_end 56# 57############################################################################### 58 59verify_runnable "global" 60 61function my_cleanup 62{ 63 poolexists $TESTPOOL1 && \ 64 destroy_pool $TESTPOOL1 65 [[ -e $TESTDIR/$TESTFILE1 ]] && \ 66 log_must $RM -f $TESTDIR/$TESTFILE1 67 cleanup 68} 69 70set -A src_dataset \ 71 "$TESTPOOL/$TESTFS1" "$TESTPOOL/$TESTCTR1" \ 72 "$TESTPOOL/$TESTCTR/$TESTFS1" "$TESTPOOL/$TESTVOL" \ 73 "$TESTPOOL/$TESTFS@snapshot" "$TESTPOOL/$TESTFS-clone" 74 75# 76# cleanup defined in zfs_rename.kshlib 77# 78log_onexit my_cleanup 79 80log_assert "'zfs rename' should fail while datasets are within different pool." 81 82additional_setup 83 84typeset FILESIZE=64m 85log_must $TRUNCATE -s $FILESIZE $TESTDIR/$TESTFILE1 86create_pool $TESTPOOL1 $TESTDIR/$TESTFILE1 87 88for src in ${src_dataset[@]} ; do 89 dest=${src#$TESTPOOL/} 90 if [[ $dest == *"@"* ]]; then 91 dest=${dest#*@} 92 dest=${TESTPOOL1}@$dest 93 else 94 dest=${TESTPOOL1}/$dest 95 fi 96 log_mustnot $ZFS rename $src $dest 97 log_mustnot $ZFS rename -p $src $dest 98 99 # 100 # Verify original dataset name still in use 101 # 102 log_must datasetexists $src 103done 104 105log_pass "'zfs rename' fail while datasets are within different pool." 106