Blame SOURCES/0051-Fix-convert-function-to-support-NVMe-devices.patch

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