|
|
28f7f8 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
39700a |
From: Peter Jones <pjones@redhat.com>
|
|
|
39700a |
Date: Fri, 5 Sep 2014 10:07:04 -0400
|
|
|
28f7f8 |
Subject: [PATCH] Allow "fallback" to include entries by title, not just
|
|
|
28f7f8 |
number.
|
|
|
39700a |
|
|
|
39700a |
Resolves: rhbz#1026084
|
|
|
39700a |
|
|
|
39700a |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
39700a |
---
|
|
|
39700a |
grub-core/normal/menu.c | 76 +++++++++++++++++++++++++++++++------------------
|
|
|
39700a |
1 file changed, 49 insertions(+), 27 deletions(-)
|
|
|
39700a |
|
|
|
39700a |
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
|
|
|
28f7f8 |
index cc27c370776..a446d9ae746 100644
|
|
|
39700a |
--- a/grub-core/normal/menu.c
|
|
|
39700a |
+++ b/grub-core/normal/menu.c
|
|
|
39700a |
@@ -163,12 +163,35 @@ grub_menu_set_timeout (int timeout)
|
|
|
39700a |
}
|
|
|
39700a |
}
|
|
|
39700a |
|
|
|
39700a |
+static int
|
|
|
39700a |
+menuentry_eq (const char *id, const char *spec)
|
|
|
39700a |
+{
|
|
|
39700a |
+ const char *ptr1, *ptr2;
|
|
|
39700a |
+ ptr1 = id;
|
|
|
39700a |
+ ptr2 = spec;
|
|
|
39700a |
+ while (1)
|
|
|
39700a |
+ {
|
|
|
39700a |
+ if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0)
|
|
|
39700a |
+ return 1;
|
|
|
39700a |
+ if (*ptr2 == '>' && ptr2[1] != '>')
|
|
|
39700a |
+ return 0;
|
|
|
39700a |
+ if (*ptr2 == '>')
|
|
|
39700a |
+ ptr2++;
|
|
|
39700a |
+ if (*ptr1 != *ptr2)
|
|
|
39700a |
+ return 0;
|
|
|
39700a |
+ if (*ptr1 == 0)
|
|
|
39700a |
+ return 1;
|
|
|
39700a |
+ ptr1++;
|
|
|
39700a |
+ ptr2++;
|
|
|
39700a |
+ }
|
|
|
39700a |
+}
|
|
|
39700a |
+
|
|
|
39700a |
/* Get the first entry number from the value of the environment variable NAME,
|
|
|
39700a |
which is a space-separated list of non-negative integers. The entry number
|
|
|
39700a |
which is returned is stripped from the value of NAME. If no entry number
|
|
|
39700a |
can be found, -1 is returned. */
|
|
|
39700a |
static int
|
|
|
39700a |
-get_and_remove_first_entry_number (const char *name)
|
|
|
39700a |
+get_and_remove_first_entry_number (grub_menu_t menu, const char *name)
|
|
|
39700a |
{
|
|
|
39700a |
const char *val;
|
|
|
39700a |
char *tail;
|
|
|
39700a |
@@ -182,9 +205,32 @@ get_and_remove_first_entry_number (const char *name)
|
|
|
39700a |
|
|
|
39700a |
entry = (int) grub_strtoul (val, &tail, 0);
|
|
|
39700a |
|
|
|
39700a |
+ if (grub_errno == GRUB_ERR_BAD_NUMBER)
|
|
|
39700a |
+ {
|
|
|
39700a |
+ /* See if the variable matches the title of a menu entry. */
|
|
|
39700a |
+ grub_menu_entry_t e = menu->entry_list;
|
|
|
39700a |
+ int i;
|
|
|
39700a |
+
|
|
|
39700a |
+ grub_errno = GRUB_ERR_NONE;
|
|
|
39700a |
+
|
|
|
39700a |
+ for (i = 0; e; i++)
|
|
|
39700a |
+ {
|
|
|
39700a |
+ if (menuentry_eq (e->title, val)
|
|
|
39700a |
+ || menuentry_eq (e->id, val))
|
|
|
39700a |
+ {
|
|
|
39700a |
+ entry = i;
|
|
|
39700a |
+ break;
|
|
|
39700a |
+ }
|
|
|
39700a |
+ e = e->next;
|
|
|
39700a |
+ }
|
|
|
39700a |
+
|
|
|
39700a |
+ if (! e)
|
|
|
39700a |
+ entry = -1;
|
|
|
39700a |
+ }
|
|
|
39700a |
+
|
|
|
39700a |
if (grub_errno == GRUB_ERR_NONE)
|
|
|
39700a |
{
|
|
|
39700a |
- /* Skip whitespace to find the next digit. */
|
|
|
39700a |
+ /* Skip whitespace to find the next entry. */
|
|
|
39700a |
while (*tail && grub_isspace (*tail))
|
|
|
39700a |
tail++;
|
|
|
39700a |
grub_env_set (name, tail);
|
|
|
39700a |
@@ -347,7 +393,7 @@ grub_menu_execute_with_fallback (grub_menu_t menu,
|
|
|
39700a |
grub_menu_execute_entry (entry, 1);
|
|
|
39700a |
|
|
|
39700a |
/* Deal with fallback entries. */
|
|
|
39700a |
- while ((fallback_entry = get_and_remove_first_entry_number ("fallback"))
|
|
|
39700a |
+ while ((fallback_entry = get_and_remove_first_entry_number (menu, "fallback"))
|
|
|
39700a |
>= 0)
|
|
|
39700a |
{
|
|
|
39700a |
grub_print_error ();
|
|
|
39700a |
@@ -465,30 +511,6 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer)
|
|
|
39700a |
viewers = viewer;
|
|
|
39700a |
}
|
|
|
39700a |
|
|
|
39700a |
-static int
|
|
|
39700a |
-menuentry_eq (const char *id, const char *spec)
|
|
|
39700a |
-{
|
|
|
39700a |
- const char *ptr1, *ptr2;
|
|
|
39700a |
- ptr1 = id;
|
|
|
39700a |
- ptr2 = spec;
|
|
|
39700a |
- while (1)
|
|
|
39700a |
- {
|
|
|
39700a |
- if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0)
|
|
|
39700a |
- return 1;
|
|
|
39700a |
- if (*ptr2 == '>' && ptr2[1] != '>')
|
|
|
39700a |
- return 0;
|
|
|
39700a |
- if (*ptr2 == '>')
|
|
|
39700a |
- ptr2++;
|
|
|
39700a |
- if (*ptr1 != *ptr2)
|
|
|
39700a |
- return 0;
|
|
|
39700a |
- if (*ptr1 == 0)
|
|
|
39700a |
- return 1;
|
|
|
39700a |
- ptr1++;
|
|
|
39700a |
- ptr2++;
|
|
|
39700a |
- }
|
|
|
39700a |
-}
|
|
|
39700a |
-
|
|
|
39700a |
-
|
|
|
39700a |
/* Get the entry number from the variable NAME. */
|
|
|
39700a |
static int
|
|
|
39700a |
get_entry_number (grub_menu_t menu, const char *name)
|