From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oSfsU-0007MF-Be for mharc-grub-devel@gnu.org; Mon, 29 Aug 2022 10:36:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSfsT-0007KV-9y for grub-devel@gnu.org; Mon, 29 Aug 2022 10:36:37 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:44504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oSfsR-0002Ch-Q5 for grub-devel@gnu.org; Mon, 29 Aug 2022 10:36:37 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 845E21F381; Mon, 29 Aug 2022 14:36:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1661783794; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sk1akyumEnqV5vgWJsp8d/uEvufFHwlzEeMy8g+4p1E=; b=Z+81PC0pqFCnGfVVYkwCRXy7N8ABcvtk7Qs1BNW38mXbUH2MHo7bfueDY9dVFII1hE9KE8 k/QoGiPKocP2KSNl/o3qTo7reOSfSY99BEBGz+jVOqfWhAieF4ULxus8O9wtTSzqIs1pEg MknTY6dFKc/O8qZGTzJnAd/KuEVuxNY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1661783794; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sk1akyumEnqV5vgWJsp8d/uEvufFHwlzEeMy8g+4p1E=; b=1Al3nbwMncAkUuzoDd5dkH2OIyJ7zC3BzA8pF/37KHnQQ4Pf4mbtA8rMG7ODq7Hi7LuJVe q/PYBn7UqQBXFQAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 653E7133A6; Mon, 29 Aug 2022 14:36:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Df35FfLODGP0bwAAMHmgww (envelope-from ); Mon, 29 Aug 2022 14:36:34 +0000 From: Ismael Luceno To: grub-devel@gnu.org Cc: Ismael Luceno Subject: [PATCH v2 2/2] grub-install: Ensure a functional /dev/nvram Date: Mon, 29 Aug 2022 16:36:25 +0200 Message-Id: <20220829143625.23769-3-iluceno@suse.de> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220829143625.23769-1-iluceno@suse.de> References: <20220829143625.23769-1-iluceno@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=195.135.220.29; envelope-from=iluceno@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2022 14:36:37 -0000 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 --- 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