aboutsummaryrefslogtreecommitdiffstats
path: root/fsck
diff options
context:
space:
mode:
authorSheng Yong <shengyong1@huawei.com>2016-01-30 09:16:39 +0000
committerSteve Kondik <steve@cyngn.com>2016-08-24 11:43:29 -0700
commit0f523032f4bb1d33187854f293c3f17cc260f92c (patch)
tree8b87f66eaa8be98cee51f2197dd8fe379f02c7f3 /fsck
parent53294f841613f2faeac2cd9098f356ff380725f8 (diff)
downloadandroid_external_f2fs-tools-0f523032f4bb1d33187854f293c3f17cc260f92c.tar.gz
android_external_f2fs-tools-0f523032f4bb1d33187854f293c3f17cc260f92c.tar.bz2
android_external_f2fs-tools-0f523032f4bb1d33187854f293c3f17cc260f92c.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>
Diffstat (limited to 'fsck')
-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]",