]>
Commit | Line | Data |
---|---|---|
74a816df MK |
1 | From 279bd5540a59e3bdc4e3702ff062f87fd842c0e9 Mon Sep 17 00:00:00 2001 |
2 | From: dann frazier <dann.frazier@canonical.com> | |
3 | Date: Fri, 7 Sep 2018 13:31:15 -0600 | |
4 | Subject: [PATCH 103/103] Read NVMe model names from sysfs | |
5 | ||
6 | parted currently shows the same generic model name for all NVMe devices: | |
7 | ||
8 | # parted /dev/nvme0n1 -s print | grep Model | |
9 | Model: NVMe Device (nvme) | |
10 | ||
11 | If the model information is available in sysfs, display that instead: | |
12 | ||
13 | # parted /dev/nvme0n1 -s print | grep Model | |
14 | Model: THNSN5512GPU7 NVMe TOSHIBA 512GB (nvme) | |
15 | ||
16 | Signed-off-by: Brian C. Lane <bcl@redhat.com> | |
17 | --- | |
18 | libparted/arch/linux.c | 18 +++++++++++++++++- | |
19 | 1 file changed, 17 insertions(+), 1 deletion(-) | |
20 | ||
21 | diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c | |
22 | index 02d7a52..7d83dfb 100644 | |
23 | --- a/libparted/arch/linux.c | |
24 | +++ b/libparted/arch/linux.c | |
25 | @@ -1405,6 +1405,22 @@ init_sdmmc (PedDevice* dev) | |
26 | return init_generic(dev, id); | |
27 | } | |
28 | ||
29 | +static int | |
30 | +init_nvme (PedDevice* dev) | |
31 | +{ | |
32 | + int ret; | |
33 | + char *model = read_device_sysfs_file (dev, "model"); | |
34 | + | |
35 | + if (!model) | |
36 | + ret = init_generic (dev, _("NVMe Device")); | |
37 | + else { | |
38 | + ret = init_generic (dev, model); | |
39 | + free (model); | |
40 | + } | |
41 | + | |
42 | + return ret; | |
43 | +} | |
44 | + | |
45 | static PedDevice* | |
46 | linux_new (const char* path) | |
47 | { | |
48 | @@ -1489,7 +1505,7 @@ linux_new (const char* path) | |
49 | break; | |
50 | ||
51 | case PED_DEVICE_NVME: | |
52 | - if (!init_generic (dev, _("NVMe Device"))) | |
53 | + if (!init_nvme (dev)) | |
54 | goto error_free_arch_specific; | |
55 | break; | |
56 | ||
57 | -- | |
58 | 2.17.2 | |
59 |