From: Hannes Reinecke Date: Fri, 22 Apr 2022 11:22:39 +0000 (+0200) Subject: nvme: add '--groups' option to nvme ana-log X-Git-Tag: v2.1-rc0~61^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=8fdd4647ea02af163bbd97bfad3ba27d7e7c50ab;p=users%2Fsagi%2Fnvme-cli.git nvme: add '--groups' option to nvme ana-log Coverity complained that the 'groups' variable was never changed, so implement a '--groups' option to 'nvme ana-log'. Signed-off-by: Hannes Reinecke --- diff --git a/Documentation/nvme-ana-log.txt b/Documentation/nvme-ana-log.txt index fdd412ee..b6dc9c58 100644 --- a/Documentation/nvme-ana-log.txt +++ b/Documentation/nvme-ana-log.txt @@ -24,6 +24,10 @@ printed to stdout for another program to parse. OPTIONS ------- +-g:: +--groups:: + Return the list of ANA groups without the namespace listing. + -o :: --output-format=:: Set the reporting format to 'normal', 'json', or diff --git a/nvme.c b/nvme.c index cfee960c..07102738 100644 --- a/nvme.c +++ b/nvme.c @@ -369,23 +369,26 @@ static int get_ana_log(int argc, char **argv, struct command *cmd, { const char *desc = "Retrieve ANA log for the given device in " \ "decoded format (default), json or binary."; + const char *groups = "Return ANA groups only."; void *ana_log; int err = -1, fd; - int groups = 0; /* Right now get all the per ANA group NSIDS */ size_t ana_log_len; struct nvme_id_ctrl ctrl; enum nvme_print_flags flags; enum nvme_log_ana_lsp lsp; struct config { + bool groups; char *output_format; }; struct config cfg = { + .groups = false, .output_format = "normal", }; OPT_ARGS(opts) = { + OPT_FLAG("groups", 'g', &cfg.groups, groups), OPT_FMT("output-format", 'o', &cfg.output_format, output_format), OPT_END() }; @@ -416,8 +419,8 @@ static int get_ana_log(int argc, char **argv, struct command *cmd, goto close_fd; } - lsp = groups ? NVME_LOG_ANA_LSP_RGO_GROUPS_ONLY : - NVME_LOG_ANA_LSP_RGO_NAMESPACES; + lsp = cfg.groups ? NVME_LOG_ANA_LSP_RGO_GROUPS_ONLY : + NVME_LOG_ANA_LSP_RGO_NAMESPACES; err = nvme_get_log_ana(fd, lsp, true, 0, ana_log_len, ana_log); if (!err) {