From: Sheng Yong <[email protected]>
Signed-off-by: Sheng Yong <[email protected]>
---
tests/f_ssa_bad_ofs_in_node/README | 5 ++++
tests/f_ssa_bad_ofs_in_node/expect.in | 3 +++
tests/f_ssa_bad_ofs_in_node/script | 36 +++++++++++++++++++++++++++
3 files changed, 44 insertions(+)
create mode 100644 tests/f_ssa_bad_ofs_in_node/README
create mode 100644 tests/f_ssa_bad_ofs_in_node/expect.in
create mode 100644 tests/f_ssa_bad_ofs_in_node/script
diff --git a/tests/f_ssa_bad_ofs_in_node/README
b/tests/f_ssa_bad_ofs_in_node/README
new file mode 100644
index 000000000000..65fbf6aa4f1b
--- /dev/null
+++ b/tests/f_ssa_bad_ofs_in_node/README
@@ -0,0 +1,5 @@
+1. create f2fs image
+2. mount f2fs and create a regular file and write data
+3. get a block address by dumping the inode
+4. inject ofs_in_node in the ssa entry of the blkaddr
+5. fsck fixes the ssa entry
diff --git a/tests/f_ssa_bad_ofs_in_node/expect.in
b/tests/f_ssa_bad_ofs_in_node/expect.in
new file mode 100644
index 000000000000..3164031aebae
--- /dev/null
+++ b/tests/f_ssa_bad_ofs_in_node/expect.in
@@ -0,0 +1,3 @@
+Info: Force to fix corruption
+[ASSERT] (is_valid_ssa_data_blk: x) --> Set data summary _SEGNO_ -> [_INO_]
[0x0] [_OFS_IN_NODE_]
+Info: Force to fix corruption
diff --git a/tests/f_ssa_bad_ofs_in_node/script
b/tests/f_ssa_bad_ofs_in_node/script
new file mode 100644
index 000000000000..1f5a60a2d342
--- /dev/null
+++ b/tests/f_ssa_bad_ofs_in_node/script
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+DESC="ssa entry with invalid ofs_in_node"
+
+. $TOPDIR/tests/helpers
+
+cleanup
+make_f2fs > $LOG
+
+mkdir $TESTDIR/mntdir
+safe_mount $MNT_OPTS $META $TESTDIR/mntdir >> $LOG
+dd if=/dev/zero of=$TESTDIR/mntdir/testfile bs=4K count=513 status=none
+ino=`stat -c "%i" $TESTDIR/mntdir/testfile`
+safe_umount $TESTDIR/mntdir >> $LOG
+rm -rf $TESTDIR/mntdir
+
+node=`$DUMP $DUMP_OPTS -i $ino $META`
+echo "$node" >> $LOG
+base=`echo "$node" | grep i_addr | head -n 1 | sed
's/i_addr\[\(0x[0-9a-f]\{1,\}\)\].*$/\1/g'`
+blkaddr=`get_mb_val "$node" 'i_addr\[0x100\]'`
+echo "ino:$ino blkaddr:$blkaddr" >> $LOG
+
+$INJECT --ssa --blk $blkaddr --mb ofs_in_node --val 99 $META >> $LOG
+$FSCK $FSCK_OPTS -f $META > $OUT
+$FSCK $FSCK_OPTS -f $META >> $OUT
+cat $OUT >> $LOG
+
+segno=`get_segno $blkaddr`
+SEGNO=`printf "0x%x" $segno`
+INO=`printf "0x%x" $ino`
+OFS_IN_NODE=`printf "0x%x" $((0x100 - base))`
+sed "s/_SEGNO_/$SEGNO/g" $TESTDIR/expect.in > $TESTDIR/expect
+sed -i "s/_INO_/$INO/g" $TESTDIR/expect
+sed -i "s/_OFS_IN_NODE_/$OFS_IN_NODE/g" $TESTDIR/expect
+
+check_result
--
2.43.0
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel