Skip to content

Commit

Permalink
Cache boot medium state of volumes
Browse files Browse the repository at this point in the history
This avoids calling IsOnBootMedium multiple times and also allows to
make that function private.

Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
jan-kiszka committed Dec 9, 2024
1 parent d423d63 commit 0fb31eb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions env/syspart.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ UINTN filter_cfg_parts(UINTN *config_volumes, UINTN numHandles)
for (UINTN index = 0; index < numHandles; index++) {
VOLUME_DESC *v = &volumes[config_volumes[index]];

if (IsOnBootMedium(v->devpath)) {
if (v->onbootmedium) {
use_envs_on_bootmedium_only = TRUE;
};
}
Expand All @@ -83,7 +83,7 @@ UINTN filter_cfg_parts(UINTN *config_volumes, UINTN numHandles)
UINTN cvi = config_volumes[j];
VOLUME_DESC *v = &volumes[cvi];

if (IsOnBootMedium(v->devpath)) {
if (v->onbootmedium) {
swap_uintn(&config_volumes[j],
&config_volumes[num_sorted++]);
} else {
Expand Down
2 changes: 1 addition & 1 deletion include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

typedef struct _VOLUME_DESC {
EFI_DEVICE_PATH *devpath;
BOOLEAN onbootmedium;
CHAR16 *fslabel;
CHAR16 *fscustomlabel;
EFI_FILE_HANDLE root;
Expand All @@ -39,7 +40,6 @@ EFI_STATUS close_volumes(VOLUME_DESC *volumes, UINTN count);
EFI_DEVICE_PATH *FileDevicePathFromConfig(EFI_HANDLE device,
CHAR16 *payloadpath);
CHAR16 *GetBootMediumPath(CHAR16 *input);
BOOLEAN IsOnBootMedium(EFI_DEVICE_PATH *dp);

typedef EFI_STATUS (*WATCHDOG_PROBE)(EFI_PCI_IO *, UINT16, UINT16, UINTN);
#define _CONCAT(prefix, func) prefix ## func
Expand Down
7 changes: 5 additions & 2 deletions utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ VOID PrintC(const UINT8 color, const CHAR16 *fmt, ...)
(VOID) ST->ConOut->SetAttribute(ST->ConOut, attr);
}

BOOLEAN IsOnBootMedium(EFI_DEVICE_PATH *dp)
static BOOLEAN IsOnBootMedium(EFI_DEVICE_PATH *dp)
{
extern CHAR16 *boot_medium_path;
CHAR16 *device_path, *tmp;
Expand Down Expand Up @@ -157,14 +157,17 @@ EFI_STATUS get_volumes(VOLUME_DESC **volumes, UINTN *count)
}
devpathstr = DevicePathToStr(devpath);

BOOLEAN onbootmedium = IsOnBootMedium(devpath);

(*volumes)[rootCount].root = tmp;
(*volumes)[rootCount].devpath = devpath;
(*volumes)[rootCount].onbootmedium = onbootmedium;
(*volumes)[rootCount].fslabel =
get_volume_label((*volumes)[rootCount].root);
(*volumes)[rootCount].fscustomlabel =
get_volume_custom_label((*volumes)[rootCount].root);
INFO(L"Volume %d: ", rootCount);
if (IsOnBootMedium(devpath)) {
if (onbootmedium) {
INFO(L"(On boot medium) ");
}
INFO(L"%s, LABEL=%s, CLABEL=%s\n",
Expand Down

0 comments on commit 0fb31eb

Please sign in to comment.