X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FFilesystems%2FFAT%2Ffat.c;h=93911de607acffbe69464c901238a22ca78100c7;hb=83612bb37fbd8e84d90ecb9e6a7157aadd1e2175;hp=25b9cb06010a91b1f6e56e8ea152a7db0a57f7f1;hpb=08c83f2fcac74de5206d587d5321af27c2cd8347;p=tpg%2Facess2.git diff --git a/Modules/Filesystems/FAT/fat.c b/Modules/Filesystems/FAT/fat.c index 25b9cb06..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 @@ -238,7 +238,8 @@ tVFS_Node *FAT_InitDevice(char *Device, char **Options) // == VFS Interface node = &diskInfo->rootNode; - node->Size = bs->files_in_root; + //node->Size = bs->files_in_root; + node->Size = -1; node->Inode = diskInfo->rootOffset; // 0:31 - Cluster, 32:63 - Parent Directory Cluster node->ImplPtr = diskInfo; // Disk info pointer node->ImplInt = 0; // 0:15 - Directory Index, 16: Dirty Flag, 17: Deletion Flag @@ -327,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) { @@ -599,14 +602,14 @@ Uint64 FAT_Read(tVFS_Node *Node, Uint64 offset, Uint64 length, void *buffer) // Sanity Check offset if(offset > Node->Size) { - LOG("Reading past EOF (%i > %i)", offset, node->Size); + LOG("Reading past EOF (%i > %i)", offset, Node->Size); LEAVE('i', 0); return 0; } // Clamp Size if(offset + length > Node->Size) { LOG("Reading past EOF (%lli + %lli > %lli), clamped to %lli", - offset, length, node->Size, node->Size - offset); + offset, length, Node->Size, Node->Size - offset); length = Node->Size - offset; } @@ -856,14 +859,11 @@ void FAT_int_ProperFilename(char *dest, char *src) char *FAT_int_CreateName(fat_filetable *ft, char *LongFileName) { char *ret; - int len; ENTER("pft sLongFileName", ft, LongFileName); #if USE_LFN if(LongFileName && LongFileName[0] != '\0') { - len = strlen(LongFileName); - ret = malloc(len+1); - strcpy(ret, LongFileName); + ret = strdup(LongFileName); } else { @@ -978,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) { @@ -1108,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; } @@ -1115,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' ) { @@ -1130,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 @@ -1260,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);