4830679275542191aae3ebd758199edbde218faaHuck Elliott#!/bin/ksh -p
4830679275542191aae3ebd758199edbde218faaHuck Elliott#
4830679275542191aae3ebd758199edbde218faaHuck Elliott# CDDL HEADER START
4830679275542191aae3ebd758199edbde218faaHuck Elliott#
4830679275542191aae3ebd758199edbde218faaHuck Elliott# The contents of this file are subject to the terms of the
4830679275542191aae3ebd758199edbde218faaHuck Elliott# Common Development and Distribution License (the "License").
4830679275542191aae3ebd758199edbde218faaHuck Elliott# You may not use this file except in compliance with the License.
4830679275542191aae3ebd758199edbde218faaHuck Elliott#
4830679275542191aae3ebd758199edbde218faaHuck Elliott# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4830679275542191aae3ebd758199edbde218faaHuck Elliott# or http://www.opensolaris.org/os/licensing.
4830679275542191aae3ebd758199edbde218faaHuck Elliott# See the License for the specific language governing permissions
4830679275542191aae3ebd758199edbde218faaHuck Elliott# and limitations under the License.
4830679275542191aae3ebd758199edbde218faaHuck Elliott#
4830679275542191aae3ebd758199edbde218faaHuck Elliott# When distributing Covered Code, include this CDDL HEADER in each
4830679275542191aae3ebd758199edbde218faaHuck Elliott# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4830679275542191aae3ebd758199edbde218faaHuck Elliott# If applicable, add the following below this CDDL HEADER, with the
4830679275542191aae3ebd758199edbde218faaHuck Elliott# fields enclosed by brackets "[]" replaced with your own identifying
4830679275542191aae3ebd758199edbde218faaHuck Elliott# information: Portions Copyright [yyyy] [name of copyright owner]
4830679275542191aae3ebd758199edbde218faaHuck Elliott#
4830679275542191aae3ebd758199edbde218faaHuck Elliott# CDDL HEADER END
4830679275542191aae3ebd758199edbde218faaHuck Elliott#
4830679275542191aae3ebd758199edbde218faaHuck Elliott
4830679275542191aae3ebd758199edbde218faaHuck Elliott#
4830679275542191aae3ebd758199edbde218faaHuck Elliott# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
4830679275542191aae3ebd758199edbde218faaHuck Elliott# Use is subject to license terms.
4830679275542191aae3ebd758199edbde218faaHuck Elliott#
4830679275542191aae3ebd758199edbde218faaHuck Elliott
4830679275542191aae3ebd758199edbde218faaHuck Elliott#
4830679275542191aae3ebd758199edbde218faaHuck Elliott# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
4830679275542191aae3ebd758199edbde218faaHuck Elliott#
4830679275542191aae3ebd758199edbde218faaHuck Elliott
4830679275542191aae3ebd758199edbde218faaHuck Elliott. $STF_SUITE/include/libtest.shlib
4830679275542191aae3ebd758199edbde218faaHuck Elliott
4830679275542191aae3ebd758199edbde218faaHuck Elliott#
4830679275542191aae3ebd758199edbde218faaHuck Elliott# DESCRIPTION:
4830679275542191aae3ebd758199edbde218faaHuck Elliott# The recursive flag -r can only be used for snapshots and not for
4830679275542191aae3ebd758199edbde218faaHuck Elliott# volumes/filesystems.
4830679275542191aae3ebd758199edbde218faaHuck Elliott#
4830679275542191aae3ebd758199edbde218faaHuck Elliott# STRATEGY:
250518431587ddbe0a5c84a182f9218eeac383b3Huck Elliott# 1. Loop pool, fs, container and volume.
4830679275542191aae3ebd758199edbde218faaHuck Elliott# 2. Verify none of them can be rename by rename -r.
4830679275542191aae3ebd758199edbde218faaHuck Elliott#
4830679275542191aae3ebd758199edbde218faaHuck Elliott
4830679275542191aae3ebd758199edbde218faaHuck Elliottverify_runnable "both"
4830679275542191aae3ebd758199edbde218faaHuck Elliott
4830679275542191aae3ebd758199edbde218faaHuck Elliottlog_assert "The recursive flag -r can only be used for snapshots."
4830679275542191aae3ebd758199edbde218faaHuck Elliott
4830679275542191aae3ebd758199edbde218faaHuck Elliottset -A datasets $TESTPOOL $TESTPOOL/$TESTCTR \
4830679275542191aae3ebd758199edbde218faaHuck Elliott $TESTPOOL/$TESTCTR/$TESTFS1 $TESTPOOL/$TESTFS
4830679275542191aae3ebd758199edbde218faaHuck Elliottif is_global_zone; then
4830679275542191aae3ebd758199edbde218faaHuck Elliott datasets[${#datasets[@]}]=$TESTPOOL/$TESTVOL
4830679275542191aae3ebd758199edbde218faaHuck Elliottfi
4830679275542191aae3ebd758199edbde218faaHuck Elliott
4830679275542191aae3ebd758199edbde218faaHuck Elliottfor opts in "-r" "-r -p"; do
250518431587ddbe0a5c84a182f9218eeac383b3Huck Elliott typeset -i i=0
250518431587ddbe0a5c84a182f9218eeac383b3Huck Elliott while ((i < ${#datasets[@]})); do
4830679275542191aae3ebd758199edbde218faaHuck Elliott log_mustnot zfs rename $opts ${datasets[$i]} \
4830679275542191aae3ebd758199edbde218faaHuck Elliott ${datasets[$i]}-new
4830679275542191aae3ebd758199edbde218faaHuck Elliott
4830679275542191aae3ebd758199edbde218faaHuck Elliott # Check datasets, make sure none of them was renamed.
4830679275542191aae3ebd758199edbde218faaHuck Elliott typeset -i j=0
4830679275542191aae3ebd758199edbde218faaHuck Elliott while ((j < ${#datasets[@]})); do
4830679275542191aae3ebd758199edbde218faaHuck Elliott if datasetexists ${datasets[$j]}-new ; then
4830679275542191aae3ebd758199edbde218faaHuck Elliott log_fail "${datasets[$j]}-new should not exists."
4830679275542191aae3ebd758199edbde218faaHuck Elliott fi
250518431587ddbe0a5c84a182f9218eeac383b3Huck Elliott ((j += 1))
250518431587ddbe0a5c84a182f9218eeac383b3Huck Elliott done
250518431587ddbe0a5c84a182f9218eeac383b3Huck Elliott
250518431587ddbe0a5c84a182f9218eeac383b3Huck Elliott ((i += 1))
250518431587ddbe0a5c84a182f9218eeac383b3Huck Elliott done
250518431587ddbe0a5c84a182f9218eeac383b3Huck Elliottdone
250518431587ddbe0a5c84a182f9218eeac383b3Huck Elliott
250518431587ddbe0a5c84a182f9218eeac383b3Huck Elliottlog_pass "The recursive flag -r can only be used for snapshots passed."
250518431587ddbe0a5c84a182f9218eeac383b3Huck Elliott