#! /bin/sh
# dinfo: Info about filesystem dumps
# Usage: dinfo [device...]
# If no devices are specified, print info for all devices
PATH=/bin:/usr/bin
root=u:
program=`basename $0`
infofile=$root/etc/dumpinfo
datesfile=$root/etc/dumpdate

if test ! -f $infofile ; then
  echo $program: Dump information file $infofile not found
  exit 1
fi

if test ! -f $dates ; then
  echo $program: Dump dates file $datesfile not found
  exit 1
fi

if test $# -eq 0 ; then
  devices="c d e f g h i j k l m n o"
else
  devices=$*
fi

echo "F L Dump starting date  Dump ending date    File                  Size now"
echo  ----------------------------------------------------------------------------

for dev in $devices ; do
  device=/dev/$dev
  gawk '
    $0 ~ /^Level [0-9]+ dump of [^ ]+ started on [^ ]+ [^ ]+$/ {
        if ($5 == device)
          printf "%s %s %s %s ", substr (device, 6, 1), $2, $8, $9;
      }
    $0 ~ /^Level [0-9]+ dump of [^ ]+ ended on [^ ]+ [^ ]+ \(written on [^ ]+\)$/ {
        if ($5 == device) {
    	  printf "%s %s %s ", $8, $9, substr ($12, 1, length ($12) - 1);
	  getline; getline; printf "%-10lu\n", $5;
        }
      }
  ' device=$device $infofile
done

