#! /sbin/sh
#Tag 0x00000f00
#ident	"$Revision: 1.45 $"
#
# This script runs those commands necessary to check file systems, to make
# generic device links, and to do anything else that should be done before
# mounting file systems.
#

# Make symlink "/usr/bin -> ../../sbin".  Must be done *before*
# /usr is mounted, so programs executed as /bin/* will work in
# single user mode.  Do not use the same algorithm as libc.so.1 since
# /usr/bin may be a real directory if root and usr are merged.
#
/sbin/ls /usr/bin > /dev/null 2>&1
if [ $? != 0 ]; then
	/sbin/ln -s ../sbin /usr/bin <&- > /dev/null 2>&1
fi

if [ "`/sbin/nvram diskless 2> /dev/null`" -eq 1 ] ; then
    if [ -f /var/boot/makedev ] ; then
	echo "Making client's devices..."
	cd /dev; ./MAKEDEV > /dev/null
	rm -f /var/boot/makedev
    fi
else
    set `/sbin/devnm /`
    rootfs=$1
    /sbin/fsstat ${rootfs}  >/dev/null 2>&1
    if [ $? -eq 1 ] ; then
	echo "The root file system, ${rootfs}, is being checked automatically."
	/sbin/fsck -y ${rootfs}
    fi
    set `ls -Lid /dev/root $rootfs`
    if [ ! -b /dev/root -o "$1" -ne "$3" -o ! -c /dev/rroot ] ; then
	rm -rf /dev/root
	ln $rootfs /dev/root
	rm -rf /dev/rroot
	ln /dev/rdsk/`basename $rootfs` /dev/rroot
    fi

	if [ -f /etc/lvtab ] ; then
		if /sbin/chkconfig verbose
		then
			echo "Starting LV:"
		fi
		/sbin/lvinit
	fi


fi

# Remove ps temporary file
rm -rf /tmp/.ps_data

# Make symlink /usr/lib/libc.so.1 -> ../../lib/libc.so.1
# Must be done *before* /usr is mounted, so dynamic linked
# programs can be run in single user mode.
if [ ! -s /usr/lib/libc.so.1 ]
then
	mkdir -p /usr/lib > /dev/null 2>&1
	rm -rf /usr/lib/libc.so.1 > /dev/null 2>&1
	ln -s ../../lib/libc.so.1 /usr/lib/libc.so.1 <&- > /dev/null 2>&1
fi

