summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2003-03-12 15:06:57 +0000
committerBjörn Stenberg <bjorn@haxx.se>2003-03-12 15:06:57 +0000
commit188be8ec579e257a3d2905ff974c3571a02770d0 (patch)
tree09e3f50c3f3fb6cf892d810ae3c352c7d901c5f8 /firmware
parentcad6f24a50284d08aa2e4d6f5f5cc438396c6ef7 (diff)
downloadrockbox-188be8ec579e257a3d2905ff974c3571a02770d0.tar.gz
rockbox-188be8ec579e257a3d2905ff974c3571a02770d0.zip
Bug fix: If head bytes were read but sector read failed, return head byte count instead of error.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3432 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/file.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c
index dd953f44c5..3755560998 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -409,7 +409,7 @@ static int readwrite(int fd, void* buf, int count, bool write)
if (count && file->dirty) {
rc = flush_cache(fd);
if (rc < 0)
- return rc * 10 - 3;
+ return nread ? nread : rc * 10 - 3;
}
/* read whole sectors right into the supplied buffer */
@@ -420,7 +420,7 @@ static int readwrite(int fd, void* buf, int count, bool write)
if ( rc < 0 ) {
DEBUGF("Failed read/writing %d sectors\n",sectors);
errno = EIO;
- return rc * 10 - 4;
+ return nread ? nread : rc * 10 - 4;
}
else {
if ( rc > 0 ) {
@@ -452,7 +452,7 @@ static int readwrite(int fd, void* buf, int count, bool write)
if ( rc < 0 ) {
DEBUGF("Failed writing\n");
errno = EIO;
- return rc * 10 - 5;
+ return nread ? nread : rc * 10 - 5;
}
/* seek back one sector to put file position right */
rc = fat_seek(&(file->fatfile),
@@ -461,7 +461,7 @@ static int readwrite(int fd, void* buf, int count, bool write)
if ( rc < 0 ) {
DEBUGF("fat_seek() failed\n");
errno = EIO;
- return rc * 10 - 6;
+ return nread ? nread : rc * 10 - 6;
}
}
memcpy( file->cache, buf + nread, count );
@@ -472,7 +472,7 @@ static int readwrite(int fd, void* buf, int count, bool write)
if (rc < 1 ) {
DEBUGF("Failed caching sector\n");
errno = EIO;
- return rc * 10 - 7;
+ return nread ? nread : rc * 10 - 7;
}
memcpy( buf + nread, file->cache, count );
}