[PATCH nvme-cli] nvme-print: Print cntlid number for controller

Nilay Shroff nilay at linux.ibm.com
Fri Apr 5 05:10:36 PDT 2024


Print the controller identifier number (cntlid) for the
nvme controller. The cntlid is printed if nvme list
verbose is specified.

Link: https://lore.kernel.org/all/20240326065752.164286-1-nilay@linux.ibm.com/
Signed-off-by: Nilay Shroff <nilay at linux.ibm.com>
---
 nvme-print-json.c   |  1 +
 nvme-print-stdout.c | 12 +++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/nvme-print-json.c b/nvme-print-json.c
index fec72b9d..8cf057f2 100644
--- a/nvme-print-json.c
+++ b/nvme-print-json.c
@@ -3899,6 +3899,7 @@ static void json_detail_list(nvme_root_t t)
 				struct json_object *jpaths = json_create_array();
 
 				obj_add_str(jctrl, "Controller", nvme_ctrl_get_name(c));
+				obj_add_str(jctrl, "Cntlid", nvme_ctrl_get_cntlid(c));
 				obj_add_str(jctrl, "SerialNumber", nvme_ctrl_get_serial(c));
 				obj_add_str(jctrl, "ModelNumber", nvme_ctrl_get_model(c));
 				obj_add_str(jctrl, "Firmware", nvme_ctrl_get_firmware(c));
diff --git a/nvme-print-stdout.c b/nvme-print-stdout.c
index 795087ee..1b62a8e4 100644
--- a/nvme-print-stdout.c
+++ b/nvme-print-stdout.c
@@ -4802,8 +4802,9 @@ static bool stdout_detailed_ctrl(const char *name, void *arg)
 	c = htable_ctrl_get(&res->ht_c, name);
 	assert(c);
 
-	printf("%-8s %-20s %-40s %-8s %-6s %-14s %-6s %-12s ",
+	printf("%-8s %-6s %-20s %-40s %-8s %-6s %-14s %-6s %-12s ",
 	       nvme_ctrl_get_name(c),
+	       nvme_ctrl_get_cntlid(c),
 	       nvme_ctrl_get_serial(c),
 	       nvme_ctrl_get_model(c),
 	       nvme_ctrl_get_firmware(c),
@@ -4882,10 +4883,11 @@ static void stdout_detailed_list(nvme_root_t r)
 	strset_iterate(&res.subsystems, stdout_detailed_subsys, &res);
 	printf("\n");
 
-	printf("%-8s %-20s %-40s %-8s %-6s %-14s %-6s %-12s %-16s\n", "Device",
-		"SN", "MN", "FR", "TxPort", "Address", "Slot", "Subsystem", "Namespaces");
-	printf("%-.8s %-.20s %-.40s %-.8s %-.6s %-.14s %-.6s %-.12s %-.16s\n", dash,
-		dash, dash, dash, dash, dash, dash, dash, dash);
+	printf("%-8s %-6s %-20s %-40s %-8s %-6s %-14s %-6s %-12s %-16s\n", "Device",
+		"Cntlid", "SN", "MN", "FR", "TxPort", "Address", "Slot", "Subsystem",
+		"Namespaces");
+	printf("%-.8s %-.6s %-.20s %-.40s %-.8s %-.6s %-.14s %-.6s %-.12s %-.16s\n",
+			dash, dash, dash, dash, dash, dash, dash, dash, dash, dash);
 	strset_iterate(&res.ctrls, stdout_detailed_ctrl, &res);
 	printf("\n");
 
-- 
2.44.0




More information about the Linux-nvme mailing list