diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/fat.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 74bdbd3491..ad1a7a0c82 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c | |||
@@ -1002,12 +1002,15 @@ int fat_truncate(struct fat_file *file) | |||
1002 | { | 1002 | { |
1003 | /* truncate trailing clusters */ | 1003 | /* truncate trailing clusters */ |
1004 | int next; | 1004 | int next; |
1005 | int last = get_next_cluster(file->lastcluster); | 1005 | int last = file->lastcluster; |
1006 | while ( last && last != FAT_EOF_MARK ) { | 1006 | |
1007 | LDEBUGF("fat_truncate(%x, %x)\n", file->firstcluster, last); | ||
1008 | |||
1009 | for ( last = get_next_cluster(last); last; last = next ) { | ||
1007 | next = get_next_cluster(last); | 1010 | next = get_next_cluster(last); |
1008 | update_fat_entry(last,0); | 1011 | update_fat_entry(last,0); |
1009 | last = next; | ||
1010 | } | 1012 | } |
1013 | update_fat_entry(file->lastcluster,FAT_EOF_MARK); | ||
1011 | 1014 | ||
1012 | return 0; | 1015 | return 0; |
1013 | } | 1016 | } |