X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fvfs%2Ffs%2Fext2.c;h=0b60e5427930921cc559588ee7e433d0d88d6844;hb=3c777e58e6baba6760f43b8fdde4daf62081048b;hp=50be904a8317268b9328dba925ecb78dc26588d0;hpb=b6c3b3cf61caafbd91bbf3acc81995e472656a5b;p=tpg%2Facess2.git diff --git a/Kernel/vfs/fs/ext2.c b/Kernel/vfs/fs/ext2.c index 50be904a..0b60e542 100644 --- a/Kernel/vfs/fs/ext2.c +++ b/Kernel/vfs/fs/ext2.c @@ -5,9 +5,10 @@ /** * \file fs/ext2.c * \brief Second Extended Filesystem Driver - * \todo Implement file read support + * \todo Implement file full write support */ #define DEBUG 1 +#define VERBOSE 0 #include #include #include @@ -69,7 +70,7 @@ int Ext2_Install(char **Arguments) } /** - \fn tVFS_Node *Ext2_initDevice(char *Device, char **Options) + \fn tVFS_Node *Ext2_InitDevice(char *Device, char **Options) \brief Initializes a device to be read by by the driver \param Device String - Device to read from \param Options NULL Terminated array of option strings @@ -88,7 +89,7 @@ tVFS_Node *Ext2_InitDevice(char *Device, char **Options) // Open Disk fd = VFS_Open(Device, VFS_OPENFLAG_READ|VFS_OPENFLAG_WRITE); //Open Device if(fd == -1) { - Warning("[EXT2 ] Unable to open '%s'\n", Device); + Warning("[EXT2 ] Unable to open '%s'", Device); LEAVE('n'); return NULL; } @@ -98,7 +99,7 @@ tVFS_Node *Ext2_InitDevice(char *Device, char **Options) // Sanity Check Magic value if(sb.s_magic != 0xEF53) { - Warning("[EXT2 ] Volume '%s' is not an EXT2 volume\n", Device); + Warning("[EXT2 ] Volume '%s' is not an EXT2 volume", Device); VFS_Close(fd); LEAVE('n'); return NULL; @@ -111,7 +112,7 @@ tVFS_Node *Ext2_InitDevice(char *Device, char **Options) // Allocate Disk Information disk = malloc(sizeof(tExt2_Disk) + sizeof(tExt2_Group)*groupCount); if(!disk) { - Warning("[EXT2 ] Unable to allocate disk structure\n"); + Warning("[EXT2 ] Unable to allocate disk structure"); VFS_Close(fd); LEAVE('n'); return NULL; @@ -135,7 +136,7 @@ tVFS_Node *Ext2_InitDevice(char *Device, char **Options) disk->Groups ); - #if DEBUG + #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); @@ -218,7 +219,7 @@ Uint64 Ext2_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) Offset = Offset / disk->BlockSize; base = Ext2_int_GetBlockAddr(disk, inode.i_block, block); if(base == 0) { - Warning("[EXT2 ] NULL Block Detected in INode 0x%llx\n", Node->Inode); + Warning("[EXT2 ] NULL Block Detected in INode 0x%llx", Node->Inode); LEAVE('i', 0); return 0; } @@ -243,7 +244,7 @@ Uint64 Ext2_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) { base = Ext2_int_GetBlockAddr(disk, inode.i_block, block); if(base == 0) { - Warning("[EXT2 ] NULL Block Detected in INode 0x%llx\n", Node->Inode); + Warning("[EXT2 ] NULL Block Detected in INode 0x%llx", Node->Inode); LEAVE('i', 0); return 0; } @@ -336,7 +337,7 @@ addBlocks: } /** - * \fn void Ext2_CloseFile(vfs_node *Node) + * \fn void Ext2_CloseFile(tVFS_Node *Node) * \brief Close a file (Remove it from the cache) */ void Ext2_CloseFile(tVFS_Node *Node) @@ -367,7 +368,7 @@ char *Ext2_ReadDir(tVFS_Node *Node, int Pos) Ext2_int_GetInode(Node, &inode); size = inode.i_size; - LOG("inode.i_block[0] = 0x%x\n", inode.i_block[0]); + LOG("inode.i_block[0] = 0x%x", inode.i_block[0]); // Find Entry // Get First Block @@ -383,7 +384,7 @@ char *Ext2_ReadDir(tVFS_Node *Node, int Pos) if(ofs >= disk->BlockSize) { block ++; if( ofs > disk->BlockSize ) { - Warning("[EXT2] Directory Entry %i of inode %i extends over a block boundary, ignoring\n", + Warning("[EXT2] Directory Entry %i of inode %i extends over a block boundary, ignoring", entNum-1, Node->Inode); } ofs = 0; @@ -391,13 +392,17 @@ char *Ext2_ReadDir(tVFS_Node *Node, int Pos) } } - if(size <= 0) return NULL; + // Check for the end of the list + if(size <= 0) { + LEAVE('n'); + return NULL; + } // Read Entry VFS_ReadAt( disk->FD, Base+ofs, sizeof(tExt2_DirEnt), &dirent ); - //LOG("dirent.inode = %i\n", dirent.inode); - //LOG("dirent.rec_len = %i\n", dirent.rec_len); - //LOG("dirent.name_len = %i\n", dirent.name_len); + //LOG("dirent.inode = %i", dirent.inode); + //LOG("dirent.rec_len = %i", dirent.rec_len); + //LOG("dirent.name_len = %i", dirent.name_len); VFS_ReadAt( disk->FD, Base+ofs+sizeof(tExt2_DirEnt), dirent.name_len, namebuf ); namebuf[ dirent.name_len ] = '\0'; // Cap off string @@ -457,7 +462,7 @@ tVFS_Node *Ext2_FindDir(tVFS_Node *Node, char *Filename) if(ofs >= disk->BlockSize) { block ++; if( ofs > disk->BlockSize ) { - Warning("[EXT2 ] Directory Entry %i of inode %i extends over a block boundary, ignoring\n", + Warning("[EXT2 ] Directory Entry %i of inode %i extends over a block boundary, ignoring", entNum-1, Node->Inode); } ofs = 0; @@ -483,11 +488,11 @@ int Ext2_MkNod(tVFS_Node *Parent, char *Name, Uint Flags) /** - \fn int Ext2_int_GetInode(vfs_node *Node, tExt2_Inode *Inode) - \brief Gets the inode descriptor for a node - \param node node to get the Inode of - \param inode Destination -*/ + * \fn int Ext2_int_GetInode(tVFS_Node *Node, tExt2_Inode *Inode) + * \brief Gets the inode descriptor for a node + * \param Node node to get the Inode of + * \param Inode Destination + */ int Ext2_int_GetInode(tVFS_Node *Node, tExt2_Inode *Inode) { return Ext2_int_ReadInode(Node->ImplPtr, Node->Inode, Inode); @@ -573,7 +578,8 @@ int Ext2_int_ReadInode(tExt2_Disk *Disk, Uint InodeId, tExt2_Inode *Inode) { int group, subId; - //LogF("Ext2_int_ReadInode: (Disk=%p, InodeId=%i, Inode=%p)\n", Disk, InodeId, Inode); + //LogF("Ext2_int_ReadInode: (Disk=%p, InodeId=%i, Inode=%p)", Disk, InodeId, Inode); + //ENTER("pDisk iInodeId pInode", Disk, InodeId, Inode); if(InodeId == 0) return 0; @@ -582,7 +588,7 @@ int Ext2_int_ReadInode(tExt2_Disk *Disk, Uint InodeId, tExt2_Inode *Inode) group = InodeId / Disk->SuperBlock.s_inodes_per_group; subId = InodeId % Disk->SuperBlock.s_inodes_per_group; - //LogF(" Ext2_int_ReadInode: group=%i, subId = %i\n", group, subId); + //LOG("group=%i, subId = %i", group, subId); // Read Inode VFS_ReadAt(Disk->FD,