summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAKASHI Takahiro <takahiro.akashi@linaro.org>2019-10-07 08:59:38 +0300
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2019-10-17 20:19:56 +0300
commit867400677cda0fac4a411f1549fe3a61bb5ed172 (patch)
treef394018622c5b05543277d68bd4c47aefdf9e7f6 /lib
parentb7cd95627baac05b7023b014c802be309be636a0 (diff)
downloadu-boot-867400677cda0fac4a411f1549fe3a61bb5ed172.tar.xz
efi_loader: disk: install FILE_SYSTEM_PROTOCOL only if available
In the current implementation, EFI_SIMPLEFILE_SYSTEM_PROTOCOL is always installed to all the partitions even if some of them may house no file system. With this patch, that protocol will be installed only if any file system exists. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_disk.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 9007a5f77f..861fcaf374 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -9,6 +9,7 @@
#include <blk.h>
#include <dm.h>
#include <efi_loader.h>
+#include <fs.h>
#include <part.h>
#include <malloc.h>
@@ -262,6 +263,27 @@ efi_fs_from_path(struct efi_device_path *full_path)
return handler->protocol_interface;
}
+/**
+ * efi_fs_exists() - check if a partition bears a file system
+ *
+ * @desc: block device descriptor
+ * @part: partition number
+ * Return: 1 if a file system exists on the partition
+ * 0 otherwise
+ */
+static int efi_fs_exists(struct blk_desc *desc, int part)
+{
+ if (fs_set_blk_dev_with_part(desc, part))
+ return 0;
+
+ if (fs_get_type() == FS_TYPE_ANY)
+ return 0;
+
+ fs_close();
+
+ return 1;
+}
+
/*
* Create a handle for a partition or disk
*
@@ -315,7 +337,7 @@ static efi_status_t efi_disk_add_dev(
diskobj->dp);
if (ret != EFI_SUCCESS)
return ret;
- if (part >= 1) {
+ if (part >= 1 && efi_fs_exists(desc, part)) {
diskobj->volume = efi_simple_file_system(desc, part,
diskobj->dp);
ret = efi_add_protocol(&diskobj->header,