|
|
0cb0b9 |
From 797d7b90c677e49552fbe7c526ce849b964e1ffe Mon Sep 17 00:00:00 2001
|
|
|
0cb0b9 |
From: Petr Uzel <petr.uzel@suse.cz>
|
|
|
0cb0b9 |
Date: Tue, 14 Jun 2016 13:17:00 +0200
|
|
|
0cb0b9 |
Subject: [PATCH 42/53] Add support for NVMe devices
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
Recognize NVMe Devices, so "parted -s /dev/nvme0n1" now prints
|
|
|
0cb0b9 |
"NVMe Device (nvme)" instead of "Model: Unknown (unknown)".
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
In order for a device to be recognized as NVMe, 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 the device
|
|
|
0cb0b9 |
path contains 'nvme' as a substring.
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
* NEWS: Mention the change
|
|
|
0cb0b9 |
* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_NVME
|
|
|
0cb0b9 |
* libparted/arch/linux.c(BLKEXT_MAJOR): New define.
|
|
|
0cb0b9 |
* libparted/arch/linux.c(_is_blkext_major): New function.
|
|
|
0cb0b9 |
* libparted/arch/linux.c(_device_probe_type): Recognize NVMe devices.
|
|
|
0cb0b9 |
* libparted/arch/linux.c(linux_new): Handle NVMe devices.
|
|
|
0cb0b9 |
* parted/parted.c(do_print): Add "nvme" to list of transports.
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
|
0cb0b9 |
(cherry picked from commit e4ae4330f3e33201aeeed3b7ca88e15d98d03e13)
|
|
|
0cb0b9 |
---
|
|
|
0cb0b9 |
include/parted/device.in.h | 3 ++-
|
|
|
0cb0b9 |
libparted/arch/linux.c | 14 ++++++++++++++
|
|
|
0cb0b9 |
parted/parted.c | 2 +-
|
|
|
0cb0b9 |
3 files changed, 17 insertions(+), 2 deletions(-)
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
diff --git a/include/parted/device.in.h b/include/parted/device.in.h
|
|
|
0cb0b9 |
index 82d4104..d38db44 100644
|
|
|
0cb0b9 |
--- a/include/parted/device.in.h
|
|
|
0cb0b9 |
+++ b/include/parted/device.in.h
|
|
|
0cb0b9 |
@@ -49,7 +49,8 @@ typedef enum {
|
|
|
0cb0b9 |
PED_DEVICE_VIRTBLK = 15,
|
|
|
0cb0b9 |
PED_DEVICE_AOE = 16,
|
|
|
0cb0b9 |
PED_DEVICE_MD = 17,
|
|
|
0cb0b9 |
- PED_DEVICE_LOOP = 18
|
|
|
0cb0b9 |
+ PED_DEVICE_LOOP = 18,
|
|
|
0cb0b9 |
+ PED_DEVICE_NVME = 19
|
|
|
0cb0b9 |
} PedDeviceType;
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
typedef struct _PedDevice PedDevice;
|
|
|
0cb0b9 |
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
|
|
|
0cb0b9 |
index eb01deb..b7ba5de 100644
|
|
|
0cb0b9 |
--- a/libparted/arch/linux.c
|
|
|
0cb0b9 |
+++ b/libparted/arch/linux.c
|
|
|
0cb0b9 |
@@ -278,6 +278,7 @@ struct blkdev_ioctl_param {
|
|
|
0cb0b9 |
#define SDMMC_MAJOR 179
|
|
|
0cb0b9 |
#define LOOP_MAJOR 7
|
|
|
0cb0b9 |
#define MD_MAJOR 9
|
|
|
0cb0b9 |
+#define BLKEXT_MAJOR 259
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
#define SCSI_BLK_MAJOR(M) ( \
|
|
|
0cb0b9 |
(M) == SCSI_DISK0_MAJOR \
|
|
|
0cb0b9 |
@@ -441,6 +442,12 @@ _is_virtblk_major (int major)
|
|
|
0cb0b9 |
return _major_type_in_devices (major, "virtblk");
|
|
|
0cb0b9 |
}
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
+static int
|
|
|
0cb0b9 |
+_is_blkext_major (int major)
|
|
|
0cb0b9 |
+{
|
|
|
0cb0b9 |
+ return _major_type_in_devices (major, "blkext");
|
|
|
0cb0b9 |
+}
|
|
|
0cb0b9 |
+
|
|
|
0cb0b9 |
#ifdef ENABLE_DEVICE_MAPPER
|
|
|
0cb0b9 |
static int
|
|
|
0cb0b9 |
_dm_task_run_wait (struct dm_task *task, uint32_t cookie)
|
|
|
0cb0b9 |
@@ -692,6 +699,8 @@ _device_probe_type (PedDevice* dev)
|
|
|
0cb0b9 |
dev->type = PED_DEVICE_LOOP;
|
|
|
0cb0b9 |
} else if (dev_major == MD_MAJOR) {
|
|
|
0cb0b9 |
dev->type = PED_DEVICE_MD;
|
|
|
0cb0b9 |
+ } else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "nvme")) {
|
|
|
0cb0b9 |
+ dev->type = PED_DEVICE_NVME;
|
|
|
0cb0b9 |
} else {
|
|
|
0cb0b9 |
dev->type = PED_DEVICE_UNKNOWN;
|
|
|
0cb0b9 |
}
|
|
|
0cb0b9 |
@@ -1465,6 +1474,11 @@ linux_new (const char* path)
|
|
|
0cb0b9 |
goto error_free_arch_specific;
|
|
|
0cb0b9 |
break;
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
+ case PED_DEVICE_NVME:
|
|
|
0cb0b9 |
+ if (!init_generic (dev, _("NVMe 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 06f9971..bd848c3 100644
|
|
|
0cb0b9 |
--- a/parted/parted.c
|
|
|
0cb0b9 |
+++ b/parted/parted.c
|
|
|
0cb0b9 |
@@ -979,7 +979,7 @@ _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"};
|
|
|
0cb0b9 |
+ "md", "loopback", "nvme"};
|
|
|
0cb0b9 |
|
|
|
0cb0b9 |
char* start = ped_unit_format (dev, 0);
|
|
|
0cb0b9 |
PedUnit default_unit = ped_unit_get_default ();
|
|
|
0cb0b9 |
--
|
|
|
0cb0b9 |
2.7.4
|
|
|
0cb0b9 |
|