diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2003-06-19 12:08:22 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2003-06-19 12:08:22 +0000 |
commit | c6db7870ef001ffd7a64884b3e03d3b4cfc67b1d (patch) | |
tree | 55480a6999283da7a1932a7ed906d9dd9f757950 /firmware/common | |
parent | 474c4b5427d4bce75ddb9217756da0173fe3ba84 (diff) | |
download | rockbox-c6db7870ef001ffd7a64884b3e03d3b4cfc67b1d.tar.gz rockbox-c6db7870ef001ffd7a64884b3e03d3b4cfc67b1d.zip |
Slightly better handling of disk-full situations
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3756 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common')
-rw-r--r-- | firmware/common/file.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c index 46af790bf7..01279d4421 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c | |||
@@ -348,8 +348,13 @@ static int flush_cache(int fd) | |||
348 | 348 | ||
349 | rc = fat_readwrite(&(file->fatfile), 1, | 349 | rc = fat_readwrite(&(file->fatfile), 1, |
350 | file->cache, true ); | 350 | file->cache, true ); |
351 | if ( rc < 0 ) | 351 | |
352 | if ( rc < 0 ) { | ||
353 | if(file->fatfile.eof) | ||
354 | errno = ENOSPC; | ||
355 | |||
352 | return rc * 10 - 2; | 356 | return rc * 10 - 2; |
357 | } | ||
353 | 358 | ||
354 | file->dirty = false; | 359 | file->dirty = false; |
355 | 360 | ||
@@ -418,14 +423,19 @@ static int readwrite(int fd, void* buf, int count, bool write) | |||
418 | return rc * 10 - 3; | 423 | return rc * 10 - 3; |
419 | } | 424 | } |
420 | 425 | ||
421 | /* read whole sectors right into the supplied buffer */ | 426 | /* read/write whole sectors right into/from the supplied buffer */ |
422 | sectors = count / SECTOR_SIZE; | 427 | sectors = count / SECTOR_SIZE; |
423 | if ( sectors ) { | 428 | if ( sectors ) { |
424 | int rc = fat_readwrite(&(file->fatfile), sectors, buf+nread, write ); | 429 | int rc = fat_readwrite(&(file->fatfile), sectors, buf+nread, write ); |
425 | if ( rc < 0 ) { | 430 | if ( rc < 0 ) { |
426 | DEBUGF("Failed read/writing %d sectors\n",sectors); | 431 | DEBUGF("Failed read/writing %d sectors\n",sectors); |
427 | errno = EIO; | 432 | errno = EIO; |
428 | file->fileoffset += nread; | 433 | if(write && file->fatfile.eof) { |
434 | DEBUGF("No space left on device\n"); | ||
435 | errno = ENOSPC; | ||
436 | } else { | ||
437 | file->fileoffset += nread; | ||
438 | } | ||
429 | file->cacheoffset = -1; | 439 | file->cacheoffset = -1; |
430 | return nread ? nread : rc * 10 - 4; | 440 | return nread ? nread : rc * 10 - 4; |
431 | } | 441 | } |