btrfs-progs: dev stats: add long option for -z

Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2016-12-08 19:12:10 +01:00
parent 9468d9285a
commit 01bafdbc90
2 changed files with 13 additions and 4 deletions

View File

@ -105,7 +105,7 @@ STATS* for more information.
+
`Options`
+
-z::::
-z|--reset::::
Print the stats and reset the values to zero afterwards.
-s::::

View 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;