From d31175a3542b5139e11b5835b1a50df0b06954fa Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 23 Jun 2013 14:42:00 +0800 Subject: [PATCH] Kernel/VFS - Update to node cache to support extra allocated data --- KernelLand/Kernel/include/vfs.h | 1 + KernelLand/Kernel/vfs/nodecache.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/KernelLand/Kernel/include/vfs.h b/KernelLand/Kernel/include/vfs.h index 82e6b56f..d2cdf204 100644 --- a/KernelLand/Kernel/include/vfs.h +++ b/KernelLand/Kernel/include/vfs.h @@ -518,6 +518,7 @@ extern tVFS_Node *Inode_GetCache(int Handle, Uint64 Inode); * \return A pointer to the node in the node cache */ extern tVFS_Node *Inode_CacheNode(int Handle, tVFS_Node *Node); +extern tVFS_Node *Inode_CacheNodeEx(int Handle, tVFS_Node *Node, size_t Size); /** * \fn int Inode_UncacheNode(int Handle, Uint64 Inode) * \brief Dereferences (and removes if needed) a node from the cache diff --git a/KernelLand/Kernel/vfs/nodecache.c b/KernelLand/Kernel/vfs/nodecache.c index b2cc57fa..aee1826e 100644 --- a/KernelLand/Kernel/vfs/nodecache.c +++ b/KernelLand/Kernel/vfs/nodecache.c @@ -83,10 +83,17 @@ tVFS_Node *Inode_GetCache(int Handle, Uint64 Inode) * \fn tVFS_Node *Inode_CacheNode(int Handle, tVFS_Node *Node) */ tVFS_Node *Inode_CacheNode(int Handle, tVFS_Node *Node) +{ + return Inode_CacheNodeEx(Handle, Node, sizeof(*Node)); +} + +tVFS_Node *Inode_CacheNodeEx(int Handle, tVFS_Node *Node, size_t Size) { tInodeCache *cache; tCachedInode *newEnt, *ent, *prev = NULL; - + + ASSERT(Size >= sizeof(tVFS_Node)); + cache = Inode_int_GetFSCache(Handle); if(!cache) return NULL; @@ -106,9 +113,9 @@ tVFS_Node *Inode_CacheNode(int Handle, tVFS_Node *Node) } // Create new entity - newEnt = malloc(sizeof(tCachedInode)); + newEnt = malloc(sizeof(tCachedInode) + (Size - sizeof(tVFS_Node))); newEnt->Next = ent; - memcpy(&newEnt->Node, Node, sizeof(tVFS_Node)); + memcpy(&newEnt->Node, Node, Size); if( prev ) prev->Next = newEnt; else -- 2.20.1