#!/bin/ksh
#
# lstape - lists a tapes block size
#
# You can find the tape block size by configuring the device to 
# accept a very large block, performing a single read, and measuring
# the size of the read block.
#
if [ $# -ne 1 ]; then
	echo "Useage : lstape device-name"
	exit 1
fi

#
# Check the name and put it in standard format
#
if [[ "$1" = /dev/* ]]; then
	TAPE=${1##/dev/}
else
	TAPE=$1
fi

#
# Set the blocksize to variable length
#
chdev -l ${TAPE} -a block_size=0 > /dev/null
if [ $? -ne 0 ]; then
	exit 1
fi

#
# Read a single block and write to /tmp
#
dd if=/dev/${TAPE} bs=128k of=/tmp/1st$$ count=1
if [ $? -ne 0 ]; then
	rm -f /tmp/1st$$
	exit 1
fi

#
# Get the blocksize from the resultant file
#
wc -c /tmp/1st$$ | read SIZE FILE
echo "$TAPE:	${SIZE} bytes per block."
if [ -x /usr/bin/file ]; then
	file /tmp/1st$$ | sed -e "s!/tmp/1st$$!/dev/${TAPE}!"
fi

rm -f /tmp/1st$$
exit 0