diff options
author | Su Yue <suy.fnst@cn.fujitsu.com> | 2017-07-14 15:47:45 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-08-24 19:07:51 +0200 |
commit | 7f3ba48000997c5a11e5ab8d3438d2e10c319702 (patch) | |
tree | 9c2a31349186f1ec130777654aab5d46a6b57b1e /cmds-check.c | |
parent | d4833d709b338df0edf7a721a155e9e00723911a (diff) |
btrfs-progs: check: verify dir item name and hash in lowmem mode
Although lowmem mode can detect name and hash mismatch in dir_item,
it's done by checking inode_ref to expose such problem.
This patch will enhance dir_item check, by also comparing name and
hash when checking dir_items.
Reported-by: Filippe LeMarchand <gasinvein@gmail.com>
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-check.c')
-rw-r--r-- | cmds-check.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/cmds-check.c b/cmds-check.c index 48e9a070..acd22f0a 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -4680,6 +4680,15 @@ static int check_dir_item(struct btrfs_root *root, struct btrfs_key *key, read_extent_buffer(node, namebuf, (unsigned long)(di + 1), len); filetype = btrfs_dir_type(node, di); + if (key->type == BTRFS_DIR_ITEM_KEY && + key->offset != btrfs_name_hash(namebuf, len)) { + err |= -EIO; + error("root %llu DIR_ITEM[%llu %llu] name %s namelen %u filetype %u mismatch with its hash, wanted %llu have %llu", + root->objectid, key->objectid, key->offset, + namebuf, len, filetype, key->offset, + btrfs_name_hash(namebuf, len)); + } + btrfs_init_path(&path); btrfs_dir_item_key_to_cpu(node, di, &location); |