155714Skris#
255714Skris# CDDL HEADER START
355714Skris#
455714Skris# The contents of this file are subject to the terms of the
555714Skris# Common Development and Distribution License (the "License").
655714Skris# You may not use this file except in compliance with the License.
755714Skris#
8280304Sjkim# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
955714Skris# or https://opensource.org/licenses/CDDL-1.0.
1055714Skris# See the License for the specific language governing permissions
1155714Skris# and limitations under the License.
1255714Skris#
1355714Skris# When distributing Covered Code, include this CDDL HEADER in each
1455714Skris# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15280304Sjkim# If applicable, add the following below this CDDL HEADER, with the
1655714Skris# fields enclosed by brackets "[]" replaced with your own identifying
1755714Skris# information: Portions Copyright [yyyy] [name of copyright owner]
1855714Skris#
1955714Skris# CDDL HEADER END
2055714Skris#
2155714Skris
22280304Sjkim#
2355714Skris# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
2455714Skris# Use is subject to license terms.
2555714Skris#
2655714Skris
2755714Skris#
2855714Skris# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
2955714Skris#
3055714Skris
3155714Skris. $STF_SUITE/include/libtest.shlib
3255714Skris. $STF_SUITE/tests/functional/cli_root/zpool_add/zpool_add.cfg
3355714Skris
3455714Skris#
3555714Skris# Find the storage device in /etc/vfstab
3655714Skris#
37280304Sjkimfunction find_vfstab_dev
3855714Skris{
3955714Skris	if is_illumos; then
40280304Sjkim		vfstab="/etc/vfstab"
4155714Skris	else
4255714Skris		vfstab="/etc/fstab"
4355714Skris	fi
4455714Skris
4555714Skris	awk -v pat="^${DEV_DSKDIR}" '$0 ~ pat {sub(/:$/, "", $1); print $1}' $vfstab
4655714Skris}
4755714Skris
4855714Skris#
4955714Skris# Find the storage device in /etc/mnttab
5055714Skris#
5155714Skrisfunction find_mnttab_dev
52280304Sjkim{
5355714Skris	typeset mnttabdev _
5455714Skris	typeset mnttabdevs=""
5555714Skris
5655714Skris	if is_freebsd; then
5755714Skris		# FreeBSD doesn't have a mnttab file.
5855714Skris		mount -p | awk -v dir="^${DEV_DSKDIR}" \
5955714Skris		    '$1 ~ dir { print $1 }'
6055714Skris		return 0
61280304Sjkim	elif is_linux; then
62280304Sjkim		typeset mnttab="/etc/mtab"
63280304Sjkim	else
64280304Sjkim		typeset mnttab="/etc/mnttab"
6555714Skris	fi
6655714Skris
67109998Smarkm	while read -r mnttabdev _
68280304Sjkim	do
69280304Sjkim		mnttabdev=${mnttabdev%%:}
70280304Sjkim		mnttabdevs="$mnttabdev $mnttabdevs"
71280304Sjkim	done < <(grep "^${DEV_DSKDIR}" $mnttab)
72280304Sjkim
73280304Sjkim	echo $mnttabdevs
74280304Sjkim}
75280304Sjkim
7655714Skris#
77280304Sjkim# Save the system current dump device configuration
78280304Sjkim#
79280304Sjkimfunction save_dump_dev
80280304Sjkim{
81280304Sjkim
82280304Sjkim	typeset dumpdev=""
83280304Sjkim
84280304Sjkim	if is_illumos; then
85280304Sjkim		typeset fnd="Dump device"
86280304Sjkim		dumpdev=`dumpadm | grep "$fnd" | cut -f2 -d : | \
87280304Sjkim			awk '{print $1}'`
88280304Sjkim	fi
89280304Sjkim	echo $dumpdev
90280304Sjkim}
91280304Sjkim