diff options
author | Peter D'Hoye <peter.dhoye@gmail.com> | 2007-12-13 23:36:22 +0000 |
---|---|---|
committer | Peter D'Hoye <peter.dhoye@gmail.com> | 2007-12-13 23:36:22 +0000 |
commit | eb947cdde1a34588de767ea75762269253af487a (patch) | |
tree | 742ba8891394103004bf37666829c2ba128bc603 /firmware/common/file.c | |
parent | 10d0344e296eeb9259e9b609bb9b656ba1d7e42a (diff) |
Another fix for file system issues when encountering disk full (like when recording)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15920 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common/file.c')
-rw-r--r-- | firmware/common/file.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c index 9290f508b8..f0437f9e68 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -548,6 +548,14 @@ static int readwrite(int fd, void* buf, long count, bool write) file->fileoffset += nread; } file->cacheoffset = -1; + /* adjust file size to length written */ + if ( write && file->fileoffset > file->size ) + { + file->size = file->fileoffset; +#ifdef HAVE_DIRCACHE + dircache_update_filesize(fd, file->size, file->fatfile.firstcluster); +#endif + } return nread ? nread : rc * 10 - 4; } else { @@ -580,6 +588,14 @@ static int readwrite(int fd, void* buf, long count, bool write) errno = EIO; file->fileoffset += nread; file->cacheoffset = -1; + /* adjust file size to length written */ + if ( file->fileoffset > file->size ) + { + file->size = file->fileoffset; +#ifdef HAVE_DIRCACHE + dircache_update_filesize(fd, file->size, file->fatfile.firstcluster); +#endif + } return nread ? nread : rc * 10 - 5; } /* seek back one sector to put file position right */ @@ -591,6 +607,14 @@ static int readwrite(int fd, void* buf, long count, bool write) errno = EIO; file->fileoffset += nread; file->cacheoffset = -1; + /* adjust file size to length written */ + if ( file->fileoffset > file->size ) + { + file->size = file->fileoffset; +#ifdef HAVE_DIRCACHE + dircache_update_filesize(fd, file->size, file->fatfile.firstcluster); +#endif + } return nread ? nread : rc * 10 - 6; } } |