]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print-stdout: add details in list-ns verbose output
authorMartin George <marting@netapp.com>
Sun, 9 Feb 2025 18:42:28 +0000 (00:12 +0530)
committerDaniel Wagner <wagi@monom.org>
Mon, 10 Feb 2025 13:02:27 +0000 (14:02 +0100)
Add identifier & NSID tags in the verbose output of the list-ns
command for better clarity. And while at it, print a common
"NVMe Namespace List" tag at the top too. For e.g.

nvme list-ns /dev/nvme1n1 -v
dev: /dev/nvme1n1, fd: 3
NVME Namespace List:
Identifier    0: NSID 0x1
Identifier    1: NSID 0x2
...

Signed-off-by: Martin George <marting@netapp.com>
nvme-print-stdout.c
nvme.c

index 5c0eee9dfaa77e4a845ce08bb933a76f72664605..c8e2ea653ec69c4babcd28381f6c71d45763804c 100644 (file)
@@ -3640,11 +3640,18 @@ static void stdout_zns_id_ns(struct nvme_zns_id_ns *ns,
 
 static void stdout_list_ns(struct nvme_ns_list *ns_list)
 {
-       int i;
+       int i, verbose = stdout_print_ops.flags & VERBOSE;
 
+       printf("NVME Namespace List:\n");
        for (i = 0; i < 1024; i++) {
-               if (ns_list->ns[i])
-                       printf("[%4u]:%#x\n", i, le32_to_cpu(ns_list->ns[i]));
+               if (ns_list->ns[i]) {
+                       if (verbose)
+                               printf("Identifier %4u: NSID %#x\n",
+                                               i, le32_to_cpu(ns_list->ns[i]));
+                       else
+                               printf("[%4u]:%#x\n",
+                                               i, le32_to_cpu(ns_list->ns[i]));
+               }
        }
 }
 
diff --git a/nvme.c b/nvme.c
index a50ffab60e4e03b1db43f73f257aefde95135f18..1f46cd55ad1c202de8fc77c0b7f40851e36663b2 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -2716,6 +2716,9 @@ static int list_ns(int argc, char **argv, struct command *cmd, struct plugin *pl
                return -EINVAL;
        }
 
+       if (argconfig_parse_seen(opts, "verbose"))
+               flags |= VERBOSE;
+
        ns_list = nvme_alloc(sizeof(*ns_list));
        if (!ns_list)
                return -ENOMEM;