]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: fix human-readable format option in primary ctrl caps
authorGollu Appalanaidu <anaidu.gollu@samsung.com>
Sun, 4 Apr 2021 05:44:18 +0000 (11:14 +0530)
committerKeith Busch <kbusch@kernel.org>
Sun, 4 Apr 2021 15:53:56 +0000 (09:53 -0600)
In Primary controller caps though it supports human readable
format, currently there is no option to view it, adding
human-readable foramt option.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
nvme.c

diff --git a/nvme.c b/nvme.c
index e5a8925e11a3fdfe3dcdccc225d3d66f8cfb2ff6..e4fa8cd721061269ffa0ac3b86b2712eaacd6daf 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -2426,6 +2426,7 @@ static int primary_ctrl_caps(int argc, char **argv, struct command *cmd, struct
        const char *desc = "Send an Identify Primary Controller Capabilities "\
                "command to the given device and report the information in a "\
                "decoded format (default), json or binary.";
+       const char *human_readable = "show info in readable format";
        struct nvme_primary_ctrl_caps caps;
 
        int err, fd;
@@ -2433,6 +2434,7 @@ static int primary_ctrl_caps(int argc, char **argv, struct command *cmd, struct
 
        struct config {
                char *output_format;
+               int human_readable;
        };
 
        struct config cfg = {
@@ -2440,7 +2442,8 @@ static int primary_ctrl_caps(int argc, char **argv, struct command *cmd, struct
        };
 
        OPT_ARGS(opts) = {
-               OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+               OPT_FMT("output-format",   'o', &cfg.output_format,  output_format),
+               OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable),
                OPT_END()
        };
 
@@ -2451,6 +2454,8 @@ static int primary_ctrl_caps(int argc, char **argv, struct command *cmd, struct
        err = flags = validate_output_format(cfg.output_format);
        if (flags < 0)
                goto close_fd;
+       if (cfg.human_readable)
+               flags |= VERBOSE;
 
        err = nvme_identify_primary_ctrl_caps(fd, &caps);
        if (!err)