#include "ext2_common.h"\r
#include <modules.h>\r
\r
+// === IMPORTS ===\r
+extern tVFS_NodeType gExt2_DirType;\r
+\r
// === PROTOTYPES ===\r
int Ext2_Install(char **Arguments);\r
// Interface Functions\r
-tVFS_Node *Ext2_InitDevice(char *Device, char **Options);\r
+tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options);\r
void Ext2_Unmount(tVFS_Node *Node);\r
void Ext2_CloseFile(tVFS_Node *Node);\r
// Internal Helpers\r
};\r
\r
// === CODE ===\r
-\r
/**\r
* \fn int Ext2_Install(char **Arguments)\r
* \brief Install the Ext2 Filesystem Driver\r
}\r
\r
/**\r
- \fn tVFS_Node *Ext2_InitDevice(char *Device, char **Options)\r
\brief Initializes a device to be read by by the driver\r
\param Device String - Device to read from\r
\param Options NULL Terminated array of option strings\r
\return Root Node\r
*/\r
-tVFS_Node *Ext2_InitDevice(char *Device, char **Options)\r
+tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options)\r
{\r
tExt2_Disk *disk;\r
int fd;\r
// Open Disk\r
fd = VFS_Open(Device, VFS_OPENFLAG_READ|VFS_OPENFLAG_WRITE); //Open Device\r
if(fd == -1) {\r
- Warning("[EXT2 ] Unable to open '%s'", Device);\r
+ Log_Warning("EXT2", "Unable to open '%s'", Device);\r
LEAVE('n');\r
return NULL;\r
}\r
\r
// Sanity Check Magic value\r
if(sb.s_magic != 0xEF53) {\r
- Warning("[EXT2 ] Volume '%s' is not an EXT2 volume", Device);\r
+ Log_Warning("EXT2", "Volume '%s' is not an EXT2 volume (0x%x != 0xEF53)",\r
+ Device, sb.s_magic);\r
VFS_Close(fd);\r
LEAVE('n');\r
return NULL;\r
// Allocate Disk Information\r
disk = malloc(sizeof(tExt2_Disk) + sizeof(tExt2_Group)*groupCount);\r
if(!disk) {\r
- Warning("[EXT2 ] Unable to allocate disk structure");\r
+ Log_Warning("EXT2", "Unable to allocate disk structure");\r
VFS_Close(fd);\r
LEAVE('n');\r
return NULL;\r
disk->RootNode.ImplPtr = disk; // Save disk pointer\r
disk->RootNode.Size = -1; // Fill in later (on readdir)\r
disk->RootNode.Flags = VFS_FFLAG_DIRECTORY;\r
- \r
- disk->RootNode.ReadDir = Ext2_ReadDir;\r
- disk->RootNode.FindDir = Ext2_FindDir;\r
- //disk->RootNode.Relink = Ext2_Relink;\r
+\r
+ disk->RootNode.Type = &gExt2_DirType;\r
\r
// Complete root node\r
disk->RootNode.UID = inode.i_uid;\r
{\r
int group, subId;\r
\r
- //ENTER("pDisk iInodeId pInode", Disk, InodeId, Inode);\r
+ ENTER("pDisk iInodeId pInode", Disk, InodeId, Inode);\r
\r
if(InodeId == 0) return 0;\r
\r
group = InodeId / Disk->SuperBlock.s_inodes_per_group;\r
subId = InodeId % Disk->SuperBlock.s_inodes_per_group;\r
\r
- //LOG("group=%i, subId = %i", group, subId);\r
+ LOG("group=%i, subId = %i", group, subId);\r
\r
// Read Inode\r
VFS_ReadAt(Disk->FD,\r
sizeof(tExt2_Inode),\r
Inode);\r
\r
- //LEAVE('i', 1);\r
+ LEAVE('i', 1);\r
return 1;\r
}\r
\r
int group, subId;\r
ENTER("pDisk iInodeId pInode", Disk, InodeId, Inode);\r
\r
- if(InodeId == 0) return 0;\r
+ if(InodeId == 0) {\r
+ LEAVE('i', 0);\r
+ return 0;\r
+ }\r
\r
InodeId --; // Inodes are numbered starting at 1\r
\r
VFS_WriteAt(Disk->FD,\r
Disk->Groups[group].bg_inode_table * Disk->BlockSize + sizeof(tExt2_Inode)*subId,\r
sizeof(tExt2_Inode),\r
- Inode);\r
+ Inode\r
+ );\r
\r
LEAVE('i', 1);\r
return 1;\r
Uint32 Ext2_int_AllocateInode(tExt2_Disk *Disk, Uint32 Parent)\r
{\r
// Uint block = (Parent - 1) / Disk->SuperBlock.s_inodes_per_group;\r
+ Log_Warning("EXT2", "Ext2_int_AllocateInode is unimplemented");\r
return 0;\r
}\r
\r
if(ngrp <= 1) return;\r
VFS_WriteAt(Disk->FD, 1*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock);\r
\r
+ #define INT_MAX (((long long int)1<<(sizeof(int)*8))-1)\r
+ \r
// Powers of 3\r
- for( i = 3; i < ngrp; i *= 3 )\r
+ for( i = 3; i < ngrp && i < INT_MAX/3; i *= 3 )\r
VFS_WriteAt(Disk->FD, i*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock);\r
\r
// Powers of 5\r
- for( i = 5; i < ngrp; i *= 5 )\r
+ for( i = 5; i < ngrp && i < INT_MAX/5; i *= 5 )\r
VFS_WriteAt(Disk->FD, i*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock);\r
\r
// Powers of 7\r
- for( i = 7; i < ngrp; i *= 7 )\r
+ for( i = 7; i < ngrp && i < INT_MAX/7; i *= 7 )\r
VFS_WriteAt(Disk->FD, i*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock);\r
}\r