]>
Commit | Line | Data |
---|---|---|
c886eb9d AM |
1 | From 797d7b90c677e49552fbe7c526ce849b964e1ffe Mon Sep 17 00:00:00 2001 |
2 | From: Petr Uzel <petr.uzel@suse.cz> | |
3 | Date: Tue, 14 Jun 2016 13:17:00 +0200 | |
4 | Subject: [PATCH 42/53] Add support for NVMe devices | |
5 | ||
6 | Recognize NVMe Devices, so "parted -s /dev/nvme0n1" now prints | |
7 | "NVMe Device (nvme)" instead of "Model: Unknown (unknown)". | |
8 | ||
9 | In order for a device to be recognized as NVMe, it has to | |
10 | have a 'blkext' major number. But since this major can be | |
11 | used also by other device types, we also check the device | |
12 | path contains 'nvme' as a substring. | |
13 | ||
14 | * NEWS: Mention the change | |
15 | * include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_NVME | |
16 | * libparted/arch/linux.c(BLKEXT_MAJOR): New define. | |
17 | * libparted/arch/linux.c(_is_blkext_major): New function. | |
18 | * libparted/arch/linux.c(_device_probe_type): Recognize NVMe devices. | |
19 | * libparted/arch/linux.c(linux_new): Handle NVMe devices. | |
20 | * parted/parted.c(do_print): Add "nvme" to list of transports. | |
21 | ||
22 | Signed-off-by: Brian C. Lane <bcl@redhat.com> | |
23 | (cherry picked from commit e4ae4330f3e33201aeeed3b7ca88e15d98d03e13) | |
24 | --- | |
25 | include/parted/device.in.h | 3 ++- | |
26 | libparted/arch/linux.c | 14 ++++++++++++++ | |
27 | parted/parted.c | 2 +- | |
28 | 3 files changed, 17 insertions(+), 2 deletions(-) | |
29 | ||
30 | diff --git a/include/parted/device.in.h b/include/parted/device.in.h | |
31 | index 82d4104..d38db44 100644 | |
32 | --- a/include/parted/device.in.h | |
33 | +++ b/include/parted/device.in.h | |
34 | @@ -49,7 +49,8 @@ typedef enum { | |
35 | PED_DEVICE_VIRTBLK = 15, | |
36 | PED_DEVICE_AOE = 16, | |
37 | PED_DEVICE_MD = 17, | |
38 | - PED_DEVICE_LOOP = 18 | |
39 | + PED_DEVICE_LOOP = 18, | |
40 | + PED_DEVICE_NVME = 19 | |
41 | } PedDeviceType; | |
42 | ||
43 | typedef struct _PedDevice PedDevice; | |
44 | diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c | |
45 | index eb01deb..b7ba5de 100644 | |
46 | --- a/libparted/arch/linux.c | |
47 | +++ b/libparted/arch/linux.c | |
48 | @@ -278,6 +278,7 @@ struct blkdev_ioctl_param { | |
49 | #define SDMMC_MAJOR 179 | |
50 | #define LOOP_MAJOR 7 | |
51 | #define MD_MAJOR 9 | |
52 | +#define BLKEXT_MAJOR 259 | |
53 | ||
54 | #define SCSI_BLK_MAJOR(M) ( \ | |
55 | (M) == SCSI_DISK0_MAJOR \ | |
56 | @@ -441,6 +442,12 @@ _is_virtblk_major (int major) | |
57 | return _major_type_in_devices (major, "virtblk"); | |
58 | } | |
59 | ||
60 | +static int | |
61 | +_is_blkext_major (int major) | |
62 | +{ | |
63 | + return _major_type_in_devices (major, "blkext"); | |
64 | +} | |
65 | + | |
66 | #ifdef ENABLE_DEVICE_MAPPER | |
67 | static int | |
68 | _dm_task_run_wait (struct dm_task *task, uint32_t cookie) | |
69 | @@ -692,6 +699,8 @@ _device_probe_type (PedDevice* dev) | |
70 | dev->type = PED_DEVICE_LOOP; | |
71 | } else if (dev_major == MD_MAJOR) { | |
72 | dev->type = PED_DEVICE_MD; | |
73 | + } else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "nvme")) { | |
74 | + dev->type = PED_DEVICE_NVME; | |
75 | } else { | |
76 | dev->type = PED_DEVICE_UNKNOWN; | |
77 | } | |
78 | @@ -1465,6 +1474,11 @@ linux_new (const char* path) | |
79 | goto error_free_arch_specific; | |
80 | break; | |
81 | ||
82 | + case PED_DEVICE_NVME: | |
83 | + if (!init_generic (dev, _("NVMe Device"))) | |
84 | + goto error_free_arch_specific; | |
85 | + break; | |
86 | + | |
87 | case PED_DEVICE_ATARAID: | |
88 | if (!init_generic (dev, _("ATARAID Controller"))) | |
89 | goto error_free_arch_specific; | |
90 | diff --git a/parted/parted.c b/parted/parted.c | |
91 | index 06f9971..bd848c3 100644 | |
92 | --- a/parted/parted.c | |
93 | +++ b/parted/parted.c | |
94 | @@ -979,7 +979,7 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp) | |
95 | "cpqarray", "file", "ataraid", "i2o", | |
96 | "ubd", "dasd", "viodasd", "sx8", "dm", | |
97 | "xvd", "sd/mmc", "virtblk", "aoe", | |
98 | - "md", "loopback"}; | |
99 | + "md", "loopback", "nvme"}; | |
100 | ||
101 | char* start = ped_unit_format (dev, 0); | |
102 | PedUnit default_unit = ped_unit_get_default (); | |
103 | -- | |
104 | 2.7.4 | |
105 |