aboutsummaryrefslogtreecommitdiffstats
path: root/btrfs-find-root.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-find-root.c
parent250a58f34d57588de8f0b2f118cb5cd152744158 (diff)
downloadbtrfs-progs-4647ab887a592516841f74fa47586771bbcad81b.tar.gz
btrfs-progs-4647ab887a592516841f74fa47586771bbcad81b.tar.xz
btrfs-progs-4647ab887a592516841f74fa47586771bbcad81b.zip
btrfs-progs: accept --help as option in the standalone utilities
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'btrfs-find-root.c')
-rw-r--r--btrfs-find-root.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/btrfs-find-root.c b/btrfs-find-root.c
index 9e56c81..1cb3085 100644
--- a/btrfs-find-root.c
+++ b/btrfs-find-root.c
@@ -22,6 +22,8 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <zlib.h>
+#include <getopt.h>
+
#include "kerncompat.h"
#include "ctree.h"
#include "disk-io.h"
@@ -142,15 +144,23 @@ int main(int argc, char **argv)
struct btrfs_find_root_filter filter = {0};
struct cache_tree result;
struct cache_extent *found;
- int opt;
int ret;
/* Default to search root tree */
filter.objectid = BTRFS_ROOT_TREE_OBJECTID;
filter.match_gen = (u64)-1;
filter.match_level = (u8)-1;
- while ((opt = getopt(argc, argv, "al:o:g:")) != -1) {
- switch(opt) {
+ while (1) {
+ static const struct option long_options[] = {
+ { "help", no_argument, NULL, GETOPT_VAL_HELP},
+ { NULL, 0, NULL, 0 }
+ };
+ int c = getopt_long(argc, argv, "al:o:g:", long_options, NULL);
+
+ if (c < 0)
+ break;
+
+ switch (c) {
case 'a':
filter.search_all = 1;
break;
@@ -163,9 +173,10 @@ int main(int argc, char **argv)
case 'l':
filter.level = arg_strtou64(optarg);
break;
+ case GETOPT_VAL_HELP:
default:
usage();
- exit(1);
+ exit(c != GETOPT_VAL_HELP);
}
}