2014-06-24 15:18:06 +00:00
|
|
|
From 5bd3e1f888eeddc2575608516220ffa7b8270c7a Mon Sep 17 00:00:00 2001
|
2012-09-19 14:43:43 +00:00
|
|
|
From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
|
|
|
|
Date: Wed, 19 Sep 2012 21:22:55 -0300
|
2014-07-02 15:49:28 +00:00
|
|
|
Subject: [PATCH 090/140] Add fw_path variable (revised)
|
2012-05-21 19:19:24 +00:00
|
|
|
|
2012-09-19 14:43:43 +00:00
|
|
|
This patch makes grub look for its config file on efi where the app was
|
|
|
|
found. It was originally written by Matthew Garrett, and adapted to fix the
|
|
|
|
"No modules are loaded on grub2 network boot" issue:
|
|
|
|
|
|
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=857936
|
2012-05-21 19:19:24 +00:00
|
|
|
---
|
2014-01-06 16:39:16 +00:00
|
|
|
grub-core/kern/main.c | 13 ++++++-------
|
2013-05-02 20:54:52 +00:00
|
|
|
grub-core/normal/main.c | 25 ++++++++++++++++++++++++-
|
2014-01-06 16:39:16 +00:00
|
|
|
2 files changed, 30 insertions(+), 8 deletions(-)
|
2012-05-21 19:19:24 +00:00
|
|
|
|
|
|
|
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
|
2014-01-06 16:39:16 +00:00
|
|
|
index 9cad0c4..8ab7794 100644
|
2012-05-21 19:19:24 +00:00
|
|
|
--- a/grub-core/kern/main.c
|
|
|
|
+++ b/grub-core/kern/main.c
|
2014-01-06 16:39:16 +00:00
|
|
|
@@ -127,16 +127,15 @@ grub_set_prefix_and_root (void)
|
2012-05-21 19:19:24 +00:00
|
|
|
|
2014-01-06 16:39:16 +00:00
|
|
|
grub_machine_get_bootlocation (&fwdevice, &fwpath);
|
2012-05-21 19:19:24 +00:00
|
|
|
|
2014-01-06 16:39:16 +00:00
|
|
|
- if (fwdevice)
|
2012-05-21 19:19:24 +00:00
|
|
|
+ if (fwdevice && fwpath)
|
2014-01-06 16:39:16 +00:00
|
|
|
{
|
|
|
|
- char *cmdpath;
|
2012-05-21 19:19:24 +00:00
|
|
|
+ char *fw_path;
|
2014-01-06 16:39:16 +00:00
|
|
|
|
|
|
|
- cmdpath = grub_xasprintf ("(%s)%s", fwdevice, fwpath ? : "");
|
|
|
|
- if (cmdpath)
|
2012-05-21 20:29:26 +00:00
|
|
|
+ fw_path = grub_xasprintf ("(%s)/%s", fwdevice, fwpath);
|
2012-05-21 19:19:24 +00:00
|
|
|
+ if (fw_path)
|
2014-01-06 16:39:16 +00:00
|
|
|
{
|
|
|
|
- grub_env_set ("cmdpath", cmdpath);
|
|
|
|
- grub_env_export ("cmdpath");
|
|
|
|
- grub_free (cmdpath);
|
2012-05-21 19:19:24 +00:00
|
|
|
+ grub_env_set ("fw_path", fw_path);
|
|
|
|
+ grub_free (fw_path);
|
2014-01-06 16:39:16 +00:00
|
|
|
}
|
2012-05-21 19:19:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
|
2014-03-13 18:02:22 +00:00
|
|
|
index 3a926fc..6f4970f 100644
|
2012-05-21 19:19:24 +00:00
|
|
|
--- a/grub-core/normal/main.c
|
|
|
|
+++ b/grub-core/normal/main.c
|
2014-03-13 18:02:22 +00:00
|
|
|
@@ -319,7 +319,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
|
2012-05-21 19:19:24 +00:00
|
|
|
/* Guess the config filename. It is necessary to make CONFIG static,
|
|
|
|
so that it won't get broken by longjmp. */
|
|
|
|
char *config;
|
|
|
|
- const char *prefix;
|
|
|
|
+ const char *prefix, *fw_path;
|
|
|
|
+
|
|
|
|
+ fw_path = grub_env_get ("fw_path");
|
|
|
|
+ if (fw_path)
|
|
|
|
+ {
|
|
|
|
+ config = grub_xasprintf ("%s/grub.cfg", fw_path);
|
|
|
|
+ if (config)
|
|
|
|
+ {
|
|
|
|
+ grub_file_t file;
|
|
|
|
+
|
|
|
|
+ file = grub_file_open (config);
|
|
|
|
+ if (file)
|
|
|
|
+ {
|
|
|
|
+ grub_file_close (file);
|
|
|
|
+ grub_enter_normal_mode (config);
|
|
|
|
+ }
|
2012-09-19 14:43:43 +00:00
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ /* Ignore all errors. */
|
|
|
|
+ grub_errno = 0;
|
|
|
|
+ }
|
2012-05-21 19:19:24 +00:00
|
|
|
+ grub_free (config);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
prefix = grub_env_get ("prefix");
|
|
|
|
if (prefix)
|
|
|
|
--
|
2014-07-02 15:49:28 +00:00
|
|
|
1.9.3
|
2012-05-21 19:19:24 +00:00
|
|
|
|