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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27. $STF_SUITE/include/libtest.kshlib 28 29# 30# check if the <pool> contains <vdev> ... 31# 32# $1 pool 33# $2..n <vdev> ... 34# 35# Return 0 if <vdev> are contained in the <pool>; 1 if not used; 2 if pool 36# name is missing 37# 38function iscontained 39{ 40 typeset pool=$1 41 typeset vdev 42 43 if [[ -z $pool ]]; then 44 log_note "Missing pool name." 45 return 2 46 fi 47 48 shift 49 50 for vdev in $@; do 51 52# remove /dev/ in vdev if there is 53 vdev=${vdev#/dev/} 54 55 $ZPOOL status "$pool" | $AWK '$1 == vdevname {exit 1}' \ 56 vdevname=$vdev >/dev/null 2>&1 57 (( $? != 1 )) && \ 58 return 1 59 done 60 61 return 0; 62 63} 64 65# 66# Common cleanup routine for partitions used in testing 67# 68function partition_cleanup 69{ 70 log_note "Cleaning up partitions..." 71 if [[ -n $DISK ]]; then 72 partition_disk $SIZE $DISK 7 73 else 74 typeset disk="" 75 for disk in $DISK0 $DISK1; do 76 partition_disk $SIZE $disk 7 77 done 78 fi 79} 80