summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle McMartin <kyle@mcmartin.ca>2008-01-22 11:32:09 -0500
committerDavid Woodhouse <dwmw2@hera.kernel.org>2008-01-22 11:32:09 -0500
commitd751af515b0ebe94a00b195d8510fc3770dadcef (patch)
tree29097deba53debfd9d500011a173f2f41b4fb647
parentfd4bca3dfea947f7031721be0a6ebf365b313fb8 (diff)
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.
-rw-r--r--btrfsck.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/btrfsck.c b/btrfsck.c
index 4bfa55c5..a3f803e9 100644
--- a/btrfsck.c
+++ b/btrfsck.c
@@ -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);