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