#	ATT: ident	"sadmin:admin/menu/diskmgmt/erase	2.3"

#ident	"%Z%sadmin/admin/menu/diskmgmt:%M%	%I%"

#menu# erase data from removable medium 
#help# 
#help#	This procedure erases a logical disk by overwriting it with null
#help#	bytes.  It's main purpose is to remove data that you don't want
#help#	anyone to ever see.  Needless to say, once performed it is
#help#	irreversible.

trap exit 1 2 15

echo '
	This procedure completely erases all data on the logical disk.
	BE SURE THAT IS WHAT YOU WANT TO DO!!
'

lumps=200	#	Number of blocks per erased segment of media.

dir=${0}.d
if [ -d ${dir} ]
then
	patterns=`ls ${dir} 2>/dev/null`
else
	patterns=
fi

cddrive=`selectdevice -c $$ /dev/rdsk ${patterns}`

if [ -n "${patterns}" ]
then
	. ${dir}/`selpattern ${ddrive}`
fi

disklabel -w -q "Warning: Erasing the contents of a drive is irreversible.
Press <RETURN> when ready. [q]" $$ ${cddrive} >/dev/null

a=`spclsize -b ${cddrive}`

while [ $a -gt 0 ]
do
	echo ""  |  dd bs=${lumps}b conv=sync 2>/dev/null
	a=`expr $a - ${lumps}`
	echo .\\c >&2
done  >${cddrive}
echo '
${cddrive} has been erased.
'
