btrfs-progs: dev stats: add long option for -z
authorDavid Sterba <dsterba@suse.com>
Thu, 8 Dec 2016 18:12:10 +0000 (19:12 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 14 Dec 2016 14:06:36 +0000 (15:06 +0100)
Signed-off-by: David Sterba <dsterba@suse.com>
Documentation/btrfs-device.asciidoc
cmds-device.c

index d398b6d..193e273 100644 (file)
@@ -105,7 +105,7 @@ STATS* for more information.
 +
 `Options`
 +
--z::::
+-z|--reset::::
 Print the stats and reset the values to zero afterwards.
 
 -s::::
index aeaaa1d..ba0e436 100644 (file)
@@ -375,7 +375,7 @@ static const char * const cmd_device_stats_usage[] = {
        "btrfs device stats [-z] <path>|<device>",
        "Show current device IO stats.",
        "",
-       "-z                     show current stats and reset values to zero",
+       "-z|--reset             show current stats and reset values to zero",
        "-s                     return non-zero if any stat counter is not zero",
        NULL
 };
@@ -388,13 +388,22 @@ static int cmd_device_stats(int argc, char **argv)
        int ret;
        int fdmnt;
        int i;
-       int c;
        int err = 0;
        int status = 0;
        __u64 flags = 0;
        DIR *dirstream = NULL;
 
-       while ((c = getopt(argc, argv, "zs")) != -1) {
+       while (1) {
+               int c;
+               static const struct option long_options[] = {
+                       {"reset", no_argument, NULL, 'z'},
+                       {NULL, 0, NULL, 0}
+               };
+
+               c = getopt_long(argc, argv, "zs", long_options, NULL);
+               if (c < 0)
+                       break;
+
                switch (c) {
                case 'z':
                        flags = BTRFS_DEV_STATS_RESET;