btrfs-progs: corrupt-block: Correctly handle -r when passing -I
The documentation for the -I option (corrupt an item) states: An item to corrupt (must also specify the field to corrupt and a root+key for the item) The code on the other hand doesn't check whether -r is in fact passed, and even if it is it's not handled at all. This means presently -I is possible to corrupt items only in the root tree. Fix this by correctly checking -r is passed and fail otherwise and passing the correct root to corrupt_btrfs_item. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
12087e6d75
commit
04be0e4b19
|
@ -1337,9 +1337,15 @@ int main(int argc, char **argv)
|
|||
goto out_close;
|
||||
}
|
||||
if (corrupt_item) {
|
||||
struct btrfs_root *target;
|
||||
if (!key.objectid)
|
||||
print_usage(1);
|
||||
ret = corrupt_btrfs_item(root, &key, field);
|
||||
if (!root_objectid)
|
||||
print_usage(1);
|
||||
|
||||
target = open_root(root->fs_info, root_objectid);
|
||||
|
||||
ret = corrupt_btrfs_item(target, &key, field);
|
||||
}
|
||||
if (delete) {
|
||||
struct btrfs_root *target = root;
|
||||
|
|
Loading…
Reference in New Issue