Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cbtps-0006VM-EJ for mharc-grub-devel@gnu.org; Thu, 09 Feb 2017 13:52:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbtpp-0006Ur-F3 for grub-devel@gnu.org; Thu, 09 Feb 2017 13:52:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbtpk-0005Up-G9 for grub-devel@gnu.org; Thu, 09 Feb 2017 13:52:49 -0500 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]:33623) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cbtpk-0005UV-2y for grub-devel@gnu.org; Thu, 09 Feb 2017 13:52:44 -0500 Received: by mail-lf0-x242.google.com with SMTP id x1so1124070lff.0 for ; Thu, 09 Feb 2017 10:52:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=CKjdyVWUmUbm15p6PVkk7EGLzKjCmIklruwSpuimObc=; b=Tl7LKz6m1mSC5QWNmUi06WRpYNwv3ob0NTYa7DQJiCHGNhEm8F0fJnHjNIBL+pq4oQ egByfxSzhqjy87fOY33Fg8+0p0e5znejtkiuY+Ymjz8rhba+B9eUagP8pgVBlEmdg/G7 KGcDg6p7or6b6+QLStXXI5kJaujXIHNuMnrgVyhSmDwc5Yw4Mr/yL0Wa7KQxi0PRrRb9 8UD9WiuUWCfsmN6f8H9U5Jh6FZrmPZu1rRSc0XYrMVl9hFLDhZeAUAF+7kCzbRPhuH8r 7KdeTr+unYsMuHoqjhX/bMvQrRi8z5nqj8mbWABVANJ/j8ABCLjY00caccZyUi5tyYR/ GUOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=CKjdyVWUmUbm15p6PVkk7EGLzKjCmIklruwSpuimObc=; b=gn41W2s9GxSl9jo4dr+7bBaBmPQ/Rm0jOXWBgk6S9tfFO/b+Z2tnbKTzTa4unTKguo NdvjRF/pqCi7LQrTE5IteHhn3ZfjlFYvmTC6fHtHwMKhh/x7rLzDnvWhBtsWZ4/JCYtE u8hEDVJiortBFpsBByw69jpj7Cpt3r3rdlIiG/dSE6BugG5mUtDdxn97D+HeXcQzq+yF Iw0FJ2g0RWsJLp9lL9tAQeVdiKp6IEG4rkl0tcGODqsT95H5fKBKbwKgyg3MKDc8h/N6 qjsa7SCaqXIt68vHwDB/UkLHEzXiloh2m5+9SRkv8w1hNLCXIt20y3sqVvhCPFqwcGE9 sPiA== X-Gm-Message-State: AMke39lFa81l962ogzuo0NdoE2dOYwdjg1XYFYKeF74q7surKed8qhWVVQPTul666MVgfg== X-Received: by 10.46.77.149 with SMTP id c21mr1846134ljd.69.1486666362391; Thu, 09 Feb 2017 10:52:42 -0800 (PST) Received: from [192.168.1.6] (ppp109-252-90-129.pppoe.spdop.ru. [109.252.90.129]) by smtp.gmail.com with ESMTPSA id i186sm3737285lfg.38.2017.02.09.10.52.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 10:52:41 -0800 (PST) Subject: Re: [PATCH] Make grub-install check for errors from efibootmgr To: The development of GNU GRUB References: <1485803091-13678-1-git-send-email-93sam@debian.org> Cc: Steve McIntyre <93sam@debian.org> From: Andrei Borzenkov Message-ID: <86064712-98a6-0d06-4c53-b7889c3c3d26@gmail.com> Date: Thu, 9 Feb 2017 21:52:40 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <1485803091-13678-1-git-send-email-93sam@debian.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::242 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Feb 2017 18:52:50 -0000 30.01.2017 22:04, Steve McIntyre пишет: > Code is currently ignoring errors from efibootmgr, giving users > clearly bogus output like: > > Setting up grub-efi-amd64 (2.02~beta3-4) ... > Installing for x86_64-efi platform. > Could not delete variable: No space left on device > Could not prepare Boot variable: No space left on device > Installation finished. No error reported. > > and then potentially unbootable systems. If efibootmgr fails, > grub-install should know that and report it! > This looks more or less cosmetic to me. First, errors are displayed to user so it is not that user is not aware. Second, efibootmgr is more or less optional. This is convenient but by far not the only one possibility to use newly installed grub. Third, even successful execution of efibootmgr does not mean it will actually boot grub - there are enough systems out there that will simply ditch grub entry and replace it with hard coded Windows one. So I'm fine with changing "no error reported" to "efibootmgr invocation failed; check your firmware settings" or similar, but I am not sure we need to abort grub-install in this case. What exact problem do you solve by aborting? > Signed-off-by: Steve McIntyre <93sam@debian.org> > --- > grub-core/osdep/unix/platform.c | 24 +++++++++++++++--------- > include/grub/util/install.h | 2 +- > util/grub-install.c | 14 +++++++++++--- > 3 files changed, 27 insertions(+), 13 deletions(-) > > diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c > index 28cb37e..f9c376c 100644 > --- a/grub-core/osdep/unix/platform.c > +++ b/grub-core/osdep/unix/platform.c > @@ -78,19 +78,20 @@ get_ofpathname (const char *dev) > dev); > } > > -static void > +static int > grub_install_remove_efi_entries_by_distributor (const char *efi_distributor) > { > int fd; > pid_t pid = grub_util_exec_pipe ((const char * []){ "efibootmgr", NULL }, &fd); > char *line = NULL; > size_t len = 0; > + int error = 0; > > if (!pid) > { > grub_util_warn (_("Unable to open stream from %s: %s"), > "efibootmgr", strerror (errno)); > - return; > + return errno; > } > > FILE *fp = fdopen (fd, "r"); > @@ -98,7 +99,7 @@ grub_install_remove_efi_entries_by_distributor (const char *efi_distributor) > { > grub_util_warn (_("Unable to open stream from %s: %s"), > "efibootmgr", strerror (errno)); > - return; > + return errno; > } > > line = xmalloc (80); > @@ -119,23 +120,25 @@ grub_install_remove_efi_entries_by_distributor (const char *efi_distributor) > bootnum = line + sizeof ("Boot") - 1; > bootnum[4] = '\0'; > if (!verbosity) > - grub_util_exec ((const char * []){ "efibootmgr", "-q", > + error = grub_util_exec ((const char * []){ "efibootmgr", "-q", > "-b", bootnum, "-B", NULL }); > else > - grub_util_exec ((const char * []){ "efibootmgr", > + error = grub_util_exec ((const char * []){ "efibootmgr", > "-b", bootnum, "-B", NULL }); > } > > free (line); > + return error; > } > > -void > +int > 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; > + int error = 0; > 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; > > @@ -151,23 +154,26 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, > grub_util_exec ((const char * []){ "modprobe", "-q", "efivars", NULL }); > #endif > /* Delete old entries from the same distributor. */ > - grub_install_remove_efi_entries_by_distributor (efi_distributor); > + error = grub_install_remove_efi_entries_by_distributor (efi_distributor); > + if (error) > + return error; > > char *efidir_part_str = xasprintf ("%d", efidir_part); > > if (!verbosity) > - grub_util_exec ((const char * []){ "efibootmgr", "-q", > + error = grub_util_exec ((const char * []){ "efibootmgr", "-q", > "-c", "-d", efidir_disk, > "-p", efidir_part_str, "-w", > "-L", efi_distributor, "-l", > efifile_path, NULL }); > else > - grub_util_exec ((const char * []){ "efibootmgr", > + error = grub_util_exec ((const char * []){ "efibootmgr", > "-c", "-d", efidir_disk, > "-p", efidir_part_str, "-w", > "-L", efi_distributor, "-l", > efifile_path, NULL }); > free (efidir_part_str); > + return error; > } > > void > diff --git a/include/grub/util/install.h b/include/grub/util/install.h > index 9f517a1..58648e2 100644 > --- a/include/grub/util/install.h > +++ b/include/grub/util/install.h > @@ -209,7 +209,7 @@ grub_install_get_default_x86_platform (void); > const char * > grub_install_get_default_powerpc_machtype (void); > > -void > +int > 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 d87d228..7a7e67e 100644 > --- a/util/grub-install.c > +++ b/util/grub-install.c > @@ -2002,9 +2002,13 @@ main (int argc, char *argv[]) > if (!removable && update_nvram) > { > /* Try to make this image bootable using the EFI Boot Manager, if available. */ > - grub_install_register_efi (efidir_grub_dev, > + int error = 0; > + error = grub_install_register_efi (efidir_grub_dev, > "\\System\\Library\\CoreServices", > efi_distributor); > + if (error) > + grub_util_error (_("efibootmgr failed to register the boot entry: %s"), > + strerror (error)); > } > > grub_device_close (ins_dev); > @@ -2094,6 +2098,7 @@ main (int argc, char *argv[]) > { > char * efifile_path; > char * part; > + int error = 0; > > /* Try to make this image bootable using the EFI Boot Manager, if available. */ > if (!efi_distributor || efi_distributor[0] == '\0') > @@ -2110,8 +2115,11 @@ main (int argc, char *argv[]) > efidir_grub_dev->disk->name, > (part ? ",": ""), (part ? : "")); > grub_free (part); > - grub_install_register_efi (efidir_grub_dev, > - efifile_path, efi_distributor); > + error = grub_install_register_efi (efidir_grub_dev, > + efifile_path, efi_distributor); > + if (error) > + grub_util_error (_("efibootmgr failed to register the boot entry: %s"), > + strerror (error)); > } > break; > >