summaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_disk.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2019-10-18 16:37:03 -0400
committerTom Rini <trini@konsulko.com>2019-10-18 16:37:03 -0400
commit4b5c4dd93a829416d159619e4a58e97e9b215206 (patch)
tree667242755939a72efebd99e815e0944c33174e4b /lib/efi_loader/efi_disk.c
parent3b985bdeabd1b05abf28fe7dc6530c203750f9fc (diff)
parent5cc349bb09eefaf43e250b2c7a8fc5a61c595715 (diff)
Merge tag 'efi-2020-01-rc1-2' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Pull request for UEFI sub-system for efi-2020-01-rc1 (2) Install the simple file protocol only if there is a file system on the partition. Enable CONFIG_CMD_NVEDIT_EFI on QEMU.
Diffstat (limited to 'lib/efi_loader/efi_disk.c')
-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 9007a5f77f3..861fcaf3747 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,