2009-10-19 00:27:52 +05:30
|
|
|
#!/bin/sh
|
|
|
|
|
2009-10-20 20:34:55 +05:30
|
|
|
system_mke2fs='/sbin/mke2fs'
|
|
|
|
bbox_mke2fs='./busybox mke2fs'
|
|
|
|
|
|
|
|
gen_image() { # params: mke2fs_invocation image_name
|
2009-10-20 03:36:03 +05:30
|
|
|
>$2
|
|
|
|
dd seek=$((kilobytes-1)) bs=1K count=1 </dev/zero of=$2 >/dev/null 2>&1 || exit 1
|
|
|
|
$1 -F $2 $kilobytes >$2.raw_out 2>&1 || return 1
|
|
|
|
cat $2.raw_out \
|
|
|
|
| grep -v '^mke2fs [0-9]*\.[0-9]*\.[0-9]* ' \
|
2009-10-19 00:27:52 +05:30
|
|
|
| grep -v '^Maximum filesystem' \
|
|
|
|
| grep -v '^Writing inode tables' \
|
|
|
|
| grep -v '^Writing superblocks and filesystem accounting information' \
|
|
|
|
| grep -v '^This filesystem will be automatically checked every' \
|
|
|
|
| grep -v '^180 days, whichever comes first' \
|
2009-10-20 03:36:03 +05:30
|
|
|
| sed 's/blocks* unused./blocks unused/' \
|
|
|
|
| sed 's/block groups*/block groups/' \
|
2009-10-19 00:27:52 +05:30
|
|
|
| sed 's/ *$//' \
|
|
|
|
| sed 's/blocks (.*%) reserved/blocks reserved/' \
|
|
|
|
| grep -v '^$' \
|
2009-10-20 03:36:03 +05:30
|
|
|
>$2.out
|
|
|
|
}
|
2009-10-19 00:27:52 +05:30
|
|
|
|
2009-10-20 03:36:03 +05:30
|
|
|
test_mke2fs() {
|
|
|
|
echo Testing $kilobytes
|
|
|
|
|
2009-10-20 20:34:55 +05:30
|
|
|
gen_image "$system_mke2fs" image_std || return 1
|
|
|
|
gen_image "$bbox_mke2fs" image_bb || return 1
|
2009-10-19 00:27:52 +05:30
|
|
|
|
|
|
|
diff -ua image_bb.out image_std.out >image.out.diff || {
|
|
|
|
cat image.out.diff
|
|
|
|
return 1
|
|
|
|
}
|
2009-10-20 03:36:03 +05:30
|
|
|
|
2009-10-20 20:34:55 +05:30
|
|
|
e2fsck -f -n image_bb >image_bb_e2fsck.out 2>&1 || {
|
2009-10-20 17:04:16 +05:30
|
|
|
echo "e2fsck error on image_bb"
|
2009-10-20 20:34:55 +05:30
|
|
|
cat image_bb_e2fsck.out
|
2009-10-20 17:04:16 +05:30
|
|
|
exit 1
|
|
|
|
}
|
2009-10-19 00:27:52 +05:30
|
|
|
}
|
|
|
|
|
2009-10-20 20:34:55 +05:30
|
|
|
# -:bbox +:standard
|
|
|
|
|
2009-10-20 21:17:23 +05:30
|
|
|
# kilobytes=60 is the minimal allowed size
|
2009-10-20 19:51:29 +05:30
|
|
|
kilobytes=60
|
2009-10-20 17:04:16 +05:30
|
|
|
while true; do
|
2009-10-20 20:34:55 +05:30
|
|
|
test_mke2fs || exit 1
|
2009-10-20 17:04:16 +05:30
|
|
|
: $((kilobytes++))
|
2009-10-20 21:17:23 +05:30
|
|
|
test $kilobytes = 200 && break
|
|
|
|
done
|
|
|
|
|
|
|
|
# Transition from one block group to two
|
|
|
|
# fails in [8378..8410] range
|
2009-10-21 01:42:11 +05:30
|
|
|
kilobytes=$((1 * 8*1024 - 50))
|
2009-10-20 21:17:23 +05:30
|
|
|
while true; do
|
|
|
|
test_mke2fs #|| exit 1
|
|
|
|
: $((kilobytes++))
|
2009-10-21 01:42:11 +05:30
|
|
|
test $kilobytes = $((1 * 8*1024 + 300)) && break
|
2009-10-20 21:17:23 +05:30
|
|
|
done
|
|
|
|
|
2009-10-21 01:42:11 +05:30
|
|
|
# Transition from 2 block groups to 3
|
2009-10-20 21:17:23 +05:30
|
|
|
# works
|
2009-10-21 01:42:11 +05:30
|
|
|
kilobytes=$((2 * 8*1024 - 50))
|
2009-10-20 21:17:23 +05:30
|
|
|
while true; do
|
|
|
|
test_mke2fs || exit 1
|
|
|
|
: $((kilobytes++))
|
2009-10-21 01:42:11 +05:30
|
|
|
test $kilobytes = $((2 * 8*1024 + 400)) && break
|
2009-10-20 17:04:16 +05:30
|
|
|
done
|
2009-10-20 03:36:03 +05:30
|
|
|
|
2009-10-21 01:42:11 +05:30
|
|
|
# Transition from 3 block groups to 4
|
|
|
|
# fails in [24825..24922] range
|
|
|
|
kilobytes=$((3 * 8*1024 - 50))
|
|
|
|
while true; do
|
|
|
|
test_mke2fs #|| exit 1
|
|
|
|
: $((kilobytes++))
|
|
|
|
test $kilobytes = $((3 * 8*1024 + 500)) && break
|
|
|
|
done
|
2009-10-20 03:36:03 +05:30
|
|
|
|
2009-10-21 01:42:11 +05:30
|
|
|
# Transition from 4 block groups to 5
|
|
|
|
# works
|
|
|
|
kilobytes=$((4 * 8*1024 - 50))
|
|
|
|
while true; do
|
|
|
|
test_mke2fs || exit 1
|
|
|
|
: $((kilobytes++))
|
|
|
|
test $kilobytes = $((4 * 8*1024 + 600)) && break
|
|
|
|
done
|
2009-10-19 00:27:52 +05:30
|
|
|
|
2009-10-21 01:42:11 +05:30
|
|
|
# Transition from 5 block groups to 6
|
|
|
|
# fails in [41230..41391] range
|
|
|
|
kilobytes=$((5 * 8*1024 - 50))
|
|
|
|
while true; do
|
|
|
|
test_mke2fs #|| exit 1
|
|
|
|
: $((kilobytes++))
|
|
|
|
test $kilobytes = $((5 * 8*1024 + 700)) && break
|
|
|
|
done
|
|
|
|
exit
|
2009-10-20 17:04:16 +05:30
|
|
|
|
2009-10-21 01:42:11 +05:30
|
|
|
# Random sizes
|
2009-10-19 00:27:52 +05:30
|
|
|
while true; do
|
2009-10-20 17:04:16 +05:30
|
|
|
kilobytes=$(( (RANDOM*RANDOM) % 1000000 + 60))
|
2009-10-19 00:27:52 +05:30
|
|
|
test_mke2fs || exit 1
|
|
|
|
done
|