summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2014-09-04 13:46:02 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2015-02-19 13:57:53 +0100
commit69a73f09e33399ba55c999b16c09bac02ed6e9ad (patch)
tree8ba1ac0c76b51c92ea473a03a91f47420fc7780a
parentad58585faa2c1169798b6457a291b6f8ed600ed8 (diff)
fs/fs.c: read up to EOF when len would read past EOF
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. (cherry picked from commit 4641b92713300089c5980259ba31e668657aa75d)
-rw-r--r--fs/fs.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/fs.c b/fs/fs.c
index dd680f39c9..1a3437a0f4 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -261,10 +261,8 @@ int fs_read(const char *filename, ulong addr, int offset, int len)
unmap_sysmem(buf);
/* If we requested a specific number of bytes, check we got it */
- if (ret >= 0 && len && ret != len) {
- printf("** Unable to read file %s **\n", filename);
- ret = -1;
- }
+ if (ret >= 0 && len && ret != len)
+ printf("** %s shorter than offset + len **\n", filename);
fs_close();
return ret;