36 |
#include <signal.h> |
#include <signal.h> |
37 |
#include <blkid/blkid.h> |
#include <blkid/blkid.h> |
38 |
|
|
39 |
|
#include "log.h" |
40 |
|
|
41 |
#ifndef DEBUG |
#ifndef DEBUG |
42 |
#define DEBUG 0 |
#define DEBUG 0 |
43 |
#endif |
#endif |
58 |
#define NOOP_OPCODE 0x90 |
#define NOOP_OPCODE 0x90 |
59 |
#define JMP_SHORT_OPCODE 0xeb |
#define JMP_SHORT_OPCODE 0xeb |
60 |
|
|
61 |
|
int isEfi = 0; |
62 |
|
|
63 |
|
char *saved_command_line = NULL; |
64 |
|
|
65 |
/* comments get lumped in with indention */ |
/* comments get lumped in with indention */ |
66 |
struct lineElement { |
struct lineElement { |
67 |
char * item; |
char * item; |
88 |
LT_MENUENTRY = 1 << 17, |
LT_MENUENTRY = 1 << 17, |
89 |
LT_ENTRY_END = 1 << 18, |
LT_ENTRY_END = 1 << 18, |
90 |
LT_SET_VARIABLE = 1 << 19, |
LT_SET_VARIABLE = 1 << 19, |
91 |
LT_UNKNOWN = 1 << 20, |
LT_KERNEL_EFI = 1 << 20, |
92 |
|
LT_INITRD_EFI = 1 << 21, |
93 |
|
LT_KERNEL_16 = 1 << 22, |
94 |
|
LT_INITRD_16 = 1 << 23, |
95 |
|
LT_DEVTREE = 1 << 24, |
96 |
|
LT_UNKNOWN = 1 << 25, |
97 |
}; |
}; |
98 |
|
|
99 |
struct singleLine { |
struct singleLine { |
122 |
#define NEED_ARGS (1 << 3) |
#define NEED_ARGS (1 << 3) |
123 |
#define NEED_MB (1 << 4) |
#define NEED_MB (1 << 4) |
124 |
#define NEED_END (1 << 5) |
#define NEED_END (1 << 5) |
125 |
|
#define NEED_DEVTREE (1 << 6) |
126 |
|
|
127 |
#define MAIN_DEFAULT (1 << 0) |
#define MAIN_DEFAULT (1 << 0) |
128 |
#define DEFAULT_SAVED -2 |
#define DEFAULT_SAVED -2 |
140 |
typedef const char *(*findConfigFunc)(struct configFileInfo *); |
typedef const char *(*findConfigFunc)(struct configFileInfo *); |
141 |
typedef const int (*writeLineFunc)(struct configFileInfo *, |
typedef const int (*writeLineFunc)(struct configFileInfo *, |
142 |
struct singleLine *line); |
struct singleLine *line); |
143 |
|
typedef char *(*getEnvFunc)(struct configFileInfo *, char *name); |
144 |
|
typedef int (*setEnvFunc)(struct configFileInfo *, char *name, char *value); |
145 |
|
|
146 |
struct configFileInfo { |
struct configFileInfo { |
147 |
char * defaultConfig; |
char * defaultConfig; |
148 |
findConfigFunc findConfig; |
findConfigFunc findConfig; |
149 |
writeLineFunc writeLine; |
writeLineFunc writeLine; |
150 |
|
getEnvFunc getEnv; |
151 |
|
setEnvFunc setEnv; |
152 |
struct keywordTypes * keywords; |
struct keywordTypes * keywords; |
153 |
|
int caseInsensitive; |
154 |
int defaultIsIndex; |
int defaultIsIndex; |
155 |
int defaultIsVariable; |
int defaultIsVariable; |
156 |
int defaultSupportSaved; |
int defaultSupportSaved; |
157 |
|
int defaultIsSaved; |
158 |
enum lineType_e entryStart; |
enum lineType_e entryStart; |
159 |
enum lineType_e entryEnd; |
enum lineType_e entryEnd; |
160 |
int needsBootPrefix; |
int needsBootPrefix; |
166 |
int mbInitRdIsModule; |
int mbInitRdIsModule; |
167 |
int mbConcatArgs; |
int mbConcatArgs; |
168 |
int mbAllowExtraInitRds; |
int mbAllowExtraInitRds; |
169 |
|
char *envFile; |
170 |
}; |
}; |
171 |
|
|
172 |
struct keywordTypes grubKeywords[] = { |
struct keywordTypes grubKeywords[] = { |
186 |
"/boot/grub/grub.conf", |
"/boot/grub/grub.conf", |
187 |
"/boot/grub/menu.lst", |
"/boot/grub/menu.lst", |
188 |
"/etc/grub.conf", |
"/etc/grub.conf", |
189 |
|
"/boot/grub2/grub.cfg", |
190 |
|
"/boot/grub2-efi/grub.cfg", |
191 |
NULL |
NULL |
192 |
}; |
}; |
193 |
static int i = -1; |
static int i = -1; |
226 |
{ "default", LT_DEFAULT, ' ' }, |
{ "default", LT_DEFAULT, ' ' }, |
227 |
{ "fallback", LT_FALLBACK, ' ' }, |
{ "fallback", LT_FALLBACK, ' ' }, |
228 |
{ "linux", LT_KERNEL, ' ' }, |
{ "linux", LT_KERNEL, ' ' }, |
229 |
|
{ "linuxefi", LT_KERNEL_EFI, ' ' }, |
230 |
|
{ "linux16", LT_KERNEL_16, ' ' }, |
231 |
{ "initrd", LT_INITRD, ' ', ' ' }, |
{ "initrd", LT_INITRD, ' ', ' ' }, |
232 |
|
{ "initrdefi", LT_INITRD_EFI, ' ', ' ' }, |
233 |
|
{ "initrd16", LT_INITRD_16, ' ', ' ' }, |
234 |
{ "module", LT_MBMODULE, ' ' }, |
{ "module", LT_MBMODULE, ' ' }, |
235 |
{ "kernel", LT_HYPER, ' ' }, |
{ "kernel", LT_HYPER, ' ' }, |
236 |
|
{ "devicetree", LT_DEVTREE, ' ' }, |
237 |
{ NULL, 0, 0 }, |
{ NULL, 0, 0 }, |
238 |
}; |
}; |
239 |
|
|
245 |
}; |
}; |
246 |
static int i = -1; |
static int i = -1; |
247 |
static const char *grub_cfg = "/boot/grub/grub.cfg"; |
static const char *grub_cfg = "/boot/grub/grub.cfg"; |
248 |
|
int rc = -1; |
249 |
|
|
250 |
if (i == -1) { |
if (i == -1) { |
251 |
for (i = 0; configFiles[i] != NULL; i++) { |
for (i = 0; configFiles[i] != NULL; i++) { |
252 |
dbgPrintf("Checking \"%s\": ", configFiles[i]); |
dbgPrintf("Checking \"%s\": ", configFiles[i]); |
253 |
if (!access(configFiles[i], R_OK)) { |
if ((rc = access(configFiles[i], R_OK))) { |
254 |
|
if (errno == EACCES) { |
255 |
|
printf("Unable to access bootloader configuration file " |
256 |
|
"\"%s\": %m\n", configFiles[i]); |
257 |
|
exit(1); |
258 |
|
} |
259 |
|
continue; |
260 |
|
} else { |
261 |
dbgPrintf("found\n"); |
dbgPrintf("found\n"); |
262 |
return configFiles[i]; |
return configFiles[i]; |
263 |
} |
} |
276 |
return configFiles[i]; |
return configFiles[i]; |
277 |
} |
} |
278 |
|
|
279 |
|
/* kind of hacky. It'll give the first 1024 bytes, ish. */ |
280 |
|
static char *grub2GetEnv(struct configFileInfo *info, char *name) |
281 |
|
{ |
282 |
|
static char buf[1025]; |
283 |
|
char *s = NULL; |
284 |
|
char *ret = NULL; |
285 |
|
char *envFile = info->envFile ? info->envFile : "/boot/grub/grubenv"; |
286 |
|
int rc = asprintf(&s, "grub-editenv %s list | grep '^%s='", envFile, name); |
287 |
|
|
288 |
|
if (rc < 0) |
289 |
|
return NULL; |
290 |
|
|
291 |
|
FILE *f = popen(s, "r"); |
292 |
|
if (!f) |
293 |
|
goto out; |
294 |
|
|
295 |
|
memset(buf, '\0', sizeof (buf)); |
296 |
|
ret = fgets(buf, 1024, f); |
297 |
|
pclose(f); |
298 |
|
|
299 |
|
if (ret) { |
300 |
|
ret += strlen(name) + 1; |
301 |
|
ret[strlen(ret) - 1] = '\0'; |
302 |
|
} |
303 |
|
dbgPrintf("grub2GetEnv(%s): %s\n", name, ret); |
304 |
|
out: |
305 |
|
free(s); |
306 |
|
return ret; |
307 |
|
} |
308 |
|
|
309 |
|
static int sPopCount(const char *s, const char *c) |
310 |
|
{ |
311 |
|
int ret = 0; |
312 |
|
if (!s) |
313 |
|
return -1; |
314 |
|
for (int i = 0; s[i] != '\0'; i++) |
315 |
|
for (int j = 0; c[j] != '\0'; j++) |
316 |
|
if (s[i] == c[j]) |
317 |
|
ret++; |
318 |
|
return ret; |
319 |
|
} |
320 |
|
|
321 |
|
static char *shellEscape(const char *s) |
322 |
|
{ |
323 |
|
int l = strlen(s) + sPopCount(s, "'") * 2; |
324 |
|
|
325 |
|
char *ret = calloc(l+1, sizeof (*ret)); |
326 |
|
if (!ret) |
327 |
|
return NULL; |
328 |
|
for (int i = 0, j = 0; s[i] != '\0'; i++, j++) { |
329 |
|
if (s[i] == '\'') |
330 |
|
ret[j++] = '\\'; |
331 |
|
ret[j] = s[i]; |
332 |
|
} |
333 |
|
return ret; |
334 |
|
} |
335 |
|
|
336 |
|
static void unquote(char *s) |
337 |
|
{ |
338 |
|
int l = strlen(s); |
339 |
|
|
340 |
|
if ((s[l-1] == '\'' && s[0] == '\'') || (s[l-1] == '"' && s[0] == '"')) { |
341 |
|
memmove(s, s+1, l-2); |
342 |
|
s[l-2] = '\0'; |
343 |
|
} |
344 |
|
} |
345 |
|
|
346 |
|
static int grub2SetEnv(struct configFileInfo *info, char *name, char *value) |
347 |
|
{ |
348 |
|
char *s = NULL; |
349 |
|
int rc = 0; |
350 |
|
char *envFile = info->envFile ? info->envFile : "/boot/grub/grubenv"; |
351 |
|
|
352 |
|
unquote(value); |
353 |
|
value = shellEscape(value); |
354 |
|
if (!value) |
355 |
|
return -1; |
356 |
|
|
357 |
|
rc = asprintf(&s, "grub-editenv %s set '%s=%s'", envFile, name, value); |
358 |
|
free(value); |
359 |
|
if (rc <0) |
360 |
|
return -1; |
361 |
|
|
362 |
|
dbgPrintf("grub2SetEnv(%s): %s\n", name, s); |
363 |
|
rc = system(s); |
364 |
|
free(s); |
365 |
|
return rc; |
366 |
|
} |
367 |
|
|
368 |
|
/* this is a gigantic hack to avoid clobbering grub2 variables... */ |
369 |
|
static int is_special_grub2_variable(const char *name) |
370 |
|
{ |
371 |
|
if (!strcmp(name,"\"${next_entry}\"")) |
372 |
|
return 1; |
373 |
|
if (!strcmp(name,"\"${prev_saved_entry}\"")) |
374 |
|
return 1; |
375 |
|
return 0; |
376 |
|
} |
377 |
|
|
378 |
int sizeOfSingleLine(struct singleLine * line) { |
int sizeOfSingleLine(struct singleLine * line) { |
379 |
int count = 0; |
int count = 0; |
380 |
|
|
404 |
return 0; |
return 0; |
405 |
} |
} |
406 |
|
|
407 |
|
static int iskernel(enum lineType_e type) { |
408 |
|
return (type == LT_KERNEL || type == LT_KERNEL_EFI || type == LT_KERNEL_16); |
409 |
|
} |
410 |
|
|
411 |
|
static int isinitrd(enum lineType_e type) { |
412 |
|
return (type == LT_INITRD || type == LT_INITRD_EFI || type == LT_INITRD_16); |
413 |
|
} |
414 |
|
|
415 |
char *grub2ExtractTitle(struct singleLine * line) { |
char *grub2ExtractTitle(struct singleLine * line) { |
416 |
char * current; |
char * current; |
417 |
char * current_indent; |
char * current_indent; |
469 |
|
|
470 |
struct configFileInfo grub2ConfigType = { |
struct configFileInfo grub2ConfigType = { |
471 |
.findConfig = grub2FindConfig, |
.findConfig = grub2FindConfig, |
472 |
|
.getEnv = grub2GetEnv, |
473 |
|
.setEnv = grub2SetEnv, |
474 |
.keywords = grub2Keywords, |
.keywords = grub2Keywords, |
475 |
.defaultIsIndex = 1, |
.defaultIsIndex = 1, |
476 |
.defaultSupportSaved = 1, |
.defaultSupportSaved = 1, |
625 |
struct configFileInfo extlinuxConfigType = { |
struct configFileInfo extlinuxConfigType = { |
626 |
.defaultConfig = "/boot/extlinux/extlinux.conf", |
.defaultConfig = "/boot/extlinux/extlinux.conf", |
627 |
.keywords = extlinuxKeywords, |
.keywords = extlinuxKeywords, |
628 |
|
.caseInsensitive = 1, |
629 |
.entryStart = LT_TITLE, |
.entryStart = LT_TITLE, |
630 |
.needsBootPrefix = 1, |
.needsBootPrefix = 1, |
631 |
.maxTitleLength = 255, |
.maxTitleLength = 255, |
650 |
struct singleEntry * findEntryByPath(struct grubConfig * cfg, |
struct singleEntry * findEntryByPath(struct grubConfig * cfg, |
651 |
const char * path, const char * prefix, |
const char * path, const char * prefix, |
652 |
int * index); |
int * index); |
653 |
|
struct singleEntry * findEntryByTitle(struct grubConfig * cfg, char *title, |
654 |
|
int * index); |
655 |
static int readFile(int fd, char ** bufPtr); |
static int readFile(int fd, char ** bufPtr); |
656 |
static void lineInit(struct singleLine * line); |
static void lineInit(struct singleLine * line); |
657 |
struct singleLine * lineDup(struct singleLine * line); |
struct singleLine * lineDup(struct singleLine * line); |
716 |
return buf; |
return buf; |
717 |
} |
} |
718 |
|
|
719 |
|
static enum lineType_e preferredLineType(enum lineType_e type, |
720 |
|
struct configFileInfo *cfi) { |
721 |
|
if (isEfi && cfi == &grub2ConfigType) { |
722 |
|
switch (type) { |
723 |
|
case LT_KERNEL: |
724 |
|
return LT_KERNEL_EFI; |
725 |
|
case LT_INITRD: |
726 |
|
return LT_INITRD_EFI; |
727 |
|
default: |
728 |
|
return type; |
729 |
|
} |
730 |
|
#if defined(__i386__) || defined(__x86_64__) |
731 |
|
} else if (cfi == &grub2ConfigType) { |
732 |
|
switch (type) { |
733 |
|
case LT_KERNEL: |
734 |
|
return LT_KERNEL_16; |
735 |
|
case LT_INITRD: |
736 |
|
return LT_INITRD_16; |
737 |
|
default: |
738 |
|
return type; |
739 |
|
} |
740 |
|
#endif |
741 |
|
} |
742 |
|
return type; |
743 |
|
} |
744 |
|
|
745 |
static struct keywordTypes * getKeywordByType(enum lineType_e type, |
static struct keywordTypes * getKeywordByType(enum lineType_e type, |
746 |
struct configFileInfo * cfi) { |
struct configFileInfo * cfi) { |
747 |
for (struct keywordTypes *kw = cfi->keywords; kw->key; kw++) { |
for (struct keywordTypes *kw = cfi->keywords; kw->key; kw++) { |
775 |
static enum lineType_e getTypeByKeyword(char * keyword, |
static enum lineType_e getTypeByKeyword(char * keyword, |
776 |
struct configFileInfo * cfi) { |
struct configFileInfo * cfi) { |
777 |
for (struct keywordTypes *kw = cfi->keywords; kw->key; kw++) { |
for (struct keywordTypes *kw = cfi->keywords; kw->key; kw++) { |
778 |
if (!strcmp(keyword, kw->key)) |
if (cfi->caseInsensitive) { |
779 |
return kw->type; |
if (!strcasecmp(keyword, kw->key)) |
780 |
|
return kw->type; |
781 |
|
} else { |
782 |
|
if (!strcmp(keyword, kw->key)) |
783 |
|
return kw->type; |
784 |
|
} |
785 |
} |
} |
786 |
return LT_UNKNOWN; |
return LT_UNKNOWN; |
787 |
} |
} |
820 |
/* extract the title from within brackets (for zipl) */ |
/* extract the title from within brackets (for zipl) */ |
821 |
static char * extractTitle(struct singleLine * line) { |
static char * extractTitle(struct singleLine * line) { |
822 |
/* bracketed title... let's extract it (leaks a byte) */ |
/* bracketed title... let's extract it (leaks a byte) */ |
823 |
char * title; |
char * title = NULL; |
824 |
title = strdup(line->elements[0].item); |
if (line->type == LT_TITLE) { |
825 |
title++; |
title = strdup(line->elements[0].item); |
826 |
*(title + strlen(title) - 1) = '\0'; |
title++; |
827 |
|
*(title + strlen(title) - 1) = '\0'; |
828 |
|
} else if (line->type == LT_MENUENTRY) |
829 |
|
title = strdup(line->elements[1].item); |
830 |
|
else |
831 |
|
return NULL; |
832 |
return title; |
return title; |
833 |
} |
} |
834 |
|
|
1086 |
return 0; |
return 0; |
1087 |
} |
} |
1088 |
|
|
1089 |
|
static int isnumber(const char *s) |
1090 |
|
{ |
1091 |
|
int i; |
1092 |
|
for (i = 0; s[i] != '\0'; i++) |
1093 |
|
if (s[i] < '0' || s[i] > '9') |
1094 |
|
return 0; |
1095 |
|
return i; |
1096 |
|
} |
1097 |
|
|
1098 |
static struct grubConfig * readConfig(const char * inName, |
static struct grubConfig * readConfig(const char * inName, |
1099 |
struct configFileInfo * cfi) { |
struct configFileInfo * cfi) { |
1100 |
int in; |
int in; |
1109 |
int len; |
int len; |
1110 |
char * buf; |
char * buf; |
1111 |
|
|
1112 |
if (!strcmp(inName, "-")) { |
if (inName == NULL) { |
1113 |
|
printf("Could not find bootloader configuration\n"); |
1114 |
|
exit(1); |
1115 |
|
} else if (!strcmp(inName, "-")) { |
1116 |
in = 0; |
in = 0; |
1117 |
} else { |
} else { |
1118 |
if ((in = open(inName, O_RDONLY)) < 0) { |
if ((in = open(inName, O_RDONLY)) < 0) { |
1179 |
dbgPrintf("\n"); |
dbgPrintf("\n"); |
1180 |
struct keywordTypes *kwType = getKeywordByType(LT_DEFAULT, cfi); |
struct keywordTypes *kwType = getKeywordByType(LT_DEFAULT, cfi); |
1181 |
if (kwType && line->numElements == 3 && |
if (kwType && line->numElements == 3 && |
1182 |
!strcmp(line->elements[1].item, kwType->key)) { |
!strcmp(line->elements[1].item, kwType->key) && |
1183 |
|
!is_special_grub2_variable(line->elements[2].item)) { |
1184 |
dbgPrintf("Line sets default config\n"); |
dbgPrintf("Line sets default config\n"); |
1185 |
cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT; |
cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT; |
1186 |
defaultLine = line; |
defaultLine = line; |
1189 |
cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT; |
cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT; |
1190 |
defaultLine = line; |
defaultLine = line; |
1191 |
|
|
1192 |
} else if (line->type == LT_KERNEL) { |
} else if (iskernel(line->type)) { |
1193 |
/* if by some freak chance this is multiboot and the "module" |
/* if by some freak chance this is multiboot and the "module" |
1194 |
* lines came earlier in the template, make sure to use LT_HYPER |
* lines came earlier in the template, make sure to use LT_HYPER |
1195 |
* instead of LT_KERNEL now |
* instead of LT_KERNEL now |
1206 |
for (struct singleLine *l = entry->lines; l; l = l->next) { |
for (struct singleLine *l = entry->lines; l; l = l->next) { |
1207 |
if (l->type == LT_HYPER) |
if (l->type == LT_HYPER) |
1208 |
break; |
break; |
1209 |
else if (l->type == LT_KERNEL) { |
else if (iskernel(l->type)) { |
1210 |
l->type = LT_HYPER; |
l->type = LT_HYPER; |
1211 |
break; |
break; |
1212 |
} |
} |
1385 |
if (defaultLine->numElements > 2 && |
if (defaultLine->numElements > 2 && |
1386 |
cfi->defaultSupportSaved && |
cfi->defaultSupportSaved && |
1387 |
!strncmp(defaultLine->elements[2].item,"\"${saved_entry}\"", 16)) { |
!strncmp(defaultLine->elements[2].item,"\"${saved_entry}\"", 16)) { |
1388 |
cfg->defaultImage = DEFAULT_SAVED_GRUB2; |
cfg->cfi->defaultIsSaved = 1; |
1389 |
|
cfg->defaultImage = DEFAULT_SAVED_GRUB2; |
1390 |
|
if (cfg->cfi->getEnv) { |
1391 |
|
char *defTitle = cfi->getEnv(cfg->cfi, "saved_entry"); |
1392 |
|
if (defTitle) { |
1393 |
|
int index = 0; |
1394 |
|
if (isnumber(defTitle)) { |
1395 |
|
index = atoi(defTitle); |
1396 |
|
entry = findEntryByIndex(cfg, index); |
1397 |
|
} else { |
1398 |
|
entry = findEntryByTitle(cfg, defTitle, &index); |
1399 |
|
} |
1400 |
|
if (entry) |
1401 |
|
cfg->defaultImage = index; |
1402 |
|
} |
1403 |
|
} |
1404 |
} else if (cfi->defaultIsVariable) { |
} else if (cfi->defaultIsVariable) { |
1405 |
char *value = defaultLine->elements[2].item; |
char *value = defaultLine->elements[2].item; |
1406 |
while (*value && (*value == '"' || *value == '\'' || |
while (*value && (*value == '"' || *value == '\'' || |
1441 |
cfg->defaultImage = -1; |
cfg->defaultImage = -1; |
1442 |
} |
} |
1443 |
} |
} |
1444 |
|
} else if (cfg->cfi->defaultIsSaved && cfg->cfi->getEnv) { |
1445 |
|
char *defTitle = cfi->getEnv(cfg->cfi, "saved_entry"); |
1446 |
|
if (defTitle) { |
1447 |
|
int index = 0; |
1448 |
|
if (isnumber(defTitle)) { |
1449 |
|
index = atoi(defTitle); |
1450 |
|
entry = findEntryByIndex(cfg, index); |
1451 |
|
} else { |
1452 |
|
entry = findEntryByTitle(cfg, defTitle, &index); |
1453 |
|
} |
1454 |
|
if (entry) |
1455 |
|
cfg->defaultImage = index; |
1456 |
|
} |
1457 |
} else { |
} else { |
1458 |
cfg->defaultImage = 0; |
cfg->defaultImage = 0; |
1459 |
} |
} |
1471 |
|
|
1472 |
if (cfg->defaultImage == DEFAULT_SAVED) |
if (cfg->defaultImage == DEFAULT_SAVED) |
1473 |
fprintf(out, "%sdefault%ssaved\n", indent, separator); |
fprintf(out, "%sdefault%ssaved\n", indent, separator); |
1474 |
else if (cfg->defaultImage == DEFAULT_SAVED_GRUB2) |
else if (cfg->cfi->defaultIsSaved) { |
1475 |
fprintf(out, "%sset default=\"${saved_entry}\"\n", indent); |
fprintf(out, "%sset default=\"${saved_entry}\"\n", indent); |
1476 |
else if (cfg->defaultImage > -1) { |
if (cfg->defaultImage >= 0 && cfg->cfi->setEnv) { |
1477 |
|
char *title; |
1478 |
|
entry = findEntryByIndex(cfg, cfg->defaultImage); |
1479 |
|
line = getLineByType(LT_MENUENTRY, entry->lines); |
1480 |
|
if (!line) |
1481 |
|
line = getLineByType(LT_TITLE, entry->lines); |
1482 |
|
if (line) { |
1483 |
|
title = extractTitle(line); |
1484 |
|
if (title) |
1485 |
|
cfg->cfi->setEnv(cfg->cfi, "saved_entry", title); |
1486 |
|
} |
1487 |
|
} |
1488 |
|
} else if (cfg->defaultImage > -1) { |
1489 |
if (cfg->cfi->defaultIsIndex) { |
if (cfg->cfi->defaultIsIndex) { |
1490 |
if (cfg->cfi->defaultIsVariable) { |
if (cfg->cfi->defaultIsVariable) { |
1491 |
fprintf(out, "%sset default=\"%d\"\n", indent, |
fprintf(out, "%sset default=\"%d\"\n", indent, |
1546 |
/* most likely the symlink is relative, so change our |
/* most likely the symlink is relative, so change our |
1547 |
directory to the dir of the symlink */ |
directory to the dir of the symlink */ |
1548 |
char *dir = strdupa(outName); |
char *dir = strdupa(outName); |
1549 |
rc = chdir(dirname(dir)); |
rc = chdir(dirname(dir)); |
|
free(dir); |
|
1550 |
do { |
do { |
1551 |
buf = alloca(len + 1); |
buf = alloca(len + 1); |
1552 |
rc = readlink(basename(outName), buf, len); |
rc = readlink(basename(outName), buf, len); |
1588 |
while (line) { |
while (line) { |
1589 |
if (line->type == LT_SET_VARIABLE && defaultKw && |
if (line->type == LT_SET_VARIABLE && defaultKw && |
1590 |
line->numElements == 3 && |
line->numElements == 3 && |
1591 |
!strcmp(line->elements[1].item, defaultKw->key)) { |
!strcmp(line->elements[1].item, defaultKw->key) && |
1592 |
|
!is_special_grub2_variable(line->elements[2].item)) { |
1593 |
writeDefault(out, line->indent, line->elements[0].indent, cfg); |
writeDefault(out, line->indent, line->elements[0].indent, cfg); |
1594 |
needs &= ~MAIN_DEFAULT; |
needs &= ~MAIN_DEFAULT; |
1595 |
} else if (line->type == LT_DEFAULT) { |
} else if (line->type == LT_DEFAULT) { |
1734 |
return NULL; |
return NULL; |
1735 |
} |
} |
1736 |
|
|
1737 |
void printEntry(struct singleEntry * entry) { |
void printEntry(struct singleEntry * entry, FILE *f) { |
1738 |
int i; |
int i; |
1739 |
struct singleLine * line; |
struct singleLine * line; |
1740 |
|
|
1741 |
for (line = entry->lines; line; line = line->next) { |
for (line = entry->lines; line; line = line->next) { |
1742 |
fprintf(stderr, "DBG: %s", line->indent); |
log_message(f, "DBG: %s", line->indent); |
1743 |
for (i = 0; i < line->numElements; i++) { |
for (i = 0; i < line->numElements; i++) { |
1744 |
/* Need to handle this, because we strip the quotes from |
/* Need to handle this, because we strip the quotes from |
1745 |
* menuentry when read it. */ |
* menuentry when read it. */ |
1746 |
if (line->type == LT_MENUENTRY && i == 1) { |
if (line->type == LT_MENUENTRY && i == 1) { |
1747 |
if(!isquote(*line->elements[i].item)) |
if(!isquote(*line->elements[i].item)) |
1748 |
fprintf(stderr, "\'%s\'", line->elements[i].item); |
log_message(f, "\'%s\'", line->elements[i].item); |
1749 |
else |
else |
1750 |
fprintf(stderr, "%s", line->elements[i].item); |
log_message(f, "%s", line->elements[i].item); |
1751 |
fprintf(stderr, "%s", line->elements[i].indent); |
log_message(f, "%s", line->elements[i].indent); |
1752 |
|
|
1753 |
continue; |
continue; |
1754 |
} |
} |
1755 |
|
|
1756 |
fprintf(stderr, "%s%s", |
log_message(f, "%s%s", |
1757 |
line->elements[i].item, line->elements[i].indent); |
line->elements[i].item, line->elements[i].indent); |
1758 |
} |
} |
1759 |
fprintf(stderr, "\n"); |
log_message(f, "\n"); |
1760 |
} |
} |
1761 |
} |
} |
1762 |
|
|
1763 |
void notSuitablePrintf(struct singleEntry * entry, const char *fmt, ...) |
void notSuitablePrintf(struct singleEntry * entry, int okay, const char *fmt, ...) |
1764 |
{ |
{ |
1765 |
va_list argp; |
static int once; |
1766 |
|
va_list argp, argq; |
1767 |
|
|
1768 |
|
va_start(argp, fmt); |
1769 |
|
|
1770 |
if (!debug) |
va_copy(argq, argp); |
1771 |
|
if (!once) { |
1772 |
|
log_time(NULL); |
1773 |
|
log_message(NULL, "command line: %s\n", saved_command_line); |
1774 |
|
} |
1775 |
|
log_message(NULL, "DBG: Image entry %s: ", okay ? "succeeded" : "failed"); |
1776 |
|
log_vmessage(NULL, fmt, argq); |
1777 |
|
|
1778 |
|
printEntry(entry, NULL); |
1779 |
|
va_end(argq); |
1780 |
|
|
1781 |
|
if (!debug) { |
1782 |
|
once = 1; |
1783 |
|
va_end(argp); |
1784 |
return; |
return; |
1785 |
|
} |
1786 |
|
|
1787 |
va_start(argp, fmt); |
if (okay) { |
1788 |
|
va_end(argp); |
1789 |
|
return; |
1790 |
|
} |
1791 |
|
|
1792 |
|
if (!once) |
1793 |
|
log_message(stderr, "DBG: command line: %s\n", saved_command_line); |
1794 |
|
once = 1; |
1795 |
fprintf(stderr, "DBG: Image entry failed: "); |
fprintf(stderr, "DBG: Image entry failed: "); |
1796 |
vfprintf(stderr, fmt, argp); |
vfprintf(stderr, fmt, argp); |
1797 |
printEntry(entry); |
printEntry(entry, stderr); |
1798 |
va_end(argp); |
va_end(argp); |
1799 |
} |
} |
1800 |
|
|
1821 |
char * rootdev; |
char * rootdev; |
1822 |
|
|
1823 |
if (skipRemoved && entry->skip) { |
if (skipRemoved && entry->skip) { |
1824 |
notSuitablePrintf(entry, "marked to skip\n"); |
notSuitablePrintf(entry, 0, "marked to skip\n"); |
1825 |
return 0; |
return 0; |
1826 |
} |
} |
1827 |
|
|
1828 |
line = getLineByType(LT_KERNEL|LT_HYPER, entry->lines); |
line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); |
1829 |
if (!line) { |
if (!line) { |
1830 |
notSuitablePrintf(entry, "no line found\n"); |
notSuitablePrintf(entry, 0, "no line found\n"); |
1831 |
return 0; |
return 0; |
1832 |
} |
} |
1833 |
if (line->numElements < 2) { |
if (line->numElements < 2) { |
1834 |
notSuitablePrintf(entry, "line has only %d elements\n", |
notSuitablePrintf(entry, 0, "line has only %d elements\n", |
1835 |
line->numElements); |
line->numElements); |
1836 |
return 0; |
return 0; |
1837 |
} |
} |
1838 |
|
|
1839 |
if (flags & GRUBBY_BADIMAGE_OKAY) return 1; |
if (flags & GRUBBY_BADIMAGE_OKAY) { |
1840 |
|
notSuitablePrintf(entry, 1, "\n"); |
1841 |
|
return 1; |
1842 |
|
} |
1843 |
|
|
1844 |
fullName = alloca(strlen(bootPrefix) + |
fullName = alloca(strlen(bootPrefix) + |
1845 |
strlen(line->elements[1].item) + 1); |
strlen(line->elements[1].item) + 1); |
1850 |
sprintf(fullName, "%s%s%s", bootPrefix, hasslash ? "" : "/", |
sprintf(fullName, "%s%s%s", bootPrefix, hasslash ? "" : "/", |
1851 |
line->elements[1].item + rootspec_offset); |
line->elements[1].item + rootspec_offset); |
1852 |
if (access(fullName, R_OK)) { |
if (access(fullName, R_OK)) { |
1853 |
notSuitablePrintf(entry, "access to %s failed\n", fullName); |
notSuitablePrintf(entry, 0, "access to %s failed\n", fullName); |
1854 |
return 0; |
return 0; |
1855 |
} |
} |
1856 |
for (i = 2; i < line->numElements; i++) |
for (i = 2; i < line->numElements; i++) |
1871 |
|
|
1872 |
/* failed to find one */ |
/* failed to find one */ |
1873 |
if (!line) { |
if (!line) { |
1874 |
notSuitablePrintf(entry, "no line found\n"); |
notSuitablePrintf(entry, 0, "no line found\n"); |
1875 |
return 0; |
return 0; |
1876 |
} |
} |
1877 |
|
|
1880 |
if (i < line->numElements) |
if (i < line->numElements) |
1881 |
dev = line->elements[i].item + 5; |
dev = line->elements[i].item + 5; |
1882 |
else { |
else { |
1883 |
notSuitablePrintf(entry, "no root= entry found\n"); |
notSuitablePrintf(entry, 0, "no root= entry found\n"); |
1884 |
/* it failed too... can't find root= */ |
/* it failed too... can't find root= */ |
1885 |
return 0; |
return 0; |
1886 |
} |
} |
1889 |
|
|
1890 |
dev = getpathbyspec(dev); |
dev = getpathbyspec(dev); |
1891 |
if (!getpathbyspec(dev)) { |
if (!getpathbyspec(dev)) { |
1892 |
notSuitablePrintf(entry, "can't find blkid entry for %s\n", dev); |
notSuitablePrintf(entry, 0, "can't find blkid entry for %s\n", dev); |
1893 |
return 0; |
return 0; |
1894 |
} else |
} else |
1895 |
dev = getpathbyspec(dev); |
dev = getpathbyspec(dev); |
1896 |
|
|
1897 |
rootdev = findDiskForRoot(); |
rootdev = findDiskForRoot(); |
1898 |
if (!rootdev) { |
if (!rootdev) { |
1899 |
notSuitablePrintf(entry, "can't find root device\n"); |
notSuitablePrintf(entry, 0, "can't find root device\n"); |
1900 |
return 0; |
return 0; |
1901 |
} |
} |
1902 |
|
|
1903 |
if (!getuuidbydev(rootdev) || !getuuidbydev(dev)) { |
if (!getuuidbydev(rootdev) || !getuuidbydev(dev)) { |
1904 |
notSuitablePrintf(entry, "uuid missing: rootdev %s, dev %s\n", |
notSuitablePrintf(entry, 0, "uuid missing: rootdev %s, dev %s\n", |
1905 |
getuuidbydev(rootdev), getuuidbydev(dev)); |
getuuidbydev(rootdev), getuuidbydev(dev)); |
1906 |
free(rootdev); |
free(rootdev); |
1907 |
return 0; |
return 0; |
1908 |
} |
} |
1909 |
|
|
1910 |
if (strcmp(getuuidbydev(rootdev), getuuidbydev(dev))) { |
if (strcmp(getuuidbydev(rootdev), getuuidbydev(dev))) { |
1911 |
notSuitablePrintf(entry, "uuid mismatch: rootdev %s, dev %s\n", |
notSuitablePrintf(entry, 0, "uuid mismatch: rootdev %s, dev %s\n", |
1912 |
getuuidbydev(rootdev), getuuidbydev(dev)); |
getuuidbydev(rootdev), getuuidbydev(dev)); |
1913 |
free(rootdev); |
free(rootdev); |
1914 |
return 0; |
return 0; |
1915 |
} |
} |
1916 |
|
|
1917 |
free(rootdev); |
free(rootdev); |
1918 |
|
notSuitablePrintf(entry, 1, "\n"); |
1919 |
|
|
1920 |
return 1; |
return 1; |
1921 |
} |
} |
1959 |
entry = findEntryByIndex(config, indexVars[i]); |
entry = findEntryByIndex(config, indexVars[i]); |
1960 |
if (!entry) return NULL; |
if (!entry) return NULL; |
1961 |
|
|
1962 |
line = getLineByType(LT_KERNEL|LT_HYPER, entry->lines); |
line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); |
1963 |
if (!line) return NULL; |
if (!line) return NULL; |
1964 |
|
|
1965 |
if (index) *index = indexVars[i]; |
if (index) *index = indexVars[i]; |
2008 |
|
|
2009 |
/* check all the lines matching checkType */ |
/* check all the lines matching checkType */ |
2010 |
for (line = entry->lines; line; line = line->next) { |
for (line = entry->lines; line; line = line->next) { |
2011 |
line = getLineByType(entry->multiboot && checkType == LT_KERNEL ? |
enum lineType_e ct = checkType; |
2012 |
LT_KERNEL|LT_MBMODULE|LT_HYPER : |
if (entry->multiboot && checkType == LT_KERNEL) |
2013 |
checkType, line); |
ct = LT_KERNEL|LT_KERNEL_EFI|LT_MBMODULE|LT_HYPER|LT_KERNEL_16; |
2014 |
if (!line) break; /* not found in this entry */ |
else if (checkType & LT_KERNEL) |
2015 |
|
ct = checkType | LT_KERNEL_EFI | LT_KERNEL_16; |
2016 |
|
line = getLineByType(ct, line); |
2017 |
|
if (!line) |
2018 |
|
break; /* not found in this entry */ |
2019 |
|
|
2020 |
if (line && line->type != LT_MENUENTRY && |
if (line && line->type != LT_MENUENTRY && |
2021 |
line->numElements >= 2) { |
line->numElements >= 2) { |
2034 |
* non-Linux boot entries (could find netbsd etc, though, which is |
* non-Linux boot entries (could find netbsd etc, though, which is |
2035 |
* unfortunate) |
* unfortunate) |
2036 |
*/ |
*/ |
2037 |
if (line && getLineByType(LT_KERNEL|LT_HYPER, entry->lines)) |
if (line && getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines)) |
2038 |
break; /* found 'im! */ |
break; /* found 'im! */ |
2039 |
} |
} |
2040 |
|
|
2044 |
return entry; |
return entry; |
2045 |
} |
} |
2046 |
|
|
2047 |
|
struct singleEntry * findEntryByTitle(struct grubConfig * cfg, char *title, |
2048 |
|
int * index) { |
2049 |
|
struct singleEntry * entry; |
2050 |
|
struct singleLine * line; |
2051 |
|
int i; |
2052 |
|
char * newtitle; |
2053 |
|
|
2054 |
|
for (i = 0, entry = cfg->entries; entry; entry = entry->next, i++) { |
2055 |
|
if (index && i < *index) |
2056 |
|
continue; |
2057 |
|
line = getLineByType(LT_TITLE, entry->lines); |
2058 |
|
if (!line) |
2059 |
|
line = getLineByType(LT_MENUENTRY, entry->lines); |
2060 |
|
if (!line) |
2061 |
|
continue; |
2062 |
|
newtitle = grub2ExtractTitle(line); |
2063 |
|
if (!newtitle) |
2064 |
|
continue; |
2065 |
|
if (!strcmp(title, newtitle)) |
2066 |
|
break; |
2067 |
|
} |
2068 |
|
|
2069 |
|
if (!entry) |
2070 |
|
return NULL; |
2071 |
|
|
2072 |
|
if (index) |
2073 |
|
*index = i; |
2074 |
|
return entry; |
2075 |
|
} |
2076 |
|
|
2077 |
struct singleEntry * findEntryByIndex(struct grubConfig * cfg, int index) { |
struct singleEntry * findEntryByIndex(struct grubConfig * cfg, int index) { |
2078 |
struct singleEntry * entry; |
struct singleEntry * entry; |
2079 |
|
|
2096 |
struct singleEntry * entry, * entry2; |
struct singleEntry * entry, * entry2; |
2097 |
int index; |
int index; |
2098 |
|
|
2099 |
if (cfg->defaultImage > -1) { |
if (cfg->cfi->defaultIsSaved) { |
2100 |
|
if (cfg->cfi->getEnv) { |
2101 |
|
char *defTitle = cfg->cfi->getEnv(cfg->cfi, "saved_entry"); |
2102 |
|
if (defTitle) { |
2103 |
|
int index = 0; |
2104 |
|
if (isnumber(defTitle)) { |
2105 |
|
index = atoi(defTitle); |
2106 |
|
entry = findEntryByIndex(cfg, index); |
2107 |
|
} else { |
2108 |
|
entry = findEntryByTitle(cfg, defTitle, &index); |
2109 |
|
} |
2110 |
|
if (entry) |
2111 |
|
cfg->defaultImage = index; |
2112 |
|
} |
2113 |
|
} |
2114 |
|
} else if (cfg->defaultImage > -1) { |
2115 |
entry = findEntryByIndex(cfg, cfg->defaultImage); |
entry = findEntryByIndex(cfg, cfg->defaultImage); |
2116 |
if (entry && suitableImage(entry, prefix, skipRemoved, flags)) { |
if (entry && suitableImage(entry, prefix, skipRemoved, flags)) { |
2117 |
if (indexPtr) *indexPtr = cfg->defaultImage; |
if (indexPtr) *indexPtr = cfg->defaultImage; |
2268 |
|
|
2269 |
printf("index=%d\n", index); |
printf("index=%d\n", index); |
2270 |
|
|
2271 |
line = getLineByType(LT_KERNEL|LT_HYPER, entry->lines); |
line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); |
2272 |
if (!line) { |
if (!line) { |
2273 |
printf("non linux entry\n"); |
printf("non linux entry\n"); |
2274 |
return; |
return; |
2333 |
printf("root=%s\n", s); |
printf("root=%s\n", s); |
2334 |
} |
} |
2335 |
|
|
2336 |
line = getLineByType(LT_INITRD, entry->lines); |
line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines); |
2337 |
|
|
2338 |
if (line && line->numElements >= 2) { |
if (line && line->numElements >= 2) { |
2339 |
if (!strncmp(prefix, line->elements[1].item, strlen(prefix))) |
if (!strncmp(prefix, line->elements[1].item, strlen(prefix))) |
2734 |
{ |
{ |
2735 |
struct singleLine * newLine = lineDup(tmplLine); |
struct singleLine * newLine = lineDup(tmplLine); |
2736 |
|
|
2737 |
|
if (isEfi && cfi == &grub2ConfigType) { |
2738 |
|
enum lineType_e old = newLine->type; |
2739 |
|
newLine->type = preferredLineType(newLine->type, cfi); |
2740 |
|
if (old != newLine->type) |
2741 |
|
newLine->elements[0].item = getKeyByType(newLine->type, cfi); |
2742 |
|
} |
2743 |
|
|
2744 |
if (val) { |
if (val) { |
2745 |
/* override the inherited value with our own. |
/* override the inherited value with our own. |
2746 |
* This is a little weak because it only applies to elements[1] |
* This is a little weak because it only applies to elements[1] |
2750 |
insertElement(newLine, val, 1, cfi); |
insertElement(newLine, val, 1, cfi); |
2751 |
|
|
2752 |
/* but try to keep the rootspec from the template... sigh */ |
/* but try to keep the rootspec from the template... sigh */ |
2753 |
if (tmplLine->type & (LT_HYPER|LT_KERNEL|LT_MBMODULE|LT_INITRD)) { |
if (tmplLine->type & (LT_HYPER|LT_KERNEL|LT_MBMODULE|LT_INITRD|LT_KERNEL_EFI|LT_INITRD_EFI|LT_KERNEL_16|LT_INITRD_16)) { |
2754 |
char * rootspec = getRootSpecifier(tmplLine->elements[1].item); |
char * rootspec = getRootSpecifier(tmplLine->elements[1].item); |
2755 |
if (rootspec != NULL) { |
if (rootspec != NULL) { |
2756 |
free(newLine->elements[1].item); |
free(newLine->elements[1].item); |
2787 |
/* NB: This function shouldn't allocate items on the heap, rather on the |
/* NB: This function shouldn't allocate items on the heap, rather on the |
2788 |
* stack since it calls addLineTmpl which will make copies. |
* stack since it calls addLineTmpl which will make copies. |
2789 |
*/ |
*/ |
|
|
|
2790 |
if (type == LT_TITLE && cfi->titleBracketed) { |
if (type == LT_TITLE && cfi->titleBracketed) { |
2791 |
/* we're doing a bracketed title (zipl) */ |
/* we're doing a bracketed title (zipl) */ |
2792 |
tmpl.type = type; |
tmpl.type = type; |
3120 |
firstElement = 2; |
firstElement = 2; |
3121 |
|
|
3122 |
} else { |
} else { |
3123 |
line = getLineByType(LT_KERNEL|LT_MBMODULE, entry->lines); |
line = getLineByType(LT_KERNEL|LT_MBMODULE|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); |
3124 |
if (!line) { |
if (!line) { |
3125 |
/* no LT_KERNEL or LT_MBMODULE in this entry? */ |
/* no LT_KERNEL or LT_MBMODULE in this entry? */ |
3126 |
continue; |
continue; |
3276 |
return rc; |
return rc; |
3277 |
} |
} |
3278 |
|
|
3279 |
|
int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel, |
3280 |
|
const char * image, const char * prefix, const char * initrd) { |
3281 |
|
struct singleEntry * entry; |
3282 |
|
struct singleLine * line, * kernelLine, *endLine = NULL; |
3283 |
|
int index = 0; |
3284 |
|
|
3285 |
|
if (!image) return 0; |
3286 |
|
|
3287 |
|
for (; (entry = findEntryByPath(cfg, newMBKernel, prefix, &index)); index++) { |
3288 |
|
kernelLine = getLineByType(LT_MBMODULE, entry->lines); |
3289 |
|
if (!kernelLine) continue; |
3290 |
|
|
3291 |
|
if (prefix) { |
3292 |
|
int prefixLen = strlen(prefix); |
3293 |
|
if (!strncmp(initrd, prefix, prefixLen)) |
3294 |
|
initrd += prefixLen; |
3295 |
|
} |
3296 |
|
endLine = getLineByType(LT_ENTRY_END, entry->lines); |
3297 |
|
if (endLine) |
3298 |
|
removeLine(entry, endLine); |
3299 |
|
line = addLine(entry, cfg->cfi, preferredLineType(LT_MBMODULE,cfg->cfi), |
3300 |
|
kernelLine->indent, initrd); |
3301 |
|
if (!line) |
3302 |
|
return 1; |
3303 |
|
if (endLine) { |
3304 |
|
line = addLine(entry, cfg->cfi, LT_ENTRY_END, "", NULL); |
3305 |
|
if (!line) |
3306 |
|
return 1; |
3307 |
|
} |
3308 |
|
|
3309 |
|
break; |
3310 |
|
} |
3311 |
|
|
3312 |
|
return 0; |
3313 |
|
} |
3314 |
|
|
3315 |
int updateInitrd(struct grubConfig * cfg, const char * image, |
int updateInitrd(struct grubConfig * cfg, const char * image, |
3316 |
const char * prefix, const char * initrd) { |
const char * prefix, const char * initrd) { |
3317 |
struct singleEntry * entry; |
struct singleEntry * entry; |
3321 |
if (!image) return 0; |
if (!image) return 0; |
3322 |
|
|
3323 |
for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) { |
for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) { |
3324 |
kernelLine = getLineByType(LT_KERNEL, entry->lines); |
kernelLine = getLineByType(LT_KERNEL|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); |
3325 |
if (!kernelLine) continue; |
if (!kernelLine) continue; |
3326 |
|
|
3327 |
line = getLineByType(LT_INITRD, entry->lines); |
line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines); |
3328 |
if (line) |
if (line) |
3329 |
removeLine(entry, line); |
removeLine(entry, line); |
3330 |
if (prefix) { |
if (prefix) { |
3335 |
endLine = getLineByType(LT_ENTRY_END, entry->lines); |
endLine = getLineByType(LT_ENTRY_END, entry->lines); |
3336 |
if (endLine) |
if (endLine) |
3337 |
removeLine(entry, endLine); |
removeLine(entry, endLine); |
3338 |
line = addLine(entry, cfg->cfi, LT_INITRD, kernelLine->indent, initrd); |
enum lineType_e lt; |
3339 |
|
switch(kernelLine->type) { |
3340 |
|
case LT_KERNEL: |
3341 |
|
lt = LT_INITRD; |
3342 |
|
break; |
3343 |
|
case LT_KERNEL_EFI: |
3344 |
|
lt = LT_INITRD_EFI; |
3345 |
|
break; |
3346 |
|
case LT_KERNEL_16: |
3347 |
|
lt = LT_INITRD_16; |
3348 |
|
break; |
3349 |
|
default: |
3350 |
|
lt = preferredLineType(LT_INITRD, cfg->cfi); |
3351 |
|
} |
3352 |
|
line = addLine(entry, cfg->cfi, lt, kernelLine->indent, initrd); |
3353 |
if (!line) |
if (!line) |
3354 |
return 1; |
return 1; |
3355 |
if (endLine) { |
if (endLine) { |
3708 |
const char * newKernelPath, const char * newKernelTitle, |
const char * newKernelPath, const char * newKernelTitle, |
3709 |
const char * newKernelArgs, const char * newKernelInitrd, |
const char * newKernelArgs, const char * newKernelInitrd, |
3710 |
const char ** extraInitrds, int extraInitrdCount, |
const char ** extraInitrds, int extraInitrdCount, |
3711 |
const char * newMBKernel, const char * newMBKernelArgs) { |
const char * newMBKernel, const char * newMBKernelArgs, |
3712 |
|
const char * newDevTreePath) { |
3713 |
struct singleEntry * new; |
struct singleEntry * new; |
3714 |
struct singleLine * newLine = NULL, * tmplLine = NULL, * masterLine = NULL; |
struct singleLine * newLine = NULL, * tmplLine = NULL, * masterLine = NULL; |
3715 |
int needs; |
int needs; |
3750 |
needs |= NEED_MB; |
needs |= NEED_MB; |
3751 |
new->multiboot = 1; |
new->multiboot = 1; |
3752 |
} |
} |
3753 |
|
if (newDevTreePath && getKeywordByType(LT_DEVTREE, config->cfi)) |
3754 |
|
needs |= NEED_DEVTREE; |
3755 |
|
|
3756 |
if (template) { |
if (template) { |
3757 |
for (masterLine = template->lines; |
for (masterLine = template->lines; |
3765 |
while (*chptr && isspace(*chptr)) chptr++; |
while (*chptr && isspace(*chptr)) chptr++; |
3766 |
if (*chptr == '#') continue; |
if (*chptr == '#') continue; |
3767 |
|
|
3768 |
if (tmplLine->type == LT_KERNEL && |
if (iskernel(tmplLine->type) && tmplLine->numElements >= 2) { |
|
tmplLine->numElements >= 2) { |
|
3769 |
if (!template->multiboot && (needs & NEED_MB)) { |
if (!template->multiboot && (needs & NEED_MB)) { |
3770 |
/* it's not a multiboot template and this is the kernel |
/* it's not a multiboot template and this is the kernel |
3771 |
* line. Try to be intelligent about inserting the |
* line. Try to be intelligent about inserting the |
3842 |
/* template is multi but new is not, |
/* template is multi but new is not, |
3843 |
* insert the kernel in the first module slot |
* insert the kernel in the first module slot |
3844 |
*/ |
*/ |
3845 |
tmplLine->type = LT_KERNEL; |
tmplLine->type = preferredLineType(LT_KERNEL, config->cfi); |
3846 |
free(tmplLine->elements[0].item); |
free(tmplLine->elements[0].item); |
3847 |
tmplLine->elements[0].item = |
tmplLine->elements[0].item = |
3848 |
strdup(getKeywordByType(LT_KERNEL, config->cfi)->key); |
strdup(getKeywordByType(tmplLine->type, |
3849 |
|
config->cfi)->key); |
3850 |
newLine = addLineTmpl(new, tmplLine, newLine, |
newLine = addLineTmpl(new, tmplLine, newLine, |
3851 |
newKernelPath + strlen(prefix), config->cfi); |
newKernelPath + strlen(prefix), |
3852 |
|
config->cfi); |
3853 |
needs &= ~NEED_KERNEL; |
needs &= ~NEED_KERNEL; |
3854 |
} else if (needs & NEED_INITRD) { |
} else if (needs & NEED_INITRD) { |
3855 |
char *initrdVal; |
char *initrdVal; |
3856 |
/* template is multi but new is not, |
/* template is multi but new is not, |
3857 |
* insert the initrd in the second module slot |
* insert the initrd in the second module slot |
3858 |
*/ |
*/ |
3859 |
tmplLine->type = LT_INITRD; |
tmplLine->type = preferredLineType(LT_INITRD, config->cfi); |
3860 |
free(tmplLine->elements[0].item); |
free(tmplLine->elements[0].item); |
3861 |
tmplLine->elements[0].item = |
tmplLine->elements[0].item = |
3862 |
strdup(getKeywordByType(LT_INITRD, config->cfi)->key); |
strdup(getKeywordByType(tmplLine->type, |
3863 |
|
config->cfi)->key); |
3864 |
initrdVal = getInitrdVal(config, prefix, tmplLine, newKernelInitrd, extraInitrds, extraInitrdCount); |
initrdVal = getInitrdVal(config, prefix, tmplLine, newKernelInitrd, extraInitrds, extraInitrdCount); |
3865 |
newLine = addLineTmpl(new, tmplLine, newLine, initrdVal, config->cfi); |
newLine = addLineTmpl(new, tmplLine, newLine, initrdVal, config->cfi); |
3866 |
free(initrdVal); |
free(initrdVal); |
3867 |
needs &= ~NEED_INITRD; |
needs &= ~NEED_INITRD; |
3868 |
} |
} |
3869 |
|
|
3870 |
} else if (tmplLine->type == LT_INITRD && |
} else if (isinitrd(tmplLine->type) && tmplLine->numElements >= 2) { |
|
tmplLine->numElements >= 2) { |
|
3871 |
if (needs & NEED_INITRD && |
if (needs & NEED_INITRD && |
3872 |
new->multiboot && !template->multiboot && |
new->multiboot && !template->multiboot && |
3873 |
config->cfi->mbInitRdIsModule) { |
config->cfi->mbInitRdIsModule) { |
3921 |
static const char *prefix = "'Loading "; |
static const char *prefix = "'Loading "; |
3922 |
if (tmplLine->numElements > 1 && |
if (tmplLine->numElements > 1 && |
3923 |
strstr(tmplLine->elements[1].item, prefix) && |
strstr(tmplLine->elements[1].item, prefix) && |
3924 |
masterLine->next && masterLine->next->type == LT_KERNEL) { |
masterLine->next && |
3925 |
|
iskernel(masterLine->next->type)) { |
3926 |
char *newTitle = malloc(strlen(prefix) + |
char *newTitle = malloc(strlen(prefix) + |
3927 |
strlen(newKernelTitle) + 2); |
strlen(newKernelTitle) + 2); |
3928 |
|
|
3937 |
newLine = addLineTmpl(new, tmplLine, newLine, NULL, |
newLine = addLineTmpl(new, tmplLine, newLine, NULL, |
3938 |
config->cfi); |
config->cfi); |
3939 |
} |
} |
3940 |
|
} else if (tmplLine->type == LT_DEVTREE && |
3941 |
|
tmplLine->numElements == 2 && newDevTreePath) { |
3942 |
|
newLine = addLineTmpl(new, tmplLine, newLine, |
3943 |
|
newDevTreePath + strlen(prefix), |
3944 |
|
config->cfi); |
3945 |
|
needs &= ~NEED_DEVTREE; |
3946 |
|
} else if (tmplLine->type == LT_ENTRY_END && needs & NEED_DEVTREE) { |
3947 |
|
const char *ndtp = newDevTreePath; |
3948 |
|
if (!strncmp(newDevTreePath, prefix, strlen(prefix))) |
3949 |
|
ndtp += strlen(prefix); |
3950 |
|
newLine = addLine(new, config->cfi, LT_DEVTREE, |
3951 |
|
config->secondaryIndent, |
3952 |
|
ndtp); |
3953 |
|
needs &= ~NEED_DEVTREE; |
3954 |
|
newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi); |
3955 |
} else { |
} else { |
3956 |
/* pass through other lines from the template */ |
/* pass through other lines from the template */ |
3957 |
newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi); |
newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi); |
3964 |
*/ |
*/ |
3965 |
switch (config->cfi->entryStart) { |
switch (config->cfi->entryStart) { |
3966 |
case LT_KERNEL: |
case LT_KERNEL: |
3967 |
|
case LT_KERNEL_EFI: |
3968 |
|
case LT_KERNEL_16: |
3969 |
if (new->multiboot && config->cfi->mbHyperFirst) { |
if (new->multiboot && config->cfi->mbHyperFirst) { |
3970 |
/* fall through to LT_HYPER */ |
/* fall through to LT_HYPER */ |
3971 |
} else { |
} else { |
3972 |
newLine = addLine(new, config->cfi, LT_KERNEL, |
newLine = addLine(new, config->cfi, |
3973 |
|
preferredLineType(LT_KERNEL, config->cfi), |
3974 |
config->primaryIndent, |
config->primaryIndent, |
3975 |
newKernelPath + strlen(prefix)); |
newKernelPath + strlen(prefix)); |
3976 |
needs &= ~NEED_KERNEL; |
needs &= ~NEED_KERNEL; |
4046 |
if (needs & NEED_KERNEL) { |
if (needs & NEED_KERNEL) { |
4047 |
newLine = addLine(new, config->cfi, |
newLine = addLine(new, config->cfi, |
4048 |
(new->multiboot && getKeywordByType(LT_MBMODULE, |
(new->multiboot && getKeywordByType(LT_MBMODULE, |
4049 |
config->cfi)) ? |
config->cfi)) |
4050 |
LT_MBMODULE : LT_KERNEL, |
? LT_MBMODULE |
4051 |
|
: preferredLineType(LT_KERNEL, config->cfi), |
4052 |
config->secondaryIndent, |
config->secondaryIndent, |
4053 |
newKernelPath + strlen(prefix)); |
newKernelPath + strlen(prefix)); |
4054 |
needs &= ~NEED_KERNEL; |
needs &= ~NEED_KERNEL; |
4064 |
initrdVal = getInitrdVal(config, prefix, NULL, newKernelInitrd, extraInitrds, extraInitrdCount); |
initrdVal = getInitrdVal(config, prefix, NULL, newKernelInitrd, extraInitrds, extraInitrdCount); |
4065 |
newLine = addLine(new, config->cfi, |
newLine = addLine(new, config->cfi, |
4066 |
(new->multiboot && getKeywordByType(LT_MBMODULE, |
(new->multiboot && getKeywordByType(LT_MBMODULE, |
4067 |
config->cfi)) ? |
config->cfi)) |
4068 |
LT_MBMODULE : LT_INITRD, |
? LT_MBMODULE |
4069 |
|
: preferredLineType(LT_INITRD, config->cfi), |
4070 |
config->secondaryIndent, |
config->secondaryIndent, |
4071 |
initrdVal); |
initrdVal); |
4072 |
free(initrdVal); |
free(initrdVal); |
4073 |
needs &= ~NEED_INITRD; |
needs &= ~NEED_INITRD; |
4074 |
} |
} |
4075 |
|
if (needs & NEED_DEVTREE) { |
4076 |
|
newLine = addLine(new, config->cfi, LT_DEVTREE, |
4077 |
|
config->secondaryIndent, |
4078 |
|
newDevTreePath); |
4079 |
|
needs &= ~NEED_DEVTREE; |
4080 |
|
} |
4081 |
|
|
4082 |
|
/* NEEDS_END must be last on bootloaders that need it... */ |
4083 |
if (needs & NEED_END) { |
if (needs & NEED_END) { |
4084 |
newLine = addLine(new, config->cfi, LT_ENTRY_END, |
newLine = addLine(new, config->cfi, LT_ENTRY_END, |
4085 |
config->secondaryIndent, NULL); |
config->secondaryIndent, NULL); |
4086 |
needs &= ~NEED_END; |
needs &= ~NEED_END; |
4087 |
} |
} |
|
|
|
4088 |
if (needs) { |
if (needs) { |
4089 |
printf(_("grubby: needs=%d, aborting\n"), needs); |
printf(_("grubby: needs=%d, aborting\n"), needs); |
4090 |
abort(); |
abort(); |
4105 |
memset(array, '\0', sizeof (array)); |
memset(array, '\0', sizeof (array)); |
4106 |
size = backtrace(array, 40); |
size = backtrace(array, 40); |
4107 |
|
|
4108 |
fprintf(stderr, "grubby recieved SIGSEGV! Backtrace (%ld):\n", |
fprintf(stderr, "grubby received SIGSEGV! Backtrace (%ld):\n", |
4109 |
(unsigned long)size); |
(unsigned long)size); |
4110 |
backtrace_symbols_fd(array, size, STDERR_FILENO); |
backtrace_symbols_fd(array, size, STDERR_FILENO); |
4111 |
exit(1); |
exit(1); |
4130 |
char * newKernelArgs = NULL; |
char * newKernelArgs = NULL; |
4131 |
char * newKernelInitrd = NULL; |
char * newKernelInitrd = NULL; |
4132 |
char * newKernelTitle = NULL; |
char * newKernelTitle = NULL; |
4133 |
char * newKernelVersion = NULL; |
char * newDevTreePath = NULL; |
4134 |
char * newMBKernel = NULL; |
char * newMBKernel = NULL; |
4135 |
char * newMBKernelArgs = NULL; |
char * newMBKernelArgs = NULL; |
4136 |
char * removeMBKernelArgs = NULL; |
char * removeMBKernelArgs = NULL; |
4140 |
char * removeArgs = NULL; |
char * removeArgs = NULL; |
4141 |
char * kernelInfo = NULL; |
char * kernelInfo = NULL; |
4142 |
char * extraInitrds[MAX_EXTRA_INITRDS] = { NULL }; |
char * extraInitrds[MAX_EXTRA_INITRDS] = { NULL }; |
4143 |
|
char * envPath = NULL; |
4144 |
const char * chptr = NULL; |
const char * chptr = NULL; |
4145 |
struct configFileInfo * cfi = NULL; |
struct configFileInfo * cfi = NULL; |
4146 |
struct grubConfig * config; |
struct grubConfig * config; |
4188 |
_("display the index of the default kernel") }, |
_("display the index of the default kernel") }, |
4189 |
{ "default-title", 0, 0, &displayDefaultTitle, 0, |
{ "default-title", 0, 0, &displayDefaultTitle, 0, |
4190 |
_("display the title of the default kernel") }, |
_("display the title of the default kernel") }, |
4191 |
|
{ "devtree", 0, POPT_ARG_STRING, &newDevTreePath, 0, |
4192 |
|
_("device tree file for new stanza"), _("dtb-path") }, |
4193 |
{ "elilo", 0, POPT_ARG_NONE, &configureELilo, 0, |
{ "elilo", 0, POPT_ARG_NONE, &configureELilo, 0, |
4194 |
_("configure elilo bootloader") }, |
_("configure elilo bootloader") }, |
4195 |
|
{ "efi", 0, POPT_ARG_NONE, &isEfi, 0, |
4196 |
|
_("force grub2 stanzas to use efi") }, |
4197 |
|
{ "env", 0, POPT_ARG_STRING, &envPath, 0, |
4198 |
|
_("path for environment data"), |
4199 |
|
_("path") }, |
4200 |
{ "extlinux", 0, POPT_ARG_NONE, &configureExtLinux, 0, |
{ "extlinux", 0, POPT_ARG_NONE, &configureExtLinux, 0, |
4201 |
_("configure extlinux bootloader (from syslinux)") }, |
_("configure extlinux bootloader (from syslinux)") }, |
4202 |
{ "grub", 0, POPT_ARG_NONE, &configureGrub, 0, |
{ "grub", 0, POPT_ARG_NONE, &configureGrub, 0, |
4209 |
{ "initrd", 0, POPT_ARG_STRING, &newKernelInitrd, 0, |
{ "initrd", 0, POPT_ARG_STRING, &newKernelInitrd, 0, |
4210 |
_("initrd image for the new kernel"), _("initrd-path") }, |
_("initrd image for the new kernel"), _("initrd-path") }, |
4211 |
{ "extra-initrd", 'i', POPT_ARG_STRING, NULL, 'i', |
{ "extra-initrd", 'i', POPT_ARG_STRING, NULL, 'i', |
4212 |
_("auxilliary initrd image for things other than the new kernel"), _("initrd-path") }, |
_("auxiliary initrd image for things other than the new kernel"), _("initrd-path") }, |
4213 |
{ "lilo", 0, POPT_ARG_NONE, &configureLilo, 0, |
{ "lilo", 0, POPT_ARG_NONE, &configureLilo, 0, |
4214 |
_("configure lilo bootloader") }, |
_("configure lilo bootloader") }, |
4215 |
{ "make-default", 0, 0, &makeDefault, 0, |
{ "make-default", 0, 0, &makeDefault, 0, |
4253 |
|
|
4254 |
signal(SIGSEGV, traceback); |
signal(SIGSEGV, traceback); |
4255 |
|
|
4256 |
|
int i = 0; |
4257 |
|
for (int j = 1; j < argc; j++) |
4258 |
|
i += strlen(argv[j]) + 1; |
4259 |
|
saved_command_line = malloc(i); |
4260 |
|
if (!saved_command_line) { |
4261 |
|
fprintf(stderr, "grubby: %m\n"); |
4262 |
|
exit(1); |
4263 |
|
} |
4264 |
|
saved_command_line[0] = '\0'; |
4265 |
|
for (int j = 1; j < argc; j++) { |
4266 |
|
strcat(saved_command_line, argv[j]); |
4267 |
|
strncat(saved_command_line, j == argc -1 ? "" : " ", 1); |
4268 |
|
} |
4269 |
|
|
4270 |
optCon = poptGetContext("grubby", argc, argv, options, 0); |
optCon = poptGetContext("grubby", argc, argv, options, 0); |
4271 |
poptReadDefaultConfig(optCon, 1); |
poptReadDefaultConfig(optCon, 1); |
4272 |
|
|
4310 |
return 1; |
return 1; |
4311 |
} else if (configureGrub2) { |
} else if (configureGrub2) { |
4312 |
cfi = &grub2ConfigType; |
cfi = &grub2ConfigType; |
4313 |
|
if (envPath) |
4314 |
|
cfi->envFile = envPath; |
4315 |
} else if (configureLilo) { |
} else if (configureLilo) { |
4316 |
cfi = &liloConfigType; |
cfi = &liloConfigType; |
4317 |
} else if (configureGrub) { |
} else if (configureGrub) { |
4355 |
grubConfig = cfi->defaultConfig; |
grubConfig = cfi->defaultConfig; |
4356 |
} |
} |
4357 |
|
|
4358 |
if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion || |
if (bootloaderProbe && (displayDefault || kernelInfo || |
4359 |
newKernelPath || removeKernelPath || makeDefault || |
newKernelPath || removeKernelPath || makeDefault || |
4360 |
defaultKernel || displayDefaultIndex || displayDefaultTitle || |
defaultKernel || displayDefaultIndex || displayDefaultTitle || |
4361 |
(defaultIndex >= 0))) { |
(defaultIndex >= 0))) { |
4364 |
return 1; |
return 1; |
4365 |
} |
} |
4366 |
|
|
4367 |
if ((displayDefault || kernelInfo) && (newKernelVersion || newKernelPath || |
if ((displayDefault || kernelInfo) && (newKernelPath || |
4368 |
removeKernelPath)) { |
removeKernelPath)) { |
4369 |
fprintf(stderr, _("grubby: --default-kernel and --info may not " |
fprintf(stderr, _("grubby: --default-kernel and --info may not " |
4370 |
"be used when adding or removing kernels\n")); |
"be used when adding or removing kernels\n")); |
4512 |
return 0; |
return 0; |
4513 |
} |
} |
4514 |
|
|
4515 |
|
if (grubConfig == NULL) { |
4516 |
|
printf("Could not find bootloader configuration file.\n"); |
4517 |
|
exit(1); |
4518 |
|
} |
4519 |
|
|
4520 |
config = readConfig(grubConfig, cfi); |
config = readConfig(grubConfig, cfi); |
4521 |
if (!config) return 1; |
if (!config) return 1; |
4522 |
|
|
4526 |
char * rootspec; |
char * rootspec; |
4527 |
|
|
4528 |
if (config->defaultImage == -1) return 0; |
if (config->defaultImage == -1) return 0; |
4529 |
|
if (config->defaultImage == DEFAULT_SAVED_GRUB2 && |
4530 |
|
cfi->defaultIsSaved) |
4531 |
|
config->defaultImage = 0; |
4532 |
entry = findEntryByIndex(config, config->defaultImage); |
entry = findEntryByIndex(config, config->defaultImage); |
4533 |
if (!entry) return 0; |
if (!entry) return 0; |
4534 |
if (!suitableImage(entry, bootPrefix, 0, flags)) return 0; |
if (!suitableImage(entry, bootPrefix, 0, flags)) return 0; |
4535 |
|
|
4536 |
line = getLineByType(LT_KERNEL|LT_HYPER, entry->lines); |
line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); |
4537 |
if (!line) return 0; |
if (!line) return 0; |
4538 |
|
|
4539 |
rootspec = getRootSpecifier(line->elements[1].item); |
rootspec = getRootSpecifier(line->elements[1].item); |
4547 |
struct singleEntry * entry; |
struct singleEntry * entry; |
4548 |
|
|
4549 |
if (config->defaultImage == -1) return 0; |
if (config->defaultImage == -1) return 0; |
4550 |
|
if (config->defaultImage == DEFAULT_SAVED_GRUB2 && |
4551 |
|
cfi->defaultIsSaved) |
4552 |
|
config->defaultImage = 0; |
4553 |
entry = findEntryByIndex(config, config->defaultImage); |
entry = findEntryByIndex(config, config->defaultImage); |
4554 |
if (!entry) return 0; |
if (!entry) return 0; |
4555 |
|
|
4572 |
|
|
4573 |
} else if (displayDefaultIndex) { |
} else if (displayDefaultIndex) { |
4574 |
if (config->defaultImage == -1) return 0; |
if (config->defaultImage == -1) return 0; |
4575 |
|
if (config->defaultImage == DEFAULT_SAVED_GRUB2 && |
4576 |
|
cfi->defaultIsSaved) |
4577 |
|
config->defaultImage = 0; |
4578 |
printf("%i\n", config->defaultImage); |
printf("%i\n", config->defaultImage); |
4579 |
|
return 0; |
4580 |
|
|
4581 |
} else if (kernelInfo) |
} else if (kernelInfo) |
4582 |
return displayInfo(config, kernelInfo, bootPrefix); |
return displayInfo(config, kernelInfo, bootPrefix); |
4594 |
if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, |
if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, |
4595 |
removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1; |
removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1; |
4596 |
if (updateKernelPath && newKernelInitrd) { |
if (updateKernelPath && newKernelInitrd) { |
4597 |
if (updateInitrd(config, updateKernelPath, bootPrefix, |
if (newMBKernel) { |
4598 |
newKernelInitrd)) return 1; |
if (addMBInitrd(config, newMBKernel, updateKernelPath, |
4599 |
|
bootPrefix, newKernelInitrd)) |
4600 |
|
return 1; |
4601 |
|
} else { |
4602 |
|
if (updateInitrd(config, updateKernelPath, bootPrefix, |
4603 |
|
newKernelInitrd)) |
4604 |
|
return 1; |
4605 |
|
} |
4606 |
} |
} |
4607 |
if (addNewKernel(config, template, bootPrefix, newKernelPath, |
if (addNewKernel(config, template, bootPrefix, newKernelPath, |
4608 |
newKernelTitle, newKernelArgs, newKernelInitrd, |
newKernelTitle, newKernelArgs, newKernelInitrd, |
4609 |
(const char **)extraInitrds, extraInitrdCount, |
(const char **)extraInitrds, extraInitrdCount, |
4610 |
newMBKernel, newMBKernelArgs)) return 1; |
newMBKernel, newMBKernelArgs, newDevTreePath)) return 1; |
4611 |
|
|
4612 |
|
|
4613 |
if (numEntries(config) == 0) { |
if (numEntries(config) == 0) { |