Added `strdup` library function and removed VFS_FREEPLZ, also added valid tVFS_Node...
[tpg/acess2.git] / Kernel / vfs / fs / fat.c
index 8cfeca4..8a55827 100644 (file)
@@ -73,7 +73,9 @@ int FAT_Install(char **Arguments)
        return 0;\r
 }\r
 \r
-/* Reads the boot sector of a disk and prepares the structures for it\r
+/**\r
+ * \fn tVFS_Node *FAT_InitDevice(char *Device, char *options)\r
+ * \brief Reads the boot sector of a disk and prepares the structures for it\r
  */\r
 tVFS_Node *FAT_InitDevice(char *Device, char *options)\r
 {\r
@@ -146,7 +148,6 @@ tVFS_Node *FAT_InitDevice(char *Device, char *options)
        #endif\r
        \r
        //Get Name\r
-       //puts(" Name: ");\r
        if(diskInfo->type == FAT32) {\r
                for(i=0;i<11;i++)\r
                        diskInfo->name[i] = (bs->spec.fat32.label[i] == ' ' ? '\0' : bs->spec.fat32.label[i]);\r
@@ -156,7 +157,6 @@ tVFS_Node *FAT_InitDevice(char *Device, char *options)
                        diskInfo->name[i] = (bs->spec.fat16.label[i] == ' ' ? '\0' : bs->spec.fat16.label[i]);\r
        }\r
        diskInfo->name[11] = '\0';\r
-       //puts(diskInfo->name); putch('\n');\r
        \r
        //Compute Root directory offset\r
        if(diskInfo->type == FAT32)\r
@@ -224,16 +224,15 @@ tVFS_Node *FAT_InitDevice(char *Device, char *options)
                Log(" FAT_InitDisk: Inode Cache handle is %i\n", gFAT_Disks[giFAT_PartCount].inodeHandle);\r
        #endif\r
        \r
-       //== VFS Interface\r
+       // == VFS Interface\r
        node = &gFAT_Disks[giFAT_PartCount].rootNode;\r
-       //node->Name = gFAT_Disks[giFAT_PartCount].name;\r
        node->Inode = diskInfo->rootOffset;\r
-       node->Size = bs->files_in_root; //Unknown - To be set on readdir\r
+       node->Size = bs->files_in_root; // Unknown - To be set on readdir\r
        node->ImplInt = giFAT_PartCount;\r
        \r
        node->ReferenceCount = 1;\r
        \r
-       node->UID = 0;  node->GID= 0;\r
+       node->UID = 0;  node->GID = 0;\r
        node->NumACLs = 1;\r
        node->ACLs = &gVFS_ACL_EveryoneRWX;\r
        node->Flags = VFS_FFLAG_DIRECTORY;\r
@@ -490,8 +489,6 @@ tVFS_Node *FAT_int_CreateNode(tVFS_Node *parent, fat_filetable *ft, char *LongFi
        \r
        ENTER("pParent pFT sLongFileName", parent, ft, LongFileName);\r
        \r
-       // Get Name\r
-       //node.Name = FAT_int_CreateName(parent, ft, LongFileName);\r
        // Set Other Data\r
        node.Inode = ft->cluster | (ft->clusterHi<<16);\r
        node.Size = ft->size;\r
@@ -530,6 +527,7 @@ tVFS_Node *FAT_int_CreateNode(tVFS_Node *parent, fat_filetable *ft, char *LongFi
                node.ReadDir = FAT_ReadDir;\r
                node.FindDir = FAT_FindDir;\r
                node.MkNod = FAT_Mknod;\r
+               node.Size = -1;\r
        } else {\r
                node.Read = FAT_Read;\r
                node.Write = FAT_Write;\r
@@ -667,16 +665,16 @@ char *FAT_ReadDir(tVFS_Node *dirNode, int dirpos)
        // Offset in sector\r
        a = dirpos & 0xF;\r
 \r
-       LOG("offset=%i, a=%i\n", (Uint)offset, a);\r
+       LOG("offset=%i, a=%i", (Uint)offset, a);\r
        \r
        // Read Sector\r
        VFS_ReadAt(disk->fileHandle, offset*512, 512, fileinfo);        // Read Dir Data\r
        \r
-       LOG("name[0] = 0x%x\n", (Uint8)fileinfo[a].name[0]);\r
+       LOG("name[0] = 0x%x", (Uint8)fileinfo[a].name[0]);\r
        //Check if this is the last entry\r
        if(fileinfo[a].name[0] == '\0') {\r
                dirNode->Size = dirpos;\r
-               LOG("End of list\n");\r
+               LOG("End of list");\r
                LEAVE('n');\r
                return NULL;    // break\r
        }\r
@@ -701,7 +699,7 @@ char *FAT_ReadDir(tVFS_Node *dirNode, int dirpos)
                // Get the current length\r
                len = strlen(lfn);\r
                \r
-               // Sanity Check (FAT implementations do not allow >255 bytes)\r
+               // Sanity Check (FAT implementations should not allow >255 bytes)\r
                if(len + 13 > 255)      return VFS_SKIP;\r
                // Rebase all bytes\r
                for(a=len+1;a--;)       lfn[a+13] = lfn[a];\r

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