aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Martinez Canillas <javierm@redhat.com>2022-08-18 13:50:12 -0400
committerDaniel Kiper <daniel.kiper@oracle.com>2022-08-20 00:23:18 +0200
commit1e79bbfbda24a08cb856ff30f8b1bec460779b91 (patch)
tree535c68cfcc39aed8f49efc4b199f75df50f95dfa
parent0eb684e8bfb0a9d2d42017a354740be25947babe (diff)
downloadgrub-1e79bbfbda24a08cb856ff30f8b1bec460779b91.tar.gz
commands/efi/efifwsetup: Print an error if boot to firmware setup is not supported
The "fwsetup" command is only registered if the firmware supports booting to the firmware setup UI. But it could be possible that the GRUB config already contains a "fwsetup" entry, because it was generated in a machine that has support for this feature. To prevent users getting an error like: error: ../../grub-core/script/function.c:109:can't find command `fwsetup'. if it is not supported by the firmware, let's just always register the command but print a more accurate message if the firmware doesn't support this option. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Robbie Harwood <rharwood@redhat.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
-rw-r--r--grub-core/commands/efi/efifwsetup.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/grub-core/commands/efi/efifwsetup.c b/grub-core/commands/efi/efifwsetup.c
index de986925c..7b6d4bc9f 100644
--- a/grub-core/commands/efi/efifwsetup.c
+++ b/grub-core/commands/efi/efifwsetup.c
@@ -27,6 +27,8 @@
GRUB_MOD_LICENSE ("GPLv3+");
+static grub_efi_boolean_t efifwsetup_is_supported (void);
+
static grub_err_t
grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
@@ -38,6 +40,10 @@ grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)),
grub_size_t oi_size;
static grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
+ if (!efifwsetup_is_supported ())
+ return grub_error (GRUB_ERR_INVALID_COMMAND,
+ N_("reboot to firmware setup is not supported by the current firmware"));
+
grub_efi_get_variable ("OsIndications", &global, &oi_size,
(void **) &old_os_indications);
@@ -82,10 +88,8 @@ efifwsetup_is_supported (void)
GRUB_MOD_INIT (efifwsetup)
{
- if (efifwsetup_is_supported ())
- cmd = grub_register_command ("fwsetup", grub_cmd_fwsetup, NULL,
- N_("Reboot into firmware setup menu."));
-
+ cmd = grub_register_command ("fwsetup", grub_cmd_fwsetup, NULL,
+ N_("Reboot into firmware setup menu."));
}
GRUB_MOD_FINI (efifwsetup)