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