Blame SOURCES/0081-Add-support-for-NVDIMM-devices.patch

0cb0b9
From b5bbee5db418e85c8fd26bf07142e71302914738 Mon Sep 17 00:00:00 2001
0cb0b9
From: Sebastian Parschauer <sparschauer@suse.de>
0cb0b9
Date: Tue, 24 Oct 2017 10:22:21 +0200
0cb0b9
Subject: [PATCH] Add support for NVDIMM devices
0cb0b9
0cb0b9
Recognize NVDIMM devices, so that "parted -s /dev/pmem7 p" now
0cb0b9
prints "Model: NVDIMM Device (pmem)" instead of
0cb0b9
"Model: Unknown (unknown)".
0cb0b9
0cb0b9
In order for a device to be recognized as NVDIMM, it has to
0cb0b9
have a 'blkext' major number. But since this major can be
0cb0b9
used also by other device types, we also check that the device
0cb0b9
path contains 'pmem' as a substring.
0cb0b9
0cb0b9
* NEWS: Mention the change
0cb0b9
* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_PMEM
0cb0b9
* libparted/arch/linux.c(_device_probe_type): Recognize NVDIMM devices.
0cb0b9
* libparted/arch/linux.c(linux_new): Handle NVDIMM devices.
0cb0b9
* parted/parted.c(do_print): Add "pmem" to list of transports.
0cb0b9
0cb0b9
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
0cb0b9
(cherry picked from commit 71885c5f493f3a5d950adbb3e8d17eff7e023053)
0cb0b9
---
0cb0b9
 include/parted/device.in.h | 3 ++-
0cb0b9
 libparted/arch/linux.c     | 7 +++++++
0cb0b9
 parted/parted.c            | 3 ++-
0cb0b9
 3 files changed, 11 insertions(+), 2 deletions(-)
0cb0b9
0cb0b9
diff --git a/include/parted/device.in.h b/include/parted/device.in.h
0cb0b9
index 1b6e7b8..d3af6bb 100644
0cb0b9
--- a/include/parted/device.in.h
0cb0b9
+++ b/include/parted/device.in.h
0cb0b9
@@ -51,7 +51,8 @@ typedef enum {
0cb0b9
         PED_DEVICE_MD           = 17,
0cb0b9
         PED_DEVICE_LOOP         = 18,
0cb0b9
         PED_DEVICE_NVME         = 19,
0cb0b9
-        PED_DEVICE_RAM          = 20
0cb0b9
+        PED_DEVICE_RAM          = 20,
0cb0b9
+        PED_DEVICE_PMEM         = 21
0cb0b9
 } PedDeviceType;
0cb0b9
 
0cb0b9
 typedef struct _PedDevice PedDevice;
0cb0b9
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
0cb0b9
index b76000e..1c26b8c 100644
0cb0b9
--- a/libparted/arch/linux.c
0cb0b9
+++ b/libparted/arch/linux.c
0cb0b9
@@ -704,6 +704,8 @@ _device_probe_type (PedDevice* dev)
0cb0b9
                 dev->type = PED_DEVICE_NVME;
0cb0b9
         } else if (dev_major == RAM_MAJOR) {
0cb0b9
                 dev->type = PED_DEVICE_RAM;
0cb0b9
+        } else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "pmem")) {
0cb0b9
+                dev->type = PED_DEVICE_PMEM;
0cb0b9
         } else {
0cb0b9
                 dev->type = PED_DEVICE_UNKNOWN;
0cb0b9
         }
0cb0b9
@@ -1487,6 +1489,11 @@ linux_new (const char* path)
0cb0b9
                         goto error_free_arch_specific;
0cb0b9
                 break;
0cb0b9
 
0cb0b9
+        case PED_DEVICE_PMEM:
0cb0b9
+                if (!init_generic (dev, _("NVDIMM Device")))
0cb0b9
+                        goto error_free_arch_specific;
0cb0b9
+                break;
0cb0b9
+
0cb0b9
         case PED_DEVICE_ATARAID:
0cb0b9
                 if (!init_generic (dev, _("ATARAID Controller")))
0cb0b9
                         goto error_free_arch_specific;
0cb0b9
diff --git a/parted/parted.c b/parted/parted.c
0cb0b9
index d2e1f24..b49e1df 100644
0cb0b9
--- a/parted/parted.c
0cb0b9
+++ b/parted/parted.c
0cb0b9
@@ -986,7 +986,8 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp)
0cb0b9
                                          "cpqarray", "file", "ataraid", "i2o",
0cb0b9
                                          "ubd", "dasd", "viodasd", "sx8", "dm",
0cb0b9
                                          "xvd", "sd/mmc", "virtblk", "aoe",
0cb0b9
-                                         "md", "loopback", "nvme", "brd"};
0cb0b9
+                                         "md", "loopback", "nvme", "brd",
0cb0b9
+                                         "pmem"};
0cb0b9
 
0cb0b9
         char* start = ped_unit_format (dev, 0);
0cb0b9
         PedUnit default_unit = ped_unit_get_default ();
0cb0b9
-- 
0cb0b9
2.13.6
0cb0b9