1# vim: filetype=sh
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
27. $STF_SUITE/include/libtest.kshlib
28
29DEPTH_FS=$TESTPOOL/depth_fs
30MAX_DEPTH=3
31DS_COUNT=3
32set -A depth_options  "d 0" "d 1" "d 2" "d 4" "d 32"
33set -A depth_array  0 1 2 4 32
34
35#
36# 'zfs get -d or zfs list -d' is supported
37#
38function zfs_get_list_d_supported
39{
40	check_opt_support "get" "-d"
41        return $?
42}
43
44#
45# Setup multiple depths datasets, including fs, volume and snapshot.
46#
47function depth_fs_setup
48{
49	typeset -i i j k
50	typeset fslist
51
52	log_must $ZFS create $DEPTH_FS
53
54	(( i=1 ))
55	while (( i<=MAX_DEPTH )); do
56		if (( i==1 )); then
57			fslist=$DEPTH_FS
58		else
59			(( k=i-1 ))
60			fslist=$($ZFS list -rH -t filesystem -o name $DEPTH_FS|$GREP d"$k"$)
61			if (( $? != 0 )); then
62				zfs list -rH -t filesystem -o name $DEPTH_FS
63				log_fail "No d$k filesystem"
64			fi
65		fi
66		for fs in $fslist; do
67			(( j=1 ))
68			while (( j<=DS_COUNT )); do
69				log_must $ZFS create $fs/fs_"$j"_d"$i"
70				if is_global_zone ; then
71					log_must $ZFS create -V 8M $fs/v_"$j"_d"$i"
72				fi
73				log_must $ZFS snapshot $fs@s_"$j"_d"$i"
74				(( j=j+1 ))
75			done
76		done
77		(( i=i+1 ))
78	done
79}
80
81#
82# Cleanup multiple depths filesystem.
83#
84function depth_fs_cleanup
85{
86	log_must $ZFS destroy -rR $DEPTH_FS
87}
88
89
90