grub2/0171-grub-core-kern-main.c-grub_set_prefix_and_root-Strip.patch
2013-05-02 16:54:52 -04:00

50 lines
1.6 KiB
Diff

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