summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAKASHI Takahiro <takahiro.akashi@linaro.org>2020-04-27 12:48:20 +0300
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2020-05-04 13:26:11 +0300
commit41fd506842c2d9385d940cffe8ceeb8456c29fc5 (patch)
tree4f9c9e77327ebf3b6e0b53d354c3a120f98150bd /lib
parentf0ff75f2491ba27c04bb1f94e502a2be8fc0e78e (diff)
downloadu-boot-41fd506842c2d9385d940cffe8ceeb8456c29fc5.tar.xz
efi_loader: disk: add efi_disk_is_system_part()
This function will check if a given handle to device is an EFI system partition. It will be utilised in implementing capsule-on-disk feature. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Add function description. Return bool. Reviewed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_disk.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index fd3df80b0b..0582e02158 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -588,3 +588,32 @@ efi_status_t efi_disk_register(void)
return EFI_SUCCESS;
}
+
+/**
+ * efi_disk_is_system_part() - check if handle refers to an EFI system partition
+ *
+ * @handle: handle of partition
+ *
+ * Return: true if handle refers to an EFI system partition
+ */
+bool efi_disk_is_system_part(efi_handle_t handle)
+{
+ struct efi_handler *handler;
+ struct efi_disk_obj *diskobj;
+ disk_partition_t info;
+ efi_status_t ret;
+ int r;
+
+ /* check if this is a block device */
+ ret = efi_search_protocol(handle, &efi_block_io_guid, &handler);
+ if (ret != EFI_SUCCESS)
+ return false;
+
+ diskobj = container_of(handle, struct efi_disk_obj, header);
+
+ r = part_get_info(diskobj->desc, diskobj->part, &info);
+ if (r)
+ return false;
+
+ return !!(info.bootable & PART_EFI_SYSTEM_PARTITION);
+}