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(
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);
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)
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();
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)
}
}
#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;
+}
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;