/*\r
- * Acess2\r
+ * Acess 2\r
* FAT12/16/32 Driver Version (Incl LFN)\r
*/\r
-//INCLUDES\r
+#define DEBUG 0\r
#include <common.h>\r
#include <modules.h>\r
#include <vfs.h>\r
#include "fs_fat.h"\r
\r
-#define DEBUG 0\r
#define VERBOSE 1\r
\r
-#if DEBUG\r
-# define DEBUGS(v...) Log(v)\r
-#else\r
-# define DEBUGS(v...)\r
-# undef ENTER\r
-# undef LOG\r
-# undef LEAVE\r
-# define ENTER(...)\r
-# define LOG(...)\r
-# define LEAVE(...)\r
-#endif\r
-\r
#define CACHE_FAT 1 //!< Caches the FAT in memory\r
#define USE_LFN 1 //!< Enables the use of Long File Names\r
\r
\r
// === PROTOTYPES ===\r
int FAT_Install(char **Arguments);\r
-tVFS_Node *FAT_InitDevice(char *device, char *options);\r
+tVFS_Node *FAT_InitDevice(char *device, char **options);\r
void FAT_Unmount(tVFS_Node *Node);\r
Uint64 FAT_Read(tVFS_Node *node, Uint64 offset, Uint64 length, void *buffer);\r
Uint64 FAT_Write(tVFS_Node *node, Uint64 offset, Uint64 length, void *buffer);\r
void FAT_CloseFile(tVFS_Node *node);\r
\r
// === SEMI-GLOBALS ===\r
-MODULE_DEFINE(0, 0x5B /*v0.90*/, FAT32, FAT_Install, NULL);\r
+MODULE_DEFINE(0, 0x51 /*v0.80*/, FAT32, FAT_Install, NULL);\r
tFAT_VolInfo gFAT_Disks[8];\r
int giFAT_PartCount = 0;\r
#if CACHE_FAT\r
}\r
\r
/**\r
- * \fn tVFS_Node *FAT_InitDevice(char *Device, char *options)\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
+tVFS_Node *FAT_InitDevice(char *Device, char **options)\r
{\r
fat_bootsect *bs;\r
int i;\r
fat_cache[giFAT_PartCount][i] = buf[i&127];\r
}\r
}\r
- DEBUGS(" FAT_InitDisk: FAT Fully Cached\n");\r
+ LOG("FAT Fully Cached");\r
}\r
#endif /*CACHE_FAT*/\r
\r
//Initalise inode cache for FAT\r
gFAT_Disks[giFAT_PartCount].inodeHandle = Inode_GetHandle();\r
- \r
- #if DEBUG\r
- Log(" FAT_InitDisk: Inode Cache handle is %i\n", gFAT_Disks[giFAT_PartCount].inodeHandle);\r
- #endif\r
+ LOG("Inode Cache handle is %i", gFAT_Disks[giFAT_PartCount].inodeHandle);\r
\r
// == VFS Interface\r
node = &gFAT_Disks[giFAT_PartCount].rootNode;\r
*/\r
static void FAT_int_ReadCluster(int Handle, Uint32 Cluster, int Length, void *Buffer)\r
{\r
- #if DEBUG\r
ENTER("iHandle xCluster iLength pBuffer", Handle, Cluster, Length, Buffer);\r
- #endif\r
VFS_ReadAt(\r
gFAT_Disks[Handle].fileHandle,\r
(gFAT_Disks[Handle].firstDataSect + (Cluster-2)*gFAT_Disks[Handle].bootsect.spc )\r
Length,\r
Buffer\r
);\r
- #if DEBUG\r
LEAVE('-');\r
- #endif\r
}\r
\r
/**\r
}\r
\r
// Sanity Check offset\r
- if(offset > node->Size){\r
+ if(offset > node->Size) {\r
+ //Log("FAT_Read: Reading past EOF (%i > %i)", offset, node->Size);\r
return 0;\r
}\r
// Clamp Size\r
- if(length + offset > node->Size) {\r
- length = offset - node->Size;\r
+ if(offset + length > node->Size) {\r
+ //Log("FAT_Read: 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
// Single Cluster including offset\r