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.
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.
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]
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
36 # Long name filesystem with snapshot should not break ZFS.
39 # 1. Create filesystem and snapshot.
40 # 2. When the snapshot length is 256, rename the filesystem.
41 # 3. Verify it does not break ZFS
44 verify_runnable "both"
48 if datasetexists $initfs ; then
49 log_must zfs destroy -rf $initfs
53 log_assert "Verify long name filesystem with snapshot should not break ZFS."
56 initfs=$TESTPOOL/$TESTFS/$TESTFS
58 typeset -i ret=0 len snaplen
59 while ((ret == 0)); do
61 zfs snapshot $basefs@snap1
65 len=$(echo $basefs | wc -c)
66 log_note "The deeply-nested filesystem len: $len"
69 # Make sure there are at lease 2 characters left
70 # for snapshot name space, otherwise snapshot name
73 if ((len >= 255)); then
74 if datasetexists $basefs; then
75 log_must zfs destroy -r $basefs
78 len=$(echo $basefs| wc -c)
83 basefs=$basefs/$TESTFS
86 # Make snapshot name length match the longest one
87 ((snaplen = 256 - len - 1)) # 1: @
88 snap=$(gen_dataset_name $snaplen "s")
89 log_must zfs snapshot $basefs@$snap
91 log_mustnot zfs rename $basefs ${basefs}a
92 log_mustnot zfs rename $basefs ${basefs}-new
93 log_mustnot zfs rename $initfs ${initfs}-new
94 log_mustnot zfs rename $TESTPOOL/$TESTFS $TESTPOOL/$TESTFS-new
96 log_pass "Verify long name filesystem with snapshot should not break ZFS."