diff options
author | Nikolay Borisov <nborisov@suse.com> | 2018-05-14 14:13:32 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-06-07 16:37:39 +0200 |
commit | 98eda1c098a5300bccc9df636948f422d130f626 (patch) | |
tree | 063ab6f4d247691647fd49920e3f3fc82ade2fd5 /btrfs-corrupt-block.c | |
parent | 32acc8eed29847616f6d99d70b9dac1466e4ec4f (diff) |
btrfs-progs: corrupt-block: Add support for handling specific root when using -K option
Currently the -K option supports corrupting items only in the default
root (which is the root tree). This makes it impossible to test the
free-space recovery (or any other) code for that matter. Fix it by
using the root corresponding to the one passed in -r (if any).
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'btrfs-corrupt-block.c')
-rw-r--r-- | btrfs-corrupt-block.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c index f4543fa3..7576699c 100644 --- a/btrfs-corrupt-block.c +++ b/btrfs-corrupt-block.c @@ -114,7 +114,7 @@ static void print_usage(int ret) printf("\t-i The inode item to corrupt (must also specify the field to corrupt)\n"); printf("\t-x The file extent item to corrupt (must also specify -i for the inode and -f for the field to corrupt)\n"); printf("\t-m The metadata block to corrupt (must also specify -f for the field to corrupt)\n"); - printf("\t-K <u64,u8,u64> Corrupt the given key (must also specify -f for the field)\n"); + printf("\t-K <u64,u8,u64> Corrupt the given key (must also specify -f for the field and optionally -r for the root)\n"); printf("\t-f The field in the item to corrupt\n"); printf("\t-I <u64,u8,u64> Corrupt an item corresponding to the passed key triplet (must also specify the field to corrupt and root for the item)\n"); printf("\t-D Corrupt a dir item, must specify key and field\n"); @@ -449,7 +449,6 @@ static int corrupt_key(struct btrfs_root *root, struct btrfs_key *key, struct btrfs_trans_handle *trans; int ret; - root = root->fs_info->fs_root; if (corrupt_field == BTRFS_KEY_BAD) { fprintf(stderr, "Invalid field %s\n", field); return -EINVAL; @@ -1364,7 +1363,8 @@ int main(int argc, char **argv) if (should_corrupt_key) { if (*field == 0) print_usage(1); - ret = corrupt_key(root, &key, field); + + ret = corrupt_key(target_root, &key, field); goto out_close; } /* |