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 https://opensource.org/licenses/CDDL-1.0. 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 if is_illumos; then 40 vfstab="/etc/vfstab" 41 else 42 vfstab="/etc/fstab" 43 fi 44 45 awk -v pat="^${DEV_DSKDIR}" '$0 ~ pat {sub(/:$/, "", $1); print $1}' $vfstab 46} 47 48# 49# Find the storage device in /etc/mnttab 50# 51function find_mnttab_dev 52{ 53 typeset mnttabdev _ 54 typeset mnttabdevs="" 55 56 if is_freebsd; then 57 # FreeBSD doesn't have a mnttab file. 58 mount -p | awk -v dir="^${DEV_DSKDIR}" \ 59 '$1 ~ dir { print $1 }' 60 return 0 61 elif is_linux; then 62 typeset mnttab="/etc/mtab" 63 else 64 typeset mnttab="/etc/mnttab" 65 fi 66 67 while read -r mnttabdev _ 68 do 69 mnttabdev=${mnttabdev%%:} 70 mnttabdevs="$mnttabdev $mnttabdevs" 71 done < <(grep "^${DEV_DSKDIR}" $mnttab) 72 73 echo $mnttabdevs 74} 75 76# 77# Save the system current dump device configuration 78# 79function save_dump_dev 80{ 81 82 typeset dumpdev="" 83 84 if is_illumos; then 85 typeset fnd="Dump device" 86 dumpdev=`dumpadm | grep "$fnd" | cut -f2 -d : | \ 87 awk '{print $1}'` 88 fi 89 echo $dumpdev 90} 91