]>
Commit | Line | Data |
---|---|---|
6bb24f4d BB |
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 2009 Sun Microsystems, Inc. All rights reserved. | |
25 | # Use is subject to license terms. | |
26 | # | |
d7958b4c MA |
27 | |
28 | # | |
29 | # Copyright (c) 2012, 2015 by Delphix. All rights reserved. | |
30 | # | |
31 | ||
6bb24f4d BB |
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 fail when the dataset are not within the same pool | |
38 | # | |
39 | # STRATEGY: | |
40 | # 1. Given a file system, snapshot and volume. | |
41 | # 2. Rename each dataset object to a different pool. | |
42 | # 3. Verify the operation fails, and only the original name | |
43 | # is displayed by zfs list. | |
44 | # | |
45 | ||
46 | verify_runnable "global" | |
47 | ||
48 | function my_cleanup | |
49 | { | |
50 | poolexists $TESTPOOL1 && \ | |
51 | destroy_pool $TESTPOOL1 | |
52 | [[ -e $TESTDIR/$TESTFILE1 ]] && \ | |
53 | log_must $RM -f $TESTDIR/$TESTFILE1 | |
54 | cleanup | |
55 | } | |
56 | ||
57 | set -A src_dataset \ | |
58 | "$TESTPOOL/$TESTFS1" "$TESTPOOL/$TESTCTR1" \ | |
59 | "$TESTPOOL/$TESTCTR/$TESTFS1" "$TESTPOOL/$TESTVOL" \ | |
60 | "$TESTPOOL/$TESTFS@snapshot" "$TESTPOOL/$TESTFS-clone" | |
61 | ||
62 | # | |
63 | # cleanup defined in zfs_rename.kshlib | |
64 | # | |
65 | log_onexit my_cleanup | |
66 | ||
67 | log_assert "'zfs rename' should fail while datasets are within different pool." | |
68 | ||
69 | additional_setup | |
70 | ||
d7958b4c | 71 | log_must $MKFILE $MINVDEVSIZE $TESTDIR/$TESTFILE1 |
6bb24f4d BB |
72 | create_pool $TESTPOOL1 $TESTDIR/$TESTFILE1 |
73 | ||
74 | for src in ${src_dataset[@]} ; do | |
75 | dest=${src#$TESTPOOL/} | |
76 | if [[ $dest == *"@"* ]]; then | |
77 | dest=${dest#*@} | |
78 | dest=${TESTPOOL1}@$dest | |
79 | else | |
80 | dest=${TESTPOOL1}/$dest | |
81 | fi | |
82 | log_mustnot $ZFS rename $src $dest | |
83 | log_mustnot $ZFS rename -p $src $dest | |
84 | ||
85 | # | |
86 | # Verify original dataset name still in use | |
87 | # | |
88 | log_must datasetexists $src | |
89 | done | |
90 | ||
91 | log_pass "'zfs rename' fail while datasets are within different pool." |