]> git.proxmox.com Git - mirror_zfs-debian.git/blame - tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib
New upstream version 0.7.2
[mirror_zfs-debian.git] / tests / zfs-tests / tests / functional / cli_root / zpool_add / zpool_add.kshlib
CommitLineData
cae5b340
AX
1#
2# CDDL HEADER START
3#
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.
7#
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.
12#
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]
18#
19# CDDL HEADER END
20#
21
22#
23# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24# Use is subject to license terms.
25#
26
27#
28# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
29#
30
31. $STF_SUITE/include/libtest.shlib
32. $STF_SUITE/tests/functional/cli_root/zpool_add/zpool_add.cfg
33
34#
35# Find the storage device in /etc/vfstab
36#
37function find_vfstab_dev
38{
39 typeset vfstabdev
40 typeset vfstabdevs=""
41 typeset line
42
43 if is_linux; then
44 vfstab="/etc/fstab"
45 tmpfile="/tmp/fstab.tmp"
46 else
47 vfstab="/etc/vfstab"
48 tmpfile="/tmp/vfstab.tmp"
49 fi
50
51 cat $vfstab | grep "^${DEV_DSKDIR}" >$tmpfile
52 while read -r line
53 do
54 vfstabdev=`echo "$line" | awk '{print $1}'`
55 vfstabdev=${vfstabdev%%:}
56 vfstabdevs="$vfstabdev $vfstabdevs"
57 done <$tmpfile
58
59 rm -f $tmpfile
60 echo $vfstabdevs
61}
62
63#
64# Find the storage device in /etc/mnttab
65#
66function find_mnttab_dev
67{
68 typeset mnttabdev
69 typeset mnttabdevs=""
70 typeset line
71
72 if is_linux; then
73 typeset mnttab="/etc/mtab"
74 typeset tmpfile="/tmp/mtab.tmp"
75 else
76 typeset mnttab="/etc/mnttab"
77 typeset tmpfile="/tmp/mnttab.tmp"
78 fi
79
80 cat $mnttab | grep "^${DEV_DSKDIR}" >$tmpfile
81 while read -r line
82 do
83 mnttabdev=`echo "$line" | awk '{print $1}'`
84 mnttabdev=${mnttabdev%%:}
85 mnttabdevs="$mnttabdev $mnttabdevs"
86 done <$tmpfile
87
88 rm -f $tmpfile
89 echo $mnttabdevs
90}
91
92#
93# Save the systme current dump device configuration
94#
95function save_dump_dev
96{
97
98 typeset dumpdev
99
100 if is_linux; then
101 dumpdev=""
102 else
103 typeset fnd="Dump device"
104 dumpdev=`dumpadm | grep "$fnd" | cut -f2 -d : | \
105 awk '{print $1}'`
106 fi
107 echo $dumpdev
108}
109
110#
111# Common cleanup routine for partitions used in testing
112#
113function partition_cleanup
114{
115
116 if [[ -n $DISK ]]; then
117 partition_disk $SIZE $DISK 7
118 else
119 typeset disk=""
120 for disk in $DISK0 $DISK1; do
121 partition_disk $SIZE $disk 7
122 done
123 fi
124
125}