#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

#
# Copyright (c) 2013 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib

if is_linux; then
	export DISKSARRAY=$DISKS
	export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
	set_device_dir
	set_slice_prefix
	export SLICE0=1
	export SLICE1=2
else
	export SLICE_PREFIX="s"
	export SLICE0=0
	export SLICE1=1
fi

verify_disk_count "$DISKS" 2
set -A disk_array $(find_disks $DISKS)
case "${#disk_array[@]}" in
2)
	FS_DISK0=${disk_array[0]}
	FS_DISK1=${disk_array[1]}
	FS_DISK2=${disk_array[0]}
	FS_DISK3=${disk_array[1]}
	FS_SIDE0=${FS_DISK0}${SLICE_PREFIX}${SLICE0}
	FS_SIDE1=${FS_DISK0}${SLICE_PREFIX}${SLICE1}
	FS_SIDE2=${FS_DISK1}${SLICE_PREFIX}${SLICE0}
	FS_SIDE3=${FS_DISK1}${SLICE_PREFIX}${SLICE1}
	disk0="${DEV_DSKDIR}/$FS_SIDE0"
	disk1="${DEV_DSKDIR}/$FS_SIDE1"
	disk2="${DEV_DSKDIR}/$FS_SIDE2"
	disk3="${DEV_DSKDIR}/$FS_SIDE3"
	disktargets="$disk0 $disk2"
	rawdisk0="${DEV_RDSKDIR}/$FS_SIDE0"
	rawdisk1="${DEV_RDSKDIR}/$FS_SIDE1"
	rawdisk2="${DEV_RDSKDIR}/$FS_SIDE2"
	rawdisk3="${DEV_RDSKDIR}/$FS_SIDE3"
	rawtargets="$rawdisk0 $rawdisk2"
	vdisks="$FS_DISK0"
	sdisks="$FS_DISK1"
	vslices="$FS_SIDE0 $FS_SIDE1 $FS_SIDE2"
	sslices="$FS_SIDE3"
	;;
3)
	FS_DISK0=${disk_array[0]}
	FS_DISK1=${disk_array[1]}
	FS_DISK2=${disk_array[2]}
	FS_DISK3=${disk_array[0]}
	FS_SIDE0=${FS_DISK0}${SLICE_PREFIX}${SLICE0}
	FS_SIDE1=${FS_DISK0}${SLICE_PREFIX}${SLICE1}
	FS_SIDE2=${FS_DISK1}${SLICE_PREFIX}${SLICE0}
	FS_SIDE3=${FS_DISK2}${SLICE_PREFIX}${SLICE0}
	disk0="${DEV_DSKDIR}/$FS_SIDE0"
	disk1="${DEV_DSKDIR}/$FS_SIDE1"
	disk2="${DEV_DSKDIR}/$FS_SIDE2"
	disk3="${DEV_DSKDIR}/$FS_SIDE3"
	disktargets="$disk0 $disk2 $disk3"
	rawdisk0="${DEV_RDSKDIR}/$FS_SIDE0"
	rawdisk1="${DEV_RDSKDIR}/$FS_SIDE1"
	rawdisk2="${DEV_RDSKDIR}/$FS_SIDE2"
	rawdisk3="${DEV_RDSKDIR}/$FS_SIDE3"
	rawtargets="$rawdisk0 $rawdisk2 $rawdisk3"
	vdisks="$FS_DISK0 $FS_DISK1"
	sdisks="$FS_DISK2"
	vslices="$FS_SIDE0 $FS_SIDE2 $FS_SIDE3"
	sslices="$FS_SIDE1"
	;;
*)
	FS_DISK0=${disk_array[0]}
	FS_DISK1=${disk_array[1]}
	FS_DISK2=${disk_array[2]}
	FS_DISK3=${disk_array[3]}
	FS_SIDE0=${FS_DISK0}${SLICE_PREFIX}${SLICE0}
	FS_SIDE1=${FS_DISK1}${SLICE_PREFIX}${SLICE0}
	FS_SIDE2=${FS_DISK2}${SLICE_PREFIX}${SLICE0}
	FS_SIDE3=${FS_DISK3}${SLICE_PREFIX}${SLICE0}
	disk0="${DEV_DSKDIR}/$FS_SIDE0"
	disk1="${DEV_DSKDIR}/$FS_SIDE1"
	disk2="${DEV_DSKDIR}/$FS_SIDE2"
	disk3="${DEV_DSKDIR}/$FS_SIDE3"
	disktargets="$disk0 $disk1 $disk2 $disk3"
	rawdisk0="${DEV_RDSKDIR}/$FS_SIDE0"
	rawdisk1="${DEV_RDSKDIR}/$FS_SIDE1"
	rawdisk2="${DEV_RDSKDIR}/$FS_SIDE2"
	rawdisk3="${DEV_RDSKDIR}/$FS_SIDE3"
	rawtargets="$rawdisk0 $rawdisk1 $rawdisk2 $rawdisk3"
	vdisks="$FS_DISK0 $FS_DISK1 $FS_DISK2"
	sdisks="$FS_DISK3"
	vslices="$FS_SIDE0 $FS_SIDE1 $FS_SIDE2"
	sslices="$FS_SIDE3"
	;;
esac

export FS_DISK0 FS_DISK1 FS_DISK2 FS_DISK3 SINGLE_DISK
export FS_SIDE0 FS_SIDE1 FS_SIDE2 FS_SIDE3
export disk0 disk1 disk2 disk3 disktargets
export rawdisk0 rawdisk1 rawdisk2 rawdisk3 rawtargets
export vdisks sdisks vslices sslices

export UFSMP=$TESTDIR/testinuseufsdump
export FS_SIZE=1g
export PREVDUMPDEV=""
export PIDUFSDUMP=""
export PIDUFSRESTORE=""
# size of block to be written to test file - currently 1mb
export BLOCK_SIZE=$(( 1024 * 1024 ))
# number of blocks to write == size of file
export BLOCK_COUNT=100
export STF_TIMEOUT=1200			# 20 minutes max.
