222 |
.mbHyperFirst = 1, |
.mbHyperFirst = 1, |
223 |
.mbInitRdIsModule = 1, |
.mbInitRdIsModule = 1, |
224 |
.mbAllowExtraInitRds = 1, |
.mbAllowExtraInitRds = 1, |
225 |
|
.titlePosition = 1, |
226 |
}; |
}; |
227 |
|
|
228 |
struct keywordTypes grub2Keywords[] = { |
struct keywordTypes grub2Keywords[] = { |
452 |
* whose last character is also quote (assuming it's the closing one) */ |
* whose last character is also quote (assuming it's the closing one) */ |
453 |
int resultMaxSize; |
int resultMaxSize; |
454 |
char * result; |
char * result; |
455 |
|
/* need to ensure that ' does not match " as we search */ |
456 |
|
char quote_char = *current; |
457 |
|
|
458 |
resultMaxSize = sizeOfSingleLine(line); |
resultMaxSize = sizeOfSingleLine(line); |
459 |
result = malloc(resultMaxSize); |
result = malloc(resultMaxSize); |
467 |
current_indent_len = strlen(current_indent); |
current_indent_len = strlen(current_indent); |
468 |
|
|
469 |
strncat(result, current_indent, current_indent_len); |
strncat(result, current_indent, current_indent_len); |
470 |
if (!isquote(current[current_len-1])) { |
if (current[current_len-1] != quote_char) { |
471 |
strncat(result, current, current_len); |
strncat(result, current, current_len); |
472 |
} else { |
} else { |
473 |
strncat(result, current, current_len - 1); |
strncat(result, current, current_len - 1); |
585 |
{ "initrd", LT_INITRD, ' ', ',' }, |
{ "initrd", LT_INITRD, ' ', ',' }, |
586 |
{ "append", LT_KERNELARGS, ' ' }, |
{ "append", LT_KERNELARGS, ' ' }, |
587 |
{ "prompt", LT_UNKNOWN, ' ' }, |
{ "prompt", LT_UNKNOWN, ' ' }, |
588 |
|
{ "fdt", LT_DEVTREE, ' ' }, |
589 |
|
{ "fdtdir", LT_DEVTREE, ' ' }, |
590 |
{ NULL, 0, 0 }, |
{ NULL, 0, 0 }, |
591 |
}; |
}; |
592 |
int useextlinuxmenu; |
int useextlinuxmenu; |
597 |
.needsBootPrefix = 1, |
.needsBootPrefix = 1, |
598 |
.argsInQuotes = 1, |
.argsInQuotes = 1, |
599 |
.mbConcatArgs = 1, |
.mbConcatArgs = 1, |
600 |
|
.titlePosition = 1, |
601 |
}; |
}; |
602 |
|
|
603 |
struct configFileInfo liloConfigType = { |
struct configFileInfo liloConfigType = { |
606 |
.entryStart = LT_KERNEL, |
.entryStart = LT_KERNEL, |
607 |
.argsInQuotes = 1, |
.argsInQuotes = 1, |
608 |
.maxTitleLength = 15, |
.maxTitleLength = 15, |
609 |
|
.titlePosition = 1, |
610 |
}; |
}; |
611 |
|
|
612 |
struct configFileInfo yabootConfigType = { |
struct configFileInfo yabootConfigType = { |
617 |
.argsInQuotes = 1, |
.argsInQuotes = 1, |
618 |
.maxTitleLength = 15, |
.maxTitleLength = 15, |
619 |
.mbAllowExtraInitRds = 1, |
.mbAllowExtraInitRds = 1, |
620 |
|
.titlePosition = 1, |
621 |
}; |
}; |
622 |
|
|
623 |
struct configFileInfo siloConfigType = { |
struct configFileInfo siloConfigType = { |
627 |
.needsBootPrefix = 1, |
.needsBootPrefix = 1, |
628 |
.argsInQuotes = 1, |
.argsInQuotes = 1, |
629 |
.maxTitleLength = 15, |
.maxTitleLength = 15, |
630 |
|
.titlePosition = 1, |
631 |
}; |
}; |
632 |
|
|
633 |
struct configFileInfo ziplConfigType = { |
struct configFileInfo ziplConfigType = { |
647 |
.maxTitleLength = 255, |
.maxTitleLength = 255, |
648 |
.mbAllowExtraInitRds = 1, |
.mbAllowExtraInitRds = 1, |
649 |
.defaultIsUnquoted = 1, |
.defaultIsUnquoted = 1, |
650 |
|
.titlePosition = 1, |
651 |
}; |
}; |
652 |
|
|
653 |
struct grubConfig { |
struct grubConfig { |
836 |
} |
} |
837 |
|
|
838 |
/* extract the title from within brackets (for zipl) */ |
/* extract the title from within brackets (for zipl) */ |
839 |
static char * extractTitle(struct singleLine * line) { |
static char * extractTitle(struct grubConfig *cfg, struct singleLine * line) { |
840 |
/* bracketed title... let's extract it (leaks a byte) */ |
/* bracketed title... let's extract it */ |
841 |
char * title = NULL; |
char * title = NULL; |
842 |
if (line->type == LT_TITLE) { |
if (line->type == LT_TITLE) { |
843 |
title = strdup(line->elements[0].item); |
char *tmp = line->elements[cfg->cfi->titlePosition].item; |
844 |
title++; |
if (cfg->cfi->titleBracketed) { |
845 |
*(title + strlen(title) - 1) = '\0'; |
tmp++; |
846 |
|
title = strdup(tmp); |
847 |
|
*(title + strlen(title) - 1) = '\0'; |
848 |
|
} else { |
849 |
|
title = strdup(tmp); |
850 |
|
} |
851 |
} else if (line->type == LT_MENUENTRY) |
} else if (line->type == LT_MENUENTRY) |
852 |
title = strdup(line->elements[1].item); |
title = strdup(line->elements[1].item); |
853 |
else |
else |
931 |
/* Need to handle this, because we strip the quotes from |
/* Need to handle this, because we strip the quotes from |
932 |
* menuentry when read it. */ |
* menuentry when read it. */ |
933 |
if (line->type == LT_MENUENTRY && i == 1) { |
if (line->type == LT_MENUENTRY && i == 1) { |
934 |
if(!isquote(*line->elements[i].item)) |
if(!isquote(*line->elements[i].item)) { |
935 |
fprintf(out, "\'%s\'", line->elements[i].item); |
int substring = 0; |
936 |
else |
/* If the line contains nested quotes, we did not strip |
937 |
|
* the "interna" quotes and we must use the right quotes |
938 |
|
* again when writing the updated file. */ |
939 |
|
for (int j = i; j < line->numElements; j++) { |
940 |
|
if (strchr(line->elements[i].item, '\'') != NULL) { |
941 |
|
substring = 1; |
942 |
|
fprintf(out, "\"%s\"", line->elements[i].item); |
943 |
|
break; |
944 |
|
} |
945 |
|
} |
946 |
|
if (!substring) |
947 |
|
fprintf(out, "\'%s\'", line->elements[i].item); |
948 |
|
} else { |
949 |
fprintf(out, "%s", line->elements[i].item); |
fprintf(out, "%s", line->elements[i].item); |
950 |
|
} |
951 |
fprintf(out, "%s", line->elements[i].indent); |
fprintf(out, "%s", line->elements[i].indent); |
952 |
|
|
953 |
continue; |
continue; |
1283 |
len = 0; |
len = 0; |
1284 |
char *extras; |
char *extras; |
1285 |
char *title; |
char *title; |
1286 |
|
/* initially unseen value */ |
1287 |
|
char quote_char = '\0'; |
1288 |
|
|
1289 |
for (int i = 1; i < line->numElements; i++) { |
for (int i = 1; i < line->numElements; i++) { |
1290 |
len += strlen(line->elements[i].item); |
len += strlen(line->elements[i].item); |
1301 |
for (int i = 0; i < line->numElements; i++) { |
for (int i = 0; i < line->numElements; i++) { |
1302 |
if (!strcmp(line->elements[i].item, "menuentry")) |
if (!strcmp(line->elements[i].item, "menuentry")) |
1303 |
continue; |
continue; |
1304 |
if (isquote(*line->elements[i].item)) |
if (isquote(*line->elements[i].item) && quote_char == '\0') { |
1305 |
|
/* ensure we properly pair off quotes */ |
1306 |
|
quote_char = *line->elements[i].item; |
1307 |
title = line->elements[i].item + 1; |
title = line->elements[i].item + 1; |
1308 |
else |
} else { |
1309 |
title = line->elements[i].item; |
title = line->elements[i].item; |
1310 |
|
} |
1311 |
|
|
1312 |
len = strlen(title); |
len = strlen(title); |
1313 |
if (isquote(title[len-1])) { |
if (title[len-1] == quote_char) { |
1314 |
strncat(buf, title,len-1); |
strncat(buf, title,len-1); |
1315 |
break; |
break; |
1316 |
} else { |
} else { |
1321 |
|
|
1322 |
/* get extras */ |
/* get extras */ |
1323 |
int count = 0; |
int count = 0; |
1324 |
|
quote_char = '\0'; |
1325 |
for (int i = 0; i < line->numElements; i++) { |
for (int i = 0; i < line->numElements; i++) { |
1326 |
if (count >= 2) { |
if (count >= 2) { |
1327 |
strcat(extras, line->elements[i].item); |
strcat(extras, line->elements[i].item); |
1332 |
continue; |
continue; |
1333 |
|
|
1334 |
/* count ' or ", there should be two in menuentry line. */ |
/* count ' or ", there should be two in menuentry line. */ |
1335 |
if (isquote(*line->elements[i].item)) |
if (isquote(*line->elements[i].item) && quote_char == '\0') { |
1336 |
|
/* ensure we properly pair off quotes */ |
1337 |
|
quote_char = *line->elements[i].item; |
1338 |
count++; |
count++; |
1339 |
|
} |
1340 |
|
|
1341 |
len = strlen(line->elements[i].item); |
len = strlen(line->elements[i].item); |
1342 |
|
|
1343 |
if (isquote(line->elements[i].item[len -1])) |
if (line->elements[i].item[len -1] == quote_char) |
1344 |
count++; |
count++; |
1345 |
|
|
1346 |
/* ok, we get the final ' or ", others are extras. */ |
/* ok, we get the final ' or ", others are extras. */ |
1477 |
line->elements[1].item)) break; |
line->elements[1].item)) break; |
1478 |
} else if (line) { |
} else if (line) { |
1479 |
if (!strcmp(defaultLine->elements[1].item, |
if (!strcmp(defaultLine->elements[1].item, |
1480 |
extractTitle(line))) break; |
extractTitle(cfg, line))) break; |
1481 |
} |
} |
1482 |
i++; |
i++; |
1483 |
entry = NULL; |
entry = NULL; |
1528 |
if (!line) |
if (!line) |
1529 |
line = getLineByType(LT_TITLE, entry->lines); |
line = getLineByType(LT_TITLE, entry->lines); |
1530 |
if (line) { |
if (line) { |
1531 |
title = extractTitle(line); |
title = extractTitle(cfg, line); |
1532 |
if (title) |
if (title) |
1533 |
cfg->cfi->setEnv(cfg->cfi, "saved_entry", title); |
cfg->cfi->setEnv(cfg->cfi, "saved_entry", title); |
1534 |
} |
} |
1566 |
else if (line && (line->numElements == 1) && |
else if (line && (line->numElements == 1) && |
1567 |
cfg->cfi->titleBracketed) { |
cfg->cfi->titleBracketed) { |
1568 |
fprintf(out, "%sdefault%s%s\n", indent, separator, |
fprintf(out, "%sdefault%s%s\n", indent, separator, |
1569 |
extractTitle(line)); |
extractTitle(cfg, line)); |
1570 |
} |
} |
1571 |
} |
} |
1572 |
} |
} |
2407 |
} else { |
} else { |
2408 |
char * title; |
char * title; |
2409 |
line = getLineByType(LT_MENUENTRY, entry->lines); |
line = getLineByType(LT_MENUENTRY, entry->lines); |
2410 |
if (!line) { |
if (line) { |
2411 |
title = grub2ExtractTitle(line); |
title = grub2ExtractTitle(line); |
2412 |
if (title) |
if (title) |
2413 |
printf("title=%s\n", title); |
printf("title=%s\n", title); |
3368 |
if (!line) |
if (!line) |
3369 |
continue; |
continue; |
3370 |
|
|
3371 |
linetitle = extractTitle(line); |
linetitle = extractTitle(cfg, line); |
3372 |
if (!linetitle) |
if (!linetitle) |
3373 |
continue; |
continue; |
3374 |
if (strcmp(title, linetitle)) { |
if (strcmp(title, linetitle)) { |
3422 |
if (!line) |
if (!line) |
3423 |
continue; |
continue; |
3424 |
|
|
3425 |
linetitle = extractTitle(line); |
linetitle = extractTitle(cfg, line); |
3426 |
if (!linetitle) |
if (!linetitle) |
3427 |
continue; |
continue; |
3428 |
if (strcmp(title, linetitle)) { |
if (strcmp(title, linetitle)) { |
4306 |
_("display the title of the default kernel") }, |
_("display the title of the default kernel") }, |
4307 |
{ "devtree", 0, POPT_ARG_STRING, &newDevTreePath, 0, |
{ "devtree", 0, POPT_ARG_STRING, &newDevTreePath, 0, |
4308 |
_("device tree file for new stanza"), _("dtb-path") }, |
_("device tree file for new stanza"), _("dtb-path") }, |
4309 |
|
{ "devtreedir", 0, POPT_ARG_STRING, &newDevTreePath, 0, |
4310 |
|
_("device tree directory for new stanza"), _("dtb-path") }, |
4311 |
{ "elilo", 0, POPT_ARG_NONE, &configureELilo, 0, |
{ "elilo", 0, POPT_ARG_NONE, &configureELilo, 0, |
4312 |
_("configure elilo bootloader") }, |
_("configure elilo bootloader") }, |
4313 |
{ "efi", 0, POPT_ARG_NONE, &isEfi, 0, |
{ "efi", 0, POPT_ARG_NONE, &isEfi, 0, |
4448 |
} |
} |
4449 |
|
|
4450 |
if (!cfi) { |
if (!cfi) { |
4451 |
if (grub2FindConfig(&grub2ConfigType)) |
if (grub2FindConfig(&grub2ConfigType)) { |
4452 |
cfi = &grub2ConfigType; |
cfi = &grub2ConfigType; |
4453 |
else |
if (envPath) |
4454 |
|
cfi->envFile = envPath; |
4455 |
|
} else |
4456 |
#ifdef __ia64__ |
#ifdef __ia64__ |
4457 |
cfi = &eliloConfigType; |
cfi = &eliloConfigType; |
4458 |
#elif __powerpc__ |
#elif __powerpc__ |