Merge mainline.
This commit is contained in:
commit
50ee5d686d
193 changed files with 9983 additions and 1425 deletions
|
@ -34,7 +34,7 @@ struct grub_auth_user
|
|||
int authenticated;
|
||||
};
|
||||
|
||||
struct grub_auth_user *users = NULL;
|
||||
static struct grub_auth_user *users = NULL;
|
||||
|
||||
grub_err_t
|
||||
grub_auth_register_authentication (const char *user,
|
||||
|
|
|
@ -113,16 +113,6 @@ grub_utf8_to_utf16 (grub_uint16_t *dest, grub_size_t destsize,
|
|||
count = 3;
|
||||
code = c & GRUB_UINT8_3_TRAILINGBITS;
|
||||
}
|
||||
else if ((c & GRUB_UINT8_6_LEADINGBITS) == GRUB_UINT8_5_LEADINGBITS)
|
||||
{
|
||||
count = 4;
|
||||
code = c & GRUB_UINT8_2_TRAILINGBITS;
|
||||
}
|
||||
else if ((c & GRUB_UINT8_7_LEADINGBITS) == GRUB_UINT8_6_LEADINGBITS)
|
||||
{
|
||||
count = 5;
|
||||
code = c & GRUB_UINT8_1_TRAILINGBIT;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
@ -177,7 +167,7 @@ grub_ucs4_to_utf8 (grub_uint32_t *src, grub_size_t size,
|
|||
/* No surrogates in UCS-4... */
|
||||
*dest++ = '?';
|
||||
}
|
||||
else
|
||||
else if (code < 0x10000)
|
||||
{
|
||||
if (dest + 2 >= destend)
|
||||
break;
|
||||
|
@ -185,6 +175,15 @@ grub_ucs4_to_utf8 (grub_uint32_t *src, grub_size_t size,
|
|||
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dest + 3 >= destend)
|
||||
break;
|
||||
*dest++ = (code >> 18) | 0xF0;
|
||||
*dest++ = ((code >> 12) & 0x3F) | 0x80;
|
||||
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
}
|
||||
*dest = 0;
|
||||
}
|
||||
|
@ -212,8 +211,10 @@ grub_ucs4_to_utf8_alloc (grub_uint32_t *src, grub_size_t size)
|
|||
|| (code >= 0xD800 && code <= 0xDBFF))
|
||||
/* No surrogates in UCS-4... */
|
||||
cnt++;
|
||||
else
|
||||
else if (code < 0x10000)
|
||||
cnt += 3;
|
||||
else
|
||||
cnt += 4;
|
||||
}
|
||||
cnt++;
|
||||
|
||||
|
@ -273,16 +274,6 @@ grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize)
|
|||
count = 3;
|
||||
code = c & 0x07;
|
||||
}
|
||||
else if ((c & 0xfc) == 0xf8)
|
||||
{
|
||||
count = 4;
|
||||
code = c & 0x03;
|
||||
}
|
||||
else if ((c & 0xfe) == 0xfc)
|
||||
{
|
||||
count = 5;
|
||||
code = c & 0x01;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -375,16 +366,6 @@ grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize,
|
|||
count = 3;
|
||||
code = c & 0x07;
|
||||
}
|
||||
else if ((c & 0xfc) == 0xf8)
|
||||
{
|
||||
count = 4;
|
||||
code = c & 0x03;
|
||||
}
|
||||
else if ((c & 0xfe) == 0xfc)
|
||||
{
|
||||
count = 5;
|
||||
code = c & 0x01;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* invalid */
|
||||
|
|
|
@ -240,7 +240,7 @@ grub_cmdline_get (const char *prompt)
|
|||
grub_term_gotoxy (cl_term->term, cl_term->xpos, cl_term->ypos);
|
||||
}
|
||||
|
||||
void cl_set_pos_all ()
|
||||
void cl_set_pos_all (void)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < nterms; i++)
|
||||
|
|
|
@ -31,8 +31,8 @@ struct menu_pointer
|
|||
struct menu_pointer *prev;
|
||||
};
|
||||
|
||||
struct menu_pointer initial_menu;
|
||||
struct menu_pointer *current_menu = &initial_menu;
|
||||
static struct menu_pointer initial_menu;
|
||||
static struct menu_pointer *current_menu = &initial_menu;
|
||||
|
||||
void
|
||||
grub_env_unset_menu (void)
|
||||
|
@ -148,7 +148,7 @@ grub_env_context_close (void)
|
|||
grub_err_t
|
||||
grub_env_extractor_close (int source)
|
||||
{
|
||||
grub_menu_t menu, menu2;
|
||||
grub_menu_t menu = NULL;
|
||||
grub_menu_entry_t *last;
|
||||
grub_err_t err;
|
||||
|
||||
|
@ -161,6 +161,7 @@ grub_env_extractor_close (int source)
|
|||
|
||||
if (source)
|
||||
{
|
||||
grub_menu_t menu2;
|
||||
menu2 = grub_env_get_menu ();
|
||||
|
||||
last = &menu2->entry_list;
|
||||
|
@ -175,26 +176,6 @@ grub_env_extractor_close (int source)
|
|||
return err;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_env_export (const char *name)
|
||||
{
|
||||
struct grub_env_var *var;
|
||||
|
||||
var = grub_env_find (name);
|
||||
if (! var)
|
||||
{
|
||||
grub_err_t err;
|
||||
|
||||
err = grub_env_set (name, "");
|
||||
if (err)
|
||||
return err;
|
||||
var = grub_env_find (name);
|
||||
}
|
||||
var->global = 1;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_command_t export_cmd;
|
||||
|
||||
static grub_err_t
|
||||
|
@ -216,9 +197,6 @@ grub_cmd_export (struct grub_command *cmd __attribute__ ((unused)),
|
|||
void
|
||||
grub_context_init (void)
|
||||
{
|
||||
grub_env_export ("root");
|
||||
grub_env_export ("prefix");
|
||||
|
||||
export_cmd = grub_register_command ("export", grub_cmd_export,
|
||||
N_("ENVVAR [ENVVAR] ..."),
|
||||
N_("Export variables."));
|
||||
|
|
|
@ -31,7 +31,7 @@ struct load_spec
|
|||
char *modname;
|
||||
};
|
||||
|
||||
struct load_spec *crypto_specs = NULL;
|
||||
static struct load_spec *crypto_specs = NULL;
|
||||
|
||||
static void
|
||||
grub_crypto_autoload (const char *name)
|
||||
|
|
|
@ -287,7 +287,7 @@ grub_normal_execute (const char *config, int nested, int batch)
|
|||
{
|
||||
if (menu && menu->size)
|
||||
{
|
||||
grub_show_menu (menu, nested);
|
||||
grub_show_menu (menu, nested, 0);
|
||||
if (nested)
|
||||
grub_normal_free_menu (menu);
|
||||
}
|
||||
|
@ -496,6 +496,7 @@ GRUB_MOD_INIT(normal)
|
|||
grub_set_history (GRUB_DEFAULT_HISTORY_SIZE);
|
||||
|
||||
grub_register_variable_hook ("pager", 0, grub_env_write_pager);
|
||||
grub_env_export ("pager");
|
||||
|
||||
/* Register a command "normal" for the rescue mode. */
|
||||
grub_register_command ("normal", grub_cmd_normal,
|
||||
|
|
|
@ -154,12 +154,15 @@ get_and_remove_first_entry_number (const char *name)
|
|||
}
|
||||
|
||||
/* Run a menu entry. */
|
||||
void
|
||||
grub_menu_execute_entry(grub_menu_entry_t entry)
|
||||
static void
|
||||
grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot)
|
||||
{
|
||||
grub_err_t err = GRUB_ERR_NONE;
|
||||
int errs_before;
|
||||
grub_menu_t menu;
|
||||
grub_menu_t menu = NULL;
|
||||
char *optr, *buf, *oldchosen = NULL, *olddefault = NULL;
|
||||
const char *ptr, *chosen, *def;
|
||||
grub_size_t sz = 0;
|
||||
|
||||
if (entry->restricted)
|
||||
err = grub_auth_check_authentication (entry->users);
|
||||
|
@ -173,6 +176,9 @@ grub_menu_execute_entry(grub_menu_entry_t entry)
|
|||
|
||||
errs_before = grub_err_printed_errors;
|
||||
|
||||
chosen = grub_env_get ("chosen");
|
||||
def = grub_env_get ("default");
|
||||
|
||||
if (entry->submenu)
|
||||
{
|
||||
grub_env_context_open ();
|
||||
|
@ -180,9 +186,64 @@ grub_menu_execute_entry(grub_menu_entry_t entry)
|
|||
if (! menu)
|
||||
return;
|
||||
grub_env_set_menu (menu);
|
||||
if (auto_boot)
|
||||
grub_env_set ("timeout", "0");
|
||||
}
|
||||
|
||||
grub_env_set ("chosen", entry->title);
|
||||
for (ptr = entry->title; *ptr; ptr++)
|
||||
sz += (*ptr == '>') ? 2 : 1;
|
||||
if (chosen)
|
||||
{
|
||||
oldchosen = grub_strdup (chosen);
|
||||
if (!oldchosen)
|
||||
grub_print_error ();
|
||||
}
|
||||
if (def)
|
||||
{
|
||||
olddefault = grub_strdup (def);
|
||||
if (!olddefault)
|
||||
grub_print_error ();
|
||||
}
|
||||
sz++;
|
||||
if (chosen)
|
||||
sz += grub_strlen (chosen);
|
||||
sz++;
|
||||
buf = grub_malloc (sz);
|
||||
if (!buf)
|
||||
grub_print_error ();
|
||||
else
|
||||
{
|
||||
optr = buf;
|
||||
if (chosen)
|
||||
{
|
||||
optr = grub_stpcpy (optr, chosen);
|
||||
*optr++ = '>';
|
||||
}
|
||||
for (ptr = entry->title; *ptr; ptr++)
|
||||
{
|
||||
if (*ptr == '>')
|
||||
*optr++ = '>';
|
||||
*optr++ = *ptr;
|
||||
}
|
||||
*optr = 0;
|
||||
grub_env_set ("chosen", buf);
|
||||
grub_env_export ("chosen");
|
||||
grub_free (buf);
|
||||
}
|
||||
for (ptr = def; *ptr; ptr++)
|
||||
{
|
||||
if (ptr[0] == '>' && ptr[1] == '>')
|
||||
{
|
||||
ptr++;
|
||||
continue;
|
||||
}
|
||||
if (ptr[0] == '>')
|
||||
break;
|
||||
}
|
||||
if (ptr[0] && ptr[1])
|
||||
grub_env_set ("default", ptr + 1);
|
||||
else
|
||||
grub_env_unset ("default");
|
||||
grub_script_execute_sourcecode (entry->sourcecode, entry->argc, entry->args);
|
||||
|
||||
if (errs_before != grub_err_printed_errors)
|
||||
|
@ -196,20 +257,30 @@ grub_menu_execute_entry(grub_menu_entry_t entry)
|
|||
{
|
||||
if (menu && menu->size)
|
||||
{
|
||||
grub_show_menu (menu, 1);
|
||||
grub_show_menu (menu, 1, auto_boot);
|
||||
grub_normal_free_menu (menu);
|
||||
}
|
||||
grub_env_context_close ();
|
||||
}
|
||||
if (oldchosen)
|
||||
grub_env_set ("chosen", oldchosen);
|
||||
else
|
||||
grub_env_unset ("chosen");
|
||||
if (olddefault)
|
||||
grub_env_set ("default", olddefault);
|
||||
else
|
||||
grub_env_unset ("default");
|
||||
grub_env_unset ("timeout");
|
||||
}
|
||||
|
||||
/* Execute ENTRY from the menu MENU, falling back to entries specified
|
||||
in the environment variable "fallback" if it fails. CALLBACK is a
|
||||
pointer to a struct of function pointers which are used to allow the
|
||||
caller provide feedback to the user. */
|
||||
void
|
||||
static void
|
||||
grub_menu_execute_with_fallback (grub_menu_t menu,
|
||||
grub_menu_entry_t entry,
|
||||
int autobooted,
|
||||
grub_menu_execute_callback_t callback,
|
||||
void *callback_data)
|
||||
{
|
||||
|
@ -217,7 +288,7 @@ grub_menu_execute_with_fallback (grub_menu_t menu,
|
|||
|
||||
callback->notify_booting (entry, callback_data);
|
||||
|
||||
grub_menu_execute_entry (entry);
|
||||
grub_menu_execute_entry (entry, 1);
|
||||
|
||||
/* Deal with fallback entries. */
|
||||
while ((fallback_entry = get_and_remove_first_entry_number ("fallback"))
|
||||
|
@ -228,14 +299,15 @@ grub_menu_execute_with_fallback (grub_menu_t menu,
|
|||
|
||||
entry = grub_menu_get_entry (menu, fallback_entry);
|
||||
callback->notify_fallback (entry, callback_data);
|
||||
grub_menu_execute_entry (entry);
|
||||
grub_menu_execute_entry (entry, 1);
|
||||
/* If the function call to execute the entry returns at all, then this is
|
||||
taken to indicate a boot failure. For menu entries that do something
|
||||
other than actually boot an operating system, this could assume
|
||||
incorrectly that something failed. */
|
||||
}
|
||||
|
||||
callback->notify_failure (callback_data);
|
||||
if (!autobooted)
|
||||
callback->notify_failure (callback_data);
|
||||
}
|
||||
|
||||
static struct grub_menu_viewer *viewers;
|
||||
|
@ -309,11 +381,35 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer)
|
|||
viewers = viewer;
|
||||
}
|
||||
|
||||
static int
|
||||
menuentry_eq (const char *title, const char *spec)
|
||||
{
|
||||
const char *ptr1, *ptr2;
|
||||
ptr1 = title;
|
||||
ptr2 = spec;
|
||||
while (1)
|
||||
{
|
||||
if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0)
|
||||
return 1;
|
||||
if (*ptr2 == '>' && ptr2[1] != '>')
|
||||
return 0;
|
||||
if (*ptr2 == '>')
|
||||
ptr2++;
|
||||
if (*ptr1 != *ptr2)
|
||||
return 0;
|
||||
if (*ptr1 == 0)
|
||||
return 1;
|
||||
ptr1++;
|
||||
ptr2++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Get the entry number from the variable NAME. */
|
||||
static int
|
||||
get_entry_number (grub_menu_t menu, const char *name)
|
||||
{
|
||||
char *val;
|
||||
const char *val;
|
||||
int entry;
|
||||
|
||||
val = grub_env_get (name);
|
||||
|
@ -334,7 +430,7 @@ get_entry_number (grub_menu_t menu, const char *name)
|
|||
|
||||
for (i = 0; e; i++)
|
||||
{
|
||||
if (grub_strcmp (e->title, val) == 0)
|
||||
if (menuentry_eq (e->title, val))
|
||||
{
|
||||
entry = i;
|
||||
break;
|
||||
|
@ -590,7 +686,7 @@ static struct grub_menu_execute_callback execution_callback =
|
|||
};
|
||||
|
||||
static grub_err_t
|
||||
show_menu (grub_menu_t menu, int nested)
|
||||
show_menu (grub_menu_t menu, int nested, int autobooted)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
|
@ -609,22 +705,26 @@ show_menu (grub_menu_t menu, int nested)
|
|||
grub_cls ();
|
||||
|
||||
if (auto_boot)
|
||||
grub_menu_execute_with_fallback (menu, e, &execution_callback, 0);
|
||||
grub_menu_execute_with_fallback (menu, e, autobooted,
|
||||
&execution_callback, 0);
|
||||
else
|
||||
grub_menu_execute_entry (e);
|
||||
grub_menu_execute_entry (e, 0);
|
||||
if (autobooted)
|
||||
break;
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_show_menu (grub_menu_t menu, int nested)
|
||||
grub_show_menu (grub_menu_t menu, int nested, int autoboot)
|
||||
{
|
||||
grub_err_t err1, err2;
|
||||
|
||||
while (1)
|
||||
{
|
||||
err1 = show_menu (menu, nested);
|
||||
err1 = show_menu (menu, nested, autoboot);
|
||||
autoboot = 0;
|
||||
grub_print_error ();
|
||||
|
||||
if (grub_normal_exit_level)
|
||||
|
|
|
@ -87,7 +87,7 @@ init_line (struct line *linep)
|
|||
{
|
||||
linep->len = 0;
|
||||
linep->max_len = 80; /* XXX */
|
||||
linep->buf = grub_malloc (linep->max_len);
|
||||
linep->buf = grub_malloc (linep->max_len + 1);
|
||||
if (! linep->buf)
|
||||
return 0;
|
||||
|
||||
|
@ -172,7 +172,7 @@ static void
|
|||
print_up (int flag, struct per_term_screen *term_screen)
|
||||
{
|
||||
grub_term_gotoxy (term_screen->term, GRUB_TERM_LEFT_BORDER_X
|
||||
+ grub_term_entry_width (term_screen->term),
|
||||
+ grub_term_border_width (term_screen->term),
|
||||
GRUB_TERM_FIRST_ENTRY_Y);
|
||||
|
||||
if (flag)
|
||||
|
@ -1163,37 +1163,35 @@ clear_completions_all (struct screen *screen)
|
|||
static int
|
||||
run (struct screen *screen)
|
||||
{
|
||||
int currline = 0;
|
||||
char *nextline;
|
||||
char *script;
|
||||
int errs_before;
|
||||
grub_menu_t menu;
|
||||
char *dummy[1] = { NULL };
|
||||
|
||||
auto grub_err_t editor_getline (char **line, int cont);
|
||||
grub_err_t editor_getline (char **line, int cont __attribute__ ((unused)))
|
||||
{
|
||||
struct line *linep = screen->lines + currline;
|
||||
char *p;
|
||||
auto char * editor_getsource (void);
|
||||
char * editor_getsource (void)
|
||||
{
|
||||
int i;
|
||||
int size = 0;
|
||||
char *source;
|
||||
|
||||
if (currline > screen->num_lines)
|
||||
{
|
||||
*line = 0;
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < screen->num_lines; i++)
|
||||
size += screen->lines[i].len + 1;
|
||||
|
||||
/* Trim down space characters. */
|
||||
for (p = linep->buf + linep->len - 1;
|
||||
p >= linep->buf && grub_isspace (*p);
|
||||
p--)
|
||||
;
|
||||
*++p = '\0';
|
||||
source = grub_malloc (size + 1);
|
||||
if (! source)
|
||||
return NULL;
|
||||
|
||||
linep->len = p - linep->buf;
|
||||
for (p = linep->buf; grub_isspace (*p); p++)
|
||||
;
|
||||
*line = grub_strdup (p);
|
||||
currline++;
|
||||
return 0;
|
||||
}
|
||||
size = 0;
|
||||
for (i = 0; i < screen->num_lines; i++)
|
||||
{
|
||||
grub_strcpy (source + size, screen->lines[i].buf);
|
||||
size += screen->lines[i].len;
|
||||
source[size++] = '\n';
|
||||
}
|
||||
source[size] = '\0';
|
||||
return source;
|
||||
}
|
||||
|
||||
grub_cls ();
|
||||
grub_printf (" ");
|
||||
|
@ -1212,12 +1210,11 @@ run (struct screen *screen)
|
|||
}
|
||||
|
||||
/* Execute the script, line for line. */
|
||||
while (currline < screen->num_lines)
|
||||
{
|
||||
editor_getline (&nextline, 0);
|
||||
if (grub_normal_parse_line (nextline, editor_getline))
|
||||
break;
|
||||
}
|
||||
script = editor_getsource ();
|
||||
if (! script)
|
||||
return 0;
|
||||
grub_script_execute_sourcecode (script, 0, dummy);
|
||||
grub_free (script);
|
||||
|
||||
if (errs_before != grub_err_printed_errors)
|
||||
grub_wait_after_message ();
|
||||
|
@ -1230,7 +1227,7 @@ run (struct screen *screen)
|
|||
{
|
||||
if (menu && menu->size)
|
||||
{
|
||||
grub_show_menu (menu, 1);
|
||||
grub_show_menu (menu, 1, 0);
|
||||
grub_normal_free_menu (menu);
|
||||
}
|
||||
grub_env_context_close ();
|
||||
|
|
|
@ -112,14 +112,13 @@ grub_normal_print_device_info (const char *name)
|
|||
grub_printf ("%s", _("Not a known filesystem"));
|
||||
|
||||
if (dev->disk->partition)
|
||||
grub_printf (_(" - Partition start at %u"),
|
||||
grub_partition_get_start (dev->disk->partition));
|
||||
grub_printf (_(" - Partition start at %llu"),
|
||||
(unsigned long long) grub_partition_get_start (dev->disk->partition));
|
||||
if (grub_disk_get_size (dev->disk) == GRUB_DISK_SIZE_UNKNOWN)
|
||||
grub_printf (_(" - Total size unknown"),
|
||||
grub_disk_get_size (dev->disk));
|
||||
grub_puts_ (" - Total size unknown");
|
||||
else
|
||||
grub_printf (_(" - Total size %u sectors"),
|
||||
grub_disk_get_size (dev->disk));
|
||||
grub_printf (_(" - Total size %llu sectors"),
|
||||
(unsigned long long) grub_disk_get_size (dev->disk));
|
||||
|
||||
grub_device_close (dev);
|
||||
}
|
||||
|
|
|
@ -91,16 +91,16 @@ print_more (void)
|
|||
grub_term_restore_pos (pos);
|
||||
grub_free (pos);
|
||||
|
||||
/* Scroll one lines or an entire page, depending on the key. */
|
||||
/* Scroll one line or an entire page, depending on the key. */
|
||||
|
||||
if (key == '\r' || key =='\n')
|
||||
grub_normal_reset_more ();
|
||||
else
|
||||
{
|
||||
static struct term_state *state;
|
||||
for (state = term_states; state; state = state->next)
|
||||
state->num_lines -= 2;
|
||||
state->num_lines--;
|
||||
}
|
||||
else
|
||||
grub_normal_reset_more ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue