7290 ZFS test suite needs to control what utilities it can run
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / cli_root / zpool_add / zpool_add.kshlib
blob09fecc3cd0a8d72fc2e2283fc80aa5480432409f
2 # CDDL HEADER START
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
19 # CDDL HEADER END
23 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24 # Use is subject to license terms.
28 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
31 . $STF_SUITE/include/libtest.shlib
32 . $STF_SUITE/tests/functional/cli_root/zpool_add/zpool_add.cfg
35 # Find the storage device in /etc/vfstab
37 function find_vfstab_dev
39         typeset vfstab="/etc/vfstab"
40         typeset tmpfile="/tmp/vfstab.tmp"
41         typeset vfstabdev
42         typeset vfstabdevs=""
43         typeset line
45         cat $vfstab | grep "^/dev/dsk" >$tmpfile
46         while read -r line
47         do
48                 vfstabdev=`echo "$line" | awk '{print $1}'`
49                 vfstabdev=${vfstabdev%%:}
50                 vfstabdevs="$vfstabdev $vfstabdevs"
51         done <$tmpfile
53         rm -f $tmpfile
54         echo $vfstabdevs
58 # Find the storage device in /etc/mnttab
60 function find_mnttab_dev
62         typeset mnttab="/etc/mnttab"
63         typeset tmpfile="/tmp/mnttab.tmp"
64         typeset mnttabdev
65         typeset mnttabdevs=""
66         typeset line
68         cat $mnttab | grep "^/dev/dsk" >$tmpfile
69         while read -r line
70         do
71                 mnttabdev=`echo "$line" | awk '{print $1}'`
72                 mnttabdev=${mnttabdev%%:}
73                 mnttabdevs="$mnttabdev $mnttabdevs"
74         done <$tmpfile
76         rm -f $tmpfile
77         echo $mnttabdevs
81 # Save the systme current dump device configuration
83 function save_dump_dev
86         typeset dumpdev
87         typeset fnd="Dump device"
89         dumpdev=`dumpadm | grep "$fnd" | cut -f2 -d : | \
90                 awk '{print $1}'`
91         echo $dumpdev
95 # Common cleanup routine for partitions used in testing
97 function partition_cleanup
100         if [[ -n $DISK ]]; then
101                 partition_disk $SIZE $DISK 7
102         else
103                 typeset disk=""
104                 for disk in $DISK0 $DISK1; do
105                         partition_disk $SIZE $disk 7
106                 done
107         fi