From 279bd5540a59e3bdc4e3702ff062f87fd842c0e9 Mon Sep 17 00:00:00 2001 From: dann frazier Date: Fri, 7 Sep 2018 13:31:15 -0600 Subject: [PATCH 103/103] Read NVMe model names from sysfs 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) Signed-off-by: Brian C. Lane --- libparted/arch/linux.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c index 02d7a52..7d83dfb 100644 --- a/libparted/arch/linux.c +++ b/libparted/arch/linux.c @@ -1405,6 +1405,22 @@ init_sdmmc (PedDevice* dev) return init_generic(dev, id); } +static int +init_nvme (PedDevice* dev) +{ + int ret; + char *model = read_device_sysfs_file (dev, "model"); + + if (!model) + ret = init_generic (dev, _("NVMe Device")); + else { + ret = init_generic (dev, model); + free (model); + } + + return ret; +} + static PedDevice* linux_new (const char* path) { @@ -1489,7 +1505,7 @@ linux_new (const char* path) break; case PED_DEVICE_NVME: - if (!init_generic (dev, _("NVMe Device"))) + if (!init_nvme (dev)) goto error_free_arch_specific; break; -- 2.17.2