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

85 lines
3.3 KiB
Diff
Raw Normal View History

2019-05-07 13:06:40 +00:00
From b5bbee5db418e85c8fd26bf07142e71302914738 Mon Sep 17 00:00:00 2001
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Tue, 24 Oct 2017 10:22:21 +0200
Subject: [PATCH] Add support for NVDIMM devices
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@suse.de>
(cherry picked from commit 71885c5f493f3a5d950adbb3e8d17eff7e023053)
---
include/parted/device.in.h | 3 ++-
libparted/arch/linux.c | 7 +++++++
parted/parted.c | 3 ++-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/parted/device.in.h b/include/parted/device.in.h
index 1b6e7b8..d3af6bb 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 b76000e..1c26b8c 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 d2e1f24..b49e1df 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -986,7 +986,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