dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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