2018-07-12 14:56:34 +00:00
|
|
|
From 0000000000000000000000000000000000000000 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-07-10 18:39:10 +00:00
|
|
|
Subject: [PATCH] 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
|
2021-03-12 21:54:28 +00:00
|
|
|
index 73967e2f5b0..d1de9fa6873 100644
|
2012-05-21 19:19:24 +00:00
|
|
|
--- a/grub-core/kern/main.c
|
|
|
|
+++ b/grub-core/kern/main.c
|
2021-03-12 21:54:28 +00:00
|
|
|
@@ -128,16 +128,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
|
2021-03-12 21:54:28 +00:00
|
|
|
index 70614de1565..62571e6dfcc 100644
|
2012-05-21 19:19:24 +00:00
|
|
|
--- a/grub-core/normal/main.c
|
|
|
|
+++ b/grub-core/normal/main.c
|
2021-03-12 21:54:28 +00:00
|
|
|
@@ -339,7 +339,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;
|
|
|
|
+
|
2019-08-15 06:01:31 +00:00
|
|
|
+ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
|
2012-05-21 19:19:24 +00:00
|
|
|
+ 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)
|