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# ident "@(#)zpool_create.kshlib 1.4 09/06/22 SMI" 28# 29 30. $STF_SUITE/include/libtest.kshlib 31 32# 33# Given a pool vdevs list, create the pool,verify the created pool, 34# and destroy the pool 35# $1, pool name 36# $2, pool type, mirror, raidz, or none 37# $3, vdevs list 38# 39function create_pool_test 40{ 41 typeset pool=$1 42 typeset keywd=$2 43 typeset vdevs 44 eval set -A diskarray $3 45 46 for vdevs in "${diskarray[@]}";do 47 create_pool $pool $keywd $vdevs 48 log_must poolexists $pool 49 destroy_pool $pool 50 done 51} 52 53# 54# Create a ufs file system and make a vdev file on it 55# 56# $1, disk name to create ufs file system 57# $2, file name 58# 59function create_blockfile 60{ 61 typeset disk=$1 62 typeset file=$2 63 typeset dir=`$DIRNAME $file` 64 65 if [[ -d $dir ]]; then 66 ismounted $dir ufs && log_must $UMOUNT -f $dir 67 else 68 log_must $MKDIR -p $dir 69 fi 70 71 log_must $NEWFS $disk 72 log_must $MOUNT $disk $dir 73 log_must create_vdevs $file 74} 75 76# 77# Umount the ufs filesystem and remove the mountpoint 78# $1, the mount point 79# 80function clean_blockfile 81{ 82 typeset dirs=$1 83 84 for dir in $dirs; do 85 if [[ -d $dir ]]; then 86 if ismounted $dir ufs; then 87 log_must $UMOUNT -f $dir 88 fi 89 log_must $RM -rf $dir 90 fi 91 done 92} 93 94# 95# Find the storage device in /etc/vfstab 96# 97function find_fstab_dev 98{ 99 typeset fstab="/etc/fstab" 100 typeset tmpfile="$TMPDIR/fstab.tmp" 101 typeset fstabdev 102 typeset fstabdevs="" 103 typeset line 104 105 $CAT $fstab | $GREP "^/dev" >$tmpfile 106 while read -r line 107 do 108 fstabdev=`$ECHO "$line" | $AWK '{print $1}'` 109 fstabdev=${fstabdev%%:} 110 fstabdevs="$fstabdev $fstabdevs" 111 done <$tmpfile 112 113 $RM -f $tmpfile 114 $ECHO $fstabdevs 115} 116