dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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