Skip to content

Commit 3f3c4ff

Browse files
martin-gpyigaw
authored andcommitted
nvme-print-stdout: add details in list-ns verbose output
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 <[email protected]>
1 parent 383609e commit 3f3c4ff

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

nvme-print-stdout.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3640,11 +3640,18 @@ static void stdout_zns_id_ns(struct nvme_zns_id_ns *ns,
36403640

36413641
static void stdout_list_ns(struct nvme_ns_list *ns_list)
36423642
{
3643-
int i;
3643+
int i, verbose = stdout_print_ops.flags & VERBOSE;
36443644

3645+
printf("NVME Namespace List:\n");
36453646
for (i = 0; i < 1024; i++) {
3646-
if (ns_list->ns[i])
3647-
printf("[%4u]:%#x\n", i, le32_to_cpu(ns_list->ns[i]));
3647+
if (ns_list->ns[i]) {
3648+
if (verbose)
3649+
printf("Identifier %4u: NSID %#x\n",
3650+
i, le32_to_cpu(ns_list->ns[i]));
3651+
else
3652+
printf("[%4u]:%#x\n",
3653+
i, le32_to_cpu(ns_list->ns[i]));
3654+
}
36483655
}
36493656
}
36503657

nvme.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,6 +2716,9 @@ static int list_ns(int argc, char **argv, struct command *cmd, struct plugin *pl
27162716
return -EINVAL;
27172717
}
27182718

2719+
if (argconfig_parse_seen(opts, "verbose"))
2720+
flags |= VERBOSE;
2721+
27192722
ns_list = nvme_alloc(sizeof(*ns_list));
27202723
if (!ns_list)
27212724
return -ENOMEM;

0 commit comments

Comments
 (0)