From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Vm5Uj-0007m9-6m for mharc-grub-devel@gnu.org; Thu, 28 Nov 2013 12:35:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm5Ua-0007jX-7e for grub-devel@gnu.org; Thu, 28 Nov 2013 12:35:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vm5UQ-0000Dv-83 for grub-devel@gnu.org; Thu, 28 Nov 2013 12:35:08 -0500 Received: from mail-la0-x235.google.com ([2a00:1450:4010:c03::235]:47081) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm5UP-0000Dj-WF for grub-devel@gnu.org; Thu, 28 Nov 2013 12:34:58 -0500 Received: by mail-la0-f53.google.com with SMTP id ea20so6315616lab.12 for ; Thu, 28 Nov 2013 09:34:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; bh=Sy1QDNcXi3e4sU03tPh0a358Y7yCF8wG4bCHmvX7keQ=; b=vogF67AvakRNATyAXk2u/Y4RlDAwlJp/jDlFnAZr8k6gnVpq4b5UbNpTwAt3Sm0Lo/ 4pMb+TqtIC5fcG8ox7ruMPAN4x6TxafslTxJhyfpAi9dBTDuHB2KLv8VxxaQKInV/iVL aWVjKNGF4X0MJ/IQuP33YwhztQiYNgTL+kNjXwaVMsT9vARGD9tJHe9aaQmos4X2w5mE zlzRAcpZmQMIMgCOxFIx/LiMW5Nze3F1lxlhT7VnW98KD6hd4jk8NmGUeOxOzrnQmLo7 /uDyExbwUSmrXPP/wHcaKqtBzw4taSL1998UpvW6MlSY1ZFFwy/qAf0XBfV3396CYoqb pUjQ== X-Received: by 10.112.189.202 with SMTP id gk10mr26597813lbc.11.1385660096655; Thu, 28 Nov 2013 09:34:56 -0800 (PST) Received: from opensuse.site (ppp91-76-170-113.pppoe.mtu-net.ru. [91.76.170.113]) by mx.google.com with ESMTPSA id dv8sm39603954lbc.15.2013.11.28.09.34.55 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Thu, 28 Nov 2013 09:34:56 -0800 (PST) Date: Thu, 28 Nov 2013 21:34:55 +0400 From: Andrey Borzenkov To: grub-devel@gnu.org Subject: Re: [PATCH v0] Require human interaction to go to normal shell if grub.cfg has a problem Message-ID: <20131128213455.2aa3d691@opensuse.site> In-Reply-To: <1385423208-18212-1-git-send-email-jonmccune@google.com> References: <1385423208-18212-1-git-send-email-jonmccune@google.com> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.18; x86_64-suse-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::235 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Nov 2013 17:35:16 -0000 В Mon, 25 Nov 2013 15:46:48 -0800 Jon McCune пишет: > The rescue prompt is very useful for human operators, but not so > useful in unattended environments. Add a facility for rebooting > after a delay, so that, e.g., the system can still PXE boot if > there is no console attached. > > Signed-off-by: Jon McCune > --- > grub-core/normal/main.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c You get rescue prompt when you can *not* launch normal.mod. > index ad36273..f8953d5 100644 > --- a/grub-core/normal/main.c > +++ b/grub-core/normal/main.c > @@ -32,6 +32,7 @@ > #include > #include > #include > +#include > > GRUB_MOD_LICENSE ("GPLv3+"); > > @@ -333,6 +334,21 @@ grub_normal_execute (const char *config, int nested, int batch) > } > } > > +/* Copied from grub-core/commands/sleep.c. */ > +static int > +grub_interruptible_millisleep (grub_uint32_t ms) > +{ > + grub_uint64_t start; > + > + start = grub_get_time_ms (); > + > + while (grub_get_time_ms () - start < ms) > + if (grub_getkey_noblock () == GRUB_TERM_ESC) > + return 1; > + > + return 0; > +} > + > /* This starts the normal mode. */ > void > grub_enter_normal_mode (const char *config) > @@ -340,6 +356,15 @@ grub_enter_normal_mode (const char *config) > grub_boot_time ("Entering normal mode"); > nested_level++; > grub_normal_execute (config, 0, 0); > + /* Control only returns from grub_normal_execute() if there is some kind of > + * problem with grub.cfg, like it does not exist. Reboot by default unless > + * ESC is pressed within 5 seconds. */ grub-mkrescue creates CD that starts normal CLI without grub.cfg. So please - not as default. You can make it dependent on variable which can be set in embedded grub.cfg for the cases when you really need it. > + grub_printf ("Press ESC in 5 seconds for a rescue shell.\n"); "for a command line". This is not rescue shell. > + if (!grub_interruptible_millisleep (5000)) > + { > + grub_printf ("Rebooting instead of going to rescue shell.\n"); Ditto. > + grub_reboot (); > + } > grub_boot_time ("Entering shell"); > grub_cmdline_run (0); > nested_level--;