Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve BOOT${ARCH}.CSV support.
Signed-off-by: Peter Jones <pjones@redhat.com>
  • Loading branch information
vathpela committed Sep 6, 2016
1 parent 6cbcfb7 commit 47f3a65
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
5 changes: 3 additions & 2 deletions README.fallback
Expand Up @@ -41,8 +41,9 @@ media. In that case, it'll invoke \EFI\BOOT\BOOTX64.EFI (or whatever
filename is right for your architecture.) In that case it'll be in
\EFI\BOOT, so it'll check for fallback.efi , and it'll find it and run
it. When it runs, fallback will look for every directory in \EFI\ with
a BOOT.CSV in it, and it'll parse that, and create new boot variables
from what it finds. Then it'll try to boot one of them.
a BOOT${ARCH}.CSV in it, or BOOT.CSV if that's not found. It'll parse that,
and create new boot variables from what it finds. Then it'll try to boot one
of them.

BOOT.CSV is a UCS-2 LE formatted CSV file. So it has the LE byte order
marker, and after that it's just a series of lines, each having
Expand Down
49 changes: 33 additions & 16 deletions fallback.c
Expand Up @@ -579,6 +579,8 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
FreePool(buffer);
buffer = NULL;

CHAR16 *bootcsv=NULL, *bootarchcsv=NULL;

bs = 0;
do {
bs = 0;
Expand Down Expand Up @@ -608,27 +610,42 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)

fi = buffer;

if (!StrCaseCmp(fi->FileName, L"boot.csv")
|| !StrCaseCmp(fi->FileName, L"boot" EFI_ARCH L".csv")) {
EFI_FILE_HANDLE fh2;
rc = uefi_call_wrapper(fh->Open, 5, fh, &fh2,
fi->FileName,
EFI_FILE_READ_ONLY, 0);
if (EFI_ERROR(rc) || fh2 == NULL) {
Print(L"Couldn't open \\EFI\\%s\\%s: %d\n",
dirname, fi->FileName, rc);
FreePool(buffer);
buffer = NULL;
continue;
}
rc = try_boot_csv(fh2, dirname, fi->FileName);
uefi_call_wrapper(fh2->Close, 1, fh2);
}
if (!bootcsv && !StrCaseCmp(fi->FileName, L"boot.csv"))
bootcsv = StrDuplicate(fi->FileName);

if (!bootarchcsv &&
!StrCaseCmp(fi->FileName, L"boot" EFI_ARCH L".csv"))
bootarchcsv = StrDuplicate(fi->FileName);

FreePool(buffer);
buffer = NULL;
} while (bs != 0);

rc = EFI_SUCCESS;
if (bootarchcsv) {
EFI_FILE_HANDLE fh2;
rc = uefi_call_wrapper(fh->Open, 5, fh, &fh2,
bootarchcsv, EFI_FILE_READ_ONLY, 0);
if (EFI_ERROR(rc) || fh2 == NULL) {
Print(L"Couldn't open \\EFI\\%s\\%s: %d\n",
dirname, bootarchcsv, rc);
} else {
rc = try_boot_csv(fh2, dirname, bootarchcsv);
uefi_call_wrapper(fh2->Close, 1, fh2);
}
}
if ((EFI_ERROR(rc) || !bootarchcsv) && bootcsv) {
EFI_FILE_HANDLE fh2;
rc = uefi_call_wrapper(fh->Open, 5, fh, &fh2,
bootcsv, EFI_FILE_READ_ONLY, 0);
if (EFI_ERROR(rc) || fh2 == NULL) {
Print(L"Couldn't open \\EFI\\%s\\%s: %d\n",
dirname, bootcsv, rc);
} else {
rc = try_boot_csv(fh2, dirname, bootcsv);
uefi_call_wrapper(fh2->Close, 1, fh2);
}
}
rc = EFI_SUCCESS;

return rc;
Expand Down

0 comments on commit 47f3a65

Please sign in to comment.