Fix btrfsck args checking

btrfsck fails to check if it actually received a dev argument though, so if you
don't pass a device, we get a nice segfault.
master
Kyle McMartin 2008-01-22 11:32:09 -05:00 committed by David Woodhouse
parent fd4bca3dfe
commit d751af515b
1 changed files with 8 additions and 0 deletions

View File

@ -709,6 +709,11 @@ int check_extent_refs(struct btrfs_root *root,
return err;
}
void print_usage(void) {
fprintf(stderr, "usage: btrfsck dev\n");
exit(1);
}
int main(int ac, char **av) {
struct btrfs_root *root;
struct cache_tree extent_cache;
@ -727,6 +732,9 @@ int main(int ac, char **av) {
int slot;
struct btrfs_root_item ri;
if (ac < 2)
print_usage();
radix_tree_init();
cache_tree_init(&extent_cache);
cache_tree_init(&seen);