[PATCH 2/3] grubby: fix initrd lost issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When tboot is used, there is no line with LT_KERNEL* flag in grubConfig, so
"kernelLine" will be null, this will cause updateInitrd() fail without setting
the initrd. The "kernelLine" is used here to get the initrd configure line's
type and indent, the initrd configure type should be LT_MBMODULE when tboot is
used, or it is preferredLineType(LT_INITRD, cfg->cfi). The initrd configure
indent is cfg->secondaryIndent. So remove "kernelLine".

Signed-off-by: Junxiao Bi <junxiao.bi@xxxxxxxxxx>
---
 grubby.c |   24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/grubby.c b/grubby.c
index 2d7ab62..491b07d 100644
--- a/grubby.c
+++ b/grubby.c
@@ -3340,15 +3340,12 @@ int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel,
 int updateInitrd(struct grubConfig * cfg, const char * image,
                  const char * prefix, const char * initrd) {
     struct singleEntry * entry;
-    struct singleLine * line, * kernelLine, *endLine = NULL;
+    struct singleLine * line, *endLine = NULL;
     int index = 0;
 
     if (!image) return 0;
 
     for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) {
-        kernelLine = getLineByType(LT_KERNEL|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines);
-        if (!kernelLine) continue;
-
         line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines);
         if (line)
             removeLine(entry, line);
@@ -3360,21 +3357,14 @@ int updateInitrd(struct grubConfig * cfg, const char * image,
 	endLine = getLineByType(LT_ENTRY_END, entry->lines);
 	if (endLine)
 	    removeLine(entry, endLine);
+
 	enum lineType_e lt;
-	switch(kernelLine->type) {
-	    case LT_KERNEL:
-	        lt = LT_INITRD;
-		break;
-	    case LT_KERNEL_EFI:
-	        lt = LT_INITRD_EFI;
-		break;
-	    case LT_KERNEL_16:
-	        lt = LT_INITRD_16;
-		break;
-	    default:
+	if (entry->multiboot && getKeywordByType(LT_MBMODULE, cfg->cfi))
+		lt = LT_MBMODULE;
+	else
 	        lt = preferredLineType(LT_INITRD, cfg->cfi);
-	}
-        line = addLine(entry, cfg->cfi, lt, kernelLine->indent, initrd);
+
+        line = addLine(entry, cfg->cfi, lt, cfg->secondaryIndent, initrd);
         if (!line)
 	    return 1;
 	if (endLine) {
-- 
1.7.9.5

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list




[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux