summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-12-08 19:12:10 +0100
committerDavid Sterba <dsterba@suse.com>2016-12-14 15:06:36 +0100
commit01bafdbc90452a17a9de6095fcdf0a9adca98dd2 (patch)
tree738a1dcb9625c71a8e7489db69e48165e54abca3
parent9468d9285ad5542855ae2963995f31036b9f943e (diff)
btrfs-progs: dev stats: add long option for -z
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--Documentation/btrfs-device.asciidoc2
-rw-r--r--cmds-device.c15
2 files changed, 13 insertions, 4 deletions
diff --git a/Documentation/btrfs-device.asciidoc b/Documentation/btrfs-device.asciidoc
index d398b6d2..193e2734 100644
--- a/Documentation/btrfs-device.asciidoc
+++ b/Documentation/btrfs-device.asciidoc
@@ -105,7 +105,7 @@ STATS* for more information.
+
`Options`
+
--z::::
+-z|--reset::::
Print the stats and reset the values to zero afterwards.
-s::::
diff --git a/cmds-device.c b/cmds-device.c
index aeaaa1d9..ba0e4368 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -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;