代码拉取完成,页面将自动刷新
From a8367596ca63156509eed0b332a077247765b811 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Tue, 28 Feb 2017 18:31:56 -0500
Subject: [PATCH 40/55] Fix initial saved_entry read issue (#1285601)
If a system has never had a kernel upgrade/rollback then grubby
does not read saved_entry properly. Added a guard to catch
saved_entry and read it to pick the proper index in these cases.
Resolves: rhbz#1285601
---
grubby.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/grubby.c b/grubby.c
index 9ccad2735dd..974b81c7864 100644
--- a/grubby.c
+++ b/grubby.c
@@ -2522,6 +2522,9 @@ void setDefaultImage(struct grubConfig *config, int isAddingBootEntry,
struct singleEntry *bootEntry, *newDefault;
int indexToVerify, firstKernelEntryIndex, currentLookupIndex;
+ /* initialize */
+ currentLookupIndex = FIRST_ENTRY_INDEX;
+
/* handle the two cases where the user explictly picks the default
* boot entry index as it would exist post-modification */
@@ -2587,8 +2590,30 @@ void setDefaultImage(struct grubConfig *config, int isAddingBootEntry,
config->defaultImage++;
}
} else {
- /* use pre-existing default entry */
- currentLookupIndex = config->defaultImage;
+ /* check to see if the default is stored in the environment */
+ if (config->defaultImage < FIRST_ENTRY_INDEX) {
+ if (config->defaultImage == DEFAULT_SAVED || config->defaultImage == DEFAULT_SAVED_GRUB2)
+ {
+ if (config->cfi->defaultIsSaved) {
+ if (config->cfi->getEnv) {
+ char *defaultTitle = config->cfi->getEnv(config->cfi, "saved_entry");
+
+ if (defaultTitle) {
+ if (isnumber(defaultTitle)) {
+ currentLookupIndex = atoi(defaultTitle);
+ } else {
+ findEntryByTitle(config, defaultTitle, ¤tLookupIndex);
+ }
+ /* set the default Image to an actual index */
+ config->defaultImage = currentLookupIndex;
+ }
+ }
+ }
+ }
+ } else {
+ /* use pre-existing default entry from the file*/
+ currentLookupIndex = config->defaultImage;
+ }
if (isAddingBootEntry
&& (newBootEntryIndex <= config->defaultImage)) {
--
2.17.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。