[parted-devel] [PATCH] Add support for NVDIMM devices

Sebastian Parschauer sparschauer at suse.de
Tue Oct 24 08:22:21 UTC 2017


Recognize NVDIMM devices, so that "parted -s /dev/pmem7 p" now
prints "Model: NVDIMM Device (pmem)" instead of
"Model: Unknown (unknown)".

In order for a device to be recognized as NVDIMM, it has to
have a 'blkext' major number. But since this major can be
used also by other device types, we also check that the device
path contains 'pmem' as a substring.

* NEWS: Mention the change
* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_PMEM
* libparted/arch/linux.c(_device_probe_type): Recognize NVDIMM devices.
* libparted/arch/linux.c(linux_new): Handle NVDIMM devices.
* parted/parted.c(do_print): Add "pmem" to list of transports.

Signed-off-by: Sebastian Parschauer <sparschauer at suse.de>
---
 NEWS                       | 2 +-
 include/parted/device.in.h | 3 ++-
 libparted/arch/linux.c     | 7 +++++++
 parted/parted.c            | 3 ++-
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index bb15212b245e..5bc305181ba1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,6 @@
 GNU parted NEWS                                    -*- outline -*-
 
-  Parted now recognizes NVMe devices and RAM drives
+  Parted now recognizes NVMe devices, NVDIMM, and RAM drives.
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
diff --git a/include/parted/device.in.h b/include/parted/device.in.h
index 1b6e7b80f90e..d3af6bb978b4 100644
--- a/include/parted/device.in.h
+++ b/include/parted/device.in.h
@@ -51,7 +51,8 @@ typedef enum {
         PED_DEVICE_MD           = 17,
         PED_DEVICE_LOOP         = 18,
         PED_DEVICE_NVME         = 19,
-        PED_DEVICE_RAM          = 20
+        PED_DEVICE_RAM          = 20,
+        PED_DEVICE_PMEM         = 21
 } PedDeviceType;
 
 typedef struct _PedDevice PedDevice;
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 1a35964e51a5..31b98ab274f8 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -704,6 +704,8 @@ _device_probe_type (PedDevice* dev)
                 dev->type = PED_DEVICE_NVME;
         } else if (dev_major == RAM_MAJOR) {
                 dev->type = PED_DEVICE_RAM;
+        } else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "pmem")) {
+                dev->type = PED_DEVICE_PMEM;
         } else {
                 dev->type = PED_DEVICE_UNKNOWN;
         }
@@ -1487,6 +1489,11 @@ linux_new (const char* path)
                         goto error_free_arch_specific;
                 break;
 
+        case PED_DEVICE_PMEM:
+                if (!init_generic (dev, _("NVDIMM Device")))
+                        goto error_free_arch_specific;
+                break;
+
         case PED_DEVICE_ATARAID:
                 if (!init_generic (dev, _("ATARAID Controller")))
                         goto error_free_arch_specific;
diff --git a/parted/parted.c b/parted/parted.c
index c471d4976d06..b5e3b9725597 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -987,7 +987,8 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp)
                                          "cpqarray", "file", "ataraid", "i2o",
                                          "ubd", "dasd", "viodasd", "sx8", "dm",
                                          "xvd", "sd/mmc", "virtblk", "aoe",
-                                         "md", "loopback", "nvme", "brd"};
+                                         "md", "loopback", "nvme", "brd",
+                                         "pmem"};
 
         char* start = ped_unit_format (dev, 0);
         PedUnit default_unit = ped_unit_get_default ();
-- 
2.13.6




More information about the parted-devel mailing list