mirror of
https://github.com/kdave/btrfs-progs
synced 2025-05-02 07:57:58 +00:00
btrfs-progs: corrupt-block: Convert -K flag argument handling to common function
There is now a common function used to parse btrfs keys triplets so use that one. No functional changes. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
3fa8b8ca45
commit
f7a27396cf
@ -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-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-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-m The metadata block to corrupt (must also specify -f for the field to corrupt)\n");
|
||||||
printf("\t-K The key to corrupt in the format <num>,<num>,<num> (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)\n");
|
||||||
printf("\t-f The field in the item to corrupt\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-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");
|
printf("\t-D Corrupt a dir item, must specify key and field\n");
|
||||||
@ -1129,6 +1129,7 @@ int main(int argc, char **argv)
|
|||||||
int corrupt_item = 0;
|
int corrupt_item = 0;
|
||||||
int corrupt_di = 0;
|
int corrupt_di = 0;
|
||||||
int delete = 0;
|
int delete = 0;
|
||||||
|
int should_corrupt_key = 0;
|
||||||
u64 metadata_block = 0;
|
u64 metadata_block = 0;
|
||||||
u64 inode = 0;
|
u64 inode = 0;
|
||||||
u64 file_extent = (u64)-1;
|
u64 file_extent = (u64)-1;
|
||||||
@ -1207,15 +1208,8 @@ int main(int argc, char **argv)
|
|||||||
metadata_block = arg_strtou64(optarg);
|
metadata_block = arg_strtou64(optarg);
|
||||||
break;
|
break;
|
||||||
case 'K':
|
case 'K':
|
||||||
ret = sscanf(optarg, "%llu,%u,%llu",
|
should_corrupt_key = 1;
|
||||||
&key.objectid,
|
parse_key(&key.objectid, &key.type, &key.offset);
|
||||||
(unsigned int *)&key.type,
|
|
||||||
&key.offset);
|
|
||||||
if (ret != 3) {
|
|
||||||
fprintf(stderr, "error reading key "
|
|
||||||
"%d\n", errno);
|
|
||||||
print_usage(1);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
corrupt_di = 1;
|
corrupt_di = 1;
|
||||||
@ -1370,7 +1364,7 @@ int main(int argc, char **argv)
|
|||||||
ret = delete_item(target, &key);
|
ret = delete_item(target, &key);
|
||||||
goto out_close;
|
goto out_close;
|
||||||
}
|
}
|
||||||
if (key.objectid || key.offset || key.type) {
|
if (should_corrupt_key) {
|
||||||
if (*field == 0)
|
if (*field == 0)
|
||||||
print_usage(1);
|
print_usage(1);
|
||||||
ret = corrupt_key(root, &key, field);
|
ret = corrupt_key(root, &key, field);
|
||||||
|
Loading…
Reference in New Issue
Block a user