zfs_rename_005_neg.ksh revision d583b39bfb4e2571d3e41097c5c357ffe353ad45
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#!/bin/ksh -p
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# CDDL HEADER START
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# The contents of this file are subject to the terms of the
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# Common Development and Distribution License (the "License").
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# You may not use this file except in compliance with the License.
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# or http://www.opensolaris.org/os/licensing.
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# See the License for the specific language governing permissions
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# and limitations under the License.
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# When distributing Covered Code, include this CDDL HEADER in each
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# If applicable, add the following below this CDDL HEADER, with the
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# fields enclosed by brackets "[]" replaced with your own identifying
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# information: Portions Copyright [yyyy] [name of copyright owner]
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# CDDL HEADER END
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# Use is subject to license terms.
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara. $STF_SUITE/include/libtest.shlib
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara. $STF_SUITE/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# DESCRIPTION:
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# 'zfs rename' should fail when the dataset are not within the same pool
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# STRATEGY:
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# 1. Given a file system, snapshot and volume.
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# 2. Rename each dataset object to a different pool.
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# 3. Verify the operation fails, and only the original name
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# is displayed by zfs list.
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwaraverify_runnable "global"
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwarafunction my_cleanup
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara{
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara poolexists $TESTPOOL1 && \
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara destroy_pool $TESTPOOL1
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara [[ -e $TESTDIR/$TESTFILE1 ]] && \
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara log_must $RM -f $TESTDIR/$TESTFILE1
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara cleanup
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara}
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwaraset -A src_dataset \
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara "$TESTPOOL/$TESTFS1" "$TESTPOOL/$TESTCTR1" \
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara "$TESTPOOL/$TESTCTR/$TESTFS1" "$TESTPOOL/$TESTVOL" \
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara "$TESTPOOL/$TESTFS@snapshot" "$TESTPOOL/$TESTFS-clone"
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara# cleanup defined in zfs_rename.kshlib
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara#
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwaralog_onexit my_cleanup
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwaralog_assert "'zfs rename' should fail while datasets are within different pool."
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwaraadditional_setup
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwaratypeset FILESIZE=64m
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwaralog_must $MKFILE $FILESIZE $TESTDIR/$TESTFILE1
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwaracreate_pool $TESTPOOL1 $TESTDIR/$TESTFILE1
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwarafor src in ${src_dataset[@]} ; do
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara dest=${src#$TESTPOOL/}
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara if [[ $dest == *"@"* ]]; then
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara dest=${dest#*@}
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara dest=${TESTPOOL1}@$dest
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara else
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara dest=${TESTPOOL1}/$dest
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara fi
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara log_mustnot $ZFS rename $src $dest
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara log_mustnot $ZFS rename -p $src $dest
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara #
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara # Verify original dataset name still in use
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara #
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara log_must datasetexists $src
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwaradone
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwaralog_pass "'zfs rename' fail while datasets are within different pool."
33f285ae904939ecef3a4a660b9e72942e10d37dVallish Vaidyeshwara