a5bd9f6
From 1d7f76afcf0ea16e362edbf053bb5b34d8dad048 Mon Sep 17 00:00:00 2001
a5bd9f6
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
a5bd9f6
Date: Fri, 1 Mar 2013 10:35:51 +0100
a5bd9f6
Subject: [PATCH 171/364] 	* grub-core/kern/main.c
a5bd9f6
 (grub_set_prefix_and_root): Strip trailing 	platform from firmware path.
a5bd9f6
a5bd9f6
---
a5bd9f6
 ChangeLog             |  5 +++++
a5bd9f6
 grub-core/kern/main.c | 11 ++++++++++-
a5bd9f6
 2 files changed, 15 insertions(+), 1 deletion(-)
a5bd9f6
a5bd9f6
diff --git a/ChangeLog b/ChangeLog
a5bd9f6
index 135586c..986871c 100644
a5bd9f6
--- a/ChangeLog
a5bd9f6
+++ b/ChangeLog
a5bd9f6
@@ -1,3 +1,8 @@
a5bd9f6
+2013-03-01  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
+
a5bd9f6
+	* grub-core/kern/main.c (grub_set_prefix_and_root): Strip trailing
a5bd9f6
+	platform from firmware path.
a5bd9f6
+
a5bd9f6
 2013-02-28  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
 
a5bd9f6
 	Enable linux16 on non-BIOS systems for i.a. memtest.
a5bd9f6
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
a5bd9f6
index 3262444..c43ac6b 100644
a5bd9f6
--- a/grub-core/kern/main.c
a5bd9f6
+++ b/grub-core/kern/main.c
a5bd9f6
@@ -168,7 +168,16 @@ grub_set_prefix_and_root (void)
a5bd9f6
   else
a5bd9f6
     grub_free (fwdevice);
a5bd9f6
   if (fwpath && !path)
a5bd9f6
-    path = fwpath;
a5bd9f6
+    {
a5bd9f6
+      grub_size_t len = grub_strlen (fwpath);
a5bd9f6
+      while (len > 1 && fwpath[len - 1] == '/')
a5bd9f6
+	fwpath[--len] = 0;
a5bd9f6
+      if (len >= sizeof (GRUB_TARGET_CPU "-" GRUB_PLATFORM) - 1
a5bd9f6
+	  && grub_memcmp (fwpath + len - (sizeof (GRUB_TARGET_CPU "-" GRUB_PLATFORM) - 1), GRUB_TARGET_CPU "-" GRUB_PLATFORM,
a5bd9f6
+			  sizeof (GRUB_TARGET_CPU "-" GRUB_PLATFORM) - 1) == 0)
a5bd9f6
+	fwpath[len - (sizeof (GRUB_TARGET_CPU "-" GRUB_PLATFORM) - 1)] = 0;
a5bd9f6
+      path = fwpath;
a5bd9f6
+    }
a5bd9f6
   else
a5bd9f6
     grub_free (fwpath);
a5bd9f6
   if (device)
a5bd9f6
-- 
a5bd9f6
1.8.1.4
a5bd9f6