#!/usr/bin/ksh ############################################################################### # # Module: sun_vtoc1.sh # Author: Peter R. Schmidt # Description: Format a SunOS vtoc # # Change Log # # Date Name Description................. # 07/09/99 Peter R. Schmidt Start Program # ############################################################################### OUTPUT=sun_vtoc1.out UDATE=`date` MACHINE=`uname -n` if [ $LOGNAME != root ] then echo echo "Sorry - you must be 'root' to run this program" echo exit 1 fi if [ -f $OUTPUT ] then rm -f $OUTPUT fi while true do echo echo "Enter filename of file containing devices to check" read FILENAME1 if [ -f $FILENAME1 ] then break fi echo echo "Error - file does not exist!" done echo "$UDATE VTOC Report for $MACHINE" >> $OUTPUT echo >> $OUTPUT echo "Link Device Slice Bytes Permissions Owner Group Actual Device" >> $OUTPUT for DEVICE in `cat $FILENAME1` do echo "Processing $DEVICE" prtvtoc $DEVICE > /dev/null if [ $? != 0 ] then echo echo "Error running prtvtoc - device skipped" echo "Device is: $DEVICE" echo "Press to continue with next device" read answer echo echo >> $OUTPUT echo "Error running prtvtoc for $DEVICE" >> $OUTPUT continue fi DEV_LINK=`ls -l $DEVICE | cut -d">" -f2 | awk '{print $1}'` # Note: need to do a "lowercase (L) UPPERcase (L)" here in order to # get the owner/group/permissions for the actual device linked to. DEV_PERM=`ls -lL $DEVICE | cut -c1-35` prtvtoc $DEVICE | egrep -v "^\*" | awk ' \ BEGIN { print } { slice=$1 tag=$2 flags=$3 sector_beg=$4 size_BLKS=$5 sector_end=$6 mount=$7 split (dev_perm, a) permissions=a[1] num_links=a[2] owner=a[3] group=a[4] size_BYTES=(size_BLKS*512) s_len=length(dev_link) # Get length of device dev_slice=substr(dev_link,s_len,s_len) # Get last character ? if (slice == dev_slice) printf "%-32s %2d %10d %-11s %-8s %-8s %-s\n", device, slice, size_BYTES, permissions, owner, group, dev_link } ' device=$DEVICE dev_link=$DEV_LINK dev_perm="$DEV_PERM" >> $OUTPUT done pg $OUTPUT