Fixed a file system driver caching bug corrupting files on certain situations

(when reading and writing the same file).


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8231 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Miika Pekkarinen 2005-12-13 16:11:00 +00:00
parent 6dd24bfbcc
commit d9dcb0fbcf

View file

@ -543,6 +543,17 @@ static int readwrite(int fd, void* buf, long count, bool write)
file->dirty = true; file->dirty = true;
} }
else { else {
/* Flush the cache first if it's dirty. */
if (file->dirty)
{
rc = flush_cache(fd);
if ( rc < 0 ) {
errno = EIO;
return rc * 10 - 8;
}
file->cacheoffset = -1;
}
rc = fat_readwrite(&(file->fatfile), 1, &(file->cache),false); rc = fat_readwrite(&(file->fatfile), 1, &(file->cache),false);
if (rc < 1 ) { if (rc < 1 ) {
DEBUGF("Failed caching sector\n"); DEBUGF("Failed caching sector\n");