1 Star 0 Fork 98

余诗/grub2

forked from src-openEuler/grub2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
grub2-btrfs-08-workaround-snapshot-menu-default-entry.patch 1.76 KB
一键复制 编辑 原始数据 按行查看 历史
zhangqiumiao 提交于 2024-03-04 03:17 . update to 2.12
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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yushi-Icy/grub2.git
[email protected]:yushi-Icy/grub2.git
yushi-Icy
grub2
grub2
master

搜索帮助