boot: Drop use of LibOpenRoot
This commit is contained in:
+11
-9
@@ -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();
|
||||
|
||||
+4
-3
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user