1*2fae26bdSAlan Somers# vim: filetype=sh 2*2fae26bdSAlan Somers# 3*2fae26bdSAlan Somers# CDDL HEADER START 4*2fae26bdSAlan Somers# 5*2fae26bdSAlan Somers# The contents of this file are subject to the terms of the 6*2fae26bdSAlan Somers# Common Development and Distribution License (the "License"). 7*2fae26bdSAlan Somers# You may not use this file except in compliance with the License. 8*2fae26bdSAlan Somers# 9*2fae26bdSAlan Somers# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*2fae26bdSAlan Somers# or http://www.opensolaris.org/os/licensing. 11*2fae26bdSAlan Somers# See the License for the specific language governing permissions 12*2fae26bdSAlan Somers# and limitations under the License. 13*2fae26bdSAlan Somers# 14*2fae26bdSAlan Somers# When distributing Covered Code, include this CDDL HEADER in each 15*2fae26bdSAlan Somers# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*2fae26bdSAlan Somers# If applicable, add the following below this CDDL HEADER, with the 17*2fae26bdSAlan Somers# fields enclosed by brackets "[]" replaced with your own identifying 18*2fae26bdSAlan Somers# information: Portions Copyright [yyyy] [name of copyright owner] 19*2fae26bdSAlan Somers# 20*2fae26bdSAlan Somers# CDDL HEADER END 21*2fae26bdSAlan Somers# 22*2fae26bdSAlan Somers 23*2fae26bdSAlan Somers# $FreeBSD$ 24*2fae26bdSAlan Somers 25*2fae26bdSAlan Somers# 26*2fae26bdSAlan Somers# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 27*2fae26bdSAlan Somers# Use is subject to license terms. 28*2fae26bdSAlan Somers# 29*2fae26bdSAlan Somers# ident "@(#)hotplug.kshlib 1.4 08/11/03 SMI" 30*2fae26bdSAlan Somers# 31*2fae26bdSAlan Somers 32*2fae26bdSAlan Somers. $STF_SUITE/include/libtest.kshlib 33*2fae26bdSAlan Somers. $STF_SUITE/include/libgnop.kshlib 34*2fae26bdSAlan Somers. $STF_SUITE/tests/hotplug/hotplug.cfg 35*2fae26bdSAlan Somers 36*2fae26bdSAlan Somers# 37*2fae26bdSAlan Somers# create lofi devices 38*2fae26bdSAlan Somers# 39*2fae26bdSAlan Somers# $1-n files 40*2fae26bdSAlan Somers# 41*2fae26bdSAlan Somersfunction create_lofi_device 42*2fae26bdSAlan Somers{ 43*2fae26bdSAlan Somers typeset lofi_files="$@" 44*2fae26bdSAlan Somers 45*2fae26bdSAlan Somers typeset file 46*2fae26bdSAlan Somers for file in $lofi_files ; do 47*2fae26bdSAlan Somers if ! $LOFIADM $file > /dev/null 2>&1 ; then 48*2fae26bdSAlan Somers insert_device $file 49*2fae26bdSAlan Somers if (($? != 0)); then 50*2fae26bdSAlan Somers return 1 51*2fae26bdSAlan Somers fi 52*2fae26bdSAlan Somers fi 53*2fae26bdSAlan Somers 54*2fae26bdSAlan Somers shift 55*2fae26bdSAlan Somers done 56*2fae26bdSAlan Somers 57*2fae26bdSAlan Somers return 0 58*2fae26bdSAlan Somers} 59*2fae26bdSAlan Somers 60*2fae26bdSAlan Somers# 61*2fae26bdSAlan Somers# Check and destroy lofi devices 62*2fae26bdSAlan Somers# 63*2fae26bdSAlan Somers# $1-n lofi files or deviece 64*2fae26bdSAlan Somers# 65*2fae26bdSAlan Somersfunction destroy_lofi_device 66*2fae26bdSAlan Somers{ 67*2fae26bdSAlan Somers typeset -i ret=0 68*2fae26bdSAlan Somers typeset dev_file="$@" 69*2fae26bdSAlan Somers 70*2fae26bdSAlan Somers typeset file 71*2fae26bdSAlan Somers for file in $dev_file ; do 72*2fae26bdSAlan Somers if $LOFIADM $file > /dev/null 2>&1; then 73*2fae26bdSAlan Somers $LOFIADM -d $file -f 74*2fae26bdSAlan Somers if (($? != 0)); then 75*2fae26bdSAlan Somers ((ret += 1)) 76*2fae26bdSAlan Somers fi 77*2fae26bdSAlan Somers fi 78*2fae26bdSAlan Somers done 79*2fae26bdSAlan Somers 80*2fae26bdSAlan Somers return $ret 81*2fae26bdSAlan Somers} 82*2fae26bdSAlan Somers 83*2fae26bdSAlan Somers# 84*2fae26bdSAlan Somers# Setup test environment using DISKS[1-4] 85*2fae26bdSAlan Somers# 86*2fae26bdSAlan Somers# $1 pool type 87*2fae26bdSAlan Somers# 88*2fae26bdSAlan Somersfunction setup_testenv 89*2fae26bdSAlan Somers{ 90*2fae26bdSAlan Somers typeset type=$1 91*2fae26bdSAlan Somers 92*2fae26bdSAlan Somers if [[ -z $type ]]; then 93*2fae26bdSAlan Somers log_fail "Usage: setup_testenv <type>" 94*2fae26bdSAlan Somers fi 95*2fae26bdSAlan Somers 96*2fae26bdSAlan Somers log_must $ZPOOL create -f \ 97*2fae26bdSAlan Somers $TESTPOOL $type ${DISK0}.nop ${DISK1}.nop ${DISK2}.nop ${DISK3}.nop 98*2fae26bdSAlan Somers} 99*2fae26bdSAlan Somers 100*2fae26bdSAlan Somers# 101*2fae26bdSAlan Somers# Cleanup test envirnment according to pool name 102*2fae26bdSAlan Somers# 103*2fae26bdSAlan Somers# $1 pool 104*2fae26bdSAlan Somers# 105*2fae26bdSAlan Somersfunction cleanup_testenv 106*2fae26bdSAlan Somers{ 107*2fae26bdSAlan Somers destroy_pool $TESTPOOL 108*2fae26bdSAlan Somers} 109*2fae26bdSAlan Somers 110*2fae26bdSAlan Somers 111*2fae26bdSAlan Somers# 112*2fae26bdSAlan Somers# Start a background process to write file on given pool. 113*2fae26bdSAlan Somers# 114*2fae26bdSAlan Somers# $1 pool 115*2fae26bdSAlan Somers# 116*2fae26bdSAlan Somersfunction start_bg_write 117*2fae26bdSAlan Somers{ 118*2fae26bdSAlan Somers typeset pool=$1 119*2fae26bdSAlan Somers 120*2fae26bdSAlan Somers if datasetnonexists $pool; then 121*2fae26bdSAlan Somers return 1 122*2fae26bdSAlan Somers fi 123*2fae26bdSAlan Somers 124*2fae26bdSAlan Somers typeset mntpnt=$(get_prop mountpoint $pool) 125*2fae26bdSAlan Somers 126*2fae26bdSAlan Somers while true; do 127*2fae26bdSAlan Somers $DD if=/dev/random of=$mntpnt/foo count=10 128*2fae26bdSAlan Somers $SYNC 129*2fae26bdSAlan Somers $SLEEP 1 130*2fae26bdSAlan Somers done & 131*2fae26bdSAlan Somers BG_PID=$! 132*2fae26bdSAlan Somers 133*2fae26bdSAlan Somers return 0 134*2fae26bdSAlan Somers} 135*2fae26bdSAlan Somers 136*2fae26bdSAlan Somers# 137*2fae26bdSAlan Somers# Kill the background write process. 138*2fae26bdSAlan Somers# 139*2fae26bdSAlan Somersfunction kill_bg_write 140*2fae26bdSAlan Somers{ 141*2fae26bdSAlan Somers typeset -i ret=0 142*2fae26bdSAlan Somers 143*2fae26bdSAlan Somers if [[ -n $BG_PID ]]; then 144*2fae26bdSAlan Somers kill -9 $BG_PID 145*2fae26bdSAlan Somers ret=$? 146*2fae26bdSAlan Somers 147*2fae26bdSAlan Somers if ((ret == 0)); then 148*2fae26bdSAlan Somers BG_PID='' 149*2fae26bdSAlan Somers fi 150*2fae26bdSAlan Somers fi 151*2fae26bdSAlan Somers 152*2fae26bdSAlan Somers $SLEEP 10 153*2fae26bdSAlan Somers return $ret 154*2fae26bdSAlan Somers} 155*2fae26bdSAlan Somers 156*2fae26bdSAlan Somers# 157*2fae26bdSAlan Somers# Insert a given file into a given device slot 158*2fae26bdSAlan Somers# 159*2fae26bdSAlan Somers# $1 file 160*2fae26bdSAlan Somers# $2 device 161*2fae26bdSAlan Somers# 162*2fae26bdSAlan Somersfunction insert_device 163*2fae26bdSAlan Somers{ 164*2fae26bdSAlan Somers typeset file=$1 165*2fae26bdSAlan Somers typeset device=$2 166*2fae26bdSAlan Somers 167*2fae26bdSAlan Somers if [[ -z $file ]]; then 168*2fae26bdSAlan Somers return 1 169*2fae26bdSAlan Somers fi 170*2fae26bdSAlan Somers 171*2fae26bdSAlan Somers # 172*2fae26bdSAlan Somers # Make sure insert device succeed within 60 seconds 173*2fae26bdSAlan Somers # 174*2fae26bdSAlan Somers typeset -i i=0 175*2fae26bdSAlan Somers while ((i < 6)); do 176*2fae26bdSAlan Somers $SLEEP 10 177*2fae26bdSAlan Somers 178*2fae26bdSAlan Somers $LOFIADM -a $file $device -f > /dev/null 2>&1 179*2fae26bdSAlan Somers if (($? == 0)); then 180*2fae26bdSAlan Somers return 0 181*2fae26bdSAlan Somers fi 182*2fae26bdSAlan Somers 183*2fae26bdSAlan Somers ((i += 1)) 184*2fae26bdSAlan Somers done 185*2fae26bdSAlan Somers 186*2fae26bdSAlan Somers return 1 187*2fae26bdSAlan Somers} 188*2fae26bdSAlan Somers 189*2fae26bdSAlan Somers# 190*2fae26bdSAlan Somers# Remove the given lofi device 191*2fae26bdSAlan Somers# 192*2fae26bdSAlan Somers# $1 device or file 193*2fae26bdSAlan Somers# 194*2fae26bdSAlan Somersfunction remove_device 195*2fae26bdSAlan Somers{ 196*2fae26bdSAlan Somers typeset devfile=$1 197*2fae26bdSAlan Somers 198*2fae26bdSAlan Somers if [[ -z $devfile ]]; then 199*2fae26bdSAlan Somers return 1 200*2fae26bdSAlan Somers fi 201*2fae26bdSAlan Somers 202*2fae26bdSAlan Somers # 203*2fae26bdSAlan Somers # Make sure remove device succeed within 60 seconds 204*2fae26bdSAlan Somers # 205*2fae26bdSAlan Somers typeset -i i=0 206*2fae26bdSAlan Somers while ((i < 6)); do 207*2fae26bdSAlan Somers $SLEEP 10 208*2fae26bdSAlan Somers $LOFIADM -d $devfile -f 209*2fae26bdSAlan Somers if (($? == 0)); then 210*2fae26bdSAlan Somers return 0 211*2fae26bdSAlan Somers fi 212*2fae26bdSAlan Somers 213*2fae26bdSAlan Somers ((i += 1)) 214*2fae26bdSAlan Somers done 215*2fae26bdSAlan Somers 216*2fae26bdSAlan Somers return 1 217*2fae26bdSAlan Somers} 218*2fae26bdSAlan Somers 219*2fae26bdSAlan Somers# 220*2fae26bdSAlan Somers# Verify the given devices have expected status in pool 221*2fae26bdSAlan Somers# 222*2fae26bdSAlan Somers# $1 pool 223*2fae26bdSAlan Somers# $2 device 224*2fae26bdSAlan Somers# $3 expected status 225*2fae26bdSAlan Somers# 226*2fae26bdSAlan Somersfunction verify_device_status 227*2fae26bdSAlan Somers{ 228*2fae26bdSAlan Somers typeset pool=$1 229*2fae26bdSAlan Somers typeset device=$2 230*2fae26bdSAlan Somers typeset expect_stat=$3 231*2fae26bdSAlan Somers 232*2fae26bdSAlan Somers if [[ -z $pool || -z $expect_stat || -z $device ]]; then 233*2fae26bdSAlan Somers log_note "Usage: verify_device_status <pool> <device> <status>" 234*2fae26bdSAlan Somers return 1 235*2fae26bdSAlan Somers fi 236*2fae26bdSAlan Somers 237*2fae26bdSAlan Somers # 238*2fae26bdSAlan Somers # 1.5 minute disk status checking, make sure zpool sync disk status. 239*2fae26bdSAlan Somers # 240*2fae26bdSAlan Somers typeset -i i=0 241*2fae26bdSAlan Somers while ((i < 9)); do 242*2fae26bdSAlan Somers $SLEEP 10 243*2fae26bdSAlan Somers 244*2fae26bdSAlan Somers typeset str=$($ZPOOL status $pool | $GREP "lofi" | \ 245*2fae26bdSAlan Somers $AWK '{print $1 " " $2}') 246*2fae26bdSAlan Somers typeset real_stat=${str##*$device } 247*2fae26bdSAlan Somers real_stat=$($ECHO $real_stat | $AWK '{print $1}') 248*2fae26bdSAlan Somers 249*2fae26bdSAlan Somers if [[ "$expect_stat" == "$real_stat" ]]; then 250*2fae26bdSAlan Somers return 0 251*2fae26bdSAlan Somers fi 252*2fae26bdSAlan Somers 253*2fae26bdSAlan Somers ((i += 1)) 254*2fae26bdSAlan Somers done 255*2fae26bdSAlan Somers 256*2fae26bdSAlan Somers log_note "Expected status($expect_stat), " \ 257*2fae26bdSAlan Somers "see status($real_stat) for $device" 258*2fae26bdSAlan Somers $ZPOOL status -v $pool 259*2fae26bdSAlan Somers 260*2fae26bdSAlan Somers return 1 261*2fae26bdSAlan Somers} 262*2fae26bdSAlan Somers 263*2fae26bdSAlan Somers# 264*2fae26bdSAlan Somers# Output fma event id to given file, the default output file is $FILE_EVENT_ID 265*2fae26bdSAlan Somers# 266*2fae26bdSAlan Somersfunction getfmri 267*2fae26bdSAlan Somers{ 268*2fae26bdSAlan Somers eval typeset output_file=${1:-$FILE_EVENT_ID} 269*2fae26bdSAlan Somers# 270*2fae26bdSAlan Somers# fmadm faulty output include several sections below 271*2fae26bdSAlan Somers# 272*2fae26bdSAlan Somers 273*2fae26bdSAlan Somers# --------------- ------------------------------------ -------------- --------- 274*2fae26bdSAlan Somers# TIME EVENT-ID MSG-ID SEVERITY 275*2fae26bdSAlan Somers# --------------- ------------------------------------ -------------- --------- 276*2fae26bdSAlan Somers# Aug 31 22:34:19 ec648a9e-0c9f-c495-e176-e38ba212e278 ZFS-8000-D3 Major 277*2fae26bdSAlan Somers# Aug 31 19:44:59 d69cdd12-b0cf-62ea-d0a3-8d2e9ebfeb50 ZFS-8000-D3 278*2fae26bdSAlan Somers# Aug 31 19:35:16 7213f0d5-00d4-ea32-ddfc-98cdd683c27e ZFS-8000-D3 279*2fae26bdSAlan Somers# Aug 31 19:29:11 33424bef-a973-4dae-94ef-cb97f2cb0759 ZFS-8000-D3 280*2fae26bdSAlan Somers# Aug 31 17:07:26 74219b66-ead4-6d2b-bbad-bc40547ca02e ZFS-8000-GH 281*2fae26bdSAlan Somers# 282*2fae26bdSAlan Somers# Fault class : fault.fs.zfs.device 283*2fae26bdSAlan Somers# 284*2fae26bdSAlan Somers# Description : A ZFS device failed. Refer to http://sun.com/msg/ZFS-8000-D3 for 285*2fae26bdSAlan Somers# more information. 286*2fae26bdSAlan Somers# 287*2fae26bdSAlan Somers# Response : No automated response will occur. 288*2fae26bdSAlan Somers# 289*2fae26bdSAlan Somers# Impact : Fault tolerance of the pool may be compromised. 290*2fae26bdSAlan Somers# 291*2fae26bdSAlan Somers# Action : Run 'zpool status -x' and replace the bad device. 292*2fae26bdSAlan Somers# 293*2fae26bdSAlan Somers $FMADM faulty | $NAWK ' 294*2fae26bdSAlan Somers BEGIN { 295*2fae26bdSAlan Somers start = 0 296*2fae26bdSAlan Somers } 297*2fae26bdSAlan Somers /^---/ && /---$/ { 298*2fae26bdSAlan Somers if (start == 0) { 299*2fae26bdSAlan Somers start = 1 300*2fae26bdSAlan Somers } 301*2fae26bdSAlan Somers } 302*2fae26bdSAlan Somers /^TIME/ && /SEVERITY$/ { 303*2fae26bdSAlan Somers if (start == 1) { 304*2fae26bdSAlan Somers start = 2 305*2fae26bdSAlan Somers } 306*2fae26bdSAlan Somers } 307*2fae26bdSAlan Somers /^---/ && /---$/ { 308*2fae26bdSAlan Somers if (start == 2) { 309*2fae26bdSAlan Somers start = 3 310*2fae26bdSAlan Somers continue 311*2fae26bdSAlan Somers } 312*2fae26bdSAlan Somers } 313*2fae26bdSAlan Somers /^$/ { 314*2fae26bdSAlan Somers start = 0 315*2fae26bdSAlan Somers } 316*2fae26bdSAlan Somers (start == 3) {print $4}' > $output_file 317*2fae26bdSAlan Somers} 318*2fae26bdSAlan Somers 319*2fae26bdSAlan Somers# 320*2fae26bdSAlan Somers# Verify if ZFS FMA faulty error message are generated. 321*2fae26bdSAlan Somers# 322*2fae26bdSAlan Somers# $1 TRUE or FALSE 323*2fae26bdSAlan Somers# 324*2fae26bdSAlan Somersfunction fma_faulty 325*2fae26bdSAlan Somers{ 326*2fae26bdSAlan Somers # 327*2fae26bdSAlan Somers # 1.5 minute for FMA faulty checking, make sure FMA sync with ZFS status 328*2fae26bdSAlan Somers # 329*2fae26bdSAlan Somers typeset expect=${1:-TRUE} 330*2fae26bdSAlan Somers 331*2fae26bdSAlan Somers typeset -i fsize 332*2fae26bdSAlan Somers typeset -i i=0 333*2fae26bdSAlan Somers while ((i < 9)); do 334*2fae26bdSAlan Somers $SLEEP 10 335*2fae26bdSAlan Somers 336*2fae26bdSAlan Somers # 337*2fae26bdSAlan Somers # try to get fma faulty 338*2fae26bdSAlan Somers # 339*2fae26bdSAlan Somers getfmri $FILE_EVENT_ID 340*2fae26bdSAlan Somers fsize=$($LS -ld $FILE_EVENT_ID | $AWK '{print $5}') 341*2fae26bdSAlan Somers 342*2fae26bdSAlan Somers case $expect in 343*2fae26bdSAlan Somers TRUE) 344*2fae26bdSAlan Somers if (( fsize != 0 )); then 345*2fae26bdSAlan Somers return 0 346*2fae26bdSAlan Somers fi 347*2fae26bdSAlan Somers ;; 348*2fae26bdSAlan Somers FALSE) 349*2fae26bdSAlan Somers if (( fsize == 0 )); then 350*2fae26bdSAlan Somers return 0 351*2fae26bdSAlan Somers fi 352*2fae26bdSAlan Somers ;; 353*2fae26bdSAlan Somers *) 354*2fae26bdSAlan Somers return 1 355*2fae26bdSAlan Somers esac 356*2fae26bdSAlan Somers 357*2fae26bdSAlan Somers ((i += 1)) 358*2fae26bdSAlan Somers done 359*2fae26bdSAlan Somers 360*2fae26bdSAlan Somers return 1 361*2fae26bdSAlan Somers} 362*2fae26bdSAlan Somers 363*2fae26bdSAlan Somers# 364*2fae26bdSAlan Somers# Create fresh file 365*2fae26bdSAlan Somers# 366*2fae26bdSAlan Somers# $1 file size 367*2fae26bdSAlan Somers# $2 file name 368*2fae26bdSAlan Somers# 369*2fae26bdSAlan Somersfunction create_file 370*2fae26bdSAlan Somers{ 371*2fae26bdSAlan Somers typeset size=$1 372*2fae26bdSAlan Somers typeset file=$2 373*2fae26bdSAlan Somers 374*2fae26bdSAlan Somers if [[ -z $size || -z $file ]]; then 375*2fae26bdSAlan Somers log_note "Usage: create_file <size> <file>" 376*2fae26bdSAlan Somers return 1 377*2fae26bdSAlan Somers fi 378*2fae26bdSAlan Somers if [[ -f $file ]]; then 379*2fae26bdSAlan Somers $RM -f $file 380*2fae26bdSAlan Somers fi 381*2fae26bdSAlan Somers $MKFILE $size $file 382*2fae26bdSAlan Somers return $? 383*2fae26bdSAlan Somers} 384*2fae26bdSAlan Somers 385*2fae26bdSAlan Somers# 386*2fae26bdSAlan Somers# Unmount all filesystem, and disable syseventd and fmd piror to 387*2fae26bdSAlan Somers# unloading ZFS module 388*2fae26bdSAlan Somers# 389*2fae26bdSAlan Somersfunction unload_zfs 390*2fae26bdSAlan Somers{ 391*2fae26bdSAlan Somers # destroy /dev/zvol link 392*2fae26bdSAlan Somers log_must $ZFS volfini 393*2fae26bdSAlan Somers 394*2fae26bdSAlan Somers log_must $ZFS unmount -f -a 395*2fae26bdSAlan Somers log_must $SVCADM disable -t sysevent fmd 396*2fae26bdSAlan Somers $SLEEP 10 397*2fae26bdSAlan Somers 398*2fae26bdSAlan Somers # 399*2fae26bdSAlan Somers # 1 minute for ZFS module unload checking 400*2fae26bdSAlan Somers # 401*2fae26bdSAlan Somers # For example: 402*2fae26bdSAlan Somers # 403*2fae26bdSAlan Somers # 192 fffffffff7c92000 99858 182 1 zfs (ZFS storage pool version 6) 404*2fae26bdSAlan Somers # 405*2fae26bdSAlan Somers typeset -i i=0 406*2fae26bdSAlan Somers while ((i < 10)); do 407*2fae26bdSAlan Somers typeset id=$($MODINFO | $GREP "ZFS storage" | $AWK '{print $1}') 408*2fae26bdSAlan Somers 409*2fae26bdSAlan Somers if [[ -n $id ]]; then 410*2fae26bdSAlan Somers $MODUNLOAD -i $id 411*2fae26bdSAlan Somers if (($? == 0)) ; then 412*2fae26bdSAlan Somers return 0 413*2fae26bdSAlan Somers fi 414*2fae26bdSAlan Somers else 415*2fae26bdSAlan Somers return 0 416*2fae26bdSAlan Somers fi 417*2fae26bdSAlan Somers 418*2fae26bdSAlan Somers $SLEEP 6 419*2fae26bdSAlan Somers ((i += 1)) 420*2fae26bdSAlan Somers done 421*2fae26bdSAlan Somers 422*2fae26bdSAlan Somers return 1 423*2fae26bdSAlan Somers} 424*2fae26bdSAlan Somers 425*2fae26bdSAlan Somers# 426*2fae26bdSAlan Somers# Load ZFS module and remount all filesystem 427*2fae26bdSAlan Somers# 428*2fae26bdSAlan Somersfunction load_zfs 429*2fae26bdSAlan Somers{ 430*2fae26bdSAlan Somers typeset -i ret=0 431*2fae26bdSAlan Somers $SVCADM enable sysevent fmd 432*2fae26bdSAlan Somers ((ret |= $?)) 433*2fae26bdSAlan Somers 434*2fae26bdSAlan Somers $SLEEP 10 435*2fae26bdSAlan Somers 436*2fae26bdSAlan Somers $ZFS mount -a 437*2fae26bdSAlan Somers ((ret |= $?)) 438*2fae26bdSAlan Somers 439*2fae26bdSAlan Somers # create /dev/zvol link 440*2fae26bdSAlan Somers $ZFS volinit 441*2fae26bdSAlan Somers ((ret |= $?)) 442*2fae26bdSAlan Somers 443*2fae26bdSAlan Somers return $ret 444*2fae26bdSAlan Somers} 445*2fae26bdSAlan Somers 446*2fae26bdSAlan Somers# 447*2fae26bdSAlan Somers# Convert file name to device name or reverse. 448*2fae26bdSAlan Somers# 449*2fae26bdSAlan Somers# $1-n lofi files or devices 450*2fae26bdSAlan Somers# 451*2fae26bdSAlan Somersfunction convert_lofi 452*2fae26bdSAlan Somers{ 453*2fae26bdSAlan Somers typeset n list 454*2fae26bdSAlan Somers 455*2fae26bdSAlan Somers for n in "$@"; do 456*2fae26bdSAlan Somers typeset item=$($LOFIADM $n) 457*2fae26bdSAlan Somers list="$list $item" 458*2fae26bdSAlan Somers 459*2fae26bdSAlan Somers shift 460*2fae26bdSAlan Somers done 461*2fae26bdSAlan Somers 462*2fae26bdSAlan Somers $ECHO $list 463*2fae26bdSAlan Somers} 464