summaryrefslogtreecommitdiff
path: root/firmware/common
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-06-19 12:08:22 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-06-19 12:08:22 +0000
commitc6db7870ef001ffd7a64884b3e03d3b4cfc67b1d (patch)
tree55480a6999283da7a1932a7ed906d9dd9f757950 /firmware/common
parent474c4b5427d4bce75ddb9217756da0173fe3ba84 (diff)
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.c16
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)
rc = fat_readwrite(&(file->fatfile), 1,
file->cache, true );
- if ( rc < 0 )
+
+ if ( rc < 0 ) {
+ if(file->fatfile.eof)
+ errno = ENOSPC;
+
return rc * 10 - 2;
+ }
file->dirty = false;
@@ -418,14 +423,19 @@ static int readwrite(int fd, void* buf, int count, bool write)
return rc * 10 - 3;
}
- /* read whole sectors right into the supplied buffer */
+ /* read/write whole sectors right into/from the supplied buffer */
sectors = count / SECTOR_SIZE;
if ( sectors ) {
int rc = fat_readwrite(&(file->fatfile), sectors, buf+nread, write );
if ( rc < 0 ) {
DEBUGF("Failed read/writing %d sectors\n",sectors);
errno = EIO;
- file->fileoffset += nread;
+ if(write && file->fatfile.eof) {
+ DEBUGF("No space left on device\n");
+ errno = ENOSPC;
+ } else {
+ file->fileoffset += nread;
+ }
file->cacheoffset = -1;
return nread ? nread : rc * 10 - 4;
}