From 474c4b5427d4bce75ddb9217756da0173fe3ba84 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Thu, 19 Jun 2003 12:03:36 +0000 Subject: Now handles a full disk a little better, and it doesn't trust the fsinfo anymore git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3755 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/fat.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index ac6d240d8e..92ac2a3bf8 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -410,10 +410,10 @@ int fat_mount(int startsector) } LDEBUGF("Freecount: %d\n",fat_bpb.fsinfo.freecount); - LDEBUGF("Nextfree: %x\n",fat_bpb.fsinfo.nextfree); - LDEBUGF("Cluster count: %x\n",fat_bpb.dataclusters); + LDEBUGF("Nextfree: 0x%x\n",fat_bpb.fsinfo.nextfree); + LDEBUGF("Cluster count: 0x%x\n",fat_bpb.dataclusters); LDEBUGF("Sectors per cluster: %d\n",fat_bpb.bpb_secperclus); - LDEBUGF("FAT sectors: %x\n",fat_bpb.fatsize); + LDEBUGF("FAT sectors: 0x%x\n",fat_bpb.fatsize); return 0; } @@ -550,10 +550,6 @@ static unsigned int find_free_cluster(unsigned int startcluster) unsigned int offset = startcluster % CLUSTERS_PER_FAT_SECTOR; unsigned int i; - /* don't waste time scanning if the disk is already full */ - if (!fat_bpb.fsinfo.freecount) - return 0; - for (i = 0; i 0) fat_bpb.fsinfo.freecount--; } else { @@ -1547,6 +1544,8 @@ int fat_readwrite( struct fat_file *file, int sectorcount, we want to append to the file */ cluster = oldcluster; clusternum--; + i = -1; /* Error code */ + break; } } else @@ -1598,6 +1597,7 @@ int fat_readwrite( struct fat_file *file, int sectorcount, if (eof) i--; + DEBUGF("Sectors written: %d\n", i); return i; } -- cgit v1.2.3