36 |
#include <signal.h> |
#include <signal.h> |
37 |
#include <blkid/blkid.h> |
#include <blkid/blkid.h> |
38 |
|
|
39 |
|
#ifndef DEBUG |
40 |
#define DEBUG 0 |
#define DEBUG 0 |
41 |
|
#endif |
42 |
|
|
43 |
#if DEBUG |
#if DEBUG |
44 |
#define dbgPrintf(format, args...) fprintf(stderr, format , ## args) |
#define dbgPrintf(format, args...) fprintf(stderr, format , ## args) |
117 |
struct keywordTypes * keywords; |
struct keywordTypes * keywords; |
118 |
int defaultIsIndex; |
int defaultIsIndex; |
119 |
int defaultSupportSaved; |
int defaultSupportSaved; |
120 |
enum lineType_e entrySeparator; |
enum lineType_e entryStart; |
121 |
int needsBootPrefix; |
int needsBootPrefix; |
122 |
int argsInQuotes; |
int argsInQuotes; |
123 |
int maxTitleLength; |
int maxTitleLength; |
141 |
}; |
}; |
142 |
|
|
143 |
struct configFileInfo grubConfigType = { |
struct configFileInfo grubConfigType = { |
144 |
"/boot/grub/grub.conf", /* defaultConfig */ |
.defaultConfig = "/boot/grub/grub.conf", |
145 |
grubKeywords, /* keywords */ |
.keywords = grubKeywords, |
146 |
1, /* defaultIsIndex */ |
.defaultIsIndex = 1, |
147 |
1, /* defaultSupportSaved */ |
.defaultSupportSaved = 1, |
148 |
LT_TITLE, /* entrySeparator */ |
.entryStart = LT_TITLE, |
149 |
1, /* needsBootPrefix */ |
.needsBootPrefix = 1, |
150 |
0, /* argsInQuotes */ |
.mbHyperFirst = 1, |
151 |
0, /* maxTitleLength */ |
.mbInitRdIsModule = 1, |
152 |
0, /* titleBracketed */ |
.mbAllowExtraInitRds = 1, |
|
1, /* mbHyperFirst */ |
|
|
1, /* mbInitRdIsModule */ |
|
|
0, /* mbConcatArgs */ |
|
|
1, /* mbAllowExtraInitRds */ |
|
153 |
}; |
}; |
154 |
|
|
155 |
struct keywordTypes yabootKeywords[] = { |
struct keywordTypes yabootKeywords[] = { |
247 |
}; |
}; |
248 |
int useextlinuxmenu; |
int useextlinuxmenu; |
249 |
struct configFileInfo eliloConfigType = { |
struct configFileInfo eliloConfigType = { |
250 |
"/boot/efi/EFI/redhat/elilo.conf", /* defaultConfig */ |
.defaultConfig = "/boot/efi/EFI/redhat/elilo.conf", |
251 |
eliloKeywords, /* keywords */ |
.keywords = eliloKeywords, |
252 |
0, /* defaultIsIndex */ |
.entryStart = LT_KERNEL, |
253 |
0, /* defaultSupportSaved */ |
.needsBootPrefix = 1, |
254 |
LT_KERNEL, /* entrySeparator */ |
.argsInQuotes = 1, |
255 |
1, /* needsBootPrefix */ |
.mbConcatArgs = 1, |
|
1, /* argsInQuotes */ |
|
|
0, /* maxTitleLength */ |
|
|
0, /* titleBracketed */ |
|
|
0, /* mbHyperFirst */ |
|
|
0, /* mbInitRdIsModule */ |
|
|
1, /* mbConcatArgs */ |
|
|
0, /* mbAllowExtraInitRds */ |
|
256 |
}; |
}; |
257 |
|
|
258 |
struct configFileInfo liloConfigType = { |
struct configFileInfo liloConfigType = { |
259 |
"/etc/lilo.conf", /* defaultConfig */ |
.defaultConfig = "/etc/lilo.conf", |
260 |
liloKeywords, /* keywords */ |
.keywords = liloKeywords, |
261 |
0, /* defaultIsIndex */ |
.entryStart = LT_KERNEL, |
262 |
0, /* defaultSupportSaved */ |
.argsInQuotes = 1, |
263 |
LT_KERNEL, /* entrySeparator */ |
.maxTitleLength = 15, |
|
0, /* needsBootPrefix */ |
|
|
1, /* argsInQuotes */ |
|
|
15, /* maxTitleLength */ |
|
|
0, /* titleBracketed */ |
|
|
0, /* mbHyperFirst */ |
|
|
0, /* mbInitRdIsModule */ |
|
|
0, /* mbConcatArgs */ |
|
|
0, /* mbAllowExtraInitRds */ |
|
264 |
}; |
}; |
265 |
|
|
266 |
struct configFileInfo yabootConfigType = { |
struct configFileInfo yabootConfigType = { |
267 |
"/etc/yaboot.conf", /* defaultConfig */ |
.defaultConfig = "/etc/yaboot.conf", |
268 |
yabootKeywords, /* keywords */ |
.keywords = yabootKeywords, |
269 |
0, /* defaultIsIndex */ |
.entryStart = LT_KERNEL, |
270 |
0, /* defaultSupportSaved */ |
.needsBootPrefix = 1, |
271 |
LT_KERNEL, /* entrySeparator */ |
.argsInQuotes = 1, |
272 |
1, /* needsBootPrefix */ |
.maxTitleLength = 15, |
273 |
1, /* argsInQuotes */ |
.mbAllowExtraInitRds = 1, |
|
15, /* maxTitleLength */ |
|
|
0, /* titleBracketed */ |
|
|
0, /* mbHyperFirst */ |
|
|
0, /* mbInitRdIsModule */ |
|
|
0, /* mbConcatArgs */ |
|
|
1, /* mbAllowExtraInitRds */ |
|
274 |
}; |
}; |
275 |
|
|
276 |
struct configFileInfo siloConfigType = { |
struct configFileInfo siloConfigType = { |
277 |
"/etc/silo.conf", /* defaultConfig */ |
.defaultConfig = "/etc/silo.conf", |
278 |
siloKeywords, /* keywords */ |
.keywords = siloKeywords, |
279 |
0, /* defaultIsIndex */ |
.entryStart = LT_KERNEL, |
280 |
0, /* defaultSupportSaved */ |
.needsBootPrefix = 1, |
281 |
LT_KERNEL, /* entrySeparator */ |
.argsInQuotes = 1, |
282 |
1, /* needsBootPrefix */ |
.maxTitleLength = 15, |
|
1, /* argsInQuotes */ |
|
|
15, /* maxTitleLength */ |
|
|
0, /* titleBracketed */ |
|
|
0, /* mbHyperFirst */ |
|
|
0, /* mbInitRdIsModule */ |
|
|
0, /* mbConcatArgs */ |
|
|
0, /* mbAllowExtraInitRds */ |
|
283 |
}; |
}; |
284 |
|
|
285 |
struct configFileInfo ziplConfigType = { |
struct configFileInfo ziplConfigType = { |
286 |
"/etc/zipl.conf", /* defaultConfig */ |
.defaultConfig = "/etc/zipl.conf", |
287 |
ziplKeywords, /* keywords */ |
.keywords = ziplKeywords, |
288 |
0, /* defaultIsIndex */ |
.entryStart = LT_TITLE, |
289 |
0, /* defaultSupportSaved */ |
.argsInQuotes = 1, |
290 |
LT_TITLE, /* entrySeparator */ |
.titleBracketed = 1, |
|
0, /* needsBootPrefix */ |
|
|
1, /* argsInQuotes */ |
|
|
0, /* maxTitleLength */ |
|
|
1, /* titleBracketed */ |
|
|
0, /* mbHyperFirst */ |
|
|
0, /* mbInitRdIsModule */ |
|
|
0, /* mbConcatArgs */ |
|
|
0, /* mbAllowExtraInitRds */ |
|
291 |
}; |
}; |
292 |
|
|
293 |
struct configFileInfo extlinuxConfigType = { |
struct configFileInfo extlinuxConfigType = { |
294 |
"/boot/extlinux/extlinux.conf", /* defaultConfig */ |
.defaultConfig = "/boot/extlinux/extlinux.conf", |
295 |
extlinuxKeywords, /* keywords */ |
.keywords = extlinuxKeywords, |
296 |
0, /* defaultIsIndex */ |
.entryStart = LT_TITLE, |
297 |
0, /* defaultSupportSaved */ |
.needsBootPrefix = 1, |
298 |
LT_TITLE, /* entrySeparator */ |
.maxTitleLength = 255, |
299 |
1, /* needsBootPrefix */ |
.mbAllowExtraInitRds = 1, |
|
0, /* argsInQuotes */ |
|
|
255, /* maxTitleLength */ |
|
|
0, /* titleBracketed */ |
|
|
0, /* mbHyperFirst */ |
|
|
0, /* mbInitRdIsModule */ |
|
|
0, /* mbConcatArgs */ |
|
|
1, /* mbAllowExtraInitRds */ |
|
300 |
}; |
}; |
301 |
|
|
302 |
struct grubConfig { |
struct grubConfig { |
439 |
return 0; |
return 0; |
440 |
} |
} |
441 |
|
|
442 |
static int isEntrySeparator(struct singleLine * line, |
static int isEntryStart(struct singleLine * line, |
443 |
struct configFileInfo * cfi) { |
struct configFileInfo * cfi) { |
444 |
return line->type == cfi->entrySeparator || line->type == LT_OTHER || |
return line->type == cfi->entryStart || line->type == LT_OTHER || |
445 |
(cfi->titleBracketed && isBracketedTitle(line)); |
(cfi->titleBracketed && isBracketedTitle(line)); |
446 |
} |
} |
447 |
|
|
764 |
cfg->secondaryIndent = strdup(line->indent); |
cfg->secondaryIndent = strdup(line->indent); |
765 |
} |
} |
766 |
|
|
767 |
if (isEntrySeparator(line, cfi)) { |
if (isEntryStart(line, cfi)) { |
768 |
sawEntry = 1; |
sawEntry = 1; |
769 |
if (!entry) { |
if (!entry) { |
770 |
cfg->entries = malloc(sizeof(*entry)); |
cfg->entries = malloc(sizeof(*entry)); |
1248 |
if (!rootdev) |
if (!rootdev) |
1249 |
return 0; |
return 0; |
1250 |
|
|
1251 |
|
if (!getuuidbydev(rootdev) || !getuuidbydev(dev)) { |
1252 |
|
free(rootdev); |
1253 |
|
return 0; |
1254 |
|
} |
1255 |
|
|
1256 |
if (strcmp(getuuidbydev(rootdev), getuuidbydev(dev))) { |
if (strcmp(getuuidbydev(rootdev), getuuidbydev(dev))) { |
1257 |
free(rootdev); |
free(rootdev); |
1934 |
const char ** arg; |
const char ** arg; |
1935 |
int useKernelArgs, useRoot; |
int useKernelArgs, useRoot; |
1936 |
int firstElement; |
int firstElement; |
1937 |
int *usedElements, *usedArgs; |
int *usedElements; |
1938 |
int doreplace; |
int doreplace; |
1939 |
|
|
1940 |
if (!image) return 0; |
if (!image) return 0; |
1969 |
useRoot = (getKeywordByType(LT_ROOT, cfg->cfi) |
useRoot = (getKeywordByType(LT_ROOT, cfg->cfi) |
1970 |
&& !multibootArgs); |
&& !multibootArgs); |
1971 |
|
|
|
for (k = 0, arg = newArgs; *arg; arg++, k++) ; |
|
|
usedArgs = calloc(k, sizeof(*usedArgs)); |
|
|
|
|
1972 |
for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) { |
for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) { |
1973 |
|
|
1974 |
if (multibootArgs && !entry->multiboot) |
if (multibootArgs && !entry->multiboot) |
2044 |
usedElements = calloc(line->numElements, sizeof(*usedElements)); |
usedElements = calloc(line->numElements, sizeof(*usedElements)); |
2045 |
|
|
2046 |
for (k = 0, arg = newArgs; *arg; arg++, k++) { |
for (k = 0, arg = newArgs; *arg; arg++, k++) { |
|
if (usedArgs[k]) continue; |
|
2047 |
|
|
2048 |
doreplace = 1; |
doreplace = 1; |
2049 |
for (i = firstElement; i < line->numElements; i++) { |
for (i = firstElement; i < line->numElements; i++) { |
2058 |
continue; |
continue; |
2059 |
if (!argMatch(line->elements[i].item, *arg)) { |
if (!argMatch(line->elements[i].item, *arg)) { |
2060 |
usedElements[i]=1; |
usedElements[i]=1; |
|
usedArgs[k]=1; |
|
2061 |
break; |
break; |
2062 |
} |
} |
2063 |
} |
} |
2127 |
} |
} |
2128 |
} |
} |
2129 |
|
|
|
free(usedArgs); |
|
2130 |
free(newArgs); |
free(newArgs); |
2131 |
free(oldArgs); |
free(oldArgs); |
2132 |
|
|
2675 |
/* don't have a template, so start the entry with the |
/* don't have a template, so start the entry with the |
2676 |
* appropriate starting line |
* appropriate starting line |
2677 |
*/ |
*/ |
2678 |
switch (config->cfi->entrySeparator) { |
switch (config->cfi->entryStart) { |
2679 |
case LT_KERNEL: |
case LT_KERNEL: |
2680 |
if (new->multiboot && config->cfi->mbHyperFirst) { |
if (new->multiboot && config->cfi->mbHyperFirst) { |
2681 |
/* fall through to LT_HYPER */ |
/* fall through to LT_HYPER */ |
2727 |
|
|
2728 |
/* add the remainder of the lines, i.e. those that either |
/* add the remainder of the lines, i.e. those that either |
2729 |
* 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, |
2730 |
* all the lines following the entrySeparator. |
* all the lines following the entryStart. |
2731 |
*/ |
*/ |
2732 |
if (needs & NEED_TITLE) { |
if (needs & NEED_TITLE) { |
2733 |
newLine = addLine(new, config->cfi, LT_TITLE, |
newLine = addLine(new, config->cfi, LT_TITLE, |