60 |
|
|
61 |
int isEfi = 0; |
int isEfi = 0; |
62 |
|
|
63 |
|
#if defined(__arch64__) |
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 |
239 |
{ "initrd16", LT_INITRD_16, ' ', ' ' }, |
{ "initrd16", LT_INITRD_16, ' ', ' ' }, |
240 |
{ "module", LT_MBMODULE, ' ' }, |
{ "module", LT_MBMODULE, ' ' }, |
241 |
{ "kernel", LT_HYPER, ' ' }, |
{ "kernel", LT_HYPER, ' ' }, |
242 |
|
{ "devicetree", LT_DEVTREE, ' ' }, |
243 |
{ NULL, 0, 0 }, |
{ NULL, 0, 0 }, |
244 |
}; |
}; |
245 |
|
|
727 |
if (isEfi && cfi == &grub2ConfigType) { |
if (isEfi && cfi == &grub2ConfigType) { |
728 |
switch (type) { |
switch (type) { |
729 |
case LT_KERNEL: |
case LT_KERNEL: |
730 |
return LT_KERNEL_EFI; |
return isEfiOnly ? LT_KERNEL : LT_KERNEL_EFI; |
731 |
case LT_INITRD: |
case LT_INITRD: |
732 |
return LT_INITRD_EFI; |
return isEfiOnly ? LT_INITRD : LT_INITRD_EFI; |
733 |
default: |
default: |
734 |
return type; |
return type; |
735 |
} |
} |
3714 |
const char * newKernelPath, const char * newKernelTitle, |
const char * newKernelPath, const char * newKernelTitle, |
3715 |
const char * newKernelArgs, const char * newKernelInitrd, |
const char * newKernelArgs, const char * newKernelInitrd, |
3716 |
const char ** extraInitrds, int extraInitrdCount, |
const char ** extraInitrds, int extraInitrdCount, |
3717 |
const char * newMBKernel, const char * newMBKernelArgs) { |
const char * newMBKernel, const char * newMBKernelArgs, |
3718 |
|
const char * newDevTreePath) { |
3719 |
struct singleEntry * new; |
struct singleEntry * new; |
3720 |
struct singleLine * newLine = NULL, * tmplLine = NULL, * masterLine = NULL; |
struct singleLine * newLine = NULL, * tmplLine = NULL, * masterLine = NULL; |
3721 |
int needs; |
int needs; |
3756 |
needs |= NEED_MB; |
needs |= NEED_MB; |
3757 |
new->multiboot = 1; |
new->multiboot = 1; |
3758 |
} |
} |
3759 |
|
if (newDevTreePath && getKeywordByType(LT_DEVTREE, config->cfi)) |
3760 |
|
needs |= NEED_DEVTREE; |
3761 |
|
|
3762 |
if (template) { |
if (template) { |
3763 |
for (masterLine = template->lines; |
for (masterLine = template->lines; |
3943 |
newLine = addLineTmpl(new, tmplLine, newLine, NULL, |
newLine = addLineTmpl(new, tmplLine, newLine, NULL, |
3944 |
config->cfi); |
config->cfi); |
3945 |
} |
} |
3946 |
|
} else if (tmplLine->type == LT_DEVTREE && |
3947 |
|
tmplLine->numElements == 2 && newDevTreePath) { |
3948 |
|
newLine = addLineTmpl(new, tmplLine, newLine, |
3949 |
|
newDevTreePath + strlen(prefix), |
3950 |
|
config->cfi); |
3951 |
|
needs &= ~NEED_DEVTREE; |
3952 |
|
} else if (tmplLine->type == LT_ENTRY_END && needs & NEED_DEVTREE) { |
3953 |
|
const char *ndtp = newDevTreePath; |
3954 |
|
if (!strncmp(newDevTreePath, prefix, strlen(prefix))) |
3955 |
|
ndtp += strlen(prefix); |
3956 |
|
newLine = addLine(new, config->cfi, LT_DEVTREE, |
3957 |
|
config->secondaryIndent, |
3958 |
|
ndtp); |
3959 |
|
needs &= ~NEED_DEVTREE; |
3960 |
|
newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi); |
3961 |
} else { |
} else { |
3962 |
/* pass through other lines from the template */ |
/* pass through other lines from the template */ |
3963 |
newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi); |
newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi); |
4078 |
free(initrdVal); |
free(initrdVal); |
4079 |
needs &= ~NEED_INITRD; |
needs &= ~NEED_INITRD; |
4080 |
} |
} |
4081 |
|
if (needs & NEED_DEVTREE) { |
4082 |
|
newLine = addLine(new, config->cfi, LT_DEVTREE, |
4083 |
|
config->secondaryIndent, |
4084 |
|
newDevTreePath); |
4085 |
|
needs &= ~NEED_DEVTREE; |
4086 |
|
} |
4087 |
|
|
4088 |
|
/* NEEDS_END must be last on bootloaders that need it... */ |
4089 |
if (needs & NEED_END) { |
if (needs & NEED_END) { |
4090 |
newLine = addLine(new, config->cfi, LT_ENTRY_END, |
newLine = addLine(new, config->cfi, LT_ENTRY_END, |
4091 |
config->secondaryIndent, NULL); |
config->secondaryIndent, NULL); |
4092 |
needs &= ~NEED_END; |
needs &= ~NEED_END; |
4093 |
} |
} |
|
|
|
4094 |
if (needs) { |
if (needs) { |
4095 |
printf(_("grubby: needs=%d, aborting\n"), needs); |
printf(_("grubby: needs=%d, aborting\n"), needs); |
4096 |
abort(); |
abort(); |
4136 |
char * newKernelArgs = NULL; |
char * newKernelArgs = NULL; |
4137 |
char * newKernelInitrd = NULL; |
char * newKernelInitrd = NULL; |
4138 |
char * newKernelTitle = NULL; |
char * newKernelTitle = NULL; |
4139 |
char * newKernelVersion = NULL; |
char * newDevTreePath = NULL; |
4140 |
char * newMBKernel = NULL; |
char * newMBKernel = NULL; |
4141 |
char * newMBKernelArgs = NULL; |
char * newMBKernelArgs = NULL; |
4142 |
char * removeMBKernelArgs = NULL; |
char * removeMBKernelArgs = NULL; |
4194 |
_("display the index of the default kernel") }, |
_("display the index of the default kernel") }, |
4195 |
{ "default-title", 0, 0, &displayDefaultTitle, 0, |
{ "default-title", 0, 0, &displayDefaultTitle, 0, |
4196 |
_("display the title of the default kernel") }, |
_("display the title of the default kernel") }, |
4197 |
|
{ "devtree", 0, POPT_ARG_STRING, &newDevTreePath, 0, |
4198 |
|
_("device tree file for new stanza"), _("dtb-path") }, |
4199 |
{ "elilo", 0, POPT_ARG_NONE, &configureELilo, 0, |
{ "elilo", 0, POPT_ARG_NONE, &configureELilo, 0, |
4200 |
_("configure elilo bootloader") }, |
_("configure elilo bootloader") }, |
4201 |
{ "efi", 0, POPT_ARG_NONE, &isEfi, 0, |
{ "efi", 0, POPT_ARG_NONE, &isEfi, 0, |
4361 |
grubConfig = cfi->defaultConfig; |
grubConfig = cfi->defaultConfig; |
4362 |
} |
} |
4363 |
|
|
4364 |
if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion || |
if (bootloaderProbe && (displayDefault || kernelInfo || |
4365 |
newKernelPath || removeKernelPath || makeDefault || |
newKernelPath || removeKernelPath || makeDefault || |
4366 |
defaultKernel || displayDefaultIndex || displayDefaultTitle || |
defaultKernel || displayDefaultIndex || displayDefaultTitle || |
4367 |
(defaultIndex >= 0))) { |
(defaultIndex >= 0))) { |
4370 |
return 1; |
return 1; |
4371 |
} |
} |
4372 |
|
|
4373 |
if ((displayDefault || kernelInfo) && (newKernelVersion || newKernelPath || |
if ((displayDefault || kernelInfo) && (newKernelPath || |
4374 |
removeKernelPath)) { |
removeKernelPath)) { |
4375 |
fprintf(stderr, _("grubby: --default-kernel and --info may not " |
fprintf(stderr, _("grubby: --default-kernel and --info may not " |
4376 |
"be used when adding or removing kernels\n")); |
"be used when adding or removing kernels\n")); |
4613 |
if (addNewKernel(config, template, bootPrefix, newKernelPath, |
if (addNewKernel(config, template, bootPrefix, newKernelPath, |
4614 |
newKernelTitle, newKernelArgs, newKernelInitrd, |
newKernelTitle, newKernelArgs, newKernelInitrd, |
4615 |
(const char **)extraInitrds, extraInitrdCount, |
(const char **)extraInitrds, extraInitrdCount, |
4616 |
newMBKernel, newMBKernelArgs)) return 1; |
newMBKernel, newMBKernelArgs, newDevTreePath)) return 1; |
4617 |
|
|
4618 |
|
|
4619 |
if (numEntries(config) == 0) { |
if (numEntries(config) == 0) { |