X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FFilesystems%2FExt2%2Fext2.c;h=460c4fbbd861e34013a385ae968dc9084ed8bcaf;hb=8e54c94fa54a975f1eea55e4dda475251d5445b6;hp=971ef28ed538e185dc73c63c83289dce872727b4;hpb=891868f0b4d64eb274b5810ac0c4f0a53d104114;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/Filesystems/Ext2/ext2.c b/KernelLand/Modules/Filesystems/Ext2/ext2.c index 971ef28e..460c4fbb 100644 --- a/KernelLand/Modules/Filesystems/Ext2/ext2.c +++ b/KernelLand/Modules/Filesystems/Ext2/ext2.c @@ -17,15 +17,16 @@ extern tVFS_NodeType gExt2_DirType; int Ext2_Install(char **Arguments); int Ext2_Cleanup(void); // - Interface Functions - int Ext2_Detect(int FD); + int Ext2_Detect(int FD); tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options); -void Ext2_Unmount(tVFS_Node *Node); -void Ext2_CloseFile(tVFS_Node *Node); +void Ext2_Unmount(tVFS_Node *Node); +void Ext2_CloseFile(tVFS_Node *Node); // - 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); + 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_DereferenceInode(tExt2_Disk *Disk, Uint32 Inode); +void Ext2_int_UpdateSuperblock(tExt2_Disk *Disk); // === SEMI-GLOBALS === MODULE_DEFINE(0, VERSION, FS_Ext2, Ext2_Install, Ext2_Cleanup); @@ -208,7 +209,40 @@ void Ext2_Unmount(tVFS_Node *Node) void Ext2_CloseFile(tVFS_Node *Node) { tExt2_Disk *disk = Node->ImplPtr; - Inode_UncacheNode(disk->CacheID, Node->Inode); + ENTER("pNode", Node); + + if( Mutex_Acquire(&Node->Lock) != 0 ) + { + LEAVE('-'); + return ; + } + + if( Node->Flags & VFS_FFLAG_DIRTY ) + { + // Commit changes + Log_Warning("Ext2", "TODO: Commit node changes"); + } + + int was_not_referenced = (Node->ImplInt == 0); + tVFS_ACL *acls = Node->ACLs; + if( Inode_UncacheNode(disk->CacheID, Node->Inode) == 1 ) + { + if( was_not_referenced ) + { + LOG("Removng inode"); + // Remove inode + Log_Warning("Ext2", "TODO: Remove inode when not deleted"); + } + if( acls != &gVFS_ACL_EveryoneRW ) { + free(acls); + } + LOG("Node cleaned"); + } + else { + LOG("Still referenced, releasing lock"); + Mutex_Release(&Node->Lock); + } + LEAVE('-'); return ; } @@ -337,6 +371,14 @@ Uint32 Ext2_int_AllocateInode(tExt2_Disk *Disk, Uint32 Parent) return 0; } +/** + * \brief Reduce the reference count on an inode + */ +void Ext2_int_DereferenceInode(tExt2_Disk *Disk, Uint32 Inode) +{ + +} + /** * \fn void Ext2_int_UpdateSuperblock(tExt2_Disk *Disk) * \brief Updates the superblock