代码拉取完成,页面将自动刷新
From 90dcadebc1b17ea4ad5dc90676d7f146c5c5be67 Mon Sep 17 00:00:00 2001
From: nilusyi <nilusyi@tencent.com>
Date: Mon, 1 Apr 2024 16:14:25 +0800
Subject: [PATCH 038/272] btrfs 08 workaround snapshot menu default entry
Signed-off-by: Michael Chang <mchang@suse.com>
---
grub-core/normal/menu.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
index 6a90e091f..0e8e48ccb 100644
--- a/grub-core/normal/menu.c
+++ b/grub-core/normal/menu.c
@@ -564,6 +564,43 @@ print_countdown (struct grub_term_coordinate *pos, int n)
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
@@ -584,6 +621,8 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot, int *notify_boot)
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)
--
2.41.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。