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) 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/include/libtest.shlib 33. $STF_SUITE/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib 34 35# 36# DESCRIPTION: 37# 'zfs rename' should successfully be capable of renaming 38# valid datasets back and forth multiple times. 39# 40# STRATEGY: 41# 1. Given a file system, snapshot and volume. 42# 2. Rename each dataset object to a new name. 43# 3. Rename each dataset back to its original name. 44# 4. Repeat steps 2 and 3 multiple times. 45# 5. Verify that the correct name is displayed by zfs list. 46# 47############################################################################### 48 49verify_runnable "both" 50 51set -A dataset "$TESTPOOL/$TESTFS@snapshot" "$TESTPOOL/$TESTFS1" \ 52 "$TESTPOOL/$TESTCTR/$TESTFS1" "$TESTPOOL/$TESTCTR1" \ 53 "$TESTPOOL/$TESTVOL" "$TESTPOOL/$TESTFS-clone" 54 55# 56# cleanup defined in zfs_rename.kshlib 57# 58log_onexit cleanup 59 60log_assert "'zfs rename' should successfully rename valid datasets" 61 62additional_setup 63 64typeset -i i=0 65typeset -i iters=10 66 67while ((i < ${#dataset[*]} )); do 68 j=0 69 while ((j < iters )); do 70 rename_dataset ${dataset[i]} ${dataset[i]}-new 71 rename_dataset ${dataset[i]}-new ${dataset[i]} 72 73 ((j = j + 1)) 74 done 75 76 if [[ ${dataset[i]} == *@* ]]; then 77 data=$(snapshot_mountpoint ${dataset[i]})/$TESTFILE0 78 elif [[ ${dataset[i]} == "$TESTPOOL/$TESTVOL" ]] && is_global_zone; then 79 log_must eval "dd if=$VOL_R_PATH of=$VOLDATA bs=$BS count=$CNT >/dev/null 2>&1" 80 data=$VOLDATA 81 else 82 data=$(get_prop mountpoint ${dataset[i]})/$TESTFILE0 83 fi 84 85 if ! cmp_data $DATA $data; then 86 log_fail "$data gets corrupted after $iters times rename operations." 87 fi 88 89 ((i = i + 1)) 90done 91 92log_pass "'zfs rename' renamed each dataset type multiple times as expected." 93