diff options
author | Björn Stenberg <bjorn@haxx.se> | 2003-04-15 08:07:50 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2003-04-15 08:07:50 +0000 |
commit | 631b8d3bb8af7d3abf86d658054f6f88f78173a2 (patch) | |
tree | 469a60203222d322c6db6cb4bb28033288b4cc5e | |
parent | 2b7898b3bb8cc6f760f105039184b34c83a25a51 (diff) | |
download | rockbox-631b8d3bb8af7d3abf86d658054f6f88f78173a2.tar.gz rockbox-631b8d3bb8af7d3abf86d658054f6f88f78173a2.zip |
Update fileoffset and cacheoffset on error.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3556 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/common/file.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c index 8c0f9a8951..46af790bf7 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -421,11 +421,12 @@ static int readwrite(int fd, void* buf, int count, bool write) /* read whole sectors right into the supplied buffer */ sectors = count / SECTOR_SIZE; if ( sectors ) { - int rc = fat_readwrite(&(file->fatfile), sectors, - buf+nread, write ); + int rc = fat_readwrite(&(file->fatfile), sectors, buf+nread, write ); if ( rc < 0 ) { DEBUGF("Failed read/writing %d sectors\n",sectors); errno = EIO; + file->fileoffset += nread; + file->cacheoffset = -1; return nread ? nread : rc * 10 - 4; } else { @@ -453,11 +454,12 @@ static int readwrite(int fd, void* buf, int count, bool write) /* sector is only partially filled. copy-back from disk */ int rc; LDEBUGF("Copy-back tail cache\n"); - rc = fat_readwrite(&(file->fatfile), 1, - file->cache, false ); + rc = fat_readwrite(&(file->fatfile), 1, file->cache, false ); if ( rc < 0 ) { DEBUGF("Failed writing\n"); errno = EIO; + file->fileoffset += nread; + file->cacheoffset = -1; return nread ? nread : rc * 10 - 5; } /* seek back one sector to put file position right */ @@ -467,6 +469,8 @@ static int readwrite(int fd, void* buf, int count, bool write) if ( rc < 0 ) { DEBUGF("fat_seek() failed\n"); errno = EIO; + file->fileoffset += nread; + file->cacheoffset = -1; return nread ? nread : rc * 10 - 6; } } @@ -478,6 +482,8 @@ static int readwrite(int fd, void* buf, int count, bool write) if (rc < 1 ) { DEBUGF("Failed caching sector\n"); errno = EIO; + file->fileoffset += nread; + file->cacheoffset = -1; return nread ? nread : rc * 10 - 7; } memcpy( buf + nread, file->cache, count ); |