Fix menu title instability bug.
* grub-core/commands/menuentry.c (options): New option --id. (grub_normal_add_menu_entry): New argument id. All users updated. (grub_cmd_menuentry): Handle --id. (grub_menu_init): Accept unknown arguments. * grub-core/normal/main.c (features): Add feature_menuentry_id and feature_menuentry_options. * grub-core/normal/menu.c (grub_menu_execute_entry): Use id for saved_entry. (get_entry_number): Match with id as well. * include/grub/menu.h (grub_menu_entry): New member id. * util/grub-mkconfig_lib.in (grub_get_device_id): New function. * util/grub.d/00_header.in: Define menuentry_id_option. * util/grub.d/10_hurd.in: Define id. * util/grub.d/10_illumos.in: Likewise. * util/grub.d/10_kfreebsd.in: Likewise. * util/grub.d/10_linux.in: Likewise. * util/grub.d/10_netbsd.in: Likewise. * util/grub.d/10_windows.in: Likewise. * util/grub.d/20_linux_xen.in: Likewise. * util/grub.d/30_os-prober.in: Likewise.
This commit is contained in:
parent
0d31b7df86
commit
d9bef9bc43
17 changed files with 126 additions and 27 deletions
|
@ -188,7 +188,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot)
|
|||
grub_env_set ("timeout", "0");
|
||||
}
|
||||
|
||||
for (ptr = entry->title; *ptr; ptr++)
|
||||
for (ptr = entry->id; *ptr; ptr++)
|
||||
sz += (*ptr == '>') ? 2 : 1;
|
||||
if (chosen)
|
||||
{
|
||||
|
@ -217,7 +217,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot)
|
|||
optr = grub_stpcpy (optr, chosen);
|
||||
*optr++ = '>';
|
||||
}
|
||||
for (ptr = entry->title; *ptr; ptr++)
|
||||
for (ptr = entry->id; *ptr; ptr++)
|
||||
{
|
||||
if (*ptr == '>')
|
||||
*optr++ = '>';
|
||||
|
@ -411,10 +411,10 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer)
|
|||
}
|
||||
|
||||
static int
|
||||
menuentry_eq (const char *title, const char *spec)
|
||||
menuentry_eq (const char *id, const char *spec)
|
||||
{
|
||||
const char *ptr1, *ptr2;
|
||||
ptr1 = title;
|
||||
ptr1 = id;
|
||||
ptr2 = spec;
|
||||
while (1)
|
||||
{
|
||||
|
@ -459,7 +459,8 @@ get_entry_number (grub_menu_t menu, const char *name)
|
|||
|
||||
for (i = 0; e; i++)
|
||||
{
|
||||
if (menuentry_eq (e->title, val))
|
||||
if (menuentry_eq (e->title, val)
|
||||
|| menuentry_eq (e->id, val))
|
||||
{
|
||||
entry = i;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue