1test_description="e2undo with debugfs -z"
2if ! test -x $E2UNDO_EXE -o ! -x $DEBUGFS_EXE; then
3	echo "$test_name: $test_description: skipped (no debugfs/e2undo)"
4	return 0
5fi
6
7TDB_FILE=${TMPDIR:-/tmp}/tune2fs-$(basename $TMPFILE).e2undo
8OUT=$test_name.log
9rm -f $TDB_FILE >/dev/null 2>&1
10
11dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
12
13echo mke2fs -q -F -o Linux -T ext4 -O ^metadata_csum,64bit -E lazy_itable_init=1 -b 1024 $TMPFILE  > $OUT
14$MKE2FS -q -F -o Linux -T ext4 -O ^metadata_csum,64bit -E lazy_itable_init=1 -b 1024 $TMPFILE  >> $OUT 2>&1
15crc0=`$CRCSUM $TMPFILE`
16echo $CRCSUM before debugfs $crc0 >> $OUT
17
18echo using debugfs to test e2undo >> $OUT
19$DEBUGFS -w -z $TDB_FILE -R 'zap -p 0x55 0' $TMPFILE >> $OUT 2>&1
20crc1=`$CRCSUM $TMPFILE`
21echo $CRCSUM after debugfs $crc1 >> $OUT
22
23$E2UNDO  $TDB_FILE $TMPFILE  >> $OUT 2>&1
24crc2=`$CRCSUM $TMPFILE`
25echo $CRCSUM after e2undo $crc2 >> $OUT
26
27if [ $crc0 = $crc2 ] && [ $crc1 != $crc2 ]; then
28	echo "$test_name: $test_description: ok"
29	touch $test_name.ok
30else
31	ln -f $test_name.log $test_name.failed
32	echo "$test_name: $test_description: failed"
33fi
34rm -f $TDB_FILE $TMPFILE
35