37b39b7
From f451ce261bcdb24d3428daac54e32e06c698e2f7 Mon Sep 17 00:00:00 2001
37b39b7
From: Peter Jones <pjones@redhat.com>
37b39b7
Date: Tue, 18 Feb 2014 11:34:00 -0500
58fe9aa
Subject: [PATCH 134/152] Fix convert function to support NVMe devices
37b39b7
37b39b7
This is adapted from the patch at
37b39b7
https://bugzilla.redhat.com/show_bug.cgi?id=1019660 , which is against
37b39b7
the now very old version of convert_system_partition_to_system_disk().
37b39b7
37b39b7
As such, it certainly not the right thing for upstream, but should
37b39b7
function for now.
37b39b7
37b39b7
Resolves: rhbz#1019660
37b39b7
37b39b7
Signed-off-by: Peter Jones <grub2-owner@fedoraproject.org>
37b39b7
---
37b39b7
 util/getroot.c | 19 +++++++++++++++++++
37b39b7
 1 file changed, 19 insertions(+)
37b39b7
37b39b7
diff --git a/util/getroot.c b/util/getroot.c
37b39b7
index 3958105..e700610 100644
37b39b7
--- a/util/getroot.c
37b39b7
+++ b/util/getroot.c
37b39b7
@@ -152,6 +152,7 @@ convert_system_partition_to_system_disk (const char *os_dev, int *is_part)
37b39b7
 {
37b39b7
 #if GRUB_UTIL_FD_STAT_IS_FUNCTIONAL
37b39b7
   struct stat st;
37b39b7
+  char *path = xmalloc(PATH_MAX);
37b39b7
 
37b39b7
   if (stat (os_dev, &st) < 0)
37b39b7
     {
37b39b7
@@ -164,6 +165,24 @@ convert_system_partition_to_system_disk (const char *os_dev, int *is_part)
37b39b7
 
37b39b7
   *is_part = 0;
37b39b7
 
37b39b7
+  if (realpath(os_dev, path))
37b39b7
+    {
37b39b7
+      if ((strncmp ("/dev/nvme", path, 9) == 0))
37b39b7
+	{
37b39b7
+	  char *p = path + 5;
37b39b7
+	  p = strchr(p, 'p');
37b39b7
+	  if (p)
37b39b7
+	    {
37b39b7
+	      *is_part = 1;
37b39b7
+	      *p = '\0';
37b39b7
+	    }
37b39b7
+	  return path;
37b39b7
+	}
37b39b7
+    }
37b39b7
+
37b39b7
+  grub_free (path);
37b39b7
+  *is_part = 0;
37b39b7
+
37b39b7
   if (grub_util_device_is_mapped_stat (&st))
37b39b7
     return grub_util_devmapper_part_to_disk (&st, is_part, os_dev);
37b39b7
 
37b39b7
-- 
37b39b7
1.9.3
37b39b7