diff options
author | Hardeep Sidhu <dyp@pobox.com> | 2003-03-15 21:13:35 +0000 |
---|---|---|
committer | Hardeep Sidhu <dyp@pobox.com> | 2003-03-15 21:13:35 +0000 |
commit | e5e9bc3e65d34de202b41ca51d8bff117e240830 (patch) | |
tree | 6a1041ca3f744d6e2ee7d2ff273117b044b3dfa4 | |
parent | 001226c7e1c20508466f77567607e623ee629389 (diff) | |
download | rockbox-e5e9bc3e65d34de202b41ca51d8bff117e240830.tar.gz rockbox-e5e9bc3e65d34de202b41ca51d8bff117e240830.zip |
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
-rw-r--r-- | firmware/common/file.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c index 4443b55bca..d2cad7c647 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c | |||
@@ -337,9 +337,15 @@ static int flush_cache(int fd) | |||
337 | { | 337 | { |
338 | int rc; | 338 | int rc; |
339 | struct filedesc* file = &openfiles[fd]; | 339 | struct filedesc* file = &openfiles[fd]; |
340 | 340 | int sector = file->fileoffset / SECTOR_SIZE; | |
341 | |||
341 | DEBUGF("Flushing dirty sector cache\n"); | 342 | DEBUGF("Flushing dirty sector cache\n"); |
342 | 343 | ||
344 | /* make sure we are on correct sector */ | ||
345 | rc = fat_seek(&(file->fatfile), sector); | ||
346 | if ( rc < 0 ) | ||
347 | return rc * 10 - 3; | ||
348 | |||
343 | rc = fat_readwrite(&(file->fatfile), 1, | 349 | rc = fat_readwrite(&(file->fatfile), 1, |
344 | file->cache, true ); | 350 | file->cache, true ); |
345 | if ( rc < 0 ) | 351 | if ( rc < 0 ) |
@@ -573,13 +579,6 @@ int lseek(int fd, int offset, int whence) | |||
573 | return rc * 10 - 6; | 579 | return rc * 10 - 6; |
574 | } | 580 | } |
575 | file->cacheoffset = sectoroffset; | 581 | file->cacheoffset = sectoroffset; |
576 | |||
577 | /* seek back to current sector */ | ||
578 | rc = fat_seek(&(file->fatfile), newsector); | ||
579 | if ( rc < 0 ) { | ||
580 | errno = EIO; | ||
581 | return rc * 10 - 7; | ||
582 | } | ||
583 | } | 582 | } |
584 | else | 583 | else |
585 | file->cacheoffset = -1; | 584 | file->cacheoffset = -1; |