[parted-devel] [PATCH] Read NVMe model names from sysfs
dann frazier
dann.frazier at canonical.com
Fri Aug 31 17:05:41 BST 2018
parted currently shows the same generic model name for all NVMe devices:
# parted /dev/nvme0n1 -s print | grep Model
Model: NVMe Device (nvme)
If the model information is available in sysfs, display that instead:
# parted /dev/nvme0n1 -s print | grep Model
Model: THNSN5512GPU7 NVMe TOSHIBA 512GB (nvme)
---
libparted/arch/linux.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 02d7a52c..b3c71edb 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1489,9 +1489,19 @@ linux_new (const char* path)
break;
case PED_DEVICE_NVME:
- if (!init_generic (dev, _("NVMe Device")))
- goto error_free_arch_specific;
- break;
+ {
+ char* model;
+ model = read_device_sysfs_file (dev, "model");
+ if (!model)
+ model = strdup (_("NVMe Device"));
+ if (!init_generic (dev, model))
+ {
+ free (model);
+ goto error_free_arch_specific;
+ }
+ free (model);
+ break;
+ }
case PED_DEVICE_PMEM:
if (!init_generic (dev, _("NVDIMM Device")))
--
2.19.0.rc1
More information about the parted-devel
mailing list