From 8537e2d12ac8af7f548972cd4ad2477112dfb5ac Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Mon, 6 Sep 2004 23:33:21 +0000 Subject: Bug fix: open() now handles O_TRUNC correctly (this was the real cause for the .playlist_control corruption) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5048 a1c6a512-1295-4272-9138-f99709370657 --- firmware/common/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/common/file.c b/firmware/common/file.c index 546a927..c09a7fe 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -135,7 +135,7 @@ int open(const char* pathname, int flags) fat_open(entry->startcluster, &(file->fatfile), &(dir->fatdir)); - file->size = entry->size; + file->size = file->trunc ? 0 : entry->size; file->attr = entry->attribute; break; } @@ -236,7 +236,7 @@ int fsync(int fd) /* truncate? */ if (file->trunc) { - rc = ftruncate(fd, file->fileoffset); + rc = ftruncate(fd, file->size); if (rc < 0) return rc * 10 - 4; } -- cgit v1.1