forked from len0rd/rockbox
Previous change broke read after seek. Reverted that change and added temporary fix in flush_cache to make sure we are on correct sector before writing to disk.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3448 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
001226c7e1
commit
e5e9bc3e65
1 changed files with 7 additions and 8 deletions
|
|
@ -337,9 +337,15 @@ static int flush_cache(int fd)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct filedesc* file = &openfiles[fd];
|
struct filedesc* file = &openfiles[fd];
|
||||||
|
int sector = file->fileoffset / SECTOR_SIZE;
|
||||||
|
|
||||||
DEBUGF("Flushing dirty sector cache\n");
|
DEBUGF("Flushing dirty sector cache\n");
|
||||||
|
|
||||||
|
/* make sure we are on correct sector */
|
||||||
|
rc = fat_seek(&(file->fatfile), sector);
|
||||||
|
if ( rc < 0 )
|
||||||
|
return rc * 10 - 3;
|
||||||
|
|
||||||
rc = fat_readwrite(&(file->fatfile), 1,
|
rc = fat_readwrite(&(file->fatfile), 1,
|
||||||
file->cache, true );
|
file->cache, true );
|
||||||
if ( rc < 0 )
|
if ( rc < 0 )
|
||||||
|
|
@ -573,13 +579,6 @@ int lseek(int fd, int offset, int whence)
|
||||||
return rc * 10 - 6;
|
return rc * 10 - 6;
|
||||||
}
|
}
|
||||||
file->cacheoffset = sectoroffset;
|
file->cacheoffset = sectoroffset;
|
||||||
|
|
||||||
/* seek back to current sector */
|
|
||||||
rc = fat_seek(&(file->fatfile), newsector);
|
|
||||||
if ( rc < 0 ) {
|
|
||||||
errno = EIO;
|
|
||||||
return rc * 10 - 7;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
file->cacheoffset = -1;
|
file->cacheoffset = -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue