1 test_description="e2undo with the offset option (-o offset)"
3 TMPFILE2="${TMPFILE}_2"
4 TDB_FILE="$TMPFILE.e2undo"
6 E2UNDO_FEATURE_COMPAT_OFFSET=1
8 trap "rm -f $TMPFILE2 $TDB_FILE" EXIT INT QUIT
11 # $2 is just used as a dummy - it is never used by e2undo
12 # when dumping the header
13 $E2UNDO -h "$1" "$2" | grep "^$3:"
16 read_header_offset() {
17 read_header_entry "$TDB_FILE" "$TMPFILE" "fs offset" | cut -f2
20 read_header_compat() {
21 read_header_entry "$TDB_FILE" "$TMPFILE" "compat" | cut -f3
24 e2undo_offset_assert() {
25 if [ "$crc_exp" != "$crc_act" -o \
26 "$offset_exp" != "$offset_act" -o \
27 $(($compat_act & $E2UNDO_FEATURE_COMPAT_OFFSET)) -ne $compat_exp ]
29 echo "$1" >> "$test_name.failed"
30 echo "crc_exp: $crc_exp" >> "$test_name.failed"
31 echo "crc_act: $crc_act" >> "$test_name.failed"
32 echo "offset_exp: $offset_exp" >> "$test_name.failed"
33 echo "offset_act: $offset_act" >> "$test_name.failed"
34 echo "compat_exp: $compat_exp" >> "$test_name.failed"
35 echo "compat_act: $compat_act" >> "$test_name.failed"
41 echo "# init fs for $1" >> "$OUT"
44 dd if=/dev/zero of="$TMPFILE" bs=1k count=1024 > /dev/null 2>&1
45 $MKE2FS -F -z "$TDB_FILE" -b 1024 -E offset=524288 "$TMPFILE" 512 \
50 # test absence of the "-o N" option
52 test_e2undo_offset_no_option() {
53 init_fs "test_e2undo_offset_no_option"
55 $E2UNDO "$TDB_FILE" "$TMPFILE" >> "$OUT" 2>&1
57 crc_exp=`dd if=/dev/zero bs=1k count=1024 2>/dev/null | $CRCSUM`
58 crc_act=`$CRCSUM "$TMPFILE"`
60 offset_act=`read_header_offset`
61 compat_exp=$E2UNDO_FEATURE_COMPAT_OFFSET
62 compat_act=`read_header_compat`
63 e2undo_offset_assert "test_e2undo_offset_no_option"
67 # test removal of the offset feature in the undo header
69 test_e2undo_offset_no_option_remove_offset_header() {
70 init_fs "test_e2undo_offset_no_option_remove_offset_header"
71 dd if="$TMPFILE" of="$TMPFILE2" bs=1k count=512 skip=512 \
73 # offset feature will be removed from the undo header
74 $TUNE2FS -z "$TDB_FILE" -C 42 "$TMPFILE2" >> "$OUT" 2>&1
76 $E2UNDO "$TDB_FILE" "$TMPFILE2" >> "$OUT" 2>&1
78 crc_exp=`dd if=/dev/zero bs=1k count=512 2>/dev/null | $CRCSUM`
79 crc_act=`$CRCSUM "$TMPFILE2"`
81 offset_act=`read_header_offset`
83 compat_act=`read_header_compat`
84 e2undo_offset_assert "test_e2undo_offset_no_option_remove_offset_header"
90 test_e2undo_offset_4096() {
91 init_fs "test_e2undo_offset_4096"
92 dd if=/dev/zero of="$TMPFILE2" bs=1k count=4 > /dev/null 2>&1
93 dd if="$TMPFILE" of="$TMPFILE2" bs=1k count=512 skip=512 seek=4 \
96 $E2UNDO -o 4096 "$TDB_FILE" "$TMPFILE2" >> "$OUT" 2>&1
98 crc_exp=`dd if=/dev/zero bs=1k count=516 2>/dev/null | $CRCSUM`
99 crc_act=`$CRCSUM "$TMPFILE2"`
100 # the same as in test_e2undo_offset_no_option
102 offset_act=`read_header_offset`
103 compat_exp=$E2UNDO_FEATURE_COMPAT_OFFSET
104 compat_act=`read_header_compat`
105 e2undo_offset_assert "test_e2undo_offset_4096"
111 test_e2undo_offset_0() {
112 init_fs "test_e2undo_offset_0"
113 dd if="$TMPFILE" of="$TMPFILE2" bs=1k count=512 skip=512 \
116 $E2UNDO -o 0 "$TDB_FILE" "$TMPFILE2" >> "$OUT" 2>&1
118 crc_exp=`dd if=/dev/zero bs=1k count=512 2>/dev/null | $CRCSUM`
119 crc_act=`$CRCSUM "$TMPFILE2"`
120 # the same as in test_e2undo_offset_no_option
122 offset_act=`read_header_offset`
123 compat_exp=$E2UNDO_FEATURE_COMPAT_OFFSET
124 compat_act=`read_header_compat`
125 e2undo_offset_assert "test_e2undo_offset_0"
128 test_e2undo_offset_no_option
129 test_e2undo_offset_no_option_remove_offset_header
130 test_e2undo_offset_4096
133 if [ -e "$test_name.failed" ]; then
134 echo "$test_name: $test_description: failed"
136 echo "$test_name: $test_description: ok"
137 touch "$test_name.ok"