new file mode 100644
@@ -0,0 +1,3 @@
+1. create f2fs image
+2. inject magic in sb 1 with value 0x12345
+3. fsck fixes bad magic by copying sb 2
new file mode 100644
@@ -0,0 +1,40 @@
+Info: Force to fix corruption
+Magic Mismatch, valid(0xf2f52010) - read(0x12345)
+ Can't find a valid F2FS superblock at 0x0
+Looking for secondary superblock assuming 4K Block Size
+Info: Write valid nat_bits in checkpoint
+Info: checkpoint state = x : nat_bits compacted_summary unmount
+
+[FSCK] Unreachable nat entries [Ok..] [x]
+[FSCK] SIT valid block bitmap checking [Ok..]
+[FSCK] Hard link checking for regular file [Ok..] [x]
+[FSCK] valid_block_count matching with CP [Ok..] [x]
+[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x]
+[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x]
+[FSCK] valid_inode_count matched with CP [Ok..] [x]
+[FSCK] free segment_count matched with CP [Ok..] [x]
+[FSCK] next block offset is free [Ok..]
+[FSCK] fixing SIT types
+[FSCK] other corrupted bugs [Ok..]
+Info: Duplicate valid checkpoint to mirror position x -> x
+Info: Write valid nat_bits in checkpoint
+Info: write_checkpoint() cur_cp:x
+Info: Write valid nat_bits in checkpoint
+Info: fix_checkpoint() cur_cp:x
+[update_superblock: x] Info: Done to update superblock
+
+Info: Force to fix corruption
+Info: checkpoint state = x : allow_nocrc nat_bits unmount
+
+[FSCK] Unreachable nat entries [Ok..] [x]
+[FSCK] SIT valid block bitmap checking [Ok..]
+[FSCK] Hard link checking for regular file [Ok..] [x]
+[FSCK] valid_block_count matching with CP [Ok..] [x]
+[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x]
+[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x]
+[FSCK] valid_inode_count matched with CP [Ok..] [x]
+[FSCK] free segment_count matched with CP [Ok..] [x]
+[FSCK] next block offset is free [Ok..]
+[FSCK] fixing SIT types
+[FSCK] other corrupted bugs [Ok..]
+
new file mode 100644
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+DESC="superblock[1] with invalid magic number"
+
+. $TOPDIR/tests/helpers
+
+cleanup pre > $LOG 2>&1
+make_f2fs >> $LOG 2>&1
+
+$INJECT --sb 1 --mb magic --val 0x12345 $META >> $LOG 2>&1
+$FSCK $FSCK_OPTS -f $META > $OUT 2>&1
+$FSCK $FSCK_OPTS -f $META >> $OUT 2>&1
+cat $OUT >> $LOG
+
+check_result
+cleanup post >> $LOG 2>&1
Signed-off-by: Sheng Yong <shengyong@oppo.com> --- tests/f_sb_bad_magic/README | 3 +++ tests/f_sb_bad_magic/expect.in | 40 ++++++++++++++++++++++++++++++++++ tests/f_sb_bad_magic/script | 16 ++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 tests/f_sb_bad_magic/README create mode 100644 tests/f_sb_bad_magic/expect.in create mode 100644 tests/f_sb_bad_magic/script