/usr/bin/test_ext4fixup is in android-tools-fsutils 5.1.1.r38-1.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #!/bin/bash
typeset -i I ITERATIONS PHASE LOC COUNT MAXCOUNT
ME=`basename $0`
if [ "$#" -ne 3 ]
then
echo "$ME: Usage: $ME <iterations> <maxcount> <filesystem_image>" >&2
exit 1;
fi
ITERATIONS="$1"
MAXCOUNT="$2"
ORIG_FS_IMAGE="$3"
FIXED_FS_IMAGE="/tmp/fixedfsimage.$$"
NEW_FS_IMAGE="/tmp/newfsimage.$$"
if [ ! -f "$ORIG_FS_IMAGE" ]
then
echo "$ME: Filesystem image $NEW_FS_IMAGE does not exist" >&2
exit 1
fi
trap "rm -f $NEW_FS_IMAGE $FIXED_FS_IMAGE" 0 1 2 3 15
rm -f "$NEW_FS_IMAGE" "$FIXED_FS_IMAGE"
# Create the fixed image to compare against
cp "$ORIG_FS_IMAGE" "$FIXED_FS_IMAGE"
ext4fixup "$FIXED_FS_IMAGE"
if [ "$?" -ne 0 ]
then
echo "$ME: ext4fixup failed!\n"
exit 1
fi
I=0
while [ "$I" -lt "$ITERATIONS" ]
do
# There is also a phase 4, which is writing out the updated superblocks and
# block group descriptors. Test the with a separate script.
let PHASE="$RANDOM"%3 # 0 to 2
let PHASE++ # 1 to 3
let LOC="$RANDOM"%2 # 0 to 1
let LOC++ # 1 to 2
let COUNT="$RANDOM"%"$MAXCOUNT"
# Make a copy of the original image to fixup
cp "$ORIG_FS_IMAGE" "$NEW_FS_IMAGE"
# Run the fixup tool, but die partway through to see if we can recover
ext4fixup -d "$PHASE,$LOC,$COUNT" "$NEW_FS_IMAGE" 2>/dev/null
# run it again without -d to have it finish the job
ext4fixup "$NEW_FS_IMAGE"
if cmp "$FIXED_FS_IMAGE" "$NEW_FS_IMAGE"
then
:
else
echo "$ME: test failed with parameters $PHASE, $LOC, $COUNT"
exit 1
fi
rm -f "$NEW_FS_IMAGE"
let I++
done
|