nvme-print: nvme list -o json fix
PATCH 1/1 nvme-print: nvme list -o json fix
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
} ]
}
--- nvme-print.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
nvme-print.c +3 -1
@@ -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,
Signature · 7 lines
2.21.0 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Applied, thank you.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme