#!/sbin/sh
#	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
#	  All Rights Reserved

#	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
#	The copyright notice above does not evidence any
#	actual or intended publication of such source code.

#
#	Copyright (c) 1996, Sun Microsystems Inc. All rights reserved.
#

#ident	"@(#)split_tempru.sh 1.1     98/11/04 SMI"


# Make sure that the libraries essential
# to this stage of booting can be found.
LD_LIBRARY_PATH=/etc/lib; export LD_LIBRARY_PATH

#
# Root is already mounted (by the kernel), but still needs to be checked,
# possibly remounted and entered into mnttab. First mount /usr read only
# if it is a separate file system. This must be done first to allow
# utilities such as fsck and setmnt to reside on /usr minimizing the space
# required by the root file system.
#
exec < ${vfstab}; readvfstab "/usr"
if [ "${mountp}" ]
then
	if [ "${fstype}" = "cachefs" ]; then
		#
		# Mount without the cache initially.  We'll enable it
		# later at remount time.  This lets us avoid
		# teaching the statically linked mount program about
		# cachefs.  Here we determine the backfstype.
		# This is not pretty, but we have no tools for parsing
		# the option string until we get /usr mounted...
		#
		case "$mntopts" in
		*backfstype=nfs*)
			cfsbacktype=nfs
			;;
		*backfstype=hsfs*)
			cfsbacktype=hsfs
			;;
		*)
			echo "invalid vfstab entry for /usr"
			cfsbacktype=nfs
			;;
		esac
		/sbin/mount -m -F ${cfsbacktype} -o ro ${special} ${mountp}
	else
		#
		# must use -o largefiles here to ensure the read-only mount
		# does not fail as a result of having a large file present
		# on /usr. This gives fsck a chance to fix up the largefiles
		# flag before we remount /usr read-write.
		#
		if [ "$mntopts" = "-" ]; then
			mntopts="ro,largefiles"
		else
			checkopt "largefiles" ${mntopts}
			if [ "X${option}" != "Xlargefiles" ]; then
				mntopts="largefiles,${mntopts}"
			fi

			checkopt "ro" ${mntopts}
			if [ "X${option}" != "Xro" ]; then
				mntopts="ro,${mntopts}"
			fi
		fi
		/sbin/mount -m -o $mntopts /usr

	fi
fi

# Reset the library path now that we are
# past the critical stage.
LD_LIBRARY_PATH=/usr/lib; export LD_LIBRARY_PATH
