Changed spinlock mechananisim
[tpg/acess2.git] / Modules / Filesystems / FAT / fat.c
index bfe52a9..e14fad0 100644 (file)
@@ -73,10 +73,10 @@ Uint64      FAT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
 #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
@@ -340,7 +340,7 @@ int FAT_int_GetAddress(tVFS_Node *Node, Uint64 Offset, Uint64 *Addr, Uint32 *Clu
                        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
@@ -393,7 +393,7 @@ Uint32 FAT_int_GetFatValue(tFAT_VolInfo *Disk, Uint32 cluster)
        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
@@ -420,7 +420,7 @@ Uint32 FAT_int_GetFatValue(tFAT_VolInfo *Disk, Uint32 cluster)
        #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
@@ -632,14 +632,14 @@ Uint64 FAT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
        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
@@ -671,7 +671,7 @@ Uint64 FAT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
        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
@@ -679,7 +679,7 @@ Uint64 FAT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
                memcpy(\r
                        Buffer,\r
                        (void*)( tmpBuf + (bpc-pos) ),\r
-                       (pos < Length ? pos : Length)\r
+                       (pos < (int)Length ? (Uint)pos : Length)\r
                        );\r
        }\r
        \r
@@ -724,7 +724,7 @@ Uint64 FAT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
        }\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
@@ -936,12 +936,14 @@ char *FAT_int_CreateName(fat_filetable *ft, char *LongFileName)
  */\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
@@ -1301,7 +1303,7 @@ char *FAT_ReadDir(tVFS_Node *Node, int ID)
  * \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

UCC git Repository :: git.ucc.asn.au