From: Sheng Yong <shengyo...@xiaomi.com> Signed-off-by: Sheng Yong <shengyo...@xiaomi.com> --- tests/f_dentry_dup_dots/README | 11 +++++++ tests/f_dentry_dup_dots/expect.in | 26 ++++++++++++++++ tests/f_dentry_dup_dots/script | 49 +++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 tests/f_dentry_dup_dots/README create mode 100644 tests/f_dentry_dup_dots/expect.in create mode 100644 tests/f_dentry_dup_dots/script
diff --git a/tests/f_dentry_dup_dots/README b/tests/f_dentry_dup_dots/README new file mode 100644 index 000000000000..e36526625ca6 --- /dev/null +++ b/tests/f_dentry_dup_dots/README @@ -0,0 +1,11 @@ +1. create f2fs image +2. mount f2fs +3. create a directory, and create a file in it +4. inject dot dentry in the directory by changing its d_ino to the dotdot's ino +5. fsck fixes the dot's d_ino +6. inject dotdot dentry in the directory by changing its d_ino to the dot's ino +7. fsck fixes the dotdot's d_ino +8. inject dot dentry in the directory by changing its filename to ".." +9. fsck fixes it by deleting duplicated dotdot dentry and adding a new dot dentry +10. inject dotdot dentry in the directory by changing its filename to "." +11. fsck fixes it by deleting duplicated dot dentry and adding a new dotdot dentry diff --git a/tests/f_dentry_dup_dots/expect.in b/tests/f_dentry_dup_dots/expect.in new file mode 100644 index 000000000000..5af443df7d12 --- /dev/null +++ b/tests/f_dentry_dup_dots/expect.in @@ -0,0 +1,26 @@ +Info: Force to fix corruption +[ASSERT] (__chk_dots_dentries:x) --> Bad inode number[_PINO_HEX_] for '.', parent_ino is [_INO_HEX_] +Info: Force to fix corruption +Info: Force to fix corruption +[ASSERT] (__chk_dots_dentries:x) --> Bad inode number[_INO_HEX_] for '..', parent parent ino is [_PINO_HEX_] +Info: Force to fix corruption +Info: Force to fix corruption +[ASSERT] (__chk_dots_dentries:x) --> Bad inode number[_INO_HEX_] for '..', parent parent ino is [_PINO_HEX_] +[ASSERT] (__chk_dentries:x) --> More than one '..', should delete the extra one, i: 1, ino:_PINO_DEC_ +[ASSERT] (fsck_chk_inode_blk:x) --> ino: _INO_HEX_ has no '.' and/or '..' dirents, dot: 0, dotdot: 1 +[FIX] (fsck_chk_inode_blk:x) --> convert inline dentry ino: _INO_DEC_, pino: _PINO_DEC_, ret: 0 +[FIX] (fsck_chk_inode_blk:x) --> add missing '.' dirent in ino: _INO_DEC_, pino: _PINO_DEC_, ret:0 +[fsck_chk_quota_files:x] Fixing Quota file ([ 0] ino [0x4]) +[FIX] (nullify_nat_entry:x) --> Remove nid [0x4] in NAT +[fsck_chk_quota_files:x] Fixing Quota file ([ 1] ino [0x5]) +[FIX] (nullify_nat_entry:x) --> Remove nid [0x5] in NAT +[fsck_chk_quota_files:x] Fixing Quota file ([ 2] ino [0x6]) +[FIX] (nullify_nat_entry:x) --> Remove nid [0x6] in NAT +Info: Force to fix corruption +Info: Force to fix corruption +[ASSERT] (__chk_dots_dentries:x) --> Bad inode number[_PINO_HEX_] for '.', parent_ino is [_INO_HEX_] +[ASSERT] (__chk_dentries:x) --> More than one '.', should delete the extra one, i: 1, ino:_INO_DEC_ +[ASSERT] (fsck_chk_inode_blk:x) --> ino: _INO_HEX_ has no '.' and/or '..' dirents, dot: 1, dotdot: 0 +[FIX] (fsck_chk_inode_blk:x) --> convert inline dentry ino: _INO_DEC_, pino: _PINO_DEC_, ret: 0 +[FIX] (fsck_chk_inode_blk:x) --> add missing '..' dirent in ino: _INO_DEC_, pino: _PINO_DEC_, ret:0 +Info: Force to fix corruption diff --git a/tests/f_dentry_dup_dots/script b/tests/f_dentry_dup_dots/script new file mode 100644 index 000000000000..881bb50f8705 --- /dev/null +++ b/tests/f_dentry_dup_dots/script @@ -0,0 +1,49 @@ +#!/bin/bash + +DESC="directory duplicated dot or dotdot" + +. $TOPDIR/tests/helpers + +cleanup +make_f2fs > $LOG + +mkdir $TESTDIR/mntdir +safe_mount $MNT_OPTS $META $TESTDIR/mntdir >> $LOG +mkdir $TESTDIR/mntdir/testdir +touch $TESTDIR/mntdir/testdir/testfile +ino=`stat -c "%i" $TESTDIR/mntdir/testdir` +pino=`stat -c "%i" $TESTDIR/mntdir/testdir/..` +safe_umount $TESTDIR/mntdir >> $LOG +rm -rf $TESTDIR/mntdir + +echo "ino:$ino pino:$pino" >> $LOG + +# inject dot's d_ino +$INJECT --dent --nid $ino --mb d_ino --dots 1 --val $pino $META >> $LOG +$FSCK $FSCK_OPTS -f $META > $OUT +$FSCK $FSCK_OPTS -f $META >> $OUT + +# inject dotdot's d_ino +$INJECT --dent --nid $ino --mb d_ino --dots 2 --val $ino $META >> $LOG +$FSCK $FSCK_OPTS -f $META >> $OUT +$FSCK $FSCK_OPTS -f $META >> $OUT + +# inject dot's filename +$INJECT --dent --nid $ino --mb filename --dots 1 --str ".." $META >> $LOG +$FSCK $FSCK_OPTS -f $META >> $OUT +$FSCK $FSCK_OPTS -f $META >> $OUT + +# inject dotdot's filename +$INJECT --dent --nid $ino --mb filename --dots 2 --str "." $META >> $LOG +$FSCK $FSCK_OPTS -f $META >> $OUT +$FSCK $FSCK_OPTS -f $META >> $OUT +cat $OUT >> $LOG + +INO_HEX=`printf "0x%x" $ino` +PINO_HEX=`printf "0x%x" $pino` +sed "s/_INO_DEC_/$ino/g" $TESTDIR/expect.in > $TESTDIR/expect +sed -i "s/_PINO_DEC_/$pino/g" $TESTDIR/expect +sed -i "s/_INO_HEX_/$INO_HEX/g" $TESTDIR/expect +sed -i "s/_PINO_HEX_/$PINO_HEX/g" $TESTDIR/expect + +check_result -- 2.43.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel