#! /bin/sh
#
#	0.1: Oct. 22, 2002 by Dai ISHIJIMA
#

PATH=/bin:/sbin:/:.
export PATH

NCYLS=`diskinfo -c`; export NCYLS
NHEAD=`diskinfo -h`; export NHEAD
NSECS=`diskinfo -s`; export NSECS
total=`expr $NCYLS '*' $NHEAD '*' $NSECS`

while echo '' ; do
	echo '0) verify disk (primary master: ad0)'
	echo '1) verify disk (primary slave: ad1)'
	echo '2) copy disk (primary master: ad0 -> primary slave: ad1)'
	echo '3) erase entire disk (primary master ATA HDD: ad0)'
	echo '4) erase entire disk (primary slave ATA HDD: ad1)'
	echo '5) escape to shell'
	echo "9) set disk geometry ($NCYLS * $NHEAD * $NSECS = $total blocks)"
	echo ''
	echo -n 'Which is your choice?  '
	read x
	case $x in
		0) /bin/sh /bin/v.sh ;;
		1) /bin/sh /bin/v.sh ad1 ;;
		2) /bin/sh /bin/c.sh ;;
		3) /bin/sh /bin/e.sh ad0 ;;
		4) /bin/sh /bin/e.sh ad1 ;;
		5) /bin/sh -i ;;
		6) /bin/sh /bin/c.sh ad1 ;;
		9)
			echo -n 'Enter # of cylinders: '
			read n
			if expr "$n" + 0 > /dev/null 2>&1 ; then
				NCYLS=`expr "$n" + 0`; export NCYLS
			else
				NCYLS=0; export NCYLS
			fi
			echo -n 'Enter # of heads (tracks/cylinder): '
			read n
			if expr "$n" + 0 > /dev/null 2>&1 ; then
				NHEAD=`expr "$n" + 0`; export NHEAD
			else
				NHEAD=0; export NHEAD
			fi
			echo -n 'Enter # of sectors (sectors/track): '
			read n
			if expr "$n" + 0 > /dev/null 2>&1 ; then
				NSECS=`expr "$n" + 0`; export NSECS
			else
				NSECS=0; export NSECS
			fi
			total=`expr $NCYLS '*' $NHEAD '*' $NSECS`
			if [ $total -le 0 ]; then
				echo -n "Hmm... total blocks wrong "
				echo -n "($NCYLS * $NHEAD * $NSECS = $total"
				echo -n " blocks), using default value instead"
				NCYLS=`diskinfo -c`; export NCYLS
				NHEAD=`diskinfo -h`; export NHEAD
				NSECS=`diskinfo -s`; export NSECS
				total=`expr $NCYLS '*' $NHEAD '*' $NSECS`
			fi
			echo ''
			echo ''
			;;
	esac
done

exit 0


