aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSheng Yong <shengyong1@huawei.com>2016-01-30 09:16:39 +0000
committerluca020400 <luca.stefani.ge1@gmail.com>2016-04-04 17:16:18 +0200
commit936247546216eee702f9e5b63163f7d819f58c9a (patch)
tree4144e9d85ad513be120f454014ec1b9e4975f887
parent1f1a81f6b62380cd2635c44c777016fbd8fa84b3 (diff)
downloadandroid_external_f2fs-tools-936247546216eee702f9e5b63163f7d819f58c9a.tar.gz
android_external_f2fs-tools-936247546216eee702f9e5b63163f7d819f58c9a.tar.bz2
android_external_f2fs-tools-936247546216eee702f9e5b63163f7d819f58c9a.zip
fsck.f2fs: check ino of an inode
If the node is an inode, its ino in the nat entry should be equal to the ino in its node footer. Otherwise, we drop the file. Signed-off-by: Sheng Yong <shengyong1@huawei.com> Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fsck/fsck.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fsck/fsck.c b/fsck/fsck.c
index 3e5dd4e..99dfe1f 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -383,6 +383,11 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
le32_to_cpu(node_blk->footer.ino));
return -EINVAL;
}
+ if (ntype == TYPE_INODE && ni->ino != node_blk->footer.ino) {
+ ASSERT_MSG("nid[0x%x] TYPE_INODE nat_entry->ino[0x%x] footer.ino[0x%x]",
+ nid, ni->ino, le32_to_cpu(node_blk->footer.ino));
+ return -EINVAL;
+ }
if (ntype != TYPE_INODE &&
node_blk->footer.nid == node_blk->footer.ino) {
ASSERT_MSG("nid[0x%x] footer.nid[0x%x] footer.ino[0x%x]",