#! /bin/sh
#
#   seldisk.sh - ディスクの選択 (floppy版)
#
#	0.0: Jun. 19, 2004 by Dai ISHIJIMA
#

dmesg=/var/run/dmesg.boot

disks=`sed -n -E '/^(da|ad)[0-9]:.*</p' $dmesg | sed 's/^\(...\).*/\1/'`

echo ''; echo ''; echo ''
echo '*** select a disk to erase data'
echo ''
n=0
m=0
for d in $disks ; do
	dname=`sed -n -E "/^${d}:.*<.*>/p" $dmesg | sed 's/.*\(<.*>\).*/\1/'`
	bytes=`diskinfo -B /dev/r$d`
	cap=`diskinfo -p /dev/r$d`
	echo "    $n: $d $dname $bytes bytes ($cap)"
	m=$n
	n=$(( $n + 1 ))
done
echo ''
echo -n "which drive to erase data? [0-$m]: "
read ans

case x"$ans" in
	x[0-$m])
		n=0;
		for d in $disks ; do
			if [ "$n" = "$ans" ]; then
				break
			fi
		done
		;;
	*)
		d=$disk
		;;
esac

disk=$d

# EOF
