SHA256
1
0
forked from pool/grub2
grub2/grub2-btrfs-08-workaround-snapshot-menu-default-entry.patch
Michael Chang de8c74037b Accepting request 1188943 from home:michael-chang:branches:Base:System
- Fix error in grub-install when root is on tmpfs (bsc#1226100)
    * 0001-grub-install-bailout-root-device-probing.patch
- Fix incorrect Platform tag in rpm header (bsc#1217967)

OBS-URL: https://build.opensuse.org/request/show/1188943
OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=508
2024-07-22 08:21:46 +00:00

59 lines
1.8 KiB
Diff

v2: Add menuentry "Help on bootable snapshot" to be excluded as default entry.
--- a/grub-core/normal/menu.c
+++ b/grub-core/normal/menu.c
@@ -574,6 +574,43 @@
grub_refresh ();
}
+/* bsc#956046 - The first entry titled 'Bootable snapshot #$NUM' is inserted on
+ top at runtime to display current snapshot information. If default entry is
+ using number as key to index the entry, the result will be shifted so here we
+ add specical handling to shift it back. We apply this workaround until a better
+ solution can be found. */
+static void
+workaround_snapshot_menu_default_entry (grub_menu_t menu, const char *name, int *default_entry)
+{
+ grub_menu_entry_t entry;
+ if ((entry = grub_menu_get_entry (menu, 0)) &&
+ ((entry->submenu && grub_strncmp (entry->title, "Bootable snapshot", sizeof("Bootable snapshot") - 1) == 0) ||
+ (!entry->submenu && grub_strncmp (entry->title, "Help on bootable snapshot", sizeof("Help on bootable snapshot") - 1) == 0)))
+ {
+ const char *val;
+
+ if (*default_entry == -1 && menu->size > 1)
+ {
+ *default_entry = 1;
+ return;
+ }
+
+ val = grub_env_get (name);
+
+ grub_error_push ();
+
+ if (val)
+ grub_strtoul (val, 0, 0);
+
+ if (*default_entry < (menu->size - 1) && grub_errno == GRUB_ERR_NONE)
+ ++(*default_entry);
+
+ grub_error_pop ();
+ }
+
+ return;
+}
+
#define GRUB_MENU_PAGE_SIZE 10
/* Show the menu and handle menu entry selection. Returns the menu entry
@@ -594,6 +631,8 @@
default_entry = get_entry_number (menu, "default");
+ workaround_snapshot_menu_default_entry (menu, "default", &default_entry);
+
/* If DEFAULT_ENTRY is not within the menu entries, fall back to
the first entry. */
if (default_entry < 0 || default_entry >= menu->size)