3 typeset
-i I ITERATIONS PHASE LOC COUNT MAXCOUNT
9 echo "$ME: Usage: $ME <iterations> <maxcount> <filesystem_image>" >&2
16 FIXED_FS_IMAGE
="/tmp/fixedfsimage.$$"
17 NEW_FS_IMAGE
="/tmp/newfsimage.$$"
19 if [ ! -f "$ORIG_FS_IMAGE" ]
21 echo "$ME: Filesystem image $NEW_FS_IMAGE does not exist" >&2
25 trap "rm -f $NEW_FS_IMAGE $FIXED_FS_IMAGE" 0 1 2 3 15
27 rm -f "$NEW_FS_IMAGE" "$FIXED_FS_IMAGE"
29 # Create the fixed image to compare against
30 cp "$ORIG_FS_IMAGE" "$FIXED_FS_IMAGE"
31 ext4fixup
"$FIXED_FS_IMAGE"
35 echo "$ME: ext4fixup failed!\n"
40 while [ "$I" -lt "$ITERATIONS" ]
42 # There is also a phase 4, which is writing out the updated superblocks and
43 # block group descriptors. Test the with a separate script.
44 let PHASE
="$RANDOM"%3 # 0 to 2
46 let LOC
="$RANDOM"%2 # 0 to 1
48 let COUNT
="$RANDOM"%"$MAXCOUNT"
50 # Make a copy of the original image to fixup
51 cp "$ORIG_FS_IMAGE" "$NEW_FS_IMAGE"
53 # Run the fixup tool, but die partway through to see if we can recover
54 ext4fixup
-d "$PHASE,$LOC,$COUNT" "$NEW_FS_IMAGE" 2>/dev
/null
56 # run it again without -d to have it finish the job
57 ext4fixup
"$NEW_FS_IMAGE"
59 if cmp "$FIXED_FS_IMAGE" "$NEW_FS_IMAGE"
63 echo "$ME: test failed with parameters $PHASE, $LOC, $COUNT"