diff options
author | Jan Janssen <medhefgo@web.de> | 2022-05-26 10:46:58 +0200 |
---|---|---|
committer | Jan Janssen <medhefgo@web.de> | 2022-06-09 12:50:13 +0200 |
commit | f747ca3ec3bdbdc55aecb5803dbd9f65bc0cd169 (patch) | |
tree | 3b7015c2759357248ea65a01dbfad6b38473fc11 /src | |
parent | boot: Drop use of LibGetSystemConfigurationTable (diff) | |
download | systemd-f747ca3ec3bdbdc55aecb5803dbd9f65bc0cd169.tar.xz systemd-f747ca3ec3bdbdc55aecb5803dbd9f65bc0cd169.zip |
boot: Drop use of LibOpenRoot
Diffstat (limited to 'src')
-rw-r--r-- | src/boot/efi/boot.c | 20 | ||||
-rw-r--r-- | src/boot/efi/shim.c | 7 | ||||
-rw-r--r-- | src/boot/efi/util.c | 19 | ||||
-rw-r--r-- | src/boot/efi/util.h | 2 | ||||
-rw-r--r-- | src/boot/efi/xbootldr.c | 10 |
5 files changed, 41 insertions, 17 deletions
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 60e8786e3e..dd5dad71f3 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -1947,8 +1947,9 @@ static void config_entry_add_osx(Config *config) { return; for (UINTN i = 0; i < n_handles; i++) { - _cleanup_(file_closep) EFI_FILE *root = LibOpenRoot(handles[i]); - if (!root) + _cleanup_(file_closep) EFI_FILE *root = NULL; + + if (open_volume(handles[i], &root) != EFI_SUCCESS) continue; if (config_entry_add_loader_auto( @@ -2249,7 +2250,7 @@ static void config_load_xbootldr( assert(device); err = xbootldr_open(device, &new_device, &root_dir); - if (EFI_ERROR(err)) + if (err != EFI_SUCCESS) return; config_entry_add_unified(config, new_device, root_dir); @@ -2344,9 +2345,10 @@ static EFI_STATUS image_start( if (entry->call) (void) entry->call(); - _cleanup_(file_closep) EFI_FILE *image_root = LibOpenRoot(entry->device); - if (!image_root) - return log_error_status_stall(EFI_DEVICE_ERROR, L"Error opening root path."); + _cleanup_(file_closep) EFI_FILE *image_root = NULL; + err = open_volume(entry->device, &image_root); + if (err != EFI_SUCCESS) + return log_error_status_stall(err, L"Error opening root path: %r", err); path = FileDevicePath(entry->device, entry->loader); if (!path) @@ -2602,9 +2604,9 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { export_variables(loaded_image, loaded_image_path, init_usec); - root_dir = LibOpenRoot(loaded_image->DeviceHandle); - if (!root_dir) - return log_error_status_stall(EFI_LOAD_ERROR, L"Unable to open root directory.", EFI_LOAD_ERROR); + err = open_volume(loaded_image->DeviceHandle, &root_dir); + if (err != EFI_SUCCESS) + return log_error_status_stall(err, L"Unable to open root directory: %r", err); if (secure_boot_enabled() && shim_loaded()) { err = security_policy_install(); diff --git a/src/boot/efi/shim.c b/src/boot/efi/shim.c index fb4aecaee0..663eafbae4 100644 --- a/src/boot/efi/shim.c +++ b/src/boot/efi/shim.c @@ -122,9 +122,10 @@ static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROT if (EFI_ERROR(status)) return status; - _cleanup_(file_closep) EFI_FILE *root = LibOpenRoot(h); - if (!root) - return EFI_NOT_FOUND; + _cleanup_(file_closep) EFI_FILE *root = NULL; + status = open_volume(h, &root); + if (status != EFI_SUCCESS) + return status; dev_path_str = DevicePathToStr(dp); if (!dev_path_str) diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c index 06859d2f3a..7d607e04c7 100644 --- a/src/boot/efi/util.c +++ b/src/boot/efi/util.c @@ -682,3 +682,22 @@ void beep(UINTN beep_count) { } } #endif + +EFI_STATUS open_volume(EFI_HANDLE device, EFI_FILE **ret_file) { + EFI_STATUS err; + EFI_FILE *file; + EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *volume; + + assert(ret_file); + + err = BS->HandleProtocol(device, &FileSystemProtocol, (void **) &volume); + if (err != EFI_SUCCESS) + return err; + + err = volume->OpenVolume(volume, &file); + if (err != EFI_SUCCESS) + return err; + + *ret_file = file; + return EFI_SUCCESS; +} diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index 06c298d776..75d3e51415 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -165,3 +165,5 @@ void beep(UINTN beep_count); #else static inline void beep(UINTN beep_count) {} #endif + +EFI_STATUS open_volume(EFI_HANDLE device, EFI_FILE **ret_file); diff --git a/src/boot/efi/xbootldr.c b/src/boot/efi/xbootldr.c index bc82768715..583bc4216f 100644 --- a/src/boot/efi/xbootldr.c +++ b/src/boot/efi/xbootldr.c @@ -247,17 +247,17 @@ EFI_STATUS xbootldr_open(EFI_HANDLE *device, EFI_HANDLE *ret_device, EFI_FILE ** assert(ret_root_dir); err = find_device(device, &partition_path); - if (EFI_ERROR(err)) + if (err != EFI_SUCCESS) return err; EFI_DEVICE_PATH *dp = partition_path; err = BS->LocateDevicePath(&BlockIoProtocol, &dp, &new_device); - if (EFI_ERROR(err)) + if (err != EFI_SUCCESS) return err; - root_dir = LibOpenRoot(new_device); - if (!root_dir) - return EFI_NOT_FOUND; + err = open_volume(new_device, &root_dir); + if (err != EFI_SUCCESS) + return err; *ret_device = new_device; *ret_root_dir = root_dir; |