Commit 7a3e70cf authored by Max Krummenacher's avatar Max Krummenacher Committed by Tom Rini

fs/fs.c: read up to EOF when len would read past EOF
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
	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: default avatarMax Krummenacher <>
Signed-off-by: default avatarMarcel Ziswiler <>
Acked-by: default avatarMarek Vasut <>
Signed-off-by: default avatarStefan Agner <>
Signed-off-by: default avatarMarcel Ziswiler <>
parent f06b454b
......@@ -301,10 +301,8 @@ int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,
/* 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);
return ret;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment