summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorMikael Larsson <mikael.xt.larsson@stericsson.com>2010-09-28 16:49:50 +0200
committerMichael BRANDT <michael.brandt@stericsson.com>2010-09-29 18:27:45 +0200
commitf1db0a1204d235fd13ea7b1ad6a3aca640125954 (patch)
tree1d39c8eaca26dbbe7cec62d485e12d960190e03d /fs
parenta528a25f4c1956b67d121c99ab3aadbfa0cdf93b (diff)
Fix mmc_read_cmd_file
mmc_read_cmd_file broke with the latest changes in fat and mmc. This makes it work again. Change-Id: I9bd0fee41bc4dfe790166415bb856104ab412536 Signed-off-by: Mikael Larsson <mikael.xt.larsson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/5765 Reviewed-by: Ulf HANSSON <ulf.hansson@stericsson.com> Reviewed-by: Michael BRANDT <michael.brandt@stericsson.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/fat/rockbox_wrapper.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/fs/fat/rockbox_wrapper.c b/fs/fat/rockbox_wrapper.c
index cfd46d602..dd91d3831 100644
--- a/fs/fat/rockbox_wrapper.c
+++ b/fs/fat/rockbox_wrapper.c
@@ -337,22 +337,20 @@ file_fat_read(const char *filename, void *buffer, unsigned long maxsize)
return -1;
}
+ file_size = filesize(fd);
+ if (file_size < 0) {
+ fat_eprintf("Call to filesize() failed\n");
+ return -1;
+ }
+
/*
* If the number of bytes to read is zero, read the entire file.
*/
- if (maxsize == 0) {
- file_size = filesize(fd);
- if (file_size < 0) {
- fat_eprintf("Call to filesize() failed\n");
- return -1;
- }
+ if ((maxsize != 0) && (maxsize < file_size))
+ file_size = maxsize;
- maxsize = (unsigned long) file_size;
- fat_dprintf("Reading entire file (%lu bytes)\n", maxsize);
- }
-
- bytes = (long) read(fd, buffer, (size_t) maxsize);
- if ((unsigned long) bytes != maxsize) {
+ bytes = (long) read(fd, buffer, (size_t) file_size);
+ if ((unsigned long) bytes != file_size) {
#ifdef CONFIG_STRERROR
fprintf(stderr, "Read error: %s\n", strerror(errno));
#endif