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

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