From 214f5285816adefadbeff98d04d04d39207c86ef Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 19 May 2012 19:38:33 +0800 Subject: [PATCH] Modules/Ext2 - Little debug removal and code cleanup --- KernelLand/Modules/Filesystems/Ext2/dir.c | 15 +++++---- KernelLand/Modules/Filesystems/Ext2/ext2.c | 36 +++++++++++++--------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/KernelLand/Modules/Filesystems/Ext2/dir.c b/KernelLand/Modules/Filesystems/Ext2/dir.c index 5eb476f4..2a7bc2fe 100644 --- a/KernelLand/Modules/Filesystems/Ext2/dir.c +++ b/KernelLand/Modules/Filesystems/Ext2/dir.c @@ -1,13 +1,11 @@ /* - * Acess OS - * Ext2 Driver Version 1 + * Acess2 Ext2 Driver + * - By John Hodge (thePowersGang) + * + * dir.c + * - Directory Handling */ -/** - * \file dir.c - * \brief Second Extended Filesystem Driver - * \todo Implement file full write support - */ -#define DEBUG 1 +#define DEBUG 0 #define VERBOSE 0 #include "ext2_common.h" @@ -143,6 +141,7 @@ tVFS_Node *Ext2_FindDir(tVFS_Node *Node, const char *Filename) while(size > 0) { VFS_ReadAt( disk->FD, Base+ofs, sizeof(tExt2_DirEnt), &dirent); + // TODO: Possible overrun if name_len == 255? dirent.name[ dirent.name_len ] = '\0'; // Cap off string // If it matches, create a node and return it if(dirent.name_len == filenameLen && strcmp(dirent.name, Filename) == 0) diff --git a/KernelLand/Modules/Filesystems/Ext2/ext2.c b/KernelLand/Modules/Filesystems/Ext2/ext2.c index 7c4bf973..6379a9d0 100644 --- a/KernelLand/Modules/Filesystems/Ext2/ext2.c +++ b/KernelLand/Modules/Filesystems/Ext2/ext2.c @@ -1,14 +1,12 @@ /* - * Acess OS - * Ext2 Driver Version 1 + * Acess2 Ext2 Driver + * - By John Hodge (thePowersGang) + * + * ext2.c + * - Driver core */ -/** - * \file fs/ext2.c - * \brief Second Extended Filesystem Driver - * \todo Implement file full write support - */ -#define DEBUG 1 -#define VERBOSE 0 +#define DEBUG 0 +#define VERSION VER2(0,90) #include "ext2_common.h" #include @@ -17,18 +15,19 @@ extern tVFS_NodeType gExt2_DirType; // === PROTOTYPES === int Ext2_Install(char **Arguments); -// Interface Functions +void Ext2_Cleanup(void); +// - Interface Functions tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options); void Ext2_Unmount(tVFS_Node *Node); void Ext2_CloseFile(tVFS_Node *Node); -// Internal Helpers +// - Internal Helpers int Ext2_int_GetInode(tVFS_Node *Node, tExt2_Inode *Inode); Uint64 Ext2_int_GetBlockAddr(tExt2_Disk *Disk, Uint32 *Blocks, int BlockNum); Uint32 Ext2_int_AllocateInode(tExt2_Disk *Disk, Uint32 Parent); void Ext2_int_UpdateSuperblock(tExt2_Disk *Disk); // === SEMI-GLOBALS === -MODULE_DEFINE(0, 0x5B /*v0.90*/, FS_Ext2, Ext2_Install, NULL); +MODULE_DEFINE(0, VERSION, FS_Ext2, Ext2_Install, Ext2_Cleanup); tExt2_Disk gExt2_disks[6]; int giExt2_count = 0; tVFS_Driver gExt2_FSInfo = { @@ -46,6 +45,14 @@ int Ext2_Install(char **Arguments) return MODULE_ERR_OK; } +/** + * \brief Clean up driver state before unload + */ +void Ext2_Cleanup(void) +{ + +} + /** \brief Initializes a device to be read by by the driver \param Device String - Device to read from @@ -102,10 +109,11 @@ tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options) disk->CacheID = Inode_GetHandle(); // Get Block Size - LOG("s_log_block_size = 0x%x", sb.s_log_block_size); disk->BlockSize = 1024 << sb.s_log_block_size; + LOG("Disk->BlockSie = 0x%x (1024 << %i)", disk->BlockSize, sb.s_log_block_size); // Read Group Information + LOG("sb,s_first_data_block = %x", sb.s_first_data_block); VFS_ReadAt( disk->FD, sb.s_first_data_block * disk->BlockSize + 1024, @@ -113,7 +121,6 @@ tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options) disk->Groups ); - #if VERBOSE LOG("Block Group 0"); LOG(".bg_block_bitmap = 0x%x", disk->Groups[0].bg_block_bitmap); LOG(".bg_inode_bitmap = 0x%x", disk->Groups[0].bg_inode_bitmap); @@ -122,7 +129,6 @@ tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options) LOG(".bg_block_bitmap = 0x%x", disk->Groups[1].bg_block_bitmap); LOG(".bg_inode_bitmap = 0x%x", disk->Groups[1].bg_inode_bitmap); LOG(".bg_inode_table = 0x%x", disk->Groups[1].bg_inode_table); - #endif // Get root Inode Ext2_int_ReadInode(disk, 2, &inode); -- 2.20.1