public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [RESEND PATCH v5] fs/fs.c: read up to EOF when len would read past EOF
@ 2015-08-05 15:16 Marcel Ziswiler
  2015-08-05 15:16 ` [U-Boot] [RESEND PATCH v5] net: asix: fix operation without eeprom Marcel Ziswiler
                   ` (7 more replies)
  0 siblings, 8 replies; 18+ messages in thread
From: Marcel Ziswiler @ 2015-08-05 15:16 UTC (permalink / raw)
  To: u-boot

From: Max Krummenacher <max.krummenacher@toradex.com>

http://lists.denx.de/pipermail/u-boot/2012-September/134347.html
allows for reading files in chunks from the shell.

When this feature is used to read past the end of a file an error
was returned instead of returning the bytes read up to the end of
file. Thus the following fails in the shell:

offset = 0
len = chunksize
do
	read file, offset, len
	write data
until bytes_read < len

The patch changes the behaviour to printing an informational
message and returning the actual read number of bytes aka read(2)
behaviour for convenient use in U-Boot scripts.

Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Acked-by: Marek Vasut <marex@denx.de>
---
Changes in v5: split up into separate patches to be picked up by the
various subsystem maintainers as suggested by Marek
Changes in v2: mention read(2) behaviour as suggested by Marek

 fs/fs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index ac0897d..827b143 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -301,10 +301,8 @@ int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,
 	unmap_sysmem(buf);
 
 	/* If we requested a specific number of bytes, check we got it */
-	if (ret == 0 && len && *actread != len) {
-		printf("** Unable to read file %s **\n", filename);
-		ret = -1;
-	}
+	if (ret == 0 && len && *actread != len)
+		printf("** %s shorter than offset + len **\n", filename);
 	fs_close();
 
 	return ret;
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2015-08-13 13:23 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-05 15:16 [U-Boot] [RESEND PATCH v5] fs/fs.c: read up to EOF when len would read past EOF Marcel Ziswiler
2015-08-05 15:16 ` [U-Boot] [RESEND PATCH v5] net: asix: fix operation without eeprom Marcel Ziswiler
2015-08-05 15:20   ` Marek Vasut
2015-08-05 15:17 ` [U-Boot] [RESEND PATCH v5] generic-board: allow showing custom board info Marcel Ziswiler
2015-08-13 13:23   ` [U-Boot] [U-Boot, RESEND, " Tom Rini
2015-08-05 15:17 ` [U-Boot] [RESEND PATCH v5] logos: add Toradex logo Marcel Ziswiler
2015-08-13 13:16   ` Tom Rini
2015-08-05 15:17 ` [U-Boot] [RESEND PATCH v5] colibri_vf: remove spurious new line Marcel Ziswiler
2015-08-13 13:23   ` [U-Boot] [U-Boot, RESEND, " Tom Rini
2015-08-05 15:17 ` [U-Boot] [RESEND PATCH v5] image-fdt.c: store returned error value Marcel Ziswiler
2015-08-13 13:23   ` [U-Boot] [U-Boot, RESEND, " Tom Rini
2015-08-05 15:17 ` [U-Boot] [RESEND PATCH v5] mtd/nand/ubi: assortment of alignment fixes Marcel Ziswiler
2015-08-12 19:43   ` [U-Boot] [U-Boot, RESEND, " Tom Rini
2015-08-13  7:52     ` Marcel Ziswiler
2015-08-05 15:17 ` [U-Boot] [RESEND PATCH v5] tftp.c: fix CONFIG_TFTP_TSIZE for small files Marcel Ziswiler
2015-08-11 16:16   ` Joe Hershberger
2015-08-12 19:29   ` Joe Hershberger
2015-08-13 13:23 ` [U-Boot] [U-Boot, RESEND, v5] fs/fs.c: read up to EOF when len would read past EOF Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox