X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FFilesystems%2FFAT%2Ffat.c;h=93911de607acffbe69464c901238a22ca78100c7;hb=b98fbd4e9c71447d81fc9bd643fb174c76346e0f;hp=3ec2a5fd331002002643004eece2a9fdf8933aae;hpb=4e2291b425621d70278b1d38c644aaa2715300ce;p=tpg%2Facess2.git diff --git a/Modules/Filesystems/FAT/fat.c b/Modules/Filesystems/FAT/fat.c index 3ec2a5fd..93911de6 100644 --- a/Modules/Filesystems/FAT/fat.c +++ b/Modules/Filesystems/FAT/fat.c @@ -3,7 +3,7 @@ * FAT12/16/32 Driver Version (Incl LFN) * * NOTE: This driver will only support _reading_ long file names, not - * writing. I don't even know why i'm adding write-support. FAT sucks. + * writing. I don't even know why I'm adding write-support. FAT sucks. * * Known Bugs: * - LFN Is buggy in FAT_ReadDir @@ -12,11 +12,11 @@ * \todo Implement changing of the parent directory when a file is written to * \todo Implement file creation / deletion */ -#define DEBUG 1 +#define DEBUG 0 #define VERBOSE 1 #define CACHE_FAT 1 //!< Caches the FAT in memory -#define USE_LFN 0 //!< Enables the use of Long File Names +#define USE_LFN 1 //!< Enables the use of Long File Names #define SUPPORT_WRITE 0 #include @@ -328,6 +328,8 @@ int FAT_int_GetAddress(tVFS_Node *Node, Uint64 Offset, Uint64 *Addr, Uint32 *Clu if(Cluster) *Cluster = cluster; } + LOG("cluster = %08x", cluster); + // Bounds Checking (Used to spot corruption) if(cluster > disk->ClusterCount + 2) { @@ -976,6 +978,7 @@ int FAT_int_ReadDirSector(tVFS_Node *Node, int Sector, fat_filetable *Buffer) return 1; } + LOG("addr = 0x%llx", addr); // Read Sector if(VFS_ReadAt(disk->fileHandle, addr, 512, Buffer) != 512) { @@ -1106,6 +1109,7 @@ char *FAT_ReadDir(tVFS_Node *Node, int ID) if(FAT_int_ReadDirSector(Node, ID/16, fileinfo)) { + LOG("End of chain, end of dir"); LEAVE('n'); return NULL; } @@ -1113,9 +1117,7 @@ char *FAT_ReadDir(tVFS_Node *Node, int ID) // Offset in sector a = ID % 16; - LOG("a = %i", a); - - LOG("name[0] = 0x%x", (Uint8)fileinfo[a].name[0]); + LOG("fileinfo[%i].name[0] = 0x%x", a, (Uint8)fileinfo[a].name[0]); // Check if this is the last entry if( fileinfo[a].name[0] == '\0' ) { @@ -1128,8 +1130,13 @@ char *FAT_ReadDir(tVFS_Node *Node, int ID) // Check for empty entry if( (Uint8)fileinfo[a].name[0] == 0xE5 ) { LOG("Empty Entry"); + #if 0 // Stop on empty entry? + LEAVE('n'); + return NULL; // Stop + #else LEAVE('p', VFS_SKIP); return VFS_SKIP; // Skip + #endif } #if USE_LFN @@ -1258,6 +1265,8 @@ tVFS_Node *FAT_FindDir(tVFS_Node *Node, char *Name) { // Remove LFN if it does not apply if(lfnId != i) lfn[0] = '\0'; + #else + if(fileinfo[i&0xF].attrib == ATTR_LFN) continue; #endif // Get Real Filename FAT_int_ProperFilename(tmpName, fileinfo[i&0xF].name);