Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 892670 Details for
Bug 1094489
add support for btrfs in grub2 on /boot
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
v1: add support for btrfs in grub2
0001-v1-add-support-for-btrfs-in-grub2.patch (text/plain), 26.37 KB, created by
Gene Czarcinski
on 2014-05-05 19:44:38 UTC
(
hide
)
Description:
v1: add support for btrfs in grub2
Filename:
MIME Type:
Creator:
Gene Czarcinski
Created:
2014-05-05 19:44:38 UTC
Size:
26.37 KB
patch
obsolete
>From af00b93a05ddc7d89e1be224ab5e801f4634df9c Mon Sep 17 00:00:00 2001 >From: Gene Czarcinski <gene@czarc.net> >Date: Mon, 5 May 2014 14:20:43 -0400 >Subject: [PATCH 1/2] v1: add support for btrfs in grub2 >Content-Type: text/plain; charset="utf-8" >Content-Transfer-Encoding: 8bit > >This patch adds getSubvolPrefix() for handling a btrfs subvol >prefix on the filenames for grub2. If get_Root_Specifier() results >in a NULL rootspec, then getSubvolPrefix() is executed to extract any >btrfs subvol prefix. With this modification, booting off >/boot on a btrfs subvol is supported. > >To determine if booting is to be performed off a btrfs volume >or subvolume, the lines of the entry are scanned to detect >if "insmod btrfs" is present. If it is, then btrfs is assumed. > >If the kernel filename includes only one slash, then there is >no btrfs prefix. Otherwise, the first part defined by "/../" >will be the btrfs prefix if booting btrfs. Unless, of course, >there are 2 slashes in the filename but bootPrefix is zero length >in which case we are booting off a btrfs volume! > >Besides the kernel, the subvol prefix must also be on the >initrd filename. The subvol prefix for initrd is based on >the entry's kernel's filename. Note that the lines of >the entry must be scanned to determine if we are booting on >btrfs. > >Code was added to addLine(tmpl() so that the subvol prefix not added >for an initrd since updateInitrd() does that already. > >Besides the code needed to provide the functionality, this patch >includes debugging code to support the implementation. This >debugging code will have no effect unless DEBUG is enabled. > >This patch also includes a couple of minor fixes. In findTemplate() >the saved_entry code is fixed so it works. > >Add code findValidEntryByIndex() to test for the >comment "### END /etc/grub.d/10_linux ###" indicating that the >previous entry was the last "valid" entry. This prevents findTemplate() >from looking at entries created by 30_os-prober and 40_custom. >--- > grubby.c | 255 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 243 insertions(+), 12 deletions(-) > >diff --git a/grubby.c b/grubby.c >index 443d390..519b227 100644 >--- a/grubby.c >+++ b/grubby.c >@@ -68,6 +68,8 @@ int isEfi = 0; > > char *saved_command_line = NULL; > >+static const char * endOfValidEntries = "### END /etc/grub.d/10_linux ###"; >+ > /* comments get lumped in with indention */ > struct lineElement { > char * item; >@@ -654,6 +656,7 @@ struct grubConfig { > blkid_cache blkid; > > struct singleEntry * findEntryByIndex(struct grubConfig * cfg, int index); >+struct singleEntry * findValidEntryByIndex(struct grubConfig * cfg, int index); > struct singleEntry * findEntryByPath(struct grubConfig * cfg, > const char * path, const char * prefix, > int * index); >@@ -668,6 +671,8 @@ static int lineWrite(FILE * out, struct singleLine * line, > static int getNextLine(char ** bufPtr, struct singleLine * line, > struct configFileInfo * cfi); > static char * getRootSpecifier(char * str); >+static char * getSubvolPrefix(struct singleLine * line, char * str); >+static char * findBootPrefix(void); > static void requote(struct singleLine *line, struct configFileInfo * cfi); > static void insertElement(struct singleLine * line, > const char * item, int insertHere, >@@ -1371,7 +1376,14 @@ static struct grubConfig * readConfig(const char * inName, > entry->lines = line; > else > last->next = line; >- dbgPrintf("readConfig added %s to %p\n", getKeyByType(line->type, cfi), entry); >+ if ((line->numElements == 0) && (line->type == LT_WHITESPACE)) { >+ dbgPrintf("readConfig added %s to %p, comment='%s'\n", >+ getKeyByType(line->type, cfi), entry, >+ line->indent ? line->indent : ""); >+ } else { >+ dbgPrintf("readConfig added %s to %p\n", >+ getKeyByType(line->type, cfi), entry); >+ } > > /* we could have seen this outside of an entry... if so, we > * ignore it like any other line we don't grok */ >@@ -1382,7 +1394,16 @@ static struct grubConfig * readConfig(const char * inName, > cfg->theLines = line; > else > last->next = line; >- dbgPrintf("readConfig added %s to cfg\n", getKeyByType(line->type, cfi)); >+ if ((line->numElements == 0) && (line->type == LT_WHITESPACE)) { >+ dbgPrintf("readConfig added %s to cfg, comment='%s'\n", >+ getKeyByType(line->type, cfi), >+ line->indent ? line->indent : ""); >+ } else { >+ dbgPrintf("readConfig added %s to cfg ... 0:'%s' 1:'%s'\n", >+ getKeyByType(line->type, cfi), >+ (line->numElements > 0) ? line->elements[0].item : "", >+ (line->numElements > 1) ? line->elements[1].item : ""); >+ } > } > > last = line; >@@ -1477,6 +1498,7 @@ static void writeDefault(FILE * out, char * indent, > struct singleLine * line; > int i; > >+ dbgPrintf("writeDefault() entered\n"); > if (!cfg->defaultImage && cfg->flags == GRUB_CONFIG_NO_DEFAULT) return; > > if (cfg->defaultImage == DEFAULT_SAVED) >@@ -1532,6 +1554,7 @@ static void writeDefault(FILE * out, char * indent, > } > } > } >+ dbgPrintf("writeDefault() done\n"); > } > > static int writeConfig(struct grubConfig * cfg, char * outName, >@@ -1544,6 +1567,7 @@ static int writeConfig(struct grubConfig * cfg, char * outName, > struct stat sb; > int i; > >+ dbgPrintf("writeConfig() to outName='%s'\n", outName); > if (!strcmp(outName, "-")) { > out = stdout; > tmpOutName = NULL; >@@ -1595,6 +1619,7 @@ static int writeConfig(struct grubConfig * cfg, char * outName, > > line = cfg->theLines; > struct keywordTypes *defaultKw = getKeywordByType(LT_DEFAULT, cfg->cfi); >+ dbgPrintf("writeConfig(): outputting the new config file\n"); > while (line) { > if (line->type == LT_SET_VARIABLE && defaultKw && > line->numElements == 3 && >@@ -1624,6 +1649,7 @@ static int writeConfig(struct grubConfig * cfg, char * outName, > } > > if (needs & MAIN_DEFAULT) { >+ dbgPrintf("writeconfig() doing main default\n"); > writeDefault(out, cfg->primaryIndent, "=", cfg); > needs &= ~MAIN_DEFAULT; > } >@@ -1645,7 +1671,9 @@ static int writeConfig(struct grubConfig * cfg, char * outName, > } > } > >+ dbgPrintf("writeConfig() done\n"); > if (tmpOutName) { >+ dbgPrintf("writeConfig() renaming '%s' to '%s'\n", tmpOutName, outName); > if (rename(tmpOutName, outName)) { > fprintf(stderr, _("grubby: error moving %s to %s: %s\n"), > tmpOutName, outName, strerror(errno)); >@@ -1770,6 +1798,26 @@ void printEntry(struct singleEntry * entry, FILE *f) { > } > } > >+#if DEBUG >+void printEntries(struct grubConfig *cfg) { >+ struct singleEntry * entry; >+ int index = 0; >+ >+ entry = cfg->entries; >+ while (entry) { >+ if (!entry->skip) { >+ fprintf(stderr,"-------- entry=%i --------\n", index); >+ printEntry(entry, stderr); >+ fprintf(stderr,"-----end entry=%i --------\n", index); >+ index++; >+ } >+ else >+ fprintf(stderr,"-----skipping entry %i -----\n", index); >+ entry = entry->next; >+ } >+} >+#endif >+ > void notSuitablePrintf(struct singleEntry * entry, int okay, const char *fmt, ...) > { > static int once; >@@ -1821,6 +1869,58 @@ static int endswith(const char *s, char c) > return s[slen] == c; > } > >+ >+/* extract any btrfs prefix on filename */ >+/* the passed string is elements[1] */ >+static char * getSubvolPrefix(struct singleLine * line, char * str) { >+ char *idx, *svPrefix = NULL; >+ int slashcnt = 0; >+ const char * bootPrefix = findBootPrefix(); >+ >+static int btrfsBootFlag = 0; >+ >+ if (btrfsBootFlag == 0){ >+ for (; line; line = line->next) { >+ dbgPrintf("checkForBtrfsBoot(%s)\n", >+ line->numElements >0 ? line->elements[0].item : ""); >+ if (line->numElements >1) { >+ if ((strcasecmp(line->elements[0].item,"insmod")==0) && >+ (strcasecmp(line->elements[1].item,"btrfs")==0)) { >+ dbgPrintf("NOTE: booting from a btrfs volume or subvolume\n"); >+ btrfsBootFlag = -1; >+ break; >+ } >+ } >+ } >+ } >+ >+ idx = str; >+ while (*idx) { >+ if (*idx == '/') >+ slashcnt++; >+ idx++; >+ } >+ >+ dbgPrintf("getSubvolPrefix(): btrfsBootFlag=%i, slashcnt=%i, str='%s', bootPrefix='%s'\n", >+ btrfsBootFlag, slashcnt, str, bootPrefix); >+ >+ if ((btrfsBootFlag == 0) || >+ (slashcnt == 0) || >+ (slashcnt == 1)) >+ return NULL; >+ >+ if ((slashcnt == 2) && (strlen(bootPrefix) == 0)) >+ return NULL; >+ >+ if ((btrfsBootFlag == -1) && (*str == '/')) { >+ idx = svPrefix = strdup(str); >+ idx++; >+ while(*idx && (*idx != '/') && (!isspace(*idx))) idx++; >+ *idx = '\0'; /* strip off the second slash */ >+ } >+ return svPrefix; >+} >+ > int suitableImage(struct singleEntry * entry, const char * bootPrefix, > int skipRemoved, int flags) { > struct singleLine * line; >@@ -1851,14 +1951,21 @@ int suitableImage(struct singleEntry * entry, const char * bootPrefix, > return 1; > } > >+ dbgPrintf("suitableImage(), bootPrefix='%s', type='%s'\n", >+ bootPrefix, line->elements[0].item); > fullName = alloca(strlen(bootPrefix) + > strlen(line->elements[1].item) + 1); > rootspec = getRootSpecifier(line->elements[1].item); >+ if (rootspec == NULL) { >+ rootspec = getSubvolPrefix(entry->lines, line->elements[1].item); >+ } > int rootspec_offset = rootspec ? strlen(rootspec) : 0; > int hasslash = endswith(bootPrefix, '/') || > beginswith(line->elements[1].item + rootspec_offset, '/'); > sprintf(fullName, "%s%s%s", bootPrefix, hasslash ? "" : "/", > line->elements[1].item + rootspec_offset); >+ dbgPrintf("suitbleImage(): fullName='%s' root/subvol prefix='%s'\n", >+ fullName, (rootspec != NULL) ? rootspec : ""); > if (access(fullName, R_OK)) { > notSuitablePrintf(entry, 0, "access to %s failed\n", fullName); > return 0; >@@ -2030,11 +2137,17 @@ struct singleEntry * findEntryByPath(struct grubConfig * config, > if (line && line->type != LT_MENUENTRY && > line->numElements >= 2) { > rootspec = getRootSpecifier(line->elements[1].item); >+ if (rootspec == NULL) { >+ rootspec = getSubvolPrefix(entry->lines, line->elements[1].item); >+ } > if (!strcmp(line->elements[1].item + > ((rootspec != NULL) ? strlen(rootspec) : 0), > kernel + strlen(prefix))) > break; > } >+ if(line->type == LT_MENUENTRY) >+ dbgPrintf("findEntryByPath: got:'%s', wanted='%s'\n", >+ line->elements[1].item, kernel); > if(line->type == LT_MENUENTRY && > !strcmp(line->elements[1].item, kernel)) > break; >@@ -2096,6 +2209,39 @@ struct singleEntry * findEntryByIndex(struct grubConfig * cfg, int index) { > return entry; > } > >+/* ** code added to detect end of valid entries ** */ >+/* A separate function because other code may depend on currect functionality. */ >+/* Right now, findTemplate() is the ony use but there may be other places */ >+/* this should be used instead of findEntryByIndex. */ >+struct singleEntry * findValidEntryByIndex(struct grubConfig * cfg, int index) { >+ struct singleEntry * entry; >+ struct singleLine * line; >+ >+ entry = cfg->entries; >+ while (index && entry) { >+ entry = entry->next; >+ index--; >+ } >+ >+ if (entry == NULL) >+ return NULL; >+ >+ line = entry->lines; >+ while(line != NULL) { >+ if ((line->numElements == 0) && >+ (line->type == LT_WHITESPACE) && >+ (line->indent != NULL) && >+ (strcmp(line->indent, endOfValidEntries) == 0)) { >+ dbgPrintf("findEntryByIndex() end valid entries: %s\n", >+ endOfValidEntries); >+ return NULL; >+ } >+ line = line->next; >+ } >+ >+ return entry; >+} >+ > /* Find a good template to use for the new kernel. An entry is > * good if the kernel and mkinitrd exist (even if the entry > * is going to be removed). Try and use the default entry, but >@@ -2113,16 +2259,21 @@ struct singleEntry * findTemplate(struct grubConfig * cfg, const char * prefix, > int index = 0; > if (isnumber(defTitle)) { > index = atoi(defTitle); >- entry = findEntryByIndex(cfg, index); >+ entry = findValidEntryByIndex(cfg, index); > } else { > entry = findEntryByTitle(cfg, defTitle, &index); > } >- if (entry) >+ if (entry) { > cfg->defaultImage = index; >+ if (suitableImage(entry, prefix, skipRemoved, flags)) { >+ dbgPrintf("suitable template found based on saved_entry"); >+ return entry; >+ } >+ } > } > } > } else if (cfg->defaultImage > -1) { >- entry = findEntryByIndex(cfg, cfg->defaultImage); >+ entry = findValidEntryByIndex(cfg, cfg->defaultImage); > if (entry && suitableImage(entry, prefix, skipRemoved, flags)) { > if (indexPtr) *indexPtr = cfg->defaultImage; > return entry; >@@ -2130,7 +2281,7 @@ struct singleEntry * findTemplate(struct grubConfig * cfg, const char * prefix, > } > > index = 0; >- while ((entry = findEntryByIndex(cfg, index))) { >+ while ((entry = findValidEntryByIndex(cfg, index))) { > if (suitableImage(entry, prefix, skipRemoved, flags)) { > int j; > for (j = 0; j < index; j++) { >@@ -2150,7 +2301,7 @@ struct singleEntry * findTemplate(struct grubConfig * cfg, const char * prefix, > return NULL; > } > >-char * findBootPrefix(void) { >+static char * findBootPrefix(void) { > struct stat sb, sb2; > > stat("/", &sb); >@@ -2762,6 +2913,9 @@ struct singleLine * addLineTmpl(struct singleEntry * entry, > /* but try to keep the rootspec from the template... sigh */ > if (tmplLine->type & (LT_HYPER|LT_KERNEL|LT_MBMODULE|LT_INITRD|LT_KERNEL_EFI|LT_INITRD_EFI|LT_KERNEL_16|LT_INITRD_16)) { > char * rootspec = getRootSpecifier(tmplLine->elements[1].item); >+ if ((rootspec == NULL) && (tmplLine->type & (LT_HYPER|LT_KERNEL|LT_KERNEL_EFI|LT_KERNEL_16))) { >+ rootspec = getSubvolPrefix(entry->lines, tmplLine->elements[1].item); >+ } > if (rootspec != NULL) { > free(newLine->elements[1].item); > newLine->elements[1].item = >@@ -2770,8 +2924,9 @@ struct singleLine * addLineTmpl(struct singleEntry * entry, > } > } > >- dbgPrintf("addLineTmpl(%s)\n", newLine->numElements ? >- newLine->elements[0].item : ""); >+ dbgPrintf("addLineTmpl(%s), type=%i 0x%x\n", >+ newLine->numElements ? newLine->elements[0].item : "", >+ tmplLine->type, tmplLine->type); > > if (!entry->lines) { > /* first one on the list */ >@@ -2797,6 +2952,7 @@ struct singleLine * addLine(struct singleEntry * entry, > /* NB: This function shouldn't allocate items on the heap, rather on the > * stack since it calls addLineTmpl which will make copies. > */ >+ dbgPrintf("addLine(): type=%i 0x%x\n", type, type); > if (type == LT_TITLE && cfi->titleBracketed) { > /* we're doing a bracketed title (zipl) */ > tmpl.type = type; >@@ -3291,23 +3447,40 @@ int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel, > struct singleEntry * entry; > struct singleLine * line, * kernelLine, *endLine = NULL; > int index = 0; >+ char * svPrefix = NULL; >+ char * newInitrd = NULL; > > if (!image) return 0; >+ dbgPrintf("addMBInitrd(), image='%s', prefix='%s', initrd='%s'\n", >+ image, prefix, initrd); > > for (; (entry = findEntryByPath(cfg, newMBKernel, prefix, &index)); index++) { > kernelLine = getLineByType(LT_MBMODULE, entry->lines); > if (!kernelLine) continue; >+ dbgPrintf("... index=%i, kernel: %s '%s'\n", index, >+ kernelLine->elements[0].item, >+ kernelLine->elements[1].item); >+ svPrefix = getSubvolPrefix(entry->lines, kernelLine->elements[1].item); > > if (prefix) { > int prefixLen = strlen(prefix); > if (!strncmp(initrd, prefix, prefixLen)) > initrd += prefixLen; > } >+ if (svPrefix) { >+ newInitrd = alloca(strlen(svPrefix) + strlen(initrd) + 2); >+ strcpy(newInitrd, svPrefix); >+ strcat(newInitrd, initrd); >+ } else >+ newInitrd = (char *)initrd; >+ dbgPrintf("... updated initrd='%s'\n", newInitrd); > endLine = getLineByType(LT_ENTRY_END, entry->lines); > if (endLine) > removeLine(entry, endLine); > line = addLine(entry, cfg->cfi, preferredLineType(LT_MBMODULE,cfg->cfi), >- kernelLine->indent, initrd); >+ kernelLine->indent, newInitrd); >+ if (svPrefix) >+ free(svPrefix); > if (!line) > return 1; > if (endLine) { >@@ -3327,12 +3500,20 @@ int updateInitrd(struct grubConfig * cfg, const char * image, > struct singleEntry * entry; > struct singleLine * line, * kernelLine, *endLine = NULL; > int index = 0; >+ char * svPrefix = NULL; >+ char * newInitrd = NULL; > > if (!image) return 0; >+ dbgPrintf("updateInitrd(), image='%s', prefix='%s', initrd='%s'\n", >+ image, prefix, initrd); > > for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) { > kernelLine = getLineByType(LT_KERNEL|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); > if (!kernelLine) continue; >+ dbgPrintf("... index=%i, kernel: %s '%s'\n", index, >+ kernelLine->elements[0].item, >+ kernelLine->elements[1].item); >+ svPrefix = getSubvolPrefix(entry->lines, kernelLine->elements[1].item); > > line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines); > if (line) >@@ -3342,6 +3523,13 @@ int updateInitrd(struct grubConfig * cfg, const char * image, > if (!strncmp(initrd, prefix, prefixLen)) > initrd += prefixLen; > } >+ if (svPrefix) { >+ newInitrd = alloca(strlen(svPrefix) + strlen(initrd) + 2); >+ strcpy(newInitrd, svPrefix); >+ strcat(newInitrd, initrd); >+ } else >+ newInitrd = (char *)initrd; >+ dbgPrintf("... updated initrd='%s'\n", newInitrd); > endLine = getLineByType(LT_ENTRY_END, entry->lines); > if (endLine) > removeLine(entry, endLine); >@@ -3359,7 +3547,9 @@ int updateInitrd(struct grubConfig * cfg, const char * image, > default: > lt = preferredLineType(LT_INITRD, cfg->cfi); > } >- line = addLine(entry, cfg->cfi, lt, kernelLine->indent, initrd); >+ line = addLine(entry, cfg->cfi, lt, kernelLine->indent, newInitrd); >+ if (svPrefix) >+ free(svPrefix); > if (!line) > return 1; > if (endLine) { >@@ -3680,11 +3870,15 @@ static char * getInitrdVal(struct grubConfig * config, > > prefixLen = strlen(prefix); > totalSize = strlen(newKernelInitrd) - prefixLen + 1 /* \0 */; >+ dbgPrintf("getInitrdVal() prefixlen=%i totalsize=%i, newKernelInitrd='%s'\n", >+ (int)prefixLen, (int)totalSize, >+ newKernelInitrd); > > for (i = 0; i < extraInitrdCount; i++) { > totalSize += sizeof(separatorChar); > totalSize += strlen(extraInitrds[i]) - prefixLen; > } >+ dbgPrintf("... totalSize with extra initrd %i\n", (int)totalSize); > > initrdVal = end = malloc(totalSize); > >@@ -3763,12 +3957,17 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > if (newDevTreePath && getKeywordByType(LT_DEVTREE, config->cfi)) > needs |= NEED_DEVTREE; > >+ dbgPrintf("addNewKernel(): needs=0x%x\n", needs); > if (template) { > for (masterLine = template->lines; > masterLine && (tmplLine = lineDup(masterLine)); > lineFree(tmplLine), masterLine = masterLine->next) > { >- dbgPrintf("addNewKernel processing %d\n", tmplLine->type); >+ dbgPrintf("addNewKernel processing %d, 0x%x '%s', needs=0x%x, operand='%s'\n", >+ tmplLine->type, tmplLine->type, >+ tmplLine->numElements ? tmplLine->elements[0].item : "", >+ needs, >+ tmplLine->numElements>1 ? tmplLine->elements[1].item : ""); > > /* skip comments */ > chptr = tmplLine->indent; >@@ -3777,6 +3976,7 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > > if (iskernel(tmplLine->type) && tmplLine->numElements >= 2) { > if (!template->multiboot && (needs & NEED_MB)) { >+ dbgPrintf("addNewKernel: multiboot template\n"); > /* it's not a multiboot template and this is the kernel > * line. Try to be intelligent about inserting the > * hypervisor at the same time. >@@ -3805,17 +4005,22 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > free(tmplLine->elements[0].item); > tmplLine->elements[0].item = strdup(mbm_kw->key); > } >+ dbgPrintf("addNewKernel processing #1, new kernel path='%s'\n", >+ newKernelPath); > newLine = addLineTmpl(new, tmplLine, newLine, > newKernelPath + strlen(prefix), config->cfi); > needs &= ~NEED_KERNEL; > } > if (needs & NEED_MB) { /* !mbHyperFirst */ >+ dbgPrintf("addNewKernel processing #2\n"); > newLine = addLine(new, config->cfi, LT_HYPER, > config->secondaryIndent, > newMBKernel + strlen(prefix)); > needs &= ~NEED_MB; > } > } else if (needs & NEED_KERNEL) { >+ dbgPrintf("addNewKernel processing #3, new kernel path='%s'\n", >+ newKernelPath); > newLine = addLineTmpl(new, tmplLine, newLine, > newKernelPath + strlen(prefix), config->cfi); > needs &= ~NEED_KERNEL; >@@ -3824,6 +4029,7 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > } else if (tmplLine->type == LT_HYPER && > tmplLine->numElements >= 2) { > if (needs & NEED_MB) { >+ dbgPrintf("addNewKernel processing #4 (LT_HYPER)\n"); > newLine = addLineTmpl(new, tmplLine, newLine, > newMBKernel + strlen(prefix), config->cfi); > needs &= ~NEED_MB; >@@ -3833,6 +4039,7 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > tmplLine->numElements >= 2) { > if (new->multiboot) { > if (needs & NEED_KERNEL) { >+ dbgPrintf("addNewKernel processing #5\n"); > newLine = addLineTmpl(new, tmplLine, newLine, > newKernelPath + > strlen(prefix), config->cfi); >@@ -3843,6 +4050,7 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > initrdVal = getInitrdVal(config, prefix, tmplLine, > newKernelInitrd, extraInitrds, > extraInitrdCount); >+ dbgPrintf("addNewKernel processing #6\n"); > newLine = addLineTmpl(new, tmplLine, newLine, > initrdVal, config->cfi); > free(initrdVal); >@@ -3857,6 +4065,7 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > tmplLine->elements[0].item = > strdup(getKeywordByType(tmplLine->type, > config->cfi)->key); >+ dbgPrintf("addNewKernel processing #7\n"); > newLine = addLineTmpl(new, tmplLine, newLine, > newKernelPath + strlen(prefix), > config->cfi); >@@ -3872,6 +4081,7 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > strdup(getKeywordByType(tmplLine->type, > config->cfi)->key); > initrdVal = getInitrdVal(config, prefix, tmplLine, newKernelInitrd, extraInitrds, extraInitrdCount); >+ dbgPrintf("addNewKernel processing #8\n"); > newLine = addLineTmpl(new, tmplLine, newLine, initrdVal, config->cfi); > free(initrdVal); > needs &= ~NEED_INITRD; >@@ -3889,6 +4099,8 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > char *initrdVal; > > initrdVal = getInitrdVal(config, prefix, tmplLine, newKernelInitrd, extraInitrds, extraInitrdCount); >+ dbgPrintf("addNewKernel processing #9, MBMODULE='%s'\n", >+ initrdVal); > newLine = addLine(new, config->cfi, LT_MBMODULE, > config->secondaryIndent, > initrdVal); >@@ -3898,6 +4110,8 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > } else if (needs & NEED_INITRD) { > char *initrdVal; > initrdVal = getInitrdVal(config, prefix, tmplLine, newKernelInitrd, extraInitrds, extraInitrdCount); >+ dbgPrintf("addNewKernel processing #10, initrdVal='%s'\n", >+ initrdVal); > newLine = addLineTmpl(new, tmplLine, newLine, initrdVal, config->cfi); > free(initrdVal); > needs &= ~NEED_INITRD; >@@ -3910,18 +4124,21 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > strcpy(nkt, "'"); > strcat(nkt, newKernelTitle); > strcat(nkt, "'"); >+ dbgPrintf("addNewKernel processing #11, new='%s'\n", nkt); > newLine = addLineTmpl(new, tmplLine, newLine, nkt, config->cfi); > free(nkt); > needs &= ~NEED_TITLE; > } else if (tmplLine->type == LT_TITLE && > (needs & NEED_TITLE)) { > if (tmplLine->numElements >= 2) { >+ dbgPrintf("addNewKernel processing #12\n"); > newLine = addLineTmpl(new, tmplLine, newLine, > newKernelTitle, config->cfi); > needs &= ~NEED_TITLE; > } else if (tmplLine->numElements == 1 && > config->cfi->titleBracketed) { > /* addLineTmpl doesn't handle titleBracketed */ >+ dbgPrintf("addNewKernel processing #13\n"); > newLine = addLine(new, config->cfi, LT_TITLE, > tmplLine->indent, newKernelTitle); > needs &= ~NEED_TITLE; >@@ -3939,6 +4156,7 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > strcpy(newTitle, prefix); > strcat(newTitle, newKernelTitle); > strcat(newTitle, "'"); >+ dbgPrintf("addNewKernel processing #14\n"); > newLine = addLine(new, config->cfi, LT_ECHO, > tmplLine->indent, newTitle); > free(newTitle); >@@ -3972,6 +4190,7 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > /* don't have a template, so start the entry with the > * appropriate starting line > */ >+ dbgPrintf("addNewKernel processing no template, create something anyway\n"); > switch (config->cfi->entryStart) { > case LT_KERNEL: > case LT_KERNEL_EFI: >@@ -4036,6 +4255,7 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > abort(); > } > } >+ dbgPrintf("addNewKernel(): done loop, needs=0x%x\n", needs); > > /* add the remainder of the lines, i.e. those that either > * weren't present in the template, or in the case of no template, >@@ -4054,6 +4274,7 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > needs &= ~NEED_MB; > } > if (needs & NEED_KERNEL) { >+ dbgPrintf("addNewKernel processing #15\n"); > newLine = addLine(new, config->cfi, > (new->multiboot && getKeywordByType(LT_MBMODULE, > config->cfi)) >@@ -4103,6 +4324,12 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template, > if (updateImage(config, "0", prefix, newKernelArgs, NULL, > newMBKernelArgs, NULL)) return 1; > >+#if DEBUG >+ fprintf(stderr,"--end of addNewKernel()-----\n"); >+ printEntry(new, stderr); >+ fprintf(stderr,"--end of addNewKernel()-----\n"); >+#endif >+ > return 0; > } > >@@ -4277,6 +4504,7 @@ int main(int argc, const char ** argv) { > strncat(saved_command_line, j == argc -1 ? "" : " ", 1); > } > >+ dbgPrintf("---> Begin grubby execution <------------------------------------\n"); > optCon = poptGetContext("grubby", argc, argv, options, 0); > poptReadDefaultConfig(optCon, 1); > >@@ -4625,6 +4853,9 @@ int main(int argc, const char ** argv) { > "Not writing out new config.\n")); > return 1; > } >+#if DEBUG >+ printEntries(config); >+#endif > > if (!outputFile) > outputFile = (char *)grubConfig; >-- >1.9.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1094489
:
892670
|
892671
|
893044
|
893046
|
903279
|
903280
|
903281
|
903283
|
906996
|
906997
|
906998
|
907052