#endif\r
// --- Directory IO\r
char *FAT_ReadDir(tVFS_Node *Node, int ID);\r
-tVFS_Node *FAT_FindDir(tVFS_Node *Node, char *Name);\r
+tVFS_Node *FAT_FindDir(tVFS_Node *Node, const char *Name);\r
#if SUPPORT_WRITE\r
- int FAT_Mknod(tVFS_Node *Node, char *Name, Uint Flags);\r
- int FAT_Relink(tVFS_Node *node, char *OldName, char *NewName);\r
+ int FAT_Mknod(tVFS_Node *Node, const char *Name, Uint Flags);\r
+ int FAT_Relink(tVFS_Node *node, const char *OldName, const char *NewName);\r
#endif\r
void FAT_CloseFile(tVFS_Node *node);\r
\r
if(Cluster) *Cluster = cluster;\r
cluster = FAT_int_GetFatValue(disk, cluster);\r
// Check for end of cluster chain\r
- if(cluster == -1) { LEAVE('i', 1); return 1;}\r
+ if(cluster == 0xFFFFFFFF) { LEAVE('i', 1); return 1;}\r
}\r
if(Cluster) *Cluster = cluster;\r
}\r
Uint32 val = 0;\r
Uint32 ofs;\r
ENTER("pDisk xCluster", Disk, cluster);\r
- LOCK( &Disk->lFAT );\r
+ Mutex_Acquire( &Disk->lFAT );\r
#if CACHE_FAT\r
if( Disk->ClusterCount <= giFAT_MaxCachedClusters )\r
{\r
#if CACHE_FAT\r
}\r
#endif /*CACHE_FAT*/\r
- RELEASE( &Disk->lFAT );\r
+ Mutex_Release( &Disk->lFAT );\r
LEAVE('x', val);\r
return val;\r
}\r
cluster = Node->Inode & 0xFFFFFFFF;\r
\r
// Clamp Size\r
- if(Offset + Length > Node->Size) {\r
+ if(Offset >= Node->Size || Offset + Length > Node->Size) {\r
LOG("Reading past EOF (%lli + %lli > %lli), clamped to %lli",\r
Offset, Length, Node->Size, Node->Size - Offset);\r
Length = Node->Size - Offset;\r
}\r
\r
// Reading from within the first cluster only?\r
- if(Offset + Length < bpc)\r
+ if((int)Offset + (int)Length < bpc)\r
{\r
LOG("First cluster only");\r
FAT_int_ReadCluster(disk, cluster, bpc, tmpBuf);\r
pos = bpc - Offset%bpc;\r
\r
// Read 1st Cluster (performs alignment for us)\r
- if( pos == bpc && Length >= bpc ) {\r
+ if( pos == bpc && (int)Length >= bpc ) {\r
FAT_int_ReadCluster(disk, cluster, bpc, Buffer);\r
}\r
else {\r
memcpy(\r
Buffer,\r
(void*)( tmpBuf + (bpc-pos) ),\r
- (pos < Length ? pos : Length)\r
+ (pos < (int)Length ? (Uint)pos : Length)\r
);\r
}\r
\r
}\r
\r
// Read final cluster\r
- if( Length - pos == bpc )\r
+ if( (int)Length - pos == bpc )\r
{\r
FAT_int_ReadCluster( disk, cluster, bpc, (void*)(Buffer+pos) );\r
}\r
*/\r
tVFS_Node *FAT_int_CreateNode(tVFS_Node *Parent, fat_filetable *Entry, int Pos)\r
{\r
- tVFS_Node node = {0};\r
+ tVFS_Node node;\r
tVFS_Node *ret;\r
tFAT_VolInfo *disk = Parent->ImplPtr;\r
\r
ENTER("pParent pFT", Parent, Entry);\r
\r
+ memset(&node, 0, sizeof(tVFS_Node));\r
+ \r
// Set Other Data\r
// 0-31: Cluster, 32-63: Parent Cluster\r
node.Inode = Entry->cluster | (Entry->clusterHi<<16) | (Parent->Inode << 32);\r
* \fn tVFS_Node *FAT_FindDir(tVFS_Node *node, char *name)\r
* \brief Finds an entry in the current directory\r
*/\r
-tVFS_Node *FAT_FindDir(tVFS_Node *Node, char *Name)\r
+tVFS_Node *FAT_FindDir(tVFS_Node *Node, const char *Name)\r
{\r
fat_filetable fileinfo[16];\r
char tmpName[13];\r