diff options
author | AKASHI Takahiro <takahiro.akashi@linaro.org> | 2022-05-12 11:29:01 +0900 |
---|---|---|
committer | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2022-05-28 10:59:27 +0200 |
commit | 05f391e2fc73bf9f746534929b4436b86518f4fc (patch) | |
tree | 97bde2d59c0d7041dc9b2ac7fe9b236f9874d8fe /lib/efi_loader/efi_disk.c | |
parent | 8131c85a77f9d06f28ccbf121545023ef78d8e86 (diff) | |
download | u-boot-05f391e2fc73bf9f746534929b4436b86518f4fc.zip u-boot-05f391e2fc73bf9f746534929b4436b86518f4fc.tar.gz u-boot-05f391e2fc73bf9f746534929b4436b86518f4fc.tar.bz2 |
efi_loader: disk: add efi_disk_is_removable()
This helper function will be used to determine if the device is
removable media, initially for handling a short-path loading.
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'lib/efi_loader/efi_disk.c')
-rw-r--r-- | lib/efi_loader/efi_disk.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index f5b462f..1e82f52 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -73,6 +73,33 @@ static efi_status_t EFIAPI efi_disk_reset(struct efi_block_io *this, return EFI_EXIT(EFI_SUCCESS); } +/** + * efi_disk_is_removable() - check if the device is removable media + * @handle: efi object handle; + * + * Examine the device and determine if the device is a local block device + * and removable media. + * + * Return: true if removable, false otherwise + */ +bool efi_disk_is_removable(efi_handle_t handle) +{ + struct efi_handler *handler; + struct efi_block_io *io; + efi_status_t ret; + + ret = efi_search_protocol(handle, &efi_block_io_guid, &handler); + if (ret != EFI_SUCCESS) + return false; + + io = handler->protocol_interface; + + if (!io || !io->media) + return false; + + return (bool)io->media->removable_media; +} + enum efi_disk_direction { EFI_DISK_READ, EFI_DISK_WRITE, |