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 2007 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zfs_rename_001_pos.ksh 1.4 07/10/09 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_001_pos 39# 40# DESCRIPTION: 41# 'zfs rename' should successfully rename valid datasets. 42# As a sub-assertion we check to ensure the datasets that can 43# be mounted are mounted. 44# 45# STRATEGY: 46# 1. Given a file system, snapshot and volume. 47# 2. Rename each dataset object to a new name. 48# 3. Verify that only the new name is displayed by zfs list. 49# 4. Verify mountable datasets are mounted. 50# 51# TESTABILITY: explicit 52# 53# TEST_AUTOMATION_LEVEL: automated 54# 55# CODING_STATUS: COMPLETED (2005-06-29) 56# 57# __stc_assertion_end 58# 59############################################################################### 60 61verify_runnable "both" 62 63set -A dataset "$TESTPOOL/$TESTFS@snapshot" "$TESTPOOL/$TESTFS1" \ 64 "$TESTPOOL/$TESTCTR/$TESTFS1" "$TESTPOOL/$TESTCTR1" \ 65 "$TESTPOOL/$TESTVOL" "$TESTPOOL/$TESTFS-clone" 66set -A mountable "$TESTPOOL/$TESTFS1-new" "$TESTPOOL/$TESTFS@snapshot-new" \ 67 "$TESTPOOL/$TESTCTR/$TESTFS1-new" "$TESTPOOL/$TESTFS-clone-new" 68 69# 70# cleanup defined in zfs_rename.kshlib 71# 72log_onexit cleanup 73 74log_assert "'zfs rename' should successfully rename valid datasets" 75 76additional_setup 77 78typeset -i i=0 79while (( i < ${#dataset[*]} )); do 80 rename_dataset ${dataset[i]} ${dataset[i]}-new 81 82 ((i = i + 1)) 83done 84 85log_note "Verify mountable datasets are mounted in their new namespace." 86typeset mtpt 87i=0 88while (( i < ${#mountable[*]} )); do 89 # Snapshot have no mountpoint 90 if [[ ${mountable[i]} != *@* ]]; then 91 log_must mounted ${mountable[i]} 92 mtpt=$(get_prop mountpoint ${mountable[i]}) 93 else 94 mtpt=$(snapshot_mountpoint ${mountable[i]}) 95 fi 96 97 if ! cmp_data $DATA $mtpt/$TESTFILE0 ; then 98 log_fail "$mtpt/$TESTFILE0 gets corrupted after rename operation." 99 fi 100 101 ((i = i + 1)) 102done 103 104#verify the data integrity in zvol 105if is_global_zone; then 106 log_must eval "$DD if=${VOL_R_PATH}-new of=$VOLDATA bs=$BS count=$CNT >/dev/null 2>&1" 107 if ! cmp_data $VOLDATA $DATA ; then 108 log_fail "$VOLDATA gets corrupted after rename operation." 109 fi 110fi 111 112# rename back fs 113typeset -i i=0 114while ((i < ${#dataset[*]} )); do 115 if datasetexists ${dataset[i]}-new ; then 116 log_must $ZFS rename ${dataset[i]}-new ${dataset[i]} 117 fi 118 ((i = i + 1)) 119done 120 121log_pass "'zfs rename' successfully renamed each dataset type." 122