summaryrefslogtreecommitdiff
path: root/btrfs-debug-tree.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-06-11 00:04:19 +0200
committerDavid Sterba <dsterba@suse.cz>2015-06-11 00:23:30 +0200
commit4647ab887a592516841f74fa47586771bbcad81b (patch)
tree7cacc6dd3fd1d6c8322e9866fcf026a0c623a63a /btrfs-debug-tree.c
parent250a58f34d57588de8f0b2f118cb5cd152744158 (diff)
btrfs-progs: accept --help as option in the standalone utilities
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'btrfs-debug-tree.c')
-rw-r--r--btrfs-debug-tree.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/btrfs-debug-tree.c b/btrfs-debug-tree.c
index 610624e4..7d8e876f 100644
--- a/btrfs-debug-tree.c
+++ b/btrfs-debug-tree.c
@@ -20,6 +20,8 @@
#include <stdlib.h>
#include <unistd.h>
#include <uuid/uuid.h>
+#include <getopt.h>
+
#include "kerncompat.h"
#include "radix-tree.h"
#include "ctree.h"
@@ -28,7 +30,7 @@
#include "transaction.h"
#include "utils.h"
-static int print_usage(void)
+static int print_usage(int ret)
{
fprintf(stderr, "usage: btrfs-debug-tree [-e] [-d] [-r] [-R] [-u]\n");
fprintf(stderr, " [-b block_num ] device\n");
@@ -43,7 +45,7 @@ static int print_usage(void)
fprintf(stderr,
"\t-t tree_id : print only the tree with the given id\n");
fprintf(stderr, "%s\n", PACKAGE_STRING);
- exit(1);
+ exit(ret);
}
static void print_extents(struct btrfs_root *root, struct extent_buffer *eb)
@@ -145,7 +147,12 @@ int main(int ac, char **av)
while(1) {
int c;
- c = getopt(ac, av, "deb:rRut:");
+ static const struct option long_options[] = {
+ { "help", no_argument, NULL, GETOPT_VAL_HELP},
+ { NULL, 0, NULL, 0 }
+ };
+
+ c = getopt_long(ac, av, "deb:rRut:", long_options, NULL);
if (c < 0)
break;
switch(c) {
@@ -171,14 +178,15 @@ int main(int ac, char **av)
case 't':
tree_id = arg_strtou64(optarg);
break;
+ case GETOPT_VAL_HELP:
default:
- print_usage();
+ print_usage(c != GETOPT_VAL_HELP);
}
}
set_argv0(av);
ac = ac - optind;
if (check_argc_exact(ac, 1))
- print_usage();
+ print_usage(1);
ret = check_arg_type(av[optind]);
if (ret != BTRFS_ARG_BLKDEV && ret != BTRFS_ARG_REG) {