Blob Blame History Raw
From 70bcdeaee2d12ad65ad61ad984f1a6bfdf3845d8 Mon Sep 17 00:00:00 2001
From: Mike Fleetwood <mike.fleetwood@googlemail.com>
Date: Wed, 16 Sep 2015 20:25:58 +0100
Subject: [PATCH] Recognise NVME devices (#755022)

Add a pattern to recognise Non-Volatile Memory Express devices as valid
devices to work with.  Devices are named by the Linux kernel device
driver like /dev/nvme0n1 [1] with partitions named like /dev/nvme0n1p1
[2].

[1] linux 3.3 drivers/block/nvme.c nvme_alloc_ns()
    https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/block/nvme.c?id=v3.3#n1351

[2] Contents of /proc/partitions for a partitioned NVME device
    $ grep nvme /proc/partitions
     259        0  390711384 nvme0n1
     259        1        977 nvme0n1p1
     259        2   31250000 nvme0n1p2
     259        3  328209496 nvme0n1p3
     259        4   31249408 nvme0n1p4

Bug 755022 - gparted doesn't recognize nvme devices
---
 src/Proc_Partitions_Info.cc |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/Proc_Partitions_Info.cc b/src/Proc_Partitions_Info.cc
index 595cdb2..f17f689 100644
--- src/Proc_Partitions_Info.cc
+++ src/Proc_Partitions_Info.cc
@@ -99,6 +99,14 @@ void Proc_Partitions_Info::load_proc_partitions_info_cache()
 			//E.g., device = /dev/mmcblk0, partition = /dev/mmcblk0p1
 			if ( device == "" )
 				device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+(mmcblk[0-9]+)$") ;
+
+			// Recognise /dev/nvme*n* devices
+			// (Non-Volatile Memory Express devices.  SSD type devices which
+			// plug directly into PCIe sockets).
+			// E.g., device = /dev/nvme0n1, partition = /dev/nvme0n1p1
+			if ( device == "" )
+				device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+(nvme[0-9]+n[0-9]+)$");
+
 			//Device names that end with a #[^p]# are HP Smart Array Devices (disks)
 			//  E.g., device = /dev/cciss/c0d0, partition = /dev/cciss/c0d0p1
 			//  (linux-x.y.z/Documentation/blockdev/cciss.txt)
-- 
1.7.1