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

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