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>
Signed-off-by: Keith Busch <kbusch@kernel.org>
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);
}
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,