mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/3] bootstrap_read_disk(): optionally inform the caller of the buffer size
Date: Thu,  5 Nov 2020 12:56:13 +0100	[thread overview]
Message-ID: <20201105115614.8802-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20201105115614.8802-1-s.hauer@pengutronix.de>

From: Ulrich Ölmann <u.oelmann@pengutronix.de>

The size of the buffer allocated in the function is needed if it shall be
inspected more closely later. Therefore optionally return it via a new pointer
argument.

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 arch/arm/mach-at91/bootstrap.c | 2 +-
 arch/arm/mach-socfpga/xload.c  | 2 +-
 include/bootstrap.h            | 4 ++--
 lib/bootstrap/disk.c           | 5 ++++-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-at91/bootstrap.c b/arch/arm/mach-at91/bootstrap.c
index 90b7b33fc9..0b1567cd23 100644
--- a/arch/arm/mach-at91/bootstrap.c
+++ b/arch/arm/mach-at91/bootstrap.c
@@ -89,7 +89,7 @@ static void at91bootstrap_boot_mmc(void)
 	kernel_entry_func func = NULL;
 
 	printf("Boot from mmc\n");
-	func = bootstrap_read_disk("disk0.0", NULL);
+	func = bootstrap_read_disk("disk0.0", NULL, NULL);
 	bootstrap_boot(func, false);
 	bootstrap_err("... failed\n");
 	free(func);
diff --git a/arch/arm/mach-socfpga/xload.c b/arch/arm/mach-socfpga/xload.c
index 8be2827e62..1131cfee41 100644
--- a/arch/arm/mach-socfpga/xload.c
+++ b/arch/arm/mach-socfpga/xload.c
@@ -37,7 +37,7 @@ static __noreturn int socfpga_xload(void)
 		socfpga_cyclone5_mmc_init();
 
 		for (part = barebox_parts; part->mmc_disk; part++) {
-			buf = bootstrap_read_disk(barebox_parts->mmc_disk, "fat");
+			buf = bootstrap_read_disk(barebox_parts->mmc_disk, "fat", NULL);
 			if (!buf) {
 				pr_info("failed to load barebox from MMC %s\n",
 					part->mmc_disk);
diff --git a/include/bootstrap.h b/include/bootstrap.h
index 8b3bb34a03..3e006d3cc9 100644
--- a/include/bootstrap.h
+++ b/include/bootstrap.h
@@ -25,9 +25,9 @@ static inline void* bootstrap_read_devfs(char *devname, bool use_bb, int offset,
 #endif
 
 #ifdef CONFIG_BOOTSTRAP_DISK
-void* bootstrap_read_disk(const char *devname, const char *fstype);
+void* bootstrap_read_disk(const char *devname, char *fstype, size_t *bufsize);
 #else
-static inline void* bootstrap_read_disk(const char *devname, const char *fstype)
+static inline void* bootstrap_read_disk(const char *devname, char *fstype, size_t *bufsize)
 {
 	return NULL;
 }
diff --git a/lib/bootstrap/disk.c b/lib/bootstrap/disk.c
index fd016166e6..ed8b1aa407 100644
--- a/lib/bootstrap/disk.c
+++ b/lib/bootstrap/disk.c
@@ -14,7 +14,7 @@
 #include <libfile.h>
 #include <bootstrap.h>
 
-void* bootstrap_read_disk(const char *dev, const char *fstype)
+void* bootstrap_read_disk(const char *dev, char *fstype, size_t *bufsize)
 {
 	int ret;
 	void *buf;
@@ -34,5 +34,8 @@ void* bootstrap_read_disk(const char *dev, const char *fstype)
 		return NULL;
 	}
 
+	if (bufsize)
+		*bufsize = len;
+
 	return buf;
 }
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2020-11-05 11:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 11:56 [PATCH 1/3] bootstrap_read_devfs(): " Sascha Hauer
2020-11-05 11:56 ` Sascha Hauer [this message]
2020-11-05 11:56 ` [PATCH 3/3] ARM: socfpga: xload: evaluate integrity of second stage barebox images Sascha Hauer

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=20201105115614.8802-2-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox