[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/20] GRUB: Avoid printing frivilous error messages
From: |
Leah Rowe |
Subject: |
[PATCH 05/20] GRUB: Avoid printing frivilous error messages |
Date: |
Sun, 14 Jan 2024 15:55:22 +0000 |
From: Leah Rowe <leah@libreboot.org>
For example, GRUB prints an error message stating that the
prefix isn't set, when it is. This is due to an early initialisation
check in GRUB, that still passes anyway, but the prefix is set later
on. Certain modules-related error messages are also silenced, to
prevent certain distro GRUB configs from causing these messages, where
they load modules that aren't actually used, that GNU Boot lacks.
Signed-off-by: Leah Rowe <leah@libreboot.org>
---
...-missing-prefix-errors-on-the-screen.patch | 102 ++++++++++++++++++
...on-t-print-error-if-module-not-found.patch | 34 ++++++
...014-don-t-print-empty-error-messages.patch | 31 ++++++
3 files changed, 167 insertions(+)
create mode 100644
resources/grub/patches/0012-don-t-print-missing-prefix-errors-on-the-screen.patch
create mode 100644
resources/grub/patches/0013-don-t-print-error-if-module-not-found.patch
create mode 100644
resources/grub/patches/0014-don-t-print-empty-error-messages.patch
diff --git
a/resources/grub/patches/0012-don-t-print-missing-prefix-errors-on-the-screen.patch
b/resources/grub/patches/0012-don-t-print-missing-prefix-errors-on-the-screen.patch
new file mode 100644
index 0000000..25091d1
--- /dev/null
+++
b/resources/grub/patches/0012-don-t-print-missing-prefix-errors-on-the-screen.patch
@@ -0,0 +1,102 @@
+From 9e7a651a0f15f2e9dec65a77765c3c4fd97b4165 Mon Sep 17 00:00:00 2001
+From: Leah Rowe <leah@libreboot.org>
+Date: Sun, 5 Nov 2023 16:14:58 +0000
+Subject: [PATCH 1/1] don't print missing prefix errors on the screen
+
+we do actually set the prefix. this patch modifies
+grub to still set grub_errno and return accordingly,
+so the behaviour is otherwise identical, but it will
+no longer print a warning message on the screen.
+
+Signed-off-by: Leah Rowe <leah@libreboot.org>
+---
+ grub-core/commands/keylayouts.c | 2 +-
+ grub-core/commands/loadenv.c | 2 +-
+ grub-core/commands/nativedisk.c | 2 +-
+ grub-core/efiemu/main.c | 3 +--
+ grub-core/font/font.c | 2 +-
+ grub-core/kern/dl.c | 2 +-
+ 6 files changed, 6 insertions(+), 7 deletions(-)
+
+diff --git a/grub-core/commands/keylayouts.c b/grub-core/commands/keylayouts.c
+index 445fa0601..00bcf7025 100644
+--- a/grub-core/commands/keylayouts.c
++++ b/grub-core/commands/keylayouts.c
+@@ -211,7 +211,7 @@ grub_cmd_keymap (struct grub_command *cmd __attribute__
((unused)),
+ {
+ const char *prefix = grub_env_get ("prefix");
+ if (!prefix)
+- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("variable `%s' isn't
set"), "prefix");
++ return (grub_errno = GRUB_ERR_BAD_ARGUMENT);
+ filename = grub_xasprintf ("%s/layouts/%s.gkb", prefix, argv[0]);
+ if (!filename)
+ return grub_errno;
+diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c
+index 166445849..699b39bfa 100644
+--- a/grub-core/commands/loadenv.c
++++ b/grub-core/commands/loadenv.c
+@@ -58,7 +58,7 @@ open_envblk_file (char *filename,
+ prefix = grub_env_get ("prefix");
+ if (! prefix)
+ {
+- grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"),
"prefix");
++ grub_errno = GRUB_ERR_FILE_NOT_FOUND;
+ return 0;
+ }
+
+diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c
+index 580c8d3b0..6806bff9c 100644
+--- a/grub-core/commands/nativedisk.c
++++ b/grub-core/commands/nativedisk.c
+@@ -186,7 +186,7 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__
((unused)),
+ prefix = grub_env_get ("prefix");
+
+ if (! prefix)
+- return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't
set"), "prefix");
++ return (grub_errno = GRUB_ERR_FILE_NOT_FOUND);
+
+ if (prefix)
+ path_prefix = (prefix[0] == '(') ? grub_strchr (prefix, ')') : NULL;
+diff --git a/grub-core/efiemu/main.c b/grub-core/efiemu/main.c
+index e7037f4ed..e5d4dbff1 100644
+--- a/grub-core/efiemu/main.c
++++ b/grub-core/efiemu/main.c
+@@ -231,8 +231,7 @@ grub_efiemu_autocore (void)
+ prefix = grub_env_get ("prefix");
+
+ if (! prefix)
+- return grub_error (GRUB_ERR_FILE_NOT_FOUND,
+- N_("variable `%s' isn't set"), "prefix");
++ return (grub_errno = GRUB_ERR_FILE_NOT_FOUND);
+
+ suffix = grub_efiemu_get_default_core_name ();
+
+diff --git a/grub-core/font/font.c b/grub-core/font/font.c
+index 18de52562..2a0fea6c8 100644
+--- a/grub-core/font/font.c
++++ b/grub-core/font/font.c
+@@ -461,7 +461,7 @@ grub_font_load (const char *filename)
+
+ if (!prefix)
+ {
+- grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't
set"), "prefix");
++ grub_errno = GRUB_ERR_FILE_NOT_FOUND;
+ goto fail;
+ }
+ file = try_open_from_prefix (prefix, filename);
+diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
+index 4011e2d15..af3bd00d0 100644
+--- a/grub-core/kern/dl.c
++++ b/grub-core/kern/dl.c
+@@ -758,7 +758,7 @@ grub_dl_load (const char *name)
+ return 0;
+
+ if (! grub_dl_dir) {
+- grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"),
"prefix");
++ grub_errno = GRUB_ERR_FILE_NOT_FOUND;
+ return 0;
+ }
+
+--
+2.39.2
+
diff --git
a/resources/grub/patches/0013-don-t-print-error-if-module-not-found.patch
b/resources/grub/patches/0013-don-t-print-error-if-module-not-found.patch
new file mode 100644
index 0000000..f4cf939
--- /dev/null
+++ b/resources/grub/patches/0013-don-t-print-error-if-module-not-found.patch
@@ -0,0 +1,34 @@
+From 6237c5762edccc1e1fa4746b1d4aa5e8d81e4883 Mon Sep 17 00:00:00 2001
+From: Leah Rowe <leah@libreboot.org>
+Date: Sun, 5 Nov 2023 16:36:22 +0000
+Subject: [PATCH 1/1] don't print error if module not found
+
+still set grub_errno accordingly, and otherwise
+behave the same. in libreboot, we remove a lot of
+modules but then rely on loading a grub.cfg
+provided by a distro; in almost all cases that works,
+but also in almost all cases, that will try to load
+a module we don't actually need, but then it prints
+a message. this can annoy some users, so silence it.
+
+Signed-off-by: Leah Rowe <leah@libreboot.org>
+---
+ grub-core/kern/dl.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
+index af3bd00d0..21d0cedb1 100644
+--- a/grub-core/kern/dl.c
++++ b/grub-core/kern/dl.c
+@@ -486,7 +486,7 @@ grub_dl_resolve_name (grub_dl_t mod, Elf_Ehdr *e)
+
+ s = grub_dl_find_section (e, ".modname");
+ if (!s)
+- return grub_error (GRUB_ERR_BAD_MODULE, "no module name found");
++ return (grub_errno = GRUB_ERR_BAD_MODULE);
+
+ mod->name = grub_strdup ((char *) e + s->sh_offset);
+ if (! mod->name)
+--
+2.39.2
+
diff --git a/resources/grub/patches/0014-don-t-print-empty-error-messages.patch
b/resources/grub/patches/0014-don-t-print-empty-error-messages.patch
new file mode 100644
index 0000000..25221c9
--- /dev/null
+++ b/resources/grub/patches/0014-don-t-print-empty-error-messages.patch
@@ -0,0 +1,31 @@
+From e5b7ec81421487e71bcaf8b6b5a27f3649a62753 Mon Sep 17 00:00:00 2001
+From: Leah Rowe <leah@libreboot.org>
+Date: Sun, 5 Nov 2023 17:25:20 +0000
+Subject: [PATCH 1/1] don't print empty error messages
+
+this is part two of the quest to kill the prefix
+error message. after i disabled prefix-related
+messages, it still printed "error: ." on screen.
+
+Signed-off-by: Leah Rowe <leah@libreboot.org>
+---
+ grub-core/kern/err.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/grub-core/kern/err.c b/grub-core/kern/err.c
+index 53c734de7..7cac53983 100644
+--- a/grub-core/kern/err.c
++++ b/grub-core/kern/err.c
+@@ -107,7 +107,8 @@ grub_print_error (void)
+ {
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+- grub_err_printf (_("error: %s.\n"), grub_errmsg);
++ if (grub_strlen(grub_errmsg) > 0)
++ grub_err_printf (_("error: %s.\n"), grub_errmsg);
+ grub_err_printed_errors++;
+ }
+ }
+--
+2.39.2
+
--
2.39.2
- [PATCH 01/20] Use GRUB 2.12, Leah Rowe, 2024/01/14
- [PATCH 03/20] GRUB: Force scancode set 2 with translation, Leah Rowe, 2024/01/14
- [PATCH 05/20] GRUB: Avoid printing frivilous error messages,
Leah Rowe <=
- [PATCH 04/20] GRUB: Don't spew "Unknown key 0xFF", Leah Rowe, 2024/01/14
- [PATCH 02/20] Argon2 KDF support in GRUB 2.12, Leah Rowe, 2024/01/14
- [PATCH 06/20] GRUB: Use reduced set of modules, Leah Rowe, 2024/01/14
- [PATCH 07/20] grub.cfg: support ESP, btrfs subvols and extlinux, Leah Rowe, 2024/01/14
- [PATCH 09/20] build/boot/roms: skip building gnat on fam15h, Leah Rowe, 2024/01/14
- [PATCH 11/20] import util/dell-flash-unlock from lbmk 09bed9a4, Leah Rowe, 2024/01/14
- [PATCH 10/20] NEW MAINBOARD: Dell Latitude E6400, Leah Rowe, 2024/01/14
- [PATCH 14/20] build/boot/roms: support "normal" seabios configs, Leah Rowe, 2024/01/14
- [PATCH 13/20] use seabios revision from canoeboot 20231103, Leah Rowe, 2024/01/14
- [PATCH 12/20] import util/nvmutil from lbmk 09bed9a4, Leah Rowe, 2024/01/14