File: dasdlist

package info (click to toggle)
hercules 3.13-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,392 kB
  • sloc: ansic: 175,124; sh: 8,792; makefile: 760; perl: 149
file content (61 lines) | stat: -rwxr-xr-x 1,368 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
#
# This command prints a track from a CKD DASD image file.
# It uses the Unix Octal Dump (od) command to obtain
# the device geometry from the CKD header, then xxd to
# print the track in hexadecimal format.
#
filename=$1
cyl=$2
head=$3

if [ -z "$filename" ]; then
    echo "Usage: dasdlist filename [cyl head]"
    exit 1
fi

if [ ! -f $filename ]; then
    echo "File $filename does not exist"
    exit 1
fi

#
# Check the first 8 bytes of the header for valid CKD DASD image file
#
ckdid=`head -n 1 $filename | cut -c1-8`
if [ $ckdid != "CKD_P370" ]; then
    echo "File $filename is not a CKD DASD image file"
    exit 2
fi

#
# The next 8 bytes contain the tracks/cyl and track length constants
#
heads=`od -An -tu4 -j 8 -N 4 $filename`
trklen=`od -An -tu4 -j 12 -N 4 $filename`

heads=`expr $heads`
trklen=`expr $trklen`

echo "$filename $heads trks/cyl, $trklen bytes/trk"

#
# If cylinder number is not given then exit
#
if [ -z "$cyl" ] || [ -z "$head" ]; then
    echo "To dump a track specify dasdlist $filename cyl head"
    exit 0
fi

#
# Calculate the offset to the requested cylinder and track
#
offset=`expr 512 + '(' $cyl '*' $heads + $head ')' '*' $trklen`
num=`expr $trklen`

#
# Dump the requested track
#
echo "$filename Cyl $cyl Head $head"
echo "xxd -E -g4 -u -s $offset -l $num $filename"
xxd -E -g4 -u -s $offset -l $num $filename