60 |
|
|
61 |
int isEfi = 0; |
int isEfi = 0; |
62 |
|
|
63 |
|
#if defined(__aarch64__) |
64 |
|
#define isEfiOnly 1 |
65 |
|
#else |
66 |
|
#define isEfiOnly 0 |
67 |
|
#endif |
68 |
|
|
69 |
char *saved_command_line = NULL; |
char *saved_command_line = NULL; |
70 |
|
|
71 |
/* comments get lumped in with indention */ |
/* comments get lumped in with indention */ |
98 |
LT_INITRD_EFI = 1 << 21, |
LT_INITRD_EFI = 1 << 21, |
99 |
LT_KERNEL_16 = 1 << 22, |
LT_KERNEL_16 = 1 << 22, |
100 |
LT_INITRD_16 = 1 << 23, |
LT_INITRD_16 = 1 << 23, |
101 |
LT_UNKNOWN = 1 << 24, |
LT_DEVTREE = 1 << 24, |
102 |
|
LT_UNKNOWN = 1 << 25, |
103 |
}; |
}; |
104 |
|
|
105 |
struct singleLine { |
struct singleLine { |
128 |
#define NEED_ARGS (1 << 3) |
#define NEED_ARGS (1 << 3) |
129 |
#define NEED_MB (1 << 4) |
#define NEED_MB (1 << 4) |
130 |
#define NEED_END (1 << 5) |
#define NEED_END (1 << 5) |
131 |
|
#define NEED_DEVTREE (1 << 6) |
132 |
|
|
133 |
#define MAIN_DEFAULT (1 << 0) |
#define MAIN_DEFAULT (1 << 0) |
134 |
#define DEFAULT_SAVED -2 |
#define DEFAULT_SAVED -2 |
161 |
int defaultIsVariable; |
int defaultIsVariable; |
162 |
int defaultSupportSaved; |
int defaultSupportSaved; |
163 |
int defaultIsSaved; |
int defaultIsSaved; |
164 |
|
int defaultIsUnquoted; |
165 |
enum lineType_e entryStart; |
enum lineType_e entryStart; |
166 |
enum lineType_e entryEnd; |
enum lineType_e entryEnd; |
167 |
int needsBootPrefix; |
int needsBootPrefix; |
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[] = { |
241 |
{ "initrd16", LT_INITRD_16, ' ', ' ' }, |
{ "initrd16", LT_INITRD_16, ' ', ' ' }, |
242 |
{ "module", LT_MBMODULE, ' ' }, |
{ "module", LT_MBMODULE, ' ' }, |
243 |
{ "kernel", LT_HYPER, ' ' }, |
{ "kernel", LT_HYPER, ' ' }, |
244 |
|
{ "devicetree", LT_DEVTREE, ' ' }, |
245 |
{ NULL, 0, 0 }, |
{ NULL, 0, 0 }, |
246 |
}; |
}; |
247 |
|
|
583 |
{ "initrd", LT_INITRD, ' ', ',' }, |
{ "initrd", LT_INITRD, ' ', ',' }, |
584 |
{ "append", LT_KERNELARGS, ' ' }, |
{ "append", LT_KERNELARGS, ' ' }, |
585 |
{ "prompt", LT_UNKNOWN, ' ' }, |
{ "prompt", LT_UNKNOWN, ' ' }, |
586 |
|
{ "fdt", LT_DEVTREE, ' ' }, |
587 |
|
{ "fdtdir", LT_DEVTREE, ' ' }, |
588 |
{ NULL, 0, 0 }, |
{ NULL, 0, 0 }, |
589 |
}; |
}; |
590 |
int useextlinuxmenu; |
int useextlinuxmenu; |
595 |
.needsBootPrefix = 1, |
.needsBootPrefix = 1, |
596 |
.argsInQuotes = 1, |
.argsInQuotes = 1, |
597 |
.mbConcatArgs = 1, |
.mbConcatArgs = 1, |
598 |
|
.titlePosition = 1, |
599 |
}; |
}; |
600 |
|
|
601 |
struct configFileInfo liloConfigType = { |
struct configFileInfo liloConfigType = { |
604 |
.entryStart = LT_KERNEL, |
.entryStart = LT_KERNEL, |
605 |
.argsInQuotes = 1, |
.argsInQuotes = 1, |
606 |
.maxTitleLength = 15, |
.maxTitleLength = 15, |
607 |
|
.titlePosition = 1, |
608 |
}; |
}; |
609 |
|
|
610 |
struct configFileInfo yabootConfigType = { |
struct configFileInfo yabootConfigType = { |
615 |
.argsInQuotes = 1, |
.argsInQuotes = 1, |
616 |
.maxTitleLength = 15, |
.maxTitleLength = 15, |
617 |
.mbAllowExtraInitRds = 1, |
.mbAllowExtraInitRds = 1, |
618 |
|
.titlePosition = 1, |
619 |
}; |
}; |
620 |
|
|
621 |
struct configFileInfo siloConfigType = { |
struct configFileInfo siloConfigType = { |
625 |
.needsBootPrefix = 1, |
.needsBootPrefix = 1, |
626 |
.argsInQuotes = 1, |
.argsInQuotes = 1, |
627 |
.maxTitleLength = 15, |
.maxTitleLength = 15, |
628 |
|
.titlePosition = 1, |
629 |
}; |
}; |
630 |
|
|
631 |
struct configFileInfo ziplConfigType = { |
struct configFileInfo ziplConfigType = { |
644 |
.needsBootPrefix = 1, |
.needsBootPrefix = 1, |
645 |
.maxTitleLength = 255, |
.maxTitleLength = 255, |
646 |
.mbAllowExtraInitRds = 1, |
.mbAllowExtraInitRds = 1, |
647 |
|
.defaultIsUnquoted = 1, |
648 |
|
.titlePosition = 1, |
649 |
}; |
}; |
650 |
|
|
651 |
struct grubConfig { |
struct grubConfig { |
737 |
if (isEfi && cfi == &grub2ConfigType) { |
if (isEfi && cfi == &grub2ConfigType) { |
738 |
switch (type) { |
switch (type) { |
739 |
case LT_KERNEL: |
case LT_KERNEL: |
740 |
return LT_KERNEL_EFI; |
return isEfiOnly ? LT_KERNEL : LT_KERNEL_EFI; |
741 |
case LT_INITRD: |
case LT_INITRD: |
742 |
return LT_INITRD_EFI; |
return isEfiOnly ? LT_INITRD : LT_INITRD_EFI; |
743 |
default: |
default: |
744 |
return type; |
return type; |
745 |
} |
} |
834 |
} |
} |
835 |
|
|
836 |
/* extract the title from within brackets (for zipl) */ |
/* extract the title from within brackets (for zipl) */ |
837 |
static char * extractTitle(struct singleLine * line) { |
static char * extractTitle(struct grubConfig *cfg, struct singleLine * line) { |
838 |
/* bracketed title... let's extract it (leaks a byte) */ |
/* bracketed title... let's extract it */ |
839 |
char * title = NULL; |
char * title = NULL; |
840 |
|
if (cfg->cfi == &grub2ConfigType) |
841 |
|
return grub2ExtractTitle(line); |
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 |
1208 |
cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT; |
cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT; |
1209 |
defaultLine = line; |
defaultLine = line; |
1210 |
} |
} |
|
} else if (line->type == LT_DEFAULT && line->numElements == 2) { |
|
|
cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT; |
|
|
defaultLine = line; |
|
1211 |
|
|
1212 |
} else if (iskernel(line->type)) { |
} else if (iskernel(line->type)) { |
1213 |
/* if by some freak chance this is multiboot and the "module" |
/* if by some freak chance this is multiboot and the "module" |
1214 |
* lines came earlier in the template, make sure to use LT_HYPER |
* lines came earlier in the template, make sure to use LT_HYPER |
1215 |
* instead of LT_KERNEL now |
* instead of LT_KERNEL now |
1216 |
*/ |
*/ |
1217 |
if (entry->multiboot) |
if (entry && entry->multiboot) |
1218 |
line->type = LT_HYPER; |
line->type = LT_HYPER; |
1219 |
|
|
1220 |
} else if (line->type == LT_MBMODULE) { |
} else if (line->type == LT_MBMODULE) { |
1240 |
cfg->fallbackImage = strtol(line->elements[1].item, &end, 10); |
cfg->fallbackImage = strtol(line->elements[1].item, &end, 10); |
1241 |
if (*end) cfg->fallbackImage = -1; |
if (*end) cfg->fallbackImage = -1; |
1242 |
|
|
1243 |
} else if (line->type == LT_TITLE && line->numElements > 1) { |
} else if ((line->type == LT_DEFAULT && cfi->defaultIsUnquoted) || |
1244 |
/* make the title a single argument (undoing our parsing) */ |
(line->type == LT_TITLE && line->numElements > 1)) { |
1245 |
|
/* make the title/default a single argument (undoing our parsing) */ |
1246 |
len = 0; |
len = 0; |
1247 |
for (int i = 1; i < line->numElements; i++) { |
for (int i = 1; i < line->numElements; i++) { |
1248 |
len += strlen(line->elements[i].item); |
len += strlen(line->elements[i].item); |
1349 |
} |
} |
1350 |
} |
} |
1351 |
|
|
1352 |
|
if (line->type == LT_DEFAULT && line->numElements == 2) { |
1353 |
|
cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT; |
1354 |
|
defaultLine = line; |
1355 |
|
} |
1356 |
|
|
1357 |
/* If we find a generic config option which should live at the |
/* If we find a generic config option which should live at the |
1358 |
top of the file, move it there. Old versions of grubby were |
top of the file, move it there. Old versions of grubby were |
1359 |
probably responsible for putting new images in the wrong |
probably responsible for putting new images in the wrong |
1455 |
line->elements[1].item)) break; |
line->elements[1].item)) break; |
1456 |
} else if (line) { |
} else if (line) { |
1457 |
if (!strcmp(defaultLine->elements[1].item, |
if (!strcmp(defaultLine->elements[1].item, |
1458 |
extractTitle(line))) break; |
extractTitle(cfg, line))) break; |
1459 |
} |
} |
1460 |
i++; |
i++; |
1461 |
entry = NULL; |
entry = NULL; |
1506 |
if (!line) |
if (!line) |
1507 |
line = getLineByType(LT_TITLE, entry->lines); |
line = getLineByType(LT_TITLE, entry->lines); |
1508 |
if (line) { |
if (line) { |
1509 |
title = extractTitle(line); |
title = extractTitle(cfg, line); |
1510 |
if (title) |
if (title) |
1511 |
cfg->cfi->setEnv(cfg->cfi, "saved_entry", title); |
cfg->cfi->setEnv(cfg->cfi, "saved_entry", title); |
1512 |
} |
} |
1544 |
else if (line && (line->numElements == 1) && |
else if (line && (line->numElements == 1) && |
1545 |
cfg->cfi->titleBracketed) { |
cfg->cfi->titleBracketed) { |
1546 |
fprintf(out, "%sdefault%s%s\n", indent, separator, |
fprintf(out, "%sdefault%s%s\n", indent, separator, |
1547 |
extractTitle(line)); |
extractTitle(cfg, line)); |
1548 |
} |
} |
1549 |
} |
} |
1550 |
} |
} |
1975 |
} |
} |
1976 |
|
|
1977 |
indexVars[i + 1] = -1; |
indexVars[i + 1] = -1; |
1978 |
|
|
1979 |
i = 0; |
i = 0; |
1980 |
if (index) { |
if (index) { |
1981 |
while (i < *index) i++; |
while (i < *index) { |
1982 |
if (indexVars[i] == -1) return NULL; |
i++; |
1983 |
|
if (indexVars[i] == -1) return NULL; |
1984 |
|
} |
1985 |
} |
} |
1986 |
|
|
1987 |
entry = findEntryByIndex(config, indexVars[i]); |
entry = findEntryByIndex(config, indexVars[i]); |
2135 |
} else { |
} else { |
2136 |
entry = findEntryByTitle(cfg, defTitle, &index); |
entry = findEntryByTitle(cfg, defTitle, &index); |
2137 |
} |
} |
2138 |
if (entry) |
if (entry && suitableImage(entry, prefix, skipRemoved, flags)) { |
2139 |
cfg->defaultImage = index; |
cfg->defaultImage = index; |
2140 |
|
if (indexPtr) |
2141 |
|
*indexPtr = index; |
2142 |
|
return entry; |
2143 |
|
} |
2144 |
} |
} |
2145 |
} |
} |
2146 |
} else if (cfg->defaultImage > -1) { |
} else if (cfg->defaultImage > -1) { |
2297 |
struct singleLine * line; |
struct singleLine * line; |
2298 |
char * root = NULL; |
char * root = NULL; |
2299 |
int i; |
int i; |
2300 |
|
int j; |
2301 |
|
|
2302 |
printf("index=%d\n", index); |
printf("index=%d\n", index); |
2303 |
|
|
2385 |
} else { |
} else { |
2386 |
char * title; |
char * title; |
2387 |
line = getLineByType(LT_MENUENTRY, entry->lines); |
line = getLineByType(LT_MENUENTRY, entry->lines); |
2388 |
title = grub2ExtractTitle(line); |
if (line) { |
2389 |
if (title) |
title = grub2ExtractTitle(line); |
2390 |
printf("title=%s\n", title); |
if (title) |
2391 |
|
printf("title=%s\n", title); |
2392 |
|
} |
2393 |
|
} |
2394 |
|
|
2395 |
|
for (j = 0, line = entry->lines; line; line = line->next) { |
2396 |
|
if ((line->type & LT_MBMODULE) && line->numElements >= 2) { |
2397 |
|
if (!strncmp(prefix, line->elements[1].item, strlen(prefix))) |
2398 |
|
printf("mbmodule%d=", j); |
2399 |
|
else |
2400 |
|
printf("mbmodule%d=%s", j, prefix); |
2401 |
|
|
2402 |
|
for (i = 1; i < line->numElements; i++) |
2403 |
|
printf("%s%s", line->elements[i].item, line->elements[i].indent); |
2404 |
|
printf("\n"); |
2405 |
|
j++; |
2406 |
|
} |
2407 |
} |
} |
2408 |
} |
} |
2409 |
|
|
3326 |
} |
} |
3327 |
|
|
3328 |
int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel, |
int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel, |
3329 |
const char * image, const char * prefix, const char * initrd) { |
const char * image, const char * prefix, const char * initrd, |
3330 |
|
const char * title) { |
3331 |
struct singleEntry * entry; |
struct singleEntry * entry; |
3332 |
struct singleLine * line, * kernelLine, *endLine = NULL; |
struct singleLine * line, * kernelLine, *endLine = NULL; |
3333 |
int index = 0; |
int index = 0; |
3334 |
|
|
3335 |
if (!image) return 0; |
if (!image) return 0; |
3336 |
|
|
3337 |
for (; (entry = findEntryByPath(cfg, newMBKernel, prefix, &index)); index++) { |
for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) { |
3338 |
kernelLine = getLineByType(LT_MBMODULE, entry->lines); |
kernelLine = getLineByType(LT_MBMODULE, entry->lines); |
3339 |
if (!kernelLine) continue; |
if (!kernelLine) continue; |
3340 |
|
|
3341 |
|
/* if title is supplied, the entry's title must match it. */ |
3342 |
|
if (title) { |
3343 |
|
char *linetitle; |
3344 |
|
|
3345 |
|
line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines); |
3346 |
|
if (!line) |
3347 |
|
continue; |
3348 |
|
|
3349 |
|
linetitle = extractTitle(cfg, line); |
3350 |
|
if (!linetitle) |
3351 |
|
continue; |
3352 |
|
if (strcmp(title, linetitle)) { |
3353 |
|
free(linetitle); |
3354 |
|
continue; |
3355 |
|
} |
3356 |
|
free(linetitle); |
3357 |
|
} |
3358 |
|
|
3359 |
if (prefix) { |
if (prefix) { |
3360 |
int prefixLen = strlen(prefix); |
int prefixLen = strlen(prefix); |
3361 |
if (!strncmp(initrd, prefix, prefixLen)) |
if (!strncmp(initrd, prefix, prefixLen)) |
3381 |
} |
} |
3382 |
|
|
3383 |
int updateInitrd(struct grubConfig * cfg, const char * image, |
int updateInitrd(struct grubConfig * cfg, const char * image, |
3384 |
const char * prefix, const char * initrd) { |
const char * prefix, const char * initrd, const char * title) { |
3385 |
struct singleEntry * entry; |
struct singleEntry * entry; |
3386 |
struct singleLine * line, * kernelLine, *endLine = NULL; |
struct singleLine * line, * kernelLine, *endLine = NULL; |
3387 |
int index = 0; |
int index = 0; |
3392 |
kernelLine = getLineByType(LT_KERNEL|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); |
kernelLine = getLineByType(LT_KERNEL|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); |
3393 |
if (!kernelLine) continue; |
if (!kernelLine) continue; |
3394 |
|
|
3395 |
|
/* if title is supplied, the entry's title must match it. */ |
3396 |
|
if (title) { |
3397 |
|
char *linetitle; |
3398 |
|
|
3399 |
|
line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines); |
3400 |
|
if (!line) |
3401 |
|
continue; |
3402 |
|
|
3403 |
|
linetitle = extractTitle(cfg, line); |
3404 |
|
if (!linetitle) |
3405 |
|
continue; |
3406 |
|
if (strcmp(title, linetitle)) { |
3407 |
|
free(linetitle); |
3408 |
|
continue; |
3409 |
|
} |
3410 |
|
free(linetitle); |
3411 |
|
} |
3412 |
|
|
3413 |
line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines); |
line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines); |
3414 |
if (line) |
if (line) |
3415 |
removeLine(entry, line); |
removeLine(entry, line); |
3794 |
const char * newKernelPath, const char * newKernelTitle, |
const char * newKernelPath, const char * newKernelTitle, |
3795 |
const char * newKernelArgs, const char * newKernelInitrd, |
const char * newKernelArgs, const char * newKernelInitrd, |
3796 |
const char ** extraInitrds, int extraInitrdCount, |
const char ** extraInitrds, int extraInitrdCount, |
3797 |
const char * newMBKernel, const char * newMBKernelArgs) { |
const char * newMBKernel, const char * newMBKernelArgs, |
3798 |
|
const char * newDevTreePath) { |
3799 |
struct singleEntry * new; |
struct singleEntry * new; |
3800 |
struct singleLine * newLine = NULL, * tmplLine = NULL, * masterLine = NULL; |
struct singleLine * newLine = NULL, * tmplLine = NULL, * masterLine = NULL; |
3801 |
int needs; |
int needs; |
3836 |
needs |= NEED_MB; |
needs |= NEED_MB; |
3837 |
new->multiboot = 1; |
new->multiboot = 1; |
3838 |
} |
} |
3839 |
|
if (newDevTreePath && getKeywordByType(LT_DEVTREE, config->cfi)) |
3840 |
|
needs |= NEED_DEVTREE; |
3841 |
|
|
3842 |
if (template) { |
if (template) { |
3843 |
for (masterLine = template->lines; |
for (masterLine = template->lines; |
4023 |
newLine = addLineTmpl(new, tmplLine, newLine, NULL, |
newLine = addLineTmpl(new, tmplLine, newLine, NULL, |
4024 |
config->cfi); |
config->cfi); |
4025 |
} |
} |
4026 |
|
} else if (tmplLine->type == LT_DEVTREE && |
4027 |
|
tmplLine->numElements == 2 && newDevTreePath) { |
4028 |
|
newLine = addLineTmpl(new, tmplLine, newLine, |
4029 |
|
newDevTreePath + strlen(prefix), |
4030 |
|
config->cfi); |
4031 |
|
needs &= ~NEED_DEVTREE; |
4032 |
|
} else if (tmplLine->type == LT_ENTRY_END && needs & NEED_DEVTREE) { |
4033 |
|
const char *ndtp = newDevTreePath; |
4034 |
|
if (!strncmp(newDevTreePath, prefix, strlen(prefix))) |
4035 |
|
ndtp += strlen(prefix); |
4036 |
|
newLine = addLine(new, config->cfi, LT_DEVTREE, |
4037 |
|
config->secondaryIndent, |
4038 |
|
ndtp); |
4039 |
|
needs &= ~NEED_DEVTREE; |
4040 |
|
newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi); |
4041 |
} else { |
} else { |
4042 |
/* pass through other lines from the template */ |
/* pass through other lines from the template */ |
4043 |
newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi); |
newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi); |
4113 |
} |
} |
4114 |
} |
} |
4115 |
|
|
4116 |
|
struct singleLine *endLine = NULL; |
4117 |
|
endLine = getLineByType(LT_ENTRY_END, new->lines); |
4118 |
|
if (endLine) { |
4119 |
|
removeLine(new, endLine); |
4120 |
|
needs |= NEED_END; |
4121 |
|
} |
4122 |
|
|
4123 |
/* add the remainder of the lines, i.e. those that either |
/* add the remainder of the lines, i.e. those that either |
4124 |
* weren't present in the template, or in the case of no template, |
* weren't present in the template, or in the case of no template, |
4125 |
* all the lines following the entryStart. |
* all the lines following the entryStart. |
4165 |
free(initrdVal); |
free(initrdVal); |
4166 |
needs &= ~NEED_INITRD; |
needs &= ~NEED_INITRD; |
4167 |
} |
} |
4168 |
|
if (needs & NEED_DEVTREE) { |
4169 |
|
newLine = addLine(new, config->cfi, LT_DEVTREE, |
4170 |
|
config->secondaryIndent, |
4171 |
|
newDevTreePath); |
4172 |
|
needs &= ~NEED_DEVTREE; |
4173 |
|
} |
4174 |
|
|
4175 |
|
/* NEEDS_END must be last on bootloaders that need it... */ |
4176 |
if (needs & NEED_END) { |
if (needs & NEED_END) { |
4177 |
newLine = addLine(new, config->cfi, LT_ENTRY_END, |
newLine = addLine(new, config->cfi, LT_ENTRY_END, |
4178 |
config->secondaryIndent, NULL); |
config->secondaryIndent, NULL); |
4224 |
char * newKernelArgs = NULL; |
char * newKernelArgs = NULL; |
4225 |
char * newKernelInitrd = NULL; |
char * newKernelInitrd = NULL; |
4226 |
char * newKernelTitle = NULL; |
char * newKernelTitle = NULL; |
4227 |
char * newKernelVersion = NULL; |
char * newDevTreePath = NULL; |
4228 |
char * newMBKernel = NULL; |
char * newMBKernel = NULL; |
4229 |
char * newMBKernelArgs = NULL; |
char * newMBKernelArgs = NULL; |
4230 |
char * removeMBKernelArgs = NULL; |
char * removeMBKernelArgs = NULL; |
4282 |
_("display the index of the default kernel") }, |
_("display the index of the default kernel") }, |
4283 |
{ "default-title", 0, 0, &displayDefaultTitle, 0, |
{ "default-title", 0, 0, &displayDefaultTitle, 0, |
4284 |
_("display the title of the default kernel") }, |
_("display the title of the default kernel") }, |
4285 |
|
{ "devtree", 0, POPT_ARG_STRING, &newDevTreePath, 0, |
4286 |
|
_("device tree file for new stanza"), _("dtb-path") }, |
4287 |
|
{ "devtreedir", 0, POPT_ARG_STRING, &newDevTreePath, 0, |
4288 |
|
_("device tree directory for new stanza"), _("dtb-path") }, |
4289 |
{ "elilo", 0, POPT_ARG_NONE, &configureELilo, 0, |
{ "elilo", 0, POPT_ARG_NONE, &configureELilo, 0, |
4290 |
_("configure elilo bootloader") }, |
_("configure elilo bootloader") }, |
4291 |
{ "efi", 0, POPT_ARG_NONE, &isEfi, 0, |
{ "efi", 0, POPT_ARG_NONE, &isEfi, 0, |
4451 |
grubConfig = cfi->defaultConfig; |
grubConfig = cfi->defaultConfig; |
4452 |
} |
} |
4453 |
|
|
4454 |
if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion || |
if (bootloaderProbe && (displayDefault || kernelInfo || |
4455 |
newKernelPath || removeKernelPath || makeDefault || |
newKernelPath || removeKernelPath || makeDefault || |
4456 |
defaultKernel || displayDefaultIndex || displayDefaultTitle || |
defaultKernel || displayDefaultIndex || displayDefaultTitle || |
4457 |
(defaultIndex >= 0))) { |
(defaultIndex >= 0))) { |
4460 |
return 1; |
return 1; |
4461 |
} |
} |
4462 |
|
|
4463 |
if ((displayDefault || kernelInfo) && (newKernelVersion || newKernelPath || |
if ((displayDefault || kernelInfo) && (newKernelPath || |
4464 |
removeKernelPath)) { |
removeKernelPath)) { |
4465 |
fprintf(stderr, _("grubby: --default-kernel and --info may not " |
fprintf(stderr, _("grubby: --default-kernel and --info may not " |
4466 |
"be used when adding or removing kernels\n")); |
"be used when adding or removing kernels\n")); |
4470 |
if (newKernelPath && !newKernelTitle) { |
if (newKernelPath && !newKernelTitle) { |
4471 |
fprintf(stderr, _("grubby: kernel title must be specified\n")); |
fprintf(stderr, _("grubby: kernel title must be specified\n")); |
4472 |
return 1; |
return 1; |
4473 |
} else if (!newKernelPath && (newKernelTitle || copyDefault || |
} else if (!newKernelPath && (copyDefault || |
4474 |
(newKernelInitrd && !updateKernelPath)|| |
(newKernelInitrd && !updateKernelPath)|| |
4475 |
makeDefault || extraInitrdCount > 0)) { |
makeDefault || extraInitrdCount > 0)) { |
4476 |
fprintf(stderr, _("grubby: kernel path expected\n")); |
fprintf(stderr, _("grubby: kernel path expected\n")); |
4692 |
if (updateKernelPath && newKernelInitrd) { |
if (updateKernelPath && newKernelInitrd) { |
4693 |
if (newMBKernel) { |
if (newMBKernel) { |
4694 |
if (addMBInitrd(config, newMBKernel, updateKernelPath, |
if (addMBInitrd(config, newMBKernel, updateKernelPath, |
4695 |
bootPrefix, newKernelInitrd)) |
bootPrefix, newKernelInitrd, |
4696 |
|
newKernelTitle)) |
4697 |
return 1; |
return 1; |
4698 |
} else { |
} else { |
4699 |
if (updateInitrd(config, updateKernelPath, bootPrefix, |
if (updateInitrd(config, updateKernelPath, bootPrefix, |
4700 |
newKernelInitrd)) |
newKernelInitrd, newKernelTitle)) |
4701 |
return 1; |
return 1; |
4702 |
} |
} |
4703 |
} |
} |
4704 |
if (addNewKernel(config, template, bootPrefix, newKernelPath, |
if (addNewKernel(config, template, bootPrefix, newKernelPath, |
4705 |
newKernelTitle, newKernelArgs, newKernelInitrd, |
newKernelTitle, newKernelArgs, newKernelInitrd, |
4706 |
(const char **)extraInitrds, extraInitrdCount, |
(const char **)extraInitrds, extraInitrdCount, |
4707 |
newMBKernel, newMBKernelArgs)) return 1; |
newMBKernel, newMBKernelArgs, newDevTreePath)) return 1; |
4708 |
|
|
4709 |
|
|
4710 |
if (numEntries(config) == 0) { |
if (numEntries(config) == 0) { |