1 Star 0 Fork 46

庞庆 / grub2

forked from src-anolis-os / grub2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0210-blscfg-Fallback-to-search-BLS-snippets-in-boot-loade.patch 2.17 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2022-04-13 15:15 . update to grub2-2.02-120.el8.src.rpm
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Wed, 18 Jul 2018 08:08:06 +0200
Subject: [PATCH] blscfg: Fallback to search BLS snippets in
/boot/loader/entries
The default path to search the BLS snippets is /loader/entries, this is
only a correct assumption if $root ($root) is a boot partition but it's
not true if /boot isn't a mount point.
A user can set a blsdir grub environment variable to choose a different
path, but instead of failing when /boot is a directory inside the root
partition fallback to search the BLS in /boot/loader/entries to cover
that case as well.
Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
grub-core/commands/blscfg.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
index 80d8814fc..321c93069 100644
--- a/grub-core/commands/blscfg.c
+++ b/grub-core/commands/blscfg.c
@@ -692,6 +692,7 @@ static int find_entry (const char *filename,
grub_device_t blsdir_dev = NULL;
const char *blsdir = NULL;
char *saved_env_buf = NULL;
+ int fallback = 0;
int r = 0;
const char *devid = grub_env_get ("boot");
@@ -797,7 +798,9 @@ static int find_entry (const char *filename,
}
read_entry_info.dirname = blsdir;
- r = blsdir_fs->dir (blsdir_dev, blsdir, read_entry, &read_entry_info);
+read_fallback:
+ r = blsdir_fs->dir (blsdir_dev, read_entry_info.dirname, read_entry,
+ &read_entry_info);
if (r != 0) {
grub_dprintf ("blscfg", "read_entry returned error\n");
grub_err_t e;
@@ -807,6 +810,14 @@ static int find_entry (const char *filename,
} while (e);
}
+ if (!nentries && !fallback && info->platform != PLATFORM_EMU) {
+ read_entry_info.dirname = "/boot" GRUB_BLS_CONFIG_PATH;
+ grub_dprintf ("blscfg", "Entries weren't found in %s, fallback to %s\n",
+ blsdir, read_entry_info.dirname);
+ fallback = 1;
+ goto read_fallback;
+ }
+
grub_dprintf ("blscfg", "Sorting %d entries\n", nentries);
grub_qsort(&entries[0], nentries, sizeof (struct bls_entry *), bls_cmp, NULL);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/pang-qing/grub2.git
git@gitee.com:pang-qing/grub2.git
pang-qing
grub2
grub2
a8

搜索帮助

344bd9b3 5694891 D2dac590 5694891