All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ismael Luceno <iluceno@suse.de>
To: grub-devel@gnu.org
Cc: Ismael Luceno <iluceno@suse.de>
Subject: [PATCH v2 2/2] grub-install: Ensure a functional /dev/nvram
Date: Mon, 29 Aug 2022 16:36:25 +0200	[thread overview]
Message-ID: <20220829143625.23769-3-iluceno@suse.de> (raw)
In-Reply-To: <20220829143625.23769-1-iluceno@suse.de>

This enables an early failure; for i386-ieee1275 and powerpc-ieee1275 on
Linux, without /dev/nvram the system may be left in an unbootable state.

Signed-off-by: Ismael Luceno <iluceno@suse.de>
---
 util/grub-install.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/util/grub-install.c b/util/grub-install.c
index 527b85e27aa7..c84a2fb0526f 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -827,6 +827,16 @@ fill_core_services (const char *core_services)
   free (sysv_plist);
 }
 
+static void
+try_open (const char *path)
+{
+  FILE *f;
+  f = grub_util_fopen (path, "r+");
+  if (!f)
+    grub_util_error (_("Unable to open %s: %s"), path, strerror(errno));
+  fclose (f);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -1026,6 +1036,19 @@ main (int argc, char *argv[])
       break;
     }
 
+  switch (platform)
+    {
+    case GRUB_INSTALL_PLATFORM_I386_IEEE1275:
+    case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275:
+#ifdef __linux__
+      /* On Linux, ensure /dev/nvram is _functional_.  */
+      try_open ("/dev/nvram");
+#endif
+      break;
+    default:
+      break;
+    }
+
   /* Find the EFI System Partition.  */
 
   if (is_efi)
-- 
2.37.1



  parent reply	other threads:[~2022-08-29 14:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-29 14:36 [PATCH v2 0/2] Fix installation issues on ppc64le Ismael Luceno
2022-08-29 14:36 ` [PATCH v2 1/2] grub-install: Add missing points of no return for IEEE1275 on i386/powerpc Ismael Luceno
2022-09-05  9:56   ` Michael Chang
2022-08-29 14:36 ` Ismael Luceno [this message]
2022-09-05 10:04   ` [PATCH v2 2/2] grub-install: Ensure a functional /dev/nvram Michael Chang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220829143625.23769-3-iluceno@suse.de \
    --to=iluceno@suse.de \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.