xref: /titanic_41/usr/src/cmd/svc/shell/fs_include.sh (revision e7cbe64f7a72dae5cb44f100db60ca88f3313c65)
17c478bd9Sstevel@tonic-gate#!/bin/sh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
65b4dc236Smishra# Common Development and Distribution License (the "License").
75b4dc236Smishra# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
227c478bd9Sstevel@tonic-gate#
23a227b7f4Shs24103# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate# Use is subject to license terms.
257c478bd9Sstevel@tonic-gate#
267c478bd9Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
277c478bd9Sstevel@tonic-gate# All rights reserved.
287c478bd9Sstevel@tonic-gate#
297c478bd9Sstevel@tonic-gate#
307c478bd9Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gatevfstab=${vfstab:=/etc/vfstab}
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate#
357c478bd9Sstevel@tonic-gate# readvfstab mount_point
367c478bd9Sstevel@tonic-gate#   -> (special, fsckdev, mountp, fstype, fsckpass, automnt, mntopts)
377c478bd9Sstevel@tonic-gate#
387c478bd9Sstevel@tonic-gate#   A vfstab-like input stream is scanned for the mount point specified
397c478bd9Sstevel@tonic-gate#   as $1.  Returns the fields of vfstab in the following shell
407c478bd9Sstevel@tonic-gate#   variables:
417c478bd9Sstevel@tonic-gate#
427c478bd9Sstevel@tonic-gate#       special		block device
437c478bd9Sstevel@tonic-gate#       fsckdev		raw device
447c478bd9Sstevel@tonic-gate#       mountp		mount point (must match $1, if found)
457c478bd9Sstevel@tonic-gate#       fstype		file system type
467c478bd9Sstevel@tonic-gate#       fsckpass	fsck(1M) pass number
477c478bd9Sstevel@tonic-gate#       automnt		automount flag (yes or no)
487c478bd9Sstevel@tonic-gate#       mntopts		file system-specific mount options.
497c478bd9Sstevel@tonic-gate#
507c478bd9Sstevel@tonic-gate#   If the mount point can not be found in the standard input stream,
517c478bd9Sstevel@tonic-gate#   then all fields are set to empty values.  This function assumes that
527c478bd9Sstevel@tonic-gate#   stdin is already set /etc/vfstab (or other appropriate input
537c478bd9Sstevel@tonic-gate#   stream).
547c478bd9Sstevel@tonic-gate#
557c478bd9Sstevel@tonic-gatereadvfstab() {
567c478bd9Sstevel@tonic-gate	while read special fsckdev mountp fstype fsckpass automnt mntopts; do
577c478bd9Sstevel@tonic-gate		case "$special" in
587c478bd9Sstevel@tonic-gate			'' )	# Ignore empty lines.
597c478bd9Sstevel@tonic-gate				continue
607c478bd9Sstevel@tonic-gate				;;
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gate			'#'* )	# Ignore comment lines.
637c478bd9Sstevel@tonic-gate				continue
647c478bd9Sstevel@tonic-gate				;;
657c478bd9Sstevel@tonic-gate
667c478bd9Sstevel@tonic-gate			'-')	# Ignore "no-action" lines.
677c478bd9Sstevel@tonic-gate				continue
687c478bd9Sstevel@tonic-gate				;;
697c478bd9Sstevel@tonic-gate		esac
707c478bd9Sstevel@tonic-gate
717c478bd9Sstevel@tonic-gate		[ "x$mountp" = "x$1" ] && break
727c478bd9Sstevel@tonic-gate	done
737c478bd9Sstevel@tonic-gate}
747c478bd9Sstevel@tonic-gate
75*e7cbe64fSgw25295readswapdev() {
76*e7cbe64fSgw25295	while read special fsckdev mountp fstype fsckpass automnt mntopts; do
77*e7cbe64fSgw25295		# Ignore comments, empty lines, and no-action lines
78*e7cbe64fSgw25295		case "$special" in
79*e7cbe64fSgw25295		'#'* | '' | '-') continue;;
80*e7cbe64fSgw25295		esac
81*e7cbe64fSgw25295
82*e7cbe64fSgw25295		[ "$fstype" != swap ] && continue
83*e7cbe64fSgw25295
84*e7cbe64fSgw25295		[ "x$special" = "x$1" ] && break
85*e7cbe64fSgw25295	done
86*e7cbe64fSgw25295}
87*e7cbe64fSgw25295
88a227b7f4Shs24103#
89a227b7f4Shs24103# readmnttab mount_point
90a227b7f4Shs24103#   -> (special, mountp, fstype, mntopts, mnttime)
91a227b7f4Shs24103#
92a227b7f4Shs24103#   A mnttab-like input stream is scanned for the mount point specified
93a227b7f4Shs24103#   as $1.  Returns the fields of mnttab in the following shell
94a227b7f4Shs24103#   variables:
95a227b7f4Shs24103#
96a227b7f4Shs24103#       special		block device
97a227b7f4Shs24103#       mountp		mount point (must match $1, if found)
98a227b7f4Shs24103#       fstype		file system type
99a227b7f4Shs24103#       mntopts		file system-specific mount options.
100a227b7f4Shs24103#	mnttime		time at which file system was mounted
101a227b7f4Shs24103#
102a227b7f4Shs24103#   If the mount point can not be found in the standard input stream,
103a227b7f4Shs24103#   then all fields are set to empty values.  This function assumes that
104a227b7f4Shs24103#   stdin is already set to /etc/mnttab (or other appropriate input
105a227b7f4Shs24103#   stream).
106a227b7f4Shs24103#
107a227b7f4Shs24103readmnttab() {
108a227b7f4Shs24103	while read special mountp fstype mntopts mnttime; do
109a227b7f4Shs24103		[ "x$mountp" = "x$1" ] && break
110a227b7f4Shs24103	done
111a227b7f4Shs24103}
112a227b7f4Shs24103
1137c478bd9Sstevel@tonic-gatececho() {
1147c478bd9Sstevel@tonic-gate	echo $*
1157c478bd9Sstevel@tonic-gate	echo $* >/dev/msglog
1167c478bd9Sstevel@tonic-gate}
1177c478bd9Sstevel@tonic-gate
1187c478bd9Sstevel@tonic-gate#
1197c478bd9Sstevel@tonic-gate# checkmessage raw_device fstype mountpoint
1207c478bd9Sstevel@tonic-gate# checkmessage2 raw_device fstype mountpoint
1217c478bd9Sstevel@tonic-gate#
1227c478bd9Sstevel@tonic-gate#   Two simple auxilary routines to the shell function checkfs.  Both
1237c478bd9Sstevel@tonic-gate#   display instructions for a manual file system check.
1247c478bd9Sstevel@tonic-gate#
1257c478bd9Sstevel@tonic-gatecheckmessage() {
1267c478bd9Sstevel@tonic-gate	cecho ""
1277c478bd9Sstevel@tonic-gate	cecho "WARNING - Unable to repair the $3 filesystem. Run fsck"
1287c478bd9Sstevel@tonic-gate	cecho "manually (fsck -F $2 $1)."
1297c478bd9Sstevel@tonic-gate	cecho ""
1307c478bd9Sstevel@tonic-gate}
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gatecheckmessage2() {
1337c478bd9Sstevel@tonic-gate	cecho ""
1347c478bd9Sstevel@tonic-gate	cecho "WARNING - fatal error from fsck - error $4"
1357c478bd9Sstevel@tonic-gate	cecho "Unable to repair the $3 filesystem. Run fsck manually"
1367c478bd9Sstevel@tonic-gate	cecho "(fsck -F $2 $1)."
1377c478bd9Sstevel@tonic-gate	cecho ""
1387c478bd9Sstevel@tonic-gate}
1397c478bd9Sstevel@tonic-gate
1407c478bd9Sstevel@tonic-gate#
1417c478bd9Sstevel@tonic-gate# checkfs raw_device fstype mountpoint
1427c478bd9Sstevel@tonic-gate#
1437c478bd9Sstevel@tonic-gate#   Check the file system specified. The return codes from fsck have the
1447c478bd9Sstevel@tonic-gate#   following meanings.
1457c478bd9Sstevel@tonic-gate#
1467c478bd9Sstevel@tonic-gate#	 0	file system is unmounted and okay
1477c478bd9Sstevel@tonic-gate#	32	file system is unmounted and needs checking (fsck -m only)
1487c478bd9Sstevel@tonic-gate#	33	file system is already mounted
1497c478bd9Sstevel@tonic-gate#	34	cannot stat device
150355d6bb5Sswilcox#	35	modified root or something equally dangerous
1517c478bd9Sstevel@tonic-gate#	36	uncorrectable errors detected - terminate normally (4.1 code 8)
1527c478bd9Sstevel@tonic-gate#	37	a signal was caught during processing (4.1 exit 12)
1537c478bd9Sstevel@tonic-gate#	39	uncorrectable errors detected - terminate rightaway (4.1 code 8)
1547c478bd9Sstevel@tonic-gate#	40	 for root, same as 0 (used here to remount root)
1557c478bd9Sstevel@tonic-gate#
1567c478bd9Sstevel@tonic-gatecheckfs() {
1577c478bd9Sstevel@tonic-gate	# skip checking if the fsckdev is "-"
1587c478bd9Sstevel@tonic-gate	[ "x$1" = x- ] && return
1597c478bd9Sstevel@tonic-gate
1607c478bd9Sstevel@tonic-gate	# if fsck isn't present, it is probably because either the mount of
1617c478bd9Sstevel@tonic-gate	# /usr failed or the /usr filesystem is badly damanged.  In either
1627c478bd9Sstevel@tonic-gate	# case, there is not much to be done automatically.  Fail with
1637c478bd9Sstevel@tonic-gate	# a message to the user.
1647c478bd9Sstevel@tonic-gate	if [ ! -x /usr/sbin/fsck ]; then
1657c478bd9Sstevel@tonic-gate		cecho ""
1667c478bd9Sstevel@tonic-gate		cecho "WARNING - /usr/sbin/fsck not found.  Most likely the"
1677c478bd9Sstevel@tonic-gate		cecho "mount of /usr failed or the /usr filesystem is badly"
1687c478bd9Sstevel@tonic-gate		cecho "damaged."
1697c478bd9Sstevel@tonic-gate		cecho ""
1707c478bd9Sstevel@tonic-gate		return 1
1717c478bd9Sstevel@tonic-gate	fi
1727c478bd9Sstevel@tonic-gate
173d805fbaaSsch	# If a filesystem-specific fsck binary is unavailable, then no
174d805fbaaSsch	# fsck pass is required.
175d805fbaaSsch	[ ! -x /usr/lib/fs/$2/fsck ] && [ ! -x /etc/fs/$2/fsck ] && return
176d805fbaaSsch
1777c478bd9Sstevel@tonic-gate	/usr/sbin/fsck -F $2 -m $1 >/dev/null 2>&1
1787c478bd9Sstevel@tonic-gate
1797c478bd9Sstevel@tonic-gate	if [ $? -ne 0 ]; then
1807c478bd9Sstevel@tonic-gate		# Determine fsck options by file system type
1817c478bd9Sstevel@tonic-gate		case $2 in
1827c478bd9Sstevel@tonic-gate			ufs)	foptions="-o p"
1837c478bd9Sstevel@tonic-gate				;;
1847c478bd9Sstevel@tonic-gate			*)	foptions="-y"
1857c478bd9Sstevel@tonic-gate				;;
1867c478bd9Sstevel@tonic-gate		esac
1877c478bd9Sstevel@tonic-gate
1887c478bd9Sstevel@tonic-gate		cecho "The $3 file system ($1) is being checked."
1897c478bd9Sstevel@tonic-gate		/usr/sbin/fsck -F $2 $foptions $1
1907c478bd9Sstevel@tonic-gate
1917c478bd9Sstevel@tonic-gate		case $? in
1927c478bd9Sstevel@tonic-gate		0|40)	# File system OK
1937c478bd9Sstevel@tonic-gate			;;
1947c478bd9Sstevel@tonic-gate
1957c478bd9Sstevel@tonic-gate		1|34|36|37|39)	# couldn't fix the file system - fail
1967c478bd9Sstevel@tonic-gate			checkmessage "$1" "$2" "$3"
1977c478bd9Sstevel@tonic-gate			return 1
1987c478bd9Sstevel@tonic-gate			;;
1995b4dc236Smishra		33)	# already mounted
2005b4dc236Smishra			return 0
2015b4dc236Smishra			;;
2027c478bd9Sstevel@tonic-gate
2037c478bd9Sstevel@tonic-gate		*)	# fsck child process killed (+ error code 35)
2047c478bd9Sstevel@tonic-gate			checkmessage2 "$1" "$2" "$3" "$?"
2057c478bd9Sstevel@tonic-gate			return 1
2067c478bd9Sstevel@tonic-gate			;;
2077c478bd9Sstevel@tonic-gate		esac
2087c478bd9Sstevel@tonic-gate	fi
2097c478bd9Sstevel@tonic-gate
2107c478bd9Sstevel@tonic-gate	return 0
2117c478bd9Sstevel@tonic-gate}
2127c478bd9Sstevel@tonic-gate
2137c478bd9Sstevel@tonic-gate#
2147c478bd9Sstevel@tonic-gate# checkopt option option-string
2157c478bd9Sstevel@tonic-gate# -> ($option, $otherops)
2167c478bd9Sstevel@tonic-gate#
2177c478bd9Sstevel@tonic-gate#   Check to see if a given mount option is present in the comma
2187c478bd9Sstevel@tonic-gate#   separated list gotten from vfstab.
2197c478bd9Sstevel@tonic-gate#
2207c478bd9Sstevel@tonic-gate#	Returns:
2217c478bd9Sstevel@tonic-gate#	${option}       : the option if found the empty string if not found
2227c478bd9Sstevel@tonic-gate#	${otherops}     : the option string with the found option deleted
2237c478bd9Sstevel@tonic-gate#
2247c478bd9Sstevel@tonic-gatecheckopt() {
2257c478bd9Sstevel@tonic-gate	option=
2267c478bd9Sstevel@tonic-gate	otherops=
2277c478bd9Sstevel@tonic-gate
2287c478bd9Sstevel@tonic-gate	[ "x$2" = x- ] && return
2297c478bd9Sstevel@tonic-gate
2307c478bd9Sstevel@tonic-gate	searchop="$1"
2317c478bd9Sstevel@tonic-gate	set -- `IFS=, ; echo $2`
2327c478bd9Sstevel@tonic-gate
2337c478bd9Sstevel@tonic-gate	while [ $# -gt 0 ]; do
2347c478bd9Sstevel@tonic-gate		if [ "x$1" = "x$searchop" ]; then
2357c478bd9Sstevel@tonic-gate			option="$1"
2367c478bd9Sstevel@tonic-gate		else
2377c478bd9Sstevel@tonic-gate			if [ -z "$otherops" ]; then
2387c478bd9Sstevel@tonic-gate				otherops="$1"
2397c478bd9Sstevel@tonic-gate			else
2407c478bd9Sstevel@tonic-gate				otherops="${otherops},$1"
2417c478bd9Sstevel@tonic-gate			fi
2427c478bd9Sstevel@tonic-gate		fi
2437c478bd9Sstevel@tonic-gate		shift
2447c478bd9Sstevel@tonic-gate	done
2457c478bd9Sstevel@tonic-gate}
2467c478bd9Sstevel@tonic-gate
2477c478bd9Sstevel@tonic-gate#
2487c478bd9Sstevel@tonic-gate# hasopts $opts $allopts
2497c478bd9Sstevel@tonic-gate#
2507c478bd9Sstevel@tonic-gate#   Check if all options from the list $opts are present in $allopts.
2517c478bd9Sstevel@tonic-gate#   Both $opts and $allopts should be in comma separated format.
2527c478bd9Sstevel@tonic-gate#
2537c478bd9Sstevel@tonic-gate# Return 0 on success, and 1 otherwise.
2547c478bd9Sstevel@tonic-gate#
2557c478bd9Sstevel@tonic-gatehasopts() {
2567c478bd9Sstevel@tonic-gate	opts="$1"
2577c478bd9Sstevel@tonic-gate	allopts="$2"
2587c478bd9Sstevel@tonic-gate
2597c478bd9Sstevel@tonic-gate	set -- `IFS=, ; echo $opts`
2607c478bd9Sstevel@tonic-gate	while [ $# -gt 0 ]; do
2617c478bd9Sstevel@tonic-gate		if [ "$1" != "remount" ]; then
2627c478bd9Sstevel@tonic-gate			checkopt $1 $allopts
2637c478bd9Sstevel@tonic-gate			#
2647c478bd9Sstevel@tonic-gate			# Don't report errors if the filesystem is already
2657c478bd9Sstevel@tonic-gate			# read-write when mounting it as read-only.
2667c478bd9Sstevel@tonic-gate			#
2677c478bd9Sstevel@tonic-gate			[ -z "$option" ] && [ "$1" = "ro" ] && \
2687c478bd9Sstevel@tonic-gate				checkopt rw $allopts
2697c478bd9Sstevel@tonic-gate			[ -z "$option" ] && return 1
2707c478bd9Sstevel@tonic-gate		fi
2717c478bd9Sstevel@tonic-gate		shift
2727c478bd9Sstevel@tonic-gate	done
2737c478bd9Sstevel@tonic-gate	return 0
2747c478bd9Sstevel@tonic-gate}
2757c478bd9Sstevel@tonic-gate
2767c478bd9Sstevel@tonic-gate#
2777c478bd9Sstevel@tonic-gate# mounted $path $fsopts $fstype
2787c478bd9Sstevel@tonic-gate#
2797c478bd9Sstevel@tonic-gate#   Check whether the specified file system of the given type is currently
2807c478bd9Sstevel@tonic-gate#   mounted with all required filesystem options by going through /etc/mnttab
2817c478bd9Sstevel@tonic-gate#   in our standard input.
2827c478bd9Sstevel@tonic-gate#
2837c478bd9Sstevel@tonic-gate#   Return values:
2847c478bd9Sstevel@tonic-gate#   0	Success.
2857c478bd9Sstevel@tonic-gate#   1	The filesystem is not currently mounted, or mounted without required
2867c478bd9Sstevel@tonic-gate#	options, or a filesystem of a different type is mounted instead.
2877c478bd9Sstevel@tonic-gate#
2887c478bd9Sstevel@tonic-gatemounted() {
2897c478bd9Sstevel@tonic-gate	path="$1"
2907c478bd9Sstevel@tonic-gate	fsopts="$2"
2917c478bd9Sstevel@tonic-gate	fstype="$3"
2927c478bd9Sstevel@tonic-gate
2937c478bd9Sstevel@tonic-gate	while read mntspec mntpath mnttype mntopts on; do
2947c478bd9Sstevel@tonic-gate		[ "$mntpath" = "$path" ] || continue
2957c478bd9Sstevel@tonic-gate		[ "$fstype" != "-" ] && [ "$mnttype" != "$fstype" ] && return 1
2967c478bd9Sstevel@tonic-gate		[ "$fsopts" = "-" ] && return 0
2977c478bd9Sstevel@tonic-gate		hasopts $fsopts $mntopts && return 0
2987c478bd9Sstevel@tonic-gate	done
2997c478bd9Sstevel@tonic-gate	return 1
3007c478bd9Sstevel@tonic-gate}
3017c478bd9Sstevel@tonic-gate
3027c478bd9Sstevel@tonic-gate#
3037c478bd9Sstevel@tonic-gate# mountfs $opts $path $type $fsopts $special
3047c478bd9Sstevel@tonic-gate#
3057c478bd9Sstevel@tonic-gate#   Try to mount a filesystem.  If failed, display our standard error
3067c478bd9Sstevel@tonic-gate#   message on the console and print more details about what happened
3077c478bd9Sstevel@tonic-gate#   to our service log.
3087c478bd9Sstevel@tonic-gate#
3097c478bd9Sstevel@tonic-gate# Arguments:
3107c478bd9Sstevel@tonic-gate#   $opts	- options for mount(1M)				[optional]
3117c478bd9Sstevel@tonic-gate#   $path	- mount point
3127c478bd9Sstevel@tonic-gate#   $type	- file system type				[optional]
3137c478bd9Sstevel@tonic-gate#   $fsopts	- file system specific options (-o)		[optional]
3147c478bd9Sstevel@tonic-gate#   $special	- device on which the file system resides	[optional]
3157c478bd9Sstevel@tonic-gate#
3167c478bd9Sstevel@tonic-gate# Return codes:
3177c478bd9Sstevel@tonic-gate#   0		- success.
3187c478bd9Sstevel@tonic-gate#   otherwise	- error code returned by mount(1M).
3197c478bd9Sstevel@tonic-gate#
3207c478bd9Sstevel@tonic-gatemountfs() {
3217c478bd9Sstevel@tonic-gate	opts="$1"
3227c478bd9Sstevel@tonic-gate	path="$2"
3237c478bd9Sstevel@tonic-gate	special="$5"
3247c478bd9Sstevel@tonic-gate
3257c478bd9Sstevel@tonic-gate	#
3267c478bd9Sstevel@tonic-gate	# Take care of optional arguments
3277c478bd9Sstevel@tonic-gate	#
3287c478bd9Sstevel@tonic-gate	[ "$opts" = "-" ] && opts=""
3297c478bd9Sstevel@tonic-gate	[ "$special" = "-" ] &&	special=""
3307c478bd9Sstevel@tonic-gate	[ "$3" = "-" ] && type=""
3317c478bd9Sstevel@tonic-gate	[ "$3" != "-" ] && type="-F $3"
3327c478bd9Sstevel@tonic-gate	[ "$4" = "-" ] && fsopts=""
3337c478bd9Sstevel@tonic-gate	[ "$4" != "-" ] && fsopts="-o $4"
3347c478bd9Sstevel@tonic-gate
3357c478bd9Sstevel@tonic-gate	cmd="/sbin/mount $opts $type $fsopts $special $path"
3367c478bd9Sstevel@tonic-gate	msg=`$cmd 2>&1`
3377c478bd9Sstevel@tonic-gate	err=$?
3387c478bd9Sstevel@tonic-gate
3397c478bd9Sstevel@tonic-gate	[ $err = 0 ] && return 0
3407c478bd9Sstevel@tonic-gate
3417c478bd9Sstevel@tonic-gate	#
3427c478bd9Sstevel@tonic-gate	# If the specified file system is already mounted with all
3437c478bd9Sstevel@tonic-gate	# required options, and has the same filesystem type
3447c478bd9Sstevel@tonic-gate	# then ignore errors and return success
3457c478bd9Sstevel@tonic-gate	#
3467c478bd9Sstevel@tonic-gate	mounted $path $4 $3 < /etc/mnttab && return 0
3477c478bd9Sstevel@tonic-gate
3487c478bd9Sstevel@tonic-gate	echo "ERROR: $SMF_FMRI failed to mount $path "\
3497c478bd9Sstevel@tonic-gate	     "(see 'svcs -x' for details)" > /dev/msglog
3507c478bd9Sstevel@tonic-gate	echo "ERROR: $cmd failed, err=$err"
3517c478bd9Sstevel@tonic-gate	echo $msg
3527c478bd9Sstevel@tonic-gate	return $err
3537c478bd9Sstevel@tonic-gate}
354