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