X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FFilesystems%2FFAT%2Ffat.c;h=7eab09371c2eea24e93266eec37ab3f5a5de0b12;hb=f67c9f03f7b4aaa3688ef74b255690d52ded3db2;hp=bfe52a9e6e0f747586e10b049673ff56bee46e71;hpb=fd6e994acc5bc3073e979b6f862a4d199bec4ff7;p=tpg%2Facess2.git diff --git a/Modules/Filesystems/FAT/fat.c b/Modules/Filesystems/FAT/fat.c index bfe52a9e..7eab0937 100644 --- a/Modules/Filesystems/FAT/fat.c +++ b/Modules/Filesystems/FAT/fat.c @@ -73,10 +73,10 @@ Uint64 FAT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); #endif // --- Directory IO char *FAT_ReadDir(tVFS_Node *Node, int ID); -tVFS_Node *FAT_FindDir(tVFS_Node *Node, char *Name); +tVFS_Node *FAT_FindDir(tVFS_Node *Node, const char *Name); #if SUPPORT_WRITE - int FAT_Mknod(tVFS_Node *Node, char *Name, Uint Flags); - int FAT_Relink(tVFS_Node *node, char *OldName, char *NewName); + int FAT_Mknod(tVFS_Node *Node, const char *Name, Uint Flags); + int FAT_Relink(tVFS_Node *node, const char *OldName, const char *NewName); #endif void FAT_CloseFile(tVFS_Node *node); @@ -340,7 +340,7 @@ int FAT_int_GetAddress(tVFS_Node *Node, Uint64 Offset, Uint64 *Addr, Uint32 *Clu if(Cluster) *Cluster = cluster; cluster = FAT_int_GetFatValue(disk, cluster); // Check for end of cluster chain - if(cluster == -1) { LEAVE('i', 1); return 1;} + if(cluster == 0xFFFFFFFF) { LEAVE('i', 1); return 1;} } if(Cluster) *Cluster = cluster; } @@ -393,7 +393,7 @@ Uint32 FAT_int_GetFatValue(tFAT_VolInfo *Disk, Uint32 cluster) Uint32 val = 0; Uint32 ofs; ENTER("pDisk xCluster", Disk, cluster); - LOCK( &Disk->lFAT ); + Mutex_Acquire( &Disk->lFAT ); #if CACHE_FAT if( Disk->ClusterCount <= giFAT_MaxCachedClusters ) { @@ -420,7 +420,7 @@ Uint32 FAT_int_GetFatValue(tFAT_VolInfo *Disk, Uint32 cluster) #if CACHE_FAT } #endif /*CACHE_FAT*/ - RELEASE( &Disk->lFAT ); + Mutex_Release( &Disk->lFAT ); LEAVE('x', val); return val; } @@ -632,14 +632,14 @@ Uint64 FAT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) cluster = Node->Inode & 0xFFFFFFFF; // Clamp Size - if(Offset + Length > Node->Size) { + if(Offset >= Node->Size || Offset + Length > Node->Size) { LOG("Reading past EOF (%lli + %lli > %lli), clamped to %lli", Offset, Length, Node->Size, Node->Size - Offset); Length = Node->Size - Offset; } // Reading from within the first cluster only? - if(Offset + Length < bpc) + if((int)Offset + (int)Length < bpc) { LOG("First cluster only"); FAT_int_ReadCluster(disk, cluster, bpc, tmpBuf); @@ -671,7 +671,7 @@ Uint64 FAT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) pos = bpc - Offset%bpc; // Read 1st Cluster (performs alignment for us) - if( pos == bpc && Length >= bpc ) { + if( pos == bpc && (int)Length >= bpc ) { FAT_int_ReadCluster(disk, cluster, bpc, Buffer); } else { @@ -679,7 +679,7 @@ Uint64 FAT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) memcpy( Buffer, (void*)( tmpBuf + (bpc-pos) ), - (pos < Length ? pos : Length) + (pos < (int)Length ? (Uint)pos : Length) ); } @@ -724,7 +724,7 @@ Uint64 FAT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) } // Read final cluster - if( Length - pos == bpc ) + if( (int)Length - pos == bpc ) { FAT_int_ReadCluster( disk, cluster, bpc, (void*)(Buffer+pos) ); } @@ -936,11 +936,14 @@ char *FAT_int_CreateName(fat_filetable *ft, char *LongFileName) */ tVFS_Node *FAT_int_CreateNode(tVFS_Node *Parent, fat_filetable *Entry, int Pos) { - tVFS_Node node = {0}; + tVFS_Node node; tVFS_Node *ret; tFAT_VolInfo *disk = Parent->ImplPtr; ENTER("pParent pFT", Parent, Entry); + LOG("disk = %p", disk); + + memset(&node, 0, sizeof(tVFS_Node)); // Set Other Data // 0-31: Cluster, 32-63: Parent Cluster @@ -1301,7 +1304,7 @@ char *FAT_ReadDir(tVFS_Node *Node, int ID) * \fn tVFS_Node *FAT_FindDir(tVFS_Node *node, char *name) * \brief Finds an entry in the current directory */ -tVFS_Node *FAT_FindDir(tVFS_Node *Node, char *Name) +tVFS_Node *FAT_FindDir(tVFS_Node *Node, const char *Name) { fat_filetable fileinfo[16]; char tmpName[13];