|
|
8e15ce |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
8e15ce |
From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
|
|
|
8e15ce |
Date: Wed, 19 Sep 2012 21:22:55 -0300
|
|
|
8e15ce |
Subject: [PATCH] Add fw_path variable (revised)
|
|
|
8e15ce |
|
|
|
8e15ce |
This patch makes grub look for its config file on efi where the app was
|
|
|
8e15ce |
found. It was originally written by Matthew Garrett, and adapted to fix the
|
|
|
8e15ce |
"No modules are loaded on grub2 network boot" issue:
|
|
|
8e15ce |
|
|
|
8e15ce |
https://bugzilla.redhat.com/show_bug.cgi?id=857936
|
|
|
b35c50 |
|
|
|
b35c50 |
Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
|
|
|
b35c50 |
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
|
|
|
8e15ce |
---
|
|
|
8e15ce |
grub-core/kern/main.c | 13 ++++++-------
|
|
|
8e15ce |
grub-core/normal/main.c | 25 ++++++++++++++++++++++++-
|
|
|
8e15ce |
2 files changed, 30 insertions(+), 8 deletions(-)
|
|
|
8e15ce |
|
|
|
8e15ce |
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
|
|
|
b35c50 |
index 73967e2f5b..d1de9fa687 100644
|
|
|
8e15ce |
--- a/grub-core/kern/main.c
|
|
|
8e15ce |
+++ b/grub-core/kern/main.c
|
|
|
8e15ce |
@@ -128,16 +128,15 @@ grub_set_prefix_and_root (void)
|
|
|
8e15ce |
|
|
|
8e15ce |
grub_machine_get_bootlocation (&fwdevice, &fwpath);
|
|
|
8e15ce |
|
|
|
8e15ce |
- if (fwdevice)
|
|
|
8e15ce |
+ if (fwdevice && fwpath)
|
|
|
8e15ce |
{
|
|
|
8e15ce |
- char *cmdpath;
|
|
|
8e15ce |
+ char *fw_path;
|
|
|
8e15ce |
|
|
|
8e15ce |
- cmdpath = grub_xasprintf ("(%s)%s", fwdevice, fwpath ? : "");
|
|
|
8e15ce |
- if (cmdpath)
|
|
|
8e15ce |
+ fw_path = grub_xasprintf ("(%s)/%s", fwdevice, fwpath);
|
|
|
8e15ce |
+ if (fw_path)
|
|
|
8e15ce |
{
|
|
|
8e15ce |
- grub_env_set ("cmdpath", cmdpath);
|
|
|
8e15ce |
- grub_env_export ("cmdpath");
|
|
|
8e15ce |
- grub_free (cmdpath);
|
|
|
8e15ce |
+ grub_env_set ("fw_path", fw_path);
|
|
|
8e15ce |
+ grub_free (fw_path);
|
|
|
8e15ce |
}
|
|
|
8e15ce |
}
|
|
|
8e15ce |
|
|
|
8e15ce |
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
|
|
|
b35c50 |
index 70614de156..62571e6dfc 100644
|
|
|
8e15ce |
--- a/grub-core/normal/main.c
|
|
|
8e15ce |
+++ b/grub-core/normal/main.c
|
|
|
8e15ce |
@@ -339,7 +339,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
|
|
|
8e15ce |
/* Guess the config filename. It is necessary to make CONFIG static,
|
|
|
8e15ce |
so that it won't get broken by longjmp. */
|
|
|
8e15ce |
char *config;
|
|
|
8e15ce |
- const char *prefix;
|
|
|
8e15ce |
+ const char *prefix, *fw_path;
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+ fw_path = grub_env_get ("fw_path");
|
|
|
8e15ce |
+ if (fw_path)
|
|
|
8e15ce |
+ {
|
|
|
8e15ce |
+ config = grub_xasprintf ("%s/grub.cfg", fw_path);
|
|
|
8e15ce |
+ if (config)
|
|
|
8e15ce |
+ {
|
|
|
8e15ce |
+ grub_file_t file;
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
|
|
|
8e15ce |
+ if (file)
|
|
|
8e15ce |
+ {
|
|
|
8e15ce |
+ grub_file_close (file);
|
|
|
8e15ce |
+ grub_enter_normal_mode (config);
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
+ else
|
|
|
8e15ce |
+ {
|
|
|
8e15ce |
+ /* Ignore all errors. */
|
|
|
8e15ce |
+ grub_errno = 0;
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
+ grub_free (config);
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
|
|
|
8e15ce |
prefix = grub_env_get ("prefix");
|
|
|
8e15ce |
if (prefix)
|