[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 12/19] Add fw_path variable to detect config file on efi
From: |
Robbie Harwood |
Subject: |
[PATCH v4 12/19] Add fw_path variable to detect config file on efi |
Date: |
Mon, 9 Jan 2023 18:30:38 -0500 |
From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
This patch makes grub look for its config file on efi where the app was
found.
Resolves: rhbz#857936, rhbz#1616395
Co-authored-by: Matthew Garrett
Co-authored-by: Javier Martinez Canillas <javierm@redhat.com>
Co-authored-by: Robbie Harwood <rharwood@redhat.com>
Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/kern/main.c | 14 +++++++-------
grub-core/normal/main.c | 25 ++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
index 731c07c290..e1e6cf7a02 100644
--- a/grub-core/kern/main.c
+++ b/grub-core/kern/main.c
@@ -128,16 +128,16 @@ grub_set_prefix_and_root (void)
grub_machine_get_bootlocation (&fwdevice, &fwpath);
- if (fwdevice)
+ if (fwdevice && fwpath)
{
- char *cmdpath;
+ char *fw_path;
- cmdpath = grub_xasprintf ("(%s)%s", fwdevice, fwpath ? : "");
- if (cmdpath)
+ fw_path = grub_xasprintf ("(%s)/%s", fwdevice, fwpath);
+ if (fw_path)
{
- grub_env_set ("cmdpath", cmdpath);
- grub_env_export ("cmdpath");
- grub_free (cmdpath);
+ grub_env_set ("fw_path", fw_path);
+ grub_env_export ("fw_path");
+ grub_free (fw_path);
}
}
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index bd44310005..a557ba5c9c 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -320,7 +320,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__
((unused)),
/* 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, GRUB_FILE_TYPE_CONFIG);
+ if (file)
+ {
+ grub_file_close (file);
+ grub_enter_normal_mode (config);
+ }
+ else
+ {
+ /* Ignore all errors. */
+ grub_errno = 0;
+ }
+ grub_free (config);
+ }
+ }
prefix = grub_env_get ("prefix");
if (prefix)
--
2.39.0
- [PATCH v4 00/19] UEFI networking support including ipv6 + dhcpv6, Robbie Harwood, 2023/01/09
- [PATCH v4 01/19] Revert "net/http: Allow use of non-standard TCP/IP ports", Robbie Harwood, 2023/01/09
- [PATCH v4 04/19] efinet: add structures for PXE messages, Robbie Harwood, 2023/01/09
- [PATCH v4 10/19] efinet: also use the firmware acceleration for http, Robbie Harwood, 2023/01/09
- [PATCH v4 02/19] net: read bracketed ipv6 addrs and port numbers, Robbie Harwood, 2023/01/09
- [PATCH v4 11/19] efi/http: match protocol+hostname of boot url in root_url, Robbie Harwood, 2023/01/09
- [PATCH v4 14/19] Try mac/guid/etc before grub.cfg on tftp config files, Robbie Harwood, 2023/01/09
- [PATCH v4 06/19] bootp: Process DHCPACK packet during HTTP Boot, Robbie Harwood, 2023/01/09
- [PATCH v4 12/19] Add fw_path variable to detect config file on efi,
Robbie Harwood <=
- [PATCH v4 13/19] use fw_path prefix when fallback searching for grub config, Robbie Harwood, 2023/01/09
- [PATCH v4 08/19] efinet: set DNS server from UEFI protocol, Robbie Harwood, 2023/01/09
- [PATCH v4 05/19] grub.texi: Add net_bootp6 doumentation, Robbie Harwood, 2023/01/09
- [PATCH v4 15/19] Prepend prefix when HTTP path is relative, Robbie Harwood, 2023/01/09
- [PATCH v4 16/19] efi/http: Enclose literal IPv6 addresses in square brackets, Robbie Harwood, 2023/01/09
- [PATCH v4 17/19] http: Prepend prefix when the HTTP path is relative, Robbie Harwood, 2023/01/09
- [PATCH v4 03/19] efinet + bootp: add net_bootp6 command supporting dhcpv6, Robbie Harwood, 2023/01/09
- [PATCH v4 18/19] normal/main: Discover the device to read the config from as a fallback, Robbie Harwood, 2023/01/09
- [PATCH v4 19/19] efinet: Add DHCP proxy support, Robbie Harwood, 2023/01/09
- [PATCH v4 07/19] efinet Configure network from UEFI device path, Robbie Harwood, 2023/01/09