File libparted-Add-support-for-NVDIMM-devices.patch of Package parted.15765

From: Sebastian Parschauer <sparschauer@suse.de>
Date: Mon, 23 Oct 2017 17:47:47 +0200
Subject: Add support for NVDIMM devices
References: bsc#1064446
Patch-mainline: v3.3
Git-commit: 71885c5f493f3a5d950adbb3e8d17eff7e023053

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.

* 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@suse.de>
---
 include/parted/device.in.h |    3 ++-
 libparted/arch/linux.c     |    7 +++++++
 parted/parted.c            |    3 ++-
 3 files changed, 11 insertions(+), 2 deletions(-)

--- 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;
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -724,6 +724,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;
         }
@@ -1497,6 +1499,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;
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1045,7 +1045,8 @@ _print_disk_info (const PedDevice *dev,
                                          "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 ();
openSUSE Build Service is sponsored by