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