2018-04-11 18:42:03 +00:00
|
|
|
From 7f021a05a5ed7c97432abbc1762f40e36a4915e3 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
|
2018-06-19 14:33:22 +00:00
|
|
|
Subject: [PATCH 081/246] 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
|
2018-02-27 18:56:41 +00:00
|
|
|
index 9cad0c4485c..8ab7794c47b 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
|
2018-02-27 18:56:41 +00:00
|
|
|
index 249e19bc788..759c475c4d9 100644
|
2012-05-21 19:19:24 +00:00
|
|
|
--- a/grub-core/normal/main.c
|
|
|
|
+++ b/grub-core/normal/main.c
|
2016-03-04 19:24:31 +00:00
|
|
|
@@ -338,7 +338,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)
|
|
|
|
--
|
2018-06-04 16:28:07 +00:00
|
|
|
2.17.1
|
2012-05-21 19:19:24 +00:00
|
|
|
|