xref: /titanic_41/usr/src/cmd/initpkg/mountall.sh (revision 812e8c05270efb3334ff7b081079ed4b71c712c8)
17c478bd9Sstevel@tonic-gate#!/sbin/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
67c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
77c478bd9Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
87c478bd9Sstevel@tonic-gate# with the License.
97c478bd9Sstevel@tonic-gate#
107c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
117c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
127c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
137c478bd9Sstevel@tonic-gate# and limitations under the License.
147c478bd9Sstevel@tonic-gate#
157c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
167c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
177c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
187c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
197c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
207c478bd9Sstevel@tonic-gate#
217c478bd9Sstevel@tonic-gate# CDDL HEADER END
227c478bd9Sstevel@tonic-gate#
23*812e8c05SGordon Ross
247c478bd9Sstevel@tonic-gate#
25*812e8c05SGordon Ross# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
267c478bd9Sstevel@tonic-gate# Use is subject to license terms.
277c478bd9Sstevel@tonic-gate#
287c478bd9Sstevel@tonic-gate#	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
297c478bd9Sstevel@tonic-gate#	  All Rights Reserved
307c478bd9Sstevel@tonic-gate#
317c478bd9Sstevel@tonic-gate
32*812e8c05SGordon Rossusage () {
33*812e8c05SGordon Ross	if [ -n "$1" ]; then
34*812e8c05SGordon Ross		echo "mountall: $1" 1>&2
35*812e8c05SGordon Ross	fi
36*812e8c05SGordon Ross	echo "Usage:\nmountall [-F FSType] [-l|-r|-g] [file_system_table]" 1>&2
37*812e8c05SGordon Ross	exit 2
38*812e8c05SGordon Ross}
39*812e8c05SGordon Ross
40*812e8c05SGordon RossPATH=/usr/sbin:/usr/bin
41*812e8c05SGordon RossTYPES=all
42*812e8c05SGordon RossFSTAB=/etc/vfstab
43*812e8c05SGordon Rosserr=0
44*812e8c05SGordon Ross
45*812e8c05SGordon Ross# Clear these in case they were already set in our environment.
46*812e8c05SGordon RossFSType=
47*812e8c05SGordon RossGFLAG=
48*812e8c05SGordon RossRFLAG=
49*812e8c05SGordon RossLFLAG=
50*812e8c05SGordon RossSFLAG=
51*812e8c05SGordon RossRemoteFSTypes=
52*812e8c05SGordon Ross
537c478bd9Sstevel@tonic-gate#	checkmessage "fsck_device | mount_point"
547c478bd9Sstevel@tonic-gate#
557c478bd9Sstevel@tonic-gate# Simple auxilary routine to the shell function checkfs. Prints out
567c478bd9Sstevel@tonic-gate# instructions for a manual file system check before entering the shell.
577c478bd9Sstevel@tonic-gate#
587c478bd9Sstevel@tonic-gatecheckmessage() {
597c478bd9Sstevel@tonic-gate	echo "" > /dev/console
607c478bd9Sstevel@tonic-gate	if [ "$1" != "" ] ; then
617c478bd9Sstevel@tonic-gate		echo "WARNING - Unable to repair one or more \c" > /dev/console
627c478bd9Sstevel@tonic-gate		echo "of the following filesystem(s):" > /dev/console
637c478bd9Sstevel@tonic-gate		echo "\t$1" > /dev/console
647c478bd9Sstevel@tonic-gate	else
657c478bd9Sstevel@tonic-gate		echo "WARNING - Unable to repair one or more filesystems." \
667c478bd9Sstevel@tonic-gate			> /dev/console
677c478bd9Sstevel@tonic-gate	fi
687c478bd9Sstevel@tonic-gate	echo "Run fsck manually (fsck filesystem...)." > /dev/console
697c478bd9Sstevel@tonic-gate	echo "" > /dev/console
707c478bd9Sstevel@tonic-gate}
717c478bd9Sstevel@tonic-gate
727c478bd9Sstevel@tonic-gate#
737c478bd9Sstevel@tonic-gate#	checkfs raw_device fstype mountpoint
747c478bd9Sstevel@tonic-gate#
757c478bd9Sstevel@tonic-gate# Check the file system specified. The return codes from fsck have the
767c478bd9Sstevel@tonic-gate# following meanings.
777c478bd9Sstevel@tonic-gate#	 0 - file system is unmounted and okay
787c478bd9Sstevel@tonic-gate#	32 - file system is unmounted and needs checking (fsck -m only)
797c478bd9Sstevel@tonic-gate#	33 - file system is already mounted
807c478bd9Sstevel@tonic-gate#	34 - cannot stat device
817c478bd9Sstevel@tonic-gate#	36 - uncorrectable errors detected - terminate normally (4.1 code 8)
827c478bd9Sstevel@tonic-gate#	37 - a signal was caught during processing (4.1 exit 12)
837c478bd9Sstevel@tonic-gate#	39 - uncorrectable errors detected - terminate rightaway (4.1 code 8)
847c478bd9Sstevel@tonic-gate#	40 - for root, same as 0 (used by rcS to remount root)
857c478bd9Sstevel@tonic-gate#
867c478bd9Sstevel@tonic-gatecheckfs() {
877c478bd9Sstevel@tonic-gate	/usr/sbin/fsck -F $2 -m $1  >/dev/null 2>&1
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gate	if [ $? -ne 0 ]
907c478bd9Sstevel@tonic-gate	then
917c478bd9Sstevel@tonic-gate		# Determine fsck options by file system type
927c478bd9Sstevel@tonic-gate		case "$2" in
937c478bd9Sstevel@tonic-gate		ufs)	foptions="-o p"
947c478bd9Sstevel@tonic-gate			;;
957c478bd9Sstevel@tonic-gate		*)	foptions="-y"
967c478bd9Sstevel@tonic-gate			;;
977c478bd9Sstevel@tonic-gate		esac
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gate		echo "The "$3" file system ("$1") is being checked."
1007c478bd9Sstevel@tonic-gate		/usr/sbin/fsck -F $2 ${foptions} $1
1017c478bd9Sstevel@tonic-gate
1027c478bd9Sstevel@tonic-gate		case $? in
1037c478bd9Sstevel@tonic-gate		0|40)	# file system OK
1047c478bd9Sstevel@tonic-gate			;;
1057c478bd9Sstevel@tonic-gate
1067c478bd9Sstevel@tonic-gate		*)	# couldn't fix the file system
1077c478bd9Sstevel@tonic-gate			echo "/usr/sbin/fsck failed with exit code "$?"."
1087c478bd9Sstevel@tonic-gate			checkmessage "$1"
1097c478bd9Sstevel@tonic-gate			;;
1107c478bd9Sstevel@tonic-gate		esac
1117c478bd9Sstevel@tonic-gate	fi
1127c478bd9Sstevel@tonic-gate}
1137c478bd9Sstevel@tonic-gate
1147c478bd9Sstevel@tonic-gate#
1157c478bd9Sstevel@tonic-gate# Used to save an entry that we will want to mount either in
1167c478bd9Sstevel@tonic-gate# a command file or as a mount point list.
1177c478bd9Sstevel@tonic-gate#
1187c478bd9Sstevel@tonic-gate# saveentry fstype options special mountp
1197c478bd9Sstevel@tonic-gate#
1207c478bd9Sstevel@tonic-gatesaveentry() {
1217c478bd9Sstevel@tonic-gate	if [ "$ALTM" ]; then
1227c478bd9Sstevel@tonic-gate		echo "/sbin/mount -F $1 $2 $3 $4" >> $ALTM
1237c478bd9Sstevel@tonic-gate	else
1247c478bd9Sstevel@tonic-gate		mntlist="$mntlist $4"
1257c478bd9Sstevel@tonic-gate	fi
1267c478bd9Sstevel@tonic-gate}
1277c478bd9Sstevel@tonic-gate
128*812e8c05SGordon Ross# Do the passed mount options include "global"?
129*812e8c05SGordon Rossisglobal() {
130*812e8c05SGordon Ross	case ",${1}," in
131*812e8c05SGordon Ross	*,global,*)
132*812e8c05SGordon Ross		return 0
133*812e8c05SGordon Ross		;;
134*812e8c05SGordon Ross	esac
135*812e8c05SGordon Ross	return 1
136*812e8c05SGordon Ross}
1377c478bd9Sstevel@tonic-gate
138*812e8c05SGordon Ross# Is the passed fstype a "remote" one?
139*812e8c05SGordon Ross# Essentially: /usr/bin/grep "^$1" /etc/dfs/fstypes
140*812e8c05SGordon Rossisremote() {
141*812e8c05SGordon Ross	for t in $RemoteFSTypes
142*812e8c05SGordon Ross	do
143*812e8c05SGordon Ross		[ "$t" = "$1" ] && return 0
144*812e8c05SGordon Ross	done
145*812e8c05SGordon Ross	return 1
146*812e8c05SGordon Ross}
147*812e8c05SGordon Ross
148*812e8c05SGordon Ross# Get list of remote FS types (just once)
149*812e8c05SGordon RossRemoteFSTypes=`while read t junk; do echo $t; done < /etc/dfs/fstypes`
150*812e8c05SGordon Ross
1517c478bd9Sstevel@tonic-gate
1527c478bd9Sstevel@tonic-gate#
1537c478bd9Sstevel@tonic-gate# Process command line args
1547c478bd9Sstevel@tonic-gate#
1557c478bd9Sstevel@tonic-gatewhile getopts ?grlsF: c
1567c478bd9Sstevel@tonic-gatedo
1577c478bd9Sstevel@tonic-gate	case $c in
1587c478bd9Sstevel@tonic-gate	g)	GFLAG="g";;
1597c478bd9Sstevel@tonic-gate	r)	RFLAG="r";;
1607c478bd9Sstevel@tonic-gate	l)	LFLAG="l";;
1617c478bd9Sstevel@tonic-gate	s)	SFLAG="s";;
1627c478bd9Sstevel@tonic-gate	F)	FSType="$OPTARG";
1637c478bd9Sstevel@tonic-gate		if [ "$TYPES" = "one" ]
1647c478bd9Sstevel@tonic-gate		then
1657c478bd9Sstevel@tonic-gate			echo "mountall: more than one FSType specified"
1667c478bd9Sstevel@tonic-gate			exit 2
1677c478bd9Sstevel@tonic-gate		fi
1687c478bd9Sstevel@tonic-gate		TYPES="one";
1697c478bd9Sstevel@tonic-gate
1707c478bd9Sstevel@tonic-gate		case $FSType in
1717c478bd9Sstevel@tonic-gate		?????????*)
1727c478bd9Sstevel@tonic-gate			echo "mountall: FSType $FSType exceeds 8 characters"
1737c478bd9Sstevel@tonic-gate			exit 2
1747c478bd9Sstevel@tonic-gate		esac
1757c478bd9Sstevel@tonic-gate		;;
176*812e8c05SGordon Ross	\?)	usage "";;
1777c478bd9Sstevel@tonic-gate	esac
1787c478bd9Sstevel@tonic-gatedone
1797c478bd9Sstevel@tonic-gate
1807c478bd9Sstevel@tonic-gateshift `/usr/bin/expr $OPTIND - 1`	# get past the processed args
1817c478bd9Sstevel@tonic-gate
1827c478bd9Sstevel@tonic-gateif [ $# -gt 1 ]; then
183*812e8c05SGordon Ross	usage "multiple arguments not supported"
1847c478bd9Sstevel@tonic-gatefi
1857c478bd9Sstevel@tonic-gate
1867c478bd9Sstevel@tonic-gate# get file system table name and make sure file exists
1877c478bd9Sstevel@tonic-gateif [ $# = 1 ]; then
1887c478bd9Sstevel@tonic-gate	case $1 in
1897c478bd9Sstevel@tonic-gate	"-")	FSTAB=""
1907c478bd9Sstevel@tonic-gate		;;
1917c478bd9Sstevel@tonic-gate	*)	FSTAB=$1
1927c478bd9Sstevel@tonic-gate		;;
1937c478bd9Sstevel@tonic-gate	esac
1947c478bd9Sstevel@tonic-gatefi
1957c478bd9Sstevel@tonic-gate#
1967c478bd9Sstevel@tonic-gate# if an alternate vfstab file is used or serial mode is specified, then
1977c478bd9Sstevel@tonic-gate# use a mount command file
1987c478bd9Sstevel@tonic-gate#
1997c478bd9Sstevel@tonic-gateif [ $# = 1 -o "$SFLAG" ]; then
2007c478bd9Sstevel@tonic-gate	ALTM=/var/tmp/mount$$
2017c478bd9Sstevel@tonic-gate	rm -f $ALTM
2027c478bd9Sstevel@tonic-gatefi
2037c478bd9Sstevel@tonic-gate
2047c478bd9Sstevel@tonic-gateif [ "$FSTAB" != ""  -a  ! -s "$FSTAB" ]
2057c478bd9Sstevel@tonic-gatethen
2067c478bd9Sstevel@tonic-gate	echo "mountall: file system table ($FSTAB) not found"
2077c478bd9Sstevel@tonic-gate	exit 1
2087c478bd9Sstevel@tonic-gatefi
2097c478bd9Sstevel@tonic-gate
2107c478bd9Sstevel@tonic-gate#
2117c478bd9Sstevel@tonic-gate# Check for incompatible args
2127c478bd9Sstevel@tonic-gate#
2137c478bd9Sstevel@tonic-gateif [ "$GFLAG" = "g" -a "$RFLAG$LFLAG" != "" -o \
2147c478bd9Sstevel@tonic-gate     "$RFLAG" = "r" -a "$GFLAG$LFLAG" != "" -o \
2157c478bd9Sstevel@tonic-gate     "$LFLAG" = "l" -a "$RFLAG$GFLAG" != "" ]
2167c478bd9Sstevel@tonic-gatethen
217*812e8c05SGordon Ross	usage "options -g, -r and -l are mutually exclusive"
2187c478bd9Sstevel@tonic-gatefi
2197c478bd9Sstevel@tonic-gate
220*812e8c05SGordon Rossif [ "$LFLAG" = "l" -a -n "$FSType" ]; then
221*812e8c05SGordon Ross	# remote FSType not allowed
222*812e8c05SGordon Ross	isremote "$FSType" &&
223*812e8c05SGordon Ross	usage "option -l and FSType are incompatible"
2247c478bd9Sstevel@tonic-gatefi
225*812e8c05SGordon Ross
226*812e8c05SGordon Rossif [ "$RFLAG" = "r" -a -n "$FSType" ]; then
227*812e8c05SGordon Ross	# remote FSType required
228*812e8c05SGordon Ross	isremote "$FSType" ||
229*812e8c05SGordon Ross	usage "option -r and FSType are incompatible"
2307c478bd9Sstevel@tonic-gatefi
2317c478bd9Sstevel@tonic-gate
2327c478bd9Sstevel@tonic-gate#	file-system-table format:
2337c478bd9Sstevel@tonic-gate#
2347c478bd9Sstevel@tonic-gate#	column 1:	special- block special device or resource name
2357c478bd9Sstevel@tonic-gate#	column 2: 	fsckdev- char special device for fsck
2367c478bd9Sstevel@tonic-gate#	column 3:	mountp- mount point
2377c478bd9Sstevel@tonic-gate#	column 4:	fstype- File system type
2387c478bd9Sstevel@tonic-gate#	column 5:	fsckpass- number if to be checked automatically
2397c478bd9Sstevel@tonic-gate#	column 6:	automnt-	yes/no for automatic mount
2407c478bd9Sstevel@tonic-gate#	column 7:	mntopts- -o specific mount options
2417c478bd9Sstevel@tonic-gate
2427c478bd9Sstevel@tonic-gate#	White-space separates columns.
2437c478bd9Sstevel@tonic-gate#	Lines beginning with \"#\" are comments.  Empty lines are ignored.
2447c478bd9Sstevel@tonic-gate#	a '-' in any field is a no-op.
2457c478bd9Sstevel@tonic-gate
2467c478bd9Sstevel@tonic-gate#
2477c478bd9Sstevel@tonic-gate# Read FSTAB, fsck'ing appropriate filesystems:
2487c478bd9Sstevel@tonic-gate#
2497c478bd9Sstevel@tonic-gateexec < $FSTAB
2507c478bd9Sstevel@tonic-gatewhile  read special fsckdev mountp fstype fsckpass automnt mntopts
2517c478bd9Sstevel@tonic-gatedo
2527c478bd9Sstevel@tonic-gate	case $special in
2537c478bd9Sstevel@tonic-gate	'#'* | '')	#  Ignore comments, empty lines
2547c478bd9Sstevel@tonic-gate			continue ;;
2557c478bd9Sstevel@tonic-gate	'-')		#  Ignore no-action lines
2567c478bd9Sstevel@tonic-gate			continue
2577c478bd9Sstevel@tonic-gate	esac
2587c478bd9Sstevel@tonic-gate
2597c478bd9Sstevel@tonic-gate	if [ "$automnt" != "yes" ]; then
2607c478bd9Sstevel@tonic-gate		continue
2617c478bd9Sstevel@tonic-gate	fi
2627c478bd9Sstevel@tonic-gate	if [ "$FSType" -a "$FSType" != "$fstype" ]; then
2637c478bd9Sstevel@tonic-gate		# ignore different fstypes
2647c478bd9Sstevel@tonic-gate		continue
2657c478bd9Sstevel@tonic-gate	fi
2667c478bd9Sstevel@tonic-gate
267*812e8c05SGordon Ross	# The -g option is not in the man page, but according to
268*812e8c05SGordon Ross	# PSARC/1998/255 it's used by Sun Cluster (via contract) to
269*812e8c05SGordon Ross	# mount disk-based filesystems with the "global" option.
270*812e8c05SGordon Ross	# Also, the -l option now skips those "global" mounts.
271*812e8c05SGordon Ross	#
272*812e8c05SGordon Ross	# Note: options -g -l -r are mutually exclusive
273*812e8c05SGordon Ross	#
274*812e8c05SGordon Ross	if [ -n "$GFLAG" ]; then
275*812e8c05SGordon Ross		# Mount "local" filesystems that have
276*812e8c05SGordon Ross		# the "global" option in mntopts.
277*812e8c05SGordon Ross		isremote "$fstype" && continue
278*812e8c05SGordon Ross		isglobal "$mntopts" || continue
2797c478bd9Sstevel@tonic-gate	fi
280*812e8c05SGordon Ross	if [ -n "$LFLAG" ]; then
281*812e8c05SGordon Ross		# Mount "local" filesystems, excluding
282*812e8c05SGordon Ross		# those marked "global".
283*812e8c05SGordon Ross		isremote "$fstype" && continue
284*812e8c05SGordon Ross		isglobal "$mntopts" && continue
2857c478bd9Sstevel@tonic-gate	fi
286*812e8c05SGordon Ross	if [ -n "$RFLAG" ]; then
287*812e8c05SGordon Ross		# Mount "remote" filesystems.
288*812e8c05SGordon Ross		isremote "$fstype" || continue
2897c478bd9Sstevel@tonic-gate	fi
2907c478bd9Sstevel@tonic-gate
2917c478bd9Sstevel@tonic-gate	if [ "$fstype" = "-" ]; then
2927c478bd9Sstevel@tonic-gate		echo "mountall: FSType of $special cannot be identified" 1>&2
2937c478bd9Sstevel@tonic-gate		continue
2947c478bd9Sstevel@tonic-gate	fi
2957c478bd9Sstevel@tonic-gate
2967c478bd9Sstevel@tonic-gate	if [ "$ALTM" -a "$mntopts" != "-" ]; then
2977c478bd9Sstevel@tonic-gate		OPTIONS="-o $mntopts"		# Use mount options if any
2987c478bd9Sstevel@tonic-gate	else
2997c478bd9Sstevel@tonic-gate		OPTIONS=""
3007c478bd9Sstevel@tonic-gate	fi
3017c478bd9Sstevel@tonic-gate
3027c478bd9Sstevel@tonic-gate	#
3037c478bd9Sstevel@tonic-gate	# Ignore entries already mounted
3047c478bd9Sstevel@tonic-gate	#
3057c478bd9Sstevel@tonic-gate	/usr/bin/grep "	$mountp	" /etc/mnttab >/dev/null 2>&1 && continue
3067c478bd9Sstevel@tonic-gate
3077c478bd9Sstevel@tonic-gate	#
3087c478bd9Sstevel@tonic-gate	# Can't fsck if no fsckdev is specified
3097c478bd9Sstevel@tonic-gate	#
3107c478bd9Sstevel@tonic-gate	if [ "$fsckdev" = "-" ]; then
3117c478bd9Sstevel@tonic-gate		saveentry $fstype "$OPTIONS" $special $mountp
3127c478bd9Sstevel@tonic-gate		continue
3137c478bd9Sstevel@tonic-gate	fi
3147c478bd9Sstevel@tonic-gate	#
3157c478bd9Sstevel@tonic-gate	# For fsck purposes, we make a distinction between file systems
3167c478bd9Sstevel@tonic-gate	# that have a /usr/lib/fs/<fstyp>/fsckall script and those
3177c478bd9Sstevel@tonic-gate	# that don't.  For those that do, just keep a list of them
3187c478bd9Sstevel@tonic-gate	# and pass the list to the fsckall script for that file
3197c478bd9Sstevel@tonic-gate	# file system type.
3207c478bd9Sstevel@tonic-gate	#
3217c478bd9Sstevel@tonic-gate	if [ -x /usr/lib/fs/$fstype/fsckall ]; then
3227c478bd9Sstevel@tonic-gate
3237c478bd9Sstevel@tonic-gate		#
3247c478bd9Sstevel@tonic-gate		# add fstype to the list of fstypes for which
3257c478bd9Sstevel@tonic-gate		# fsckall should be called, if it's not already
3267c478bd9Sstevel@tonic-gate		# in the list.
3277c478bd9Sstevel@tonic-gate		#
3287c478bd9Sstevel@tonic-gate		found=no
3297c478bd9Sstevel@tonic-gate		if [ "$fsckall_fstypes" != "" ] ; then
3307c478bd9Sstevel@tonic-gate			for fst in $fsckall_fstypes; do
3317c478bd9Sstevel@tonic-gate				if [ "$fst" = "$fstype" ] ; then
3327c478bd9Sstevel@tonic-gate					found=yes
3337c478bd9Sstevel@tonic-gate					break
3347c478bd9Sstevel@tonic-gate				fi
3357c478bd9Sstevel@tonic-gate			done
3367c478bd9Sstevel@tonic-gate		fi
3377c478bd9Sstevel@tonic-gate		if [ $found = no ] ; then
3387c478bd9Sstevel@tonic-gate			fsckall_fstypes="$fsckall_fstypes ${fstype}"
3397c478bd9Sstevel@tonic-gate		fi
3407c478bd9Sstevel@tonic-gate
3417c478bd9Sstevel@tonic-gate		#
3427c478bd9Sstevel@tonic-gate		# add the device to the name of devices to be passed
3437c478bd9Sstevel@tonic-gate		# to the fsckall program for this file system type
3447c478bd9Sstevel@tonic-gate		#
3457c478bd9Sstevel@tonic-gate		cmd="${fstype}_fscklist=\"\$${fstype}_fscklist $fsckdev\""
3467c478bd9Sstevel@tonic-gate		eval $cmd
3477c478bd9Sstevel@tonic-gate		saveentry $fstype "$OPTIONS" $special $mountp
3487c478bd9Sstevel@tonic-gate		continue
3497c478bd9Sstevel@tonic-gate	fi
3507c478bd9Sstevel@tonic-gate	#
3517c478bd9Sstevel@tonic-gate	# fsck everything else:
3527c478bd9Sstevel@tonic-gate 	#
3537c478bd9Sstevel@tonic-gate 	# fsck -m simply returns true if the filesystem is suitable for
3547c478bd9Sstevel@tonic-gate 	# mounting.
3557c478bd9Sstevel@tonic-gate 	#
3567c478bd9Sstevel@tonic-gate	/usr/sbin/fsck -m -F $fstype $fsckdev >/dev/null 2>&1
3577c478bd9Sstevel@tonic-gate	case $? in
3587c478bd9Sstevel@tonic-gate	0|40)	saveentry $fstype "$OPTIONS" $special $mountp
3597c478bd9Sstevel@tonic-gate		continue
3607c478bd9Sstevel@tonic-gate		;;
3617c478bd9Sstevel@tonic-gate	32)	checkfs $fsckdev $fstype $mountp
3627c478bd9Sstevel@tonic-gate		saveentry $fstype "$OPTIONS" $special $mountp
3637c478bd9Sstevel@tonic-gate		continue
3647c478bd9Sstevel@tonic-gate		;;
3657c478bd9Sstevel@tonic-gate	33)	# already mounted
3667c478bd9Sstevel@tonic-gate		echo "$special already mounted"
3677c478bd9Sstevel@tonic-gate		;;
3687c478bd9Sstevel@tonic-gate	34)	# bogus special device
3697c478bd9Sstevel@tonic-gate		echo "Cannot stat $fsckdev - ignoring"
3707c478bd9Sstevel@tonic-gate		err=1
3717c478bd9Sstevel@tonic-gate		;;
3727c478bd9Sstevel@tonic-gate	*)	# uncorrectable errors
3737c478bd9Sstevel@tonic-gate		echo "$fsckdev uncorrectable error"
3747c478bd9Sstevel@tonic-gate		err=1
3757c478bd9Sstevel@tonic-gate		;;
3767c478bd9Sstevel@tonic-gate	esac
3777c478bd9Sstevel@tonic-gatedone
3787c478bd9Sstevel@tonic-gate
3797c478bd9Sstevel@tonic-gate#
3807c478bd9Sstevel@tonic-gate# Call the fsckall programs
3817c478bd9Sstevel@tonic-gate#
3827c478bd9Sstevel@tonic-gatefor fst in $fsckall_fstypes
3837c478bd9Sstevel@tonic-gatedo
3847c478bd9Sstevel@tonic-gate	cmd="/usr/lib/fs/$fst/fsckall \$${fst}_fscklist"
3857c478bd9Sstevel@tonic-gate	eval $cmd
3867c478bd9Sstevel@tonic-gate
3877c478bd9Sstevel@tonic-gate	case $? in
3887c478bd9Sstevel@tonic-gate	0)	# file systems OK
3897c478bd9Sstevel@tonic-gate			;;
3907c478bd9Sstevel@tonic-gate
3917c478bd9Sstevel@tonic-gate	*)	# couldn't fix some of the filesystems
3927c478bd9Sstevel@tonic-gate		echo "fsckall failed with exit code "$?"."
3937c478bd9Sstevel@tonic-gate		checkmessage
3947c478bd9Sstevel@tonic-gate		;;
3957c478bd9Sstevel@tonic-gate	esac
3967c478bd9Sstevel@tonic-gatedone
3977c478bd9Sstevel@tonic-gate
3987c478bd9Sstevel@tonic-gateif [ "$ALTM" ]; then
3997c478bd9Sstevel@tonic-gate	if [ ! -f "$ALTM" ]; then
4007c478bd9Sstevel@tonic-gate		exit
4017c478bd9Sstevel@tonic-gate	fi
4027c478bd9Sstevel@tonic-gate	/sbin/sh $ALTM		# run the saved mount commands
4037c478bd9Sstevel@tonic-gate	/usr/bin/rm -f $ALTM
4047c478bd9Sstevel@tonic-gate	exit
4057c478bd9Sstevel@tonic-gatefi
4067c478bd9Sstevel@tonic-gate
4077c478bd9Sstevel@tonic-gateif [ -n "$FSType" ]; then
4087c478bd9Sstevel@tonic-gate	/sbin/mount -a -F $FSType
4097c478bd9Sstevel@tonic-gate	exit
4107c478bd9Sstevel@tonic-gatefi
4117c478bd9Sstevel@tonic-gate
412*812e8c05SGordon Ross# Some remote filesystems (e.g. cachefs or autofs) shouldn't be be mounted
413*812e8c05SGordon Ross# with mountall, so the list here is explicit (not from /etc/dfs/fstypes)
4147c478bd9Sstevel@tonic-gateif [ "$RFLAG" ]; then
4157c478bd9Sstevel@tonic-gate	/sbin/mount -a -F nfs
416*812e8c05SGordon Ross	/sbin/mount -a -F smbfs
4177c478bd9Sstevel@tonic-gate	exit
4187c478bd9Sstevel@tonic-gatefi
4197c478bd9Sstevel@tonic-gate
4207c478bd9Sstevel@tonic-gateif [ "$LFLAG" -o "$GFLAG" -o $err != 0 ]; then
4217c478bd9Sstevel@tonic-gate	[ -z "$mntlist" ] || /sbin/mount -a $mntlist
4227c478bd9Sstevel@tonic-gate	exit
4237c478bd9Sstevel@tonic-gatefi
4247c478bd9Sstevel@tonic-gate
4257c478bd9Sstevel@tonic-gate# else mount them all
4267c478bd9Sstevel@tonic-gate
4277c478bd9Sstevel@tonic-gate/sbin/mount -a
428