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