All of lore.kernel.org
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 3/4] efi_loader: disk: install FILE_SYSTEM_PROTOCOL only if available
Date: Fri,  4 Oct 2019 12:05:22 +0900	[thread overview]
Message-ID: <20191004030523.21579-4-takahiro.akashi@linaro.org> (raw)
In-Reply-To: <20191004030523.21579-1-takahiro.akashi@linaro.org>

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>
---
 lib/efi_loader/efi_disk.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 9007a5f77f3d..27329cadb6f1 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,19 @@ efi_fs_from_path(struct efi_device_path *full_path)
 	return handler->protocol_interface;
 }
 
+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 +329,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,
-- 
2.21.0

  parent reply	other threads:[~2019-10-04  3:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-04  3:05 [U-Boot] [PATCH v3 0/4] efi_loader: disk: install FILE_SYSTEM_PROTOCOL to whole disk AKASHI Takahiro
2019-10-04  3:05 ` [U-Boot] [PATCH v3 1/4] fs: export fs_close() AKASHI Takahiro
2019-10-04 18:53   ` Heinrich Schuchardt
2019-10-07  2:08     ` AKASHI Takahiro
2019-10-04  3:05 ` [U-Boot] [PATCH v3 2/4] fs: add fs_get_type() for current filesystem type AKASHI Takahiro
2019-10-04 19:04   ` Heinrich Schuchardt
2019-10-07  2:13     ` AKASHI Takahiro
2019-10-04  3:05 ` AKASHI Takahiro [this message]
2019-10-04 19:13   ` [U-Boot] [PATCH v3 3/4] efi_loader: disk: install FILE_SYSTEM_PROTOCOL only if available Heinrich Schuchardt
2019-10-07  2:15     ` AKASHI Takahiro
2019-10-04  3:05 ` [U-Boot] [PATCH v3 4/4] efi_loader: disk: install file system protocol to a whole disk AKASHI Takahiro
2019-10-04 19:15   ` Heinrich Schuchardt
2019-10-07  2:27     ` AKASHI Takahiro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191004030523.21579-4-takahiro.akashi@linaro.org \
    --to=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.