--- trunk/grubby/grubby.c 2016/06/29 14:40:57 2962 +++ tags/grubby-8_39/grubby.c 2016/06/30 10:26:53 2982 @@ -222,6 +222,7 @@ .mbHyperFirst = 1, .mbInitRdIsModule = 1, .mbAllowExtraInitRds = 1, + .titlePosition = 1, }; struct keywordTypes grub2Keywords[] = { @@ -582,6 +583,8 @@ { "initrd", LT_INITRD, ' ', ',' }, { "append", LT_KERNELARGS, ' ' }, { "prompt", LT_UNKNOWN, ' ' }, + { "fdt", LT_DEVTREE, ' ' }, + { "fdtdir", LT_DEVTREE, ' ' }, { NULL, 0, 0 }, }; int useextlinuxmenu; @@ -592,6 +595,7 @@ .needsBootPrefix = 1, .argsInQuotes = 1, .mbConcatArgs = 1, + .titlePosition = 1, }; struct configFileInfo liloConfigType = { @@ -600,6 +604,7 @@ .entryStart = LT_KERNEL, .argsInQuotes = 1, .maxTitleLength = 15, + .titlePosition = 1, }; struct configFileInfo yabootConfigType = { @@ -610,6 +615,7 @@ .argsInQuotes = 1, .maxTitleLength = 15, .mbAllowExtraInitRds = 1, + .titlePosition = 1, }; struct configFileInfo siloConfigType = { @@ -619,6 +625,7 @@ .needsBootPrefix = 1, .argsInQuotes = 1, .maxTitleLength = 15, + .titlePosition = 1, }; struct configFileInfo ziplConfigType = { @@ -638,6 +645,7 @@ .maxTitleLength = 255, .mbAllowExtraInitRds = 1, .defaultIsUnquoted = 1, + .titlePosition = 1, }; struct grubConfig { @@ -826,13 +834,20 @@ } /* extract the title from within brackets (for zipl) */ -static char * extractTitle(struct singleLine * line) { - /* bracketed title... let's extract it (leaks a byte) */ +static char * extractTitle(struct grubConfig *cfg, struct singleLine * line) { + /* bracketed title... let's extract it */ char * title = NULL; + if (cfg->cfi == &grub2ConfigType) + return grub2ExtractTitle(line); if (line->type == LT_TITLE) { - title = strdup(line->elements[0].item); - title++; - *(title + strlen(title) - 1) = '\0'; + char *tmp = line->elements[cfg->cfi->titlePosition].item; + if (cfg->cfi->titleBracketed) { + tmp++; + title = strdup(tmp); + *(title + strlen(title) - 1) = '\0'; + } else { + title = strdup(tmp); + } } else if (line->type == LT_MENUENTRY) title = strdup(line->elements[1].item); else @@ -1440,7 +1455,7 @@ line->elements[1].item)) break; } else if (line) { if (!strcmp(defaultLine->elements[1].item, - extractTitle(line))) break; + extractTitle(cfg, line))) break; } i++; entry = NULL; @@ -1491,7 +1506,7 @@ if (!line) line = getLineByType(LT_TITLE, entry->lines); if (line) { - title = extractTitle(line); + title = extractTitle(cfg, line); if (title) cfg->cfi->setEnv(cfg->cfi, "saved_entry", title); } @@ -1529,7 +1544,7 @@ else if (line && (line->numElements == 1) && cfg->cfi->titleBracketed) { fprintf(out, "%sdefault%s%s\n", indent, separator, - extractTitle(line)); + extractTitle(cfg, line)); } } } @@ -2370,7 +2385,7 @@ } else { char * title; line = getLineByType(LT_MENUENTRY, entry->lines); - if (!line) { + if (line) { title = grub2ExtractTitle(line); if (title) printf("title=%s\n", title); @@ -3331,7 +3346,7 @@ if (!line) continue; - linetitle = extractTitle(line); + linetitle = extractTitle(cfg, line); if (!linetitle) continue; if (strcmp(title, linetitle)) { @@ -3385,7 +3400,7 @@ if (!line) continue; - linetitle = extractTitle(line); + linetitle = extractTitle(cfg, line); if (!linetitle) continue; if (strcmp(title, linetitle)) { @@ -4269,6 +4284,8 @@ _("display the title of the default kernel") }, { "devtree", 0, POPT_ARG_STRING, &newDevTreePath, 0, _("device tree file for new stanza"), _("dtb-path") }, + { "devtreedir", 0, POPT_ARG_STRING, &newDevTreePath, 0, + _("device tree directory for new stanza"), _("dtb-path") }, { "elilo", 0, POPT_ARG_NONE, &configureELilo, 0, _("configure elilo bootloader") }, { "efi", 0, POPT_ARG_NONE, &isEfi, 0,