#! /bin/sh
#
# Add the us driver if it isn't already installed
#
#
# SUNWusx.u postpatch script
#
# We are putting this in drivers patch because the us driver has not
# changed but just the postinstall script. There are no deliverables and
# just a postinsrall. So there is nowhere to put it
# other than in generic drivers patch.

PATH="/usr/bin:/usr/sbin:${PATH}"
export PATH

if [ -f $ROOTDIR/usr/sbin/add_drv ]; then

	if [ -f $ROOTDIR/usr/sbin/rem_drv ]; then

		if [ -f $ROOTDIR/platform/sun4u/kernel/drv/sparcv9/us ]; then
			$ROOTDIR/usr/sbin/rem_drv -b $ROOTDIR us
			$ROOTDIR/usr/sbin/add_drv -b $ROOTDIR -i 'SUNW,UltraSPARC-III "SUNW,UltraSPARC-III+" SUNW,UltraSPARC-IIIi SUNW,UltraSPARC-IIe' -n us 
		fi

	fi

fi

# Create allkmem pseudo device and symlink. 
# Get major number from name_to_major if mm driver is
# on the system.

if [ -f $ROOTDIR/kernel/drv/mm ]; then
	devnode=$ROOTDIR/devices/pseudo/mm@0:allkmem
	grep "^mm " $ROOTDIR/etc/name_to_major >/dev/null 2>&1
	if [ "$?" = "0" ]; then
		minor_mm=3
		major_mm=`grep "^mm " \
		$ROOTDIR/etc/name_to_major | nawk '{ print $2 }'`
	else
		exit -1
	fi
else 
	exit 0
fi

rm -f $devnode
mknod $devnode c $major_mm $minor_mm
chmod 0600 $devnode
chown root:sys $devnode

devnode=../devices/pseudo/mm@0:allkmem

devlink=allkmem
( cd $ROOTDIR/dev ; \
	rm -f $devlink ; ln -s $devnode $devlink )

exit 0

