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