* [PATCH nvme-cli] nvme-print: nvme list -o json fix
@ 2020-05-01 7:42 Yi Zhang
2020-05-01 17:03 ` Keith Busch
0 siblings, 1 reply; 2+ messages in thread
From: Yi Zhang @ 2020-05-01 7:42 UTC (permalink / raw)
To: linux-nvme; +Cc: kbusch, Justin Tee
Bellow error log will be triggered on non pcie transport, so only print the
ProductName for pcie transport, also add print "\n" and json_free_object fix
Failed to open /sys/class/nvme/nvme1/device/subsystem_vendor with errno No such file or directory
Failed to open /sys/class/nvme/nvme1/device/subsystem_device with errno No such file or directory
Failed to open /sys/class/nvme/nvme1/device/vendor with errno No such file or directory
Failed to open /sys/class/nvme/nvme1/device/device with errno No such file or directory
Failed to open /sys/class/nvme/nvme1/device/class with errno No such file or directory
{
"Devices" : [
{
"NameSpace" : 1,
"DevicePath" : "/dev/nvme1n1",
"Firmware" : "4.18.0-1",
"Index" : 1,
"ModelNumber" : "Linux",
"ProductName" : "NULL",
"SerialNumber" : "eb4695bf0da275a3",
"UsedBytes" : 268435456000,
"MaximumLBA" : 524288000,
"PhysicalSize" : 268435456000,
"SectorSize" : 512
}
]
}
Reported-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
---
nvme-print.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/nvme-print.c b/nvme-print.c
index 42e27a3..7414280 100644
--- a/nvme-print.c
+++ b/nvme-print.c
@@ -4629,7 +4629,7 @@ static void json_simple_ns(struct nvme_namespace *n, struct json_array *devices)
json_object_add_value_string(device_attrs, "ModelNumber", formatter);
- if (index >= 0) {
+ if (index >= 0 && !strcmp(n->ctrl->transport, "pcie")) {
char *product = nvme_product_name(index);
json_object_add_value_string(device_attrs, "ProductName", product);
@@ -4682,6 +4682,8 @@ static void json_simple_list(struct nvme_topology *t)
}
json_object_add_value_array(root, "Devices", devices);
json_print_object(root, NULL);
+ printf("\n");
+ json_free_object(root);
}
static void json_print_list_items(struct nvme_topology *t,
--
2.21.0
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nvme-cli] nvme-print: nvme list -o json fix
2020-05-01 7:42 [PATCH nvme-cli] nvme-print: nvme list -o json fix Yi Zhang
@ 2020-05-01 17:03 ` Keith Busch
0 siblings, 0 replies; 2+ messages in thread
From: Keith Busch @ 2020-05-01 17:03 UTC (permalink / raw)
To: Yi Zhang; +Cc: Justin Tee, linux-nvme
Applied, thank you.
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-01 17:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-01 7:42 [PATCH nvme-cli] nvme-print: nvme list -o json fix Yi Zhang
2020-05-01 17:03 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).