From a24725cc6e9a3de0dfadda38a97d3171863a208a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 14 Dec 2013 23:31:56 +0100 Subject: [PATCH] Change grub_install_register_efi interface to pass GRUB device. This allows grub_install_register_efi to request partition info directly. --- ChangeLog | 7 +++++++ grub-core/osdep/basic/no_platform.c | 2 +- grub-core/osdep/unix/platform.c | 8 +++++++- include/grub/util/install.h | 2 +- util/grub-install.c | 16 +++++++++++----- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4cfed4835..a7f84666b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-12-14 Vladimir Serbinenko + + Change grub_install_register_efi interface to pass GRUB device. + + This allows grub_install_register_efi to request partition info + directly. + 2013-12-14 Vladimir Serbinenko Workaround cygwin bug when using \\?\Volume{GUID} syntax. diff --git a/grub-core/osdep/basic/no_platform.c b/grub-core/osdep/basic/no_platform.c index 32be5e8e3..ab7652a7f 100644 --- a/grub-core/osdep/basic/no_platform.c +++ b/grub-core/osdep/basic/no_platform.c @@ -31,7 +31,7 @@ grub_install_register_ieee1275 (int is_prep, const char *install_device, } void -grub_install_register_efi (const char *efidir_disk, int efidir_part, +grub_install_register_efi (grub_device_t efidir_grub_dev, const char *efifile_path, const char *efi_distributor) { diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c index dc296c98b..b2ec6bd8d 100644 --- a/grub-core/osdep/unix/platform.c +++ b/grub-core/osdep/unix/platform.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -129,10 +130,15 @@ grub_install_remove_efi_entries_by_distributor (const char *efi_distributor) } void -grub_install_register_efi (const char *efidir_disk, int efidir_part, +grub_install_register_efi (grub_device_t efidir_grub_dev, const char *efifile_path, const char *efi_distributor) { + const char * efidir_disk; + int efidir_part; + efidir_disk = grub_util_biosdisk_get_osdev (efidir_grub_dev->disk); + efidir_part = efidir_grub_dev->disk->partition ? efidir_grub_dev->disk->partition->number + 1 : 1; + if (grub_util_exec_redirect_null ((const char * []){ "efibootmgr", "--version", NULL })) { /* TRANSLATORS: This message is shown when required executable `%s' diff --git a/include/grub/util/install.h b/include/grub/util/install.h index 20626d4e6..a647af4ad 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -205,7 +205,7 @@ const char * grub_install_get_default_x86_platform (void); void -grub_install_register_efi (const char *efidir_disk, int efidir_part, +grub_install_register_efi (grub_device_t efidir_grub_dev, const char *efifile_path, const char *efi_distributor); diff --git a/util/grub-install.c b/util/grub-install.c index 5d22f902e..0fbf052b8 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1559,19 +1559,25 @@ main (int argc, char *argv[]) } if (!removable && update_nvram) { - char * efidir_disk; - int efidir_part; char * efifile_path; + char * part; /* Try to make this image bootable using the EFI Boot Manager, if available. */ if (!efi_distributor || efi_distributor[0] == '\0') grub_util_error ("%s", "EFI distributor id isn't specified."); - efidir_disk = grub_util_get_os_disk (efidir_device_names[0]); - efidir_part = efidir_grub_dev->disk->partition ? efidir_grub_dev->disk->partition->number + 1 : 1; efifile_path = xasprintf ("\\EFI\\%s\\%s", efi_distributor, efi_file); - grub_install_register_efi (efidir_disk, efidir_part, + part = (efidir_grub_dev->disk->partition + ? grub_partition_get_name (efidir_grub_dev->disk->partition) + : 0); + grub_util_info ("Registering with EFI: distributor = `%s'," + " path = `%s', ESP at %s%s%s", + efi_distributor, efifile_path, + efidir_grub_dev->disk->name, + (part ? ",": ""), (part ? : "")); + grub_free (part); + grub_install_register_efi (efidir_grub_dev, efifile_path, efi_distributor); } break;