1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-14 15:21:37 +03:00

sd-boot:Show stub cmdline when edit

If Linux efi stub is used, embedded cmdline in efi stub is
not shown. As a result, it is required to rewrite all the
line, if is only required to modify it. This behavior only
happen using Linux efi stub.

This patch allows boot loader to show embedded cmdline when
'e' key is pressed to edit boot loader options.
This commit is contained in:
Jose Carlos Venegas Munoz 2015-07-16 15:39:44 -05:00
parent 3083663e5d
commit b1da143f2a

View File

@ -1495,6 +1495,7 @@ static VOID config_entry_add_osx(Config *config) {
static VOID config_entry_add_linux( Config *config, EFI_LOADED_IMAGE *loaded_image, EFI_FILE *root_dir) { static VOID config_entry_add_linux( Config *config, EFI_LOADED_IMAGE *loaded_image, EFI_FILE *root_dir) {
EFI_FILE_HANDLE linux_dir; EFI_FILE_HANDLE linux_dir;
EFI_STATUS err; EFI_STATUS err;
ConfigEntry *entry;
err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &linux_dir, L"\\EFI\\Linux", EFI_FILE_MODE_READ, 0ULL); err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &linux_dir, L"\\EFI\\Linux", EFI_FILE_MODE_READ, 0ULL);
if (!EFI_ERROR(err)) { if (!EFI_ERROR(err)) {
@ -1504,6 +1505,7 @@ static VOID config_entry_add_linux( Config *config, EFI_LOADED_IMAGE *loaded_ima
EFI_FILE_INFO *f; EFI_FILE_INFO *f;
CHAR8 *sections[] = { CHAR8 *sections[] = {
(UINT8 *)".osrel", (UINT8 *)".osrel",
(UINT8 *)".cmdline",
NULL NULL
}; };
UINTN offs[ELEMENTSOF(sections)-1] = {}; UINTN offs[ELEMENTSOF(sections)-1] = {};
@ -1535,7 +1537,7 @@ static VOID config_entry_add_linux( Config *config, EFI_LOADED_IMAGE *loaded_ima
if (StriCmp(f->FileName + len - 4, L".efi") != 0) if (StriCmp(f->FileName + len - 4, L".efi") != 0)
continue; continue;
/* look for an .osrel section in the .efi binary */ /* look for .osrel and .cmdline sections in the .efi binary */
err = pefile_locate_sections(linux_dir, f->FileName, sections, addrs, offs, szs); err = pefile_locate_sections(linux_dir, f->FileName, sections, addrs, offs, szs);
if (EFI_ERROR(err)) if (EFI_ERROR(err))
continue; continue;
@ -1575,10 +1577,21 @@ static VOID config_entry_add_linux( Config *config, EFI_LOADED_IMAGE *loaded_ima
if (os_name && os_id && (os_version || os_build)) { if (os_name && os_id && (os_version || os_build)) {
CHAR16 *conf; CHAR16 *conf;
CHAR16 *path; CHAR16 *path;
CHAR16 *cmdline;
conf = PoolPrint(L"%s-%s", os_id, os_version ? : os_build); conf = PoolPrint(L"%s-%s", os_id, os_version ? : os_build);
path = PoolPrint(L"\\EFI\\Linux\\%s", f->FileName); path = PoolPrint(L"\\EFI\\Linux\\%s", f->FileName);
config_entry_add_loader(config, loaded_image->DeviceHandle, LOADER_LINUX, conf, 'l', os_name, path); entry = config_entry_add_loader(config, loaded_image->DeviceHandle, LOADER_LINUX, conf, 'l', os_name, path);
FreePool(content);
/* read the embedded cmdline file */
len = file_read(linux_dir, f->FileName, offs[1], szs[1] - 1 , &content);
if (len > 0) {
cmdline = stra_to_str(content);
entry->options = cmdline;
cmdline = NULL;
}
FreePool(cmdline);
FreePool(conf); FreePool(conf);
FreePool(path); FreePool(path);
} }