| 1 |
#!/bin/sh |
| 2 |
#$Id$ |
| 3 |
# Create Adobe-PostScript file that graphically displays the output of |
| 4 |
# dumpe2fs(8). Use "dumpe2fs | dconf" to create a PostScript file on stdout. |
| 5 |
# Developed and tested for Linux 1.0. |
| 6 |
# Copyright (c) 1994 |
| 7 |
# Ulrich Windl |
| 8 |
# ALte Regensburger Strasse 11a |
| 9 |
# D-93149 Nittenau, Germany |
| 10 |
# <[email protected]> |
| 11 |
SELF=`basename $0` |
| 12 |
AWKFILE=/tmp/${SELF}.awk |
| 13 |
TEMPFILE=/tmp/${SELF}.tmp |
| 14 |
echo ' |
| 15 |
BEGIN { |
| 16 |
print "B" |
| 17 |
} |
| 18 |
/^Inode count:/ { |
| 19 |
ic=$3; next |
| 20 |
} |
| 21 |
/^Block count:/ { |
| 22 |
bc=$3; next |
| 23 |
} |
| 24 |
/^First block:/ { |
| 25 |
fb=$3; next |
| 26 |
} |
| 27 |
/^Block size:/ { |
| 28 |
bs=$3; next |
| 29 |
} |
| 30 |
/^Blocks per group:/ { |
| 31 |
bpg=$4 |
| 32 |
printf("BC %d\n", bpg) |
| 33 |
printf("GC %d\n", (bc + bpg - 1) / bpg) |
| 34 |
next |
| 35 |
} |
| 36 |
/^Inodes per group:/ { |
| 37 |
ipg=$4; next |
| 38 |
} |
| 39 |
/^Last write time:/ { |
| 40 |
lwtime=$0; gsub("Last write time:[ ]+", "", lwtime) |
| 41 |
printf("T %s\n", lwtime) |
| 42 |
next |
| 43 |
} |
| 44 |
/^Group [0-9]+:/ { |
| 45 |
group=$2; gsub(":", "", group) |
| 46 |
block="" |
| 47 |
group_start=group*bpg+fb |
| 48 |
group_end=group_start+bpg |
| 49 |
printf("G %d : %d - %d\n", group, group_start, group_end) |
| 50 |
next |
| 51 |
} |
| 52 |
/^[ ]+Free blocks: / { |
| 53 |
for ( i=3; i < NF; ++i ) { |
| 54 |
block=$i; gsub(",", "", block) |
| 55 |
if ( index(block, "-") == 0 ) block=block "-" block |
| 56 |
pos=index(block, "-") |
| 57 |
printf("FB %d-%d\n", |
| 58 |
substr(block, 0, pos) - group_start, |
| 59 |
substr(block, pos + 1) - group_start) |
| 60 |
} |
| 61 |
if ( block == "" ) printf("Group %d is full\n", group) |
| 62 |
print "----" |
| 63 |
next |
| 64 |
} |
| 65 |
END { |
| 66 |
printf("E %s\n", lwtime) |
| 67 |
}' >$AWKFILE |
| 68 |
awk -f $AWKFILE $* >$TEMPFILE |
| 69 |
echo ' |
| 70 |
BEGIN { |
| 71 |
printf("%%!PS-Adobe\n") |
| 72 |
printf("%%%%BoundingBox: 0 0 1 1\n") |
| 73 |
printf("/rect {/y2 exch def /x2 exch def /y1 exch def /x1 exch def\n") |
| 74 |
printf(" newpath x1 y1 moveto x2 y1 lineto x2 y2 lineto\n") |
| 75 |
printf(" x1 y2 lineto closepath} def\n") |
| 76 |
printf("/fb {rect gsave 1.0 setgray fill grestore} def\n") |
| 77 |
printf("/dg {rect gsave gsave 0.0 setgray fill grestore\n") |
| 78 |
printf(" 0.5 setgray stroke grestore} def\n") |
| 79 |
printf("/textxy {moveto show} bind def\n") |
| 80 |
printf("0.0001 setlinewidth\n") |
| 81 |
} |
| 82 |
$1 == "GC" && NF == 2 { |
| 83 |
number_of_groups=$2 |
| 84 |
printf("/Times-Roman findfont %g scalefont setfont\n", |
| 85 |
1.0 / number_of_groups) |
| 86 |
next |
| 87 |
} |
| 88 |
$1 == "BC" && NF == 2 { |
| 89 |
blocks_per_group=$2; next |
| 90 |
} |
| 91 |
$1 == "T" && NF > 1 { |
| 92 |
printf("(%s) %g %g textxy\n", |
| 93 |
substr($0, 2), 0, 1.02) |
| 94 |
next |
| 95 |
} |
| 96 |
$1 == "G" && NF == 6 && $3 == ":" && $5 == "-" { |
| 97 |
group_index=$2 |
| 98 |
gs=$4 |
| 99 |
ge=$6 |
| 100 |
height=1.0 / number_of_groups |
| 101 |
vstart=group_index * height |
| 102 |
printf("%% group %d of %d:\n0 %g 1 %g dg\n", |
| 103 |
group_index, number_of_groups, vstart, vstart + height) |
| 104 |
printf("(Group %s) 1.02 %g textxy\n", group_index, vstart) |
| 105 |
next |
| 106 |
} |
| 107 |
$1 == "FB" && NF == 2 { |
| 108 |
pos = index($2, "-") |
| 109 |
printf("%% hole %s\n%g %g %g %g fb\n", |
| 110 |
$2, substr($2, 0, pos) / blocks_per_group, vstart, |
| 111 |
(substr($2, pos + 1) + 1) / blocks_per_group, vstart + height) |
| 112 |
next |
| 113 |
} |
| 114 |
END { |
| 115 |
printf("%%%%EOF\n") |
| 116 |
} |
| 117 |
' >$AWKFILE |
| 118 |
awk -f $AWKFILE $TEMPFILE |