:
#
#	vdfixroot
#
#		A utility to repair a mirrored root file system.
#		This should be invoked from a booted emergency floppy.
#
if [ -x /bin/grep ]
    then
	ls -l /dev/root | grep " 2," > /dev/null
	if [ $? -ne 0 ]
	    then
		echo "You must be booted from an emergency"
		echo "floppy to run vdfixroot."
		exit 1
	fi
fi

fsck /dev/vd0
if [ $? -ne 0 ]
    then
	echo "vdfixroot: fsck on /dev/vd0 failed."
	echo "Unable to repair mirrored root file system."
	echo "Aborting."
	exit 1
fi

/altos/bin/vdbadblk -r -n 0
if [ $? -ne 0 ]
    then
	echo "vdbadblk failed. The mirrored root file system may not be fixable."
	exit 1
fi

sync
sync
/bin/sleep 15

if [ -f /etc/vdbadtab ]
    then
	mount /dev/vd0 /mnt
	if [ $? -ne 0 ]
	    then
		echo "vdfixroot: unable to mount /dev/vd0"
		echo "The bad block list /etc/vdbadtab on the"
		echo "mirrored root file system is out of date."
		echo "It is suggested that /etc/vdbadtab on the hard disk be removed."
		exit 1
	fi

	/altos/bin/vdmrgbad /mnt/etc/vdbadtab

	umount /dev/vd0
fi

echo "vdfixroot: the mirrored root file system has been repaired"
exit 0
