4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
28 # Copyright (c) 2012 by Delphix. All rights reserved.
31 . $STF_SUITE/tests/functional/cli_root/zfs_rename/zfs_rename.cfg
33 function additional_setup
36 log_must $CP $DATA $TESTDIR/$TESTFILE0
37 log_must $CP $DATA $TESTDIR1/$TESTFILE0
40 if ! snapexists $TESTPOOL/$TESTFS@snapshot; then
41 log_must $ZFS snapshot $TESTPOOL/$TESTFS@snapshot
42 log_must $ZFS clone $TESTPOOL/$TESTFS@snapshot \
43 $TESTPOOL/$TESTFS-clone
47 datasetexists $TESTPOOL/$TESTFS1 || \
48 log_must $ZFS create $TESTPOOL/$TESTFS1
51 log_must $CP $DATA $(get_prop mountpoint $TESTPOOL/$TESTFS1)/$TESTFILE0
54 datasetexists $TESTPOOL/$TESTCTR1 || \
55 log_must $ZFS create $TESTPOOL/$TESTCTR1
56 log_must $CP $DATA $(get_prop mountpoint $TESTPOOL/$TESTCTR1)/$TESTFILE0
59 if is_global_zone; then
60 log_must eval "$DD if=$DATA of=$VOL_R_PATH bs=$BS count=$CNT \
63 log_must $CP $DATA $(get_prop mountpoint $TESTPOOL/$TESTVOL)/$TESTFILE0
68 function rename_dataset # src dest
73 log_must $ZFS rename $src $dest
77 # Verify src name no longer in use
79 log_mustnot datasetexists $src
80 log_must datasetexists $dest
86 while ((i < ${#dataset[*]} )); do
87 if ! datasetexists ${dataset[i]}-new ; then
92 if [[ ${dataset[i]}-new != *@* ]] ; then
93 $ZFS rename ${dataset[i]}-new ${dataset[i]}
94 if [[ $? -ne 0 ]]; then
95 typeset newfs=${dataset[i]}-new
96 typeset oldfs=${dataset[i]}
97 typeset mntp=$(get_prop mountpoint $newfs)
98 log_must $ZFS destroy -f $newfs
99 log_must $ZFS create -p $oldfs
100 log_must $ZFS set mountpoint=$mntp $oldfs
103 log_must $ZFS destroy -fR ${dataset[i]}-new
109 if snapexists $TESTPOOL/$TESTFS@snapshot; then
110 log_must $ZFS destroy -fR $TESTPOOL/$TESTFS@snapshot
115 function cmp_data #<$1 src data, $2 tgt data>
120 $CMP $src $tgt >/dev/null 2>&1