mirror of
https://git.proxmox.com/git/grub2
synced 2025-10-04 18:53:29 +00:00

If this option is enabled, then do all of the following: Don't display introductory message about line editing unless we're actually offering a shell prompt. (This is believed to be a workaround for a different bug. We'll go with this for now, but will drop this in favour of a better fix upstream if somebody figures out what that is.) Don't clear the screen just before booting if we never drew the menu in the first place. Remove verbose messages printed before reading configuration. In some ways this is awkward because it makes debugging harder, but it's a requirement for a smooth-looking boot process; we may be able to do better in future. Upstream doesn't want this, though. Disable the cursor as well, for similar reasons of tidiness. Suppress kernel/initrd progress messages, except in recovery mode. Suppress "GRUB loading" message unless Shift is held down. Upstream doesn't want this, as it makes debugging harder. Ubuntu wants it to provide a cleaner boot experience. Author: Will Thompson <will@willthompson.co.uk> Bug-Ubuntu: https://bugs.launchpad.net/bugs/386922 Bug-Ubuntu: https://bugs.launchpad.net/bugs/861048 Forwarded: (partial) http://lists.gnu.org/archive/html/grub-devel/2009-09/msg00056.html Last-Update: 2019-06-24 Patch-Name: maybe-quiet.patch
101 lines
2.3 KiB
C
101 lines
2.3 KiB
C
/* rescue_reader.c - rescue mode reader */
|
|
/*
|
|
* GRUB -- GRand Unified Bootloader
|
|
* Copyright (C) 2009,2010 Free Software Foundation, Inc.
|
|
*
|
|
* GRUB is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* GRUB is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <grub/types.h>
|
|
#include <grub/reader.h>
|
|
#include <grub/parser.h>
|
|
#include <grub/misc.h>
|
|
#include <grub/term.h>
|
|
#include <grub/mm.h>
|
|
|
|
#define GRUB_RESCUE_BUF_SIZE 256
|
|
|
|
static char linebuf[GRUB_RESCUE_BUF_SIZE];
|
|
|
|
/* Prompt to input a command and read the line. */
|
|
static grub_err_t
|
|
grub_rescue_read_line (char **line, int cont,
|
|
void *data __attribute__ ((unused)))
|
|
{
|
|
int c;
|
|
int pos = 0;
|
|
char str[4];
|
|
|
|
grub_printf ((cont) ? "> " : "grub rescue> ");
|
|
grub_memset (linebuf, 0, GRUB_RESCUE_BUF_SIZE);
|
|
|
|
while ((c = grub_getkey ()) != '\n' && c != '\r')
|
|
{
|
|
if (grub_isprint (c))
|
|
{
|
|
if (pos < GRUB_RESCUE_BUF_SIZE - 1)
|
|
{
|
|
str[0] = c;
|
|
str[1] = 0;
|
|
linebuf[pos++] = c;
|
|
grub_xputs (str);
|
|
}
|
|
}
|
|
else if (c == '\b')
|
|
{
|
|
if (pos > 0)
|
|
{
|
|
str[0] = c;
|
|
str[1] = ' ';
|
|
str[2] = c;
|
|
str[3] = 0;
|
|
linebuf[--pos] = 0;
|
|
grub_xputs (str);
|
|
}
|
|
}
|
|
grub_refresh ();
|
|
}
|
|
|
|
grub_xputs ("\n");
|
|
grub_refresh ();
|
|
|
|
*line = grub_strdup (linebuf);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void __attribute__ ((noreturn))
|
|
grub_rescue_run (void)
|
|
{
|
|
#if QUIET_BOOT
|
|
grub_printf ("Entering rescue mode...\n");
|
|
#endif
|
|
|
|
while (1)
|
|
{
|
|
char *line;
|
|
|
|
/* Print an error, if any. */
|
|
grub_print_error ();
|
|
grub_errno = GRUB_ERR_NONE;
|
|
|
|
grub_rescue_read_line (&line, 0, NULL);
|
|
if (! line || line[0] == '\0')
|
|
continue;
|
|
|
|
grub_rescue_parse_line (line, grub_rescue_read_line, NULL);
|
|
grub_free (line);
|
|
}
|
|
}
|