blob: a000c85e5941372009d764c54091d60f67b9e406 (
plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
#!/bin/sh
# old distros are missing "truncate", emulate it with "dd" if necessary
do_truncate()
{
[ "$1" = "-s" ] && size=$2 && shift 2
if ! truncate -s $size $1 >> $LOG 2>&1 ; then
dd if=/dev/zero of=$1 bs=1 count=0 seek=$size >> $LOG 2>&1
fi
}
resize_test () {
DBG_FLAGS=63
echo $test_description starting > $LOG
rm -f $TMPFILE
touch $TMPFILE
# Verify that the $TMP filesystem handles $SIZE_2 sparse files.
# If that fails, try the local filesystem instead.
if do_truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then
echo "using $TMPFILE" >> $LOG
else
rm $TMPFILE
export TMPFILE=$(mktemp ./$test_name.tmp.XXXXXX)
touch $TMPFILE
echo "using $TMPFILE" >> $LOG
if ! do_truncate -s $SIZE_2 $TMPFILE >> $LOG 2>&1; then
rm $TMPFILE
return 111
fi
fi
> $TMPFILE
echo $MKE2FS $FEATURES -qF $TMPFILE $SIZE_1 >> $LOG
$MKE2FS $FEATURES -qF $TMPFILE $SIZE_1 >> $LOG
OUT_TMP=$(mktemp ${TMPDIR:-/tmp}/csum-tmp.XXXXXX)
date > $OUT_TMP
cat $E2FSCK >> $OUT_TMP
echo $CRCSUM $OUT_TMP >> $LOG 2>&1
CSUM_1=$($CRCSUM $OUT_TMP)
echo Checksum is $CSUM_1 >> $LOG
echo Setting up file system >> $LOG
$DEBUGFS -w $TMPFILE >> $LOG 2>&1 << EOF
mkdir test
cd test
write $OUT_TMP e2fsck
ls /test
stat /test/e2fsck
quit
EOF
echo " " >> $LOG
rm -f $OUT_TMP
echo $FSCK -fy $TMPFILE >> $LOG 2>&1
$FSCK -fy $TMPFILE >> $LOG 2>&1
chmod u-w $TMPFILE
echo $RESIZE2FS -P $TMPFILE >> $LOG 2>&1
if ! $RESIZE2FS -P $TMPFILE >> $LOG 2>&1
then
return 1
fi
chmod u+w $TMPFILE
echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS $TMPFILE $SIZE_2 >> $LOG 2>&1
if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS $TMPFILE $SIZE_2 >> $LOG 2>&1
then
return 1
fi
echo $FSCK -fy $TMPFILE >> $LOG 2>&1
if ! $FSCK -fy $TMPFILE >> $LOG 2>&1
then
$DUMPE2FS $TMPFILE >> $LOG
return 1
fi
echo $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
echo $CRCSUM $OUT_TMP >> $LOG 2>&1
CSUM_2=$($CRCSUM $OUT_TMP)
echo Checksum is $CSUM_2 >> $LOG
if test "$CSUM_1" != "$CSUM_2"
then
return 1
fi
# Uncomment to grab extra debugging image
#
#mv $TMPFILE /tmp/foo.img
#return 0
echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
then
return 1
fi
echo $FSCK -fy $TMPFILE >> $LOG 2>&1
if ! $FSCK -fy $TMPFILE >> $LOG 2>&1
then
$DUMPE2FS $TMPFILE >> $LOG
return 1
fi
echo $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
echo $CRCSUM $OUT_TMP >> $LOG 2>&1
CSUM_2=$($CRCSUM $OUT_TMP)
echo Checksum is $CSUM_2 >> $LOG
if test "$CSUM_1" != "$CSUM_2"
then
return 1
fi
echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
then
return 1
fi
echo $FSCK -fy $TMPFILE >> $LOG 2>&1
if ! $FSCK -fy $TMPFILE >> $LOG 2>&1
then
$DUMPE2FS $TMPFILE >> $LOG
return 1
fi
echo $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
echo $CRCSUM $OUT_TMP >> $LOG 2>&1
CSUM_2=$($CRCSUM $OUT_TMP)
echo Checksum is $CSUM_2 >> $LOG
if test "$CSUM_1" != "$CSUM_2"
then
return 1
fi
echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
then
return 1
fi
echo $FSCK -fy $TMPFILE >> $LOG 2>&1
if ! $FSCK -fy $TMPFILE >> $LOG 2>&1
then
$DUMPE2FS $TMPFILE >> $LOG
return 1
fi
echo $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
echo $CRCSUM $OUT_TMP >> $LOG 2>&1
CSUM_2=$($CRCSUM $OUT_TMP)
echo Checksum is $CSUM_2 >> $LOG
rm $OUT_TMP
unset OUT_TMP
rm -f $TMPFILE
if test "$CSUM_1" != "$CSUM_2"
then
return 1
fi
return 0
}
|