AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
vcache.h File Reference
#include <fs/vfs.h>
#include <ds/hashmap.h>

Go to the source code of this file.

Data Structures

struct  vcache
 A filesystem's vnode cache (fs/vcache.c): its vnodes in memory, by their inode number, so that a file has one vnode however it's reached. More...

Functions

void vcache_init (struct vcache *vcache)
 Sets up an empty vnode cache.
int vcache_insert (struct vcache *vcache, struct vnode *vnode)
 Adds a vnode to a cache.
int vcache_remove (struct vcache *vcache, struct vnode *vnode)
 Takes a vnode out of a cache.
struct vnode * vcache_find (struct vcache *vcache, ino_t ino)
 Finds the cached vnode of an inode.

Function Documentation

◆ vcache_find()

struct vnode * vcache_find ( struct vcache * vcache,
ino_t ino )

Finds the cached vnode of an inode.

Parameters
vcachethe cache
inothe inode number
Returns
the vnode, or NULL if it isn't cached

Definition at line 80 of file vcache.c.

References hashmap_node::entry, hashmap_node::hash, vcache::hashmap, vnode::ino, NULL, and vcache_find().

Referenced by ext2_inode_build(), minix_inode_build(), procfs_close(), procfs_vget(), and vcache_find().

◆ vcache_init()

void vcache_init ( struct vcache * vcache)

Sets up an empty vnode cache.

Parameters
vcachethe cache

Definition at line 25 of file vcache.c.

References vcache::hashmap, vcache_eq(), and vcache_init().

Referenced by ext2_load(), minix_load(), procfs_init(), vcache_init(), and vcache_insert().

◆ vcache_insert()

int vcache_insert ( struct vcache * vcache,
struct vnode * vnode )

Adds a vnode to a cache.

Parameters
vcachethe cache, set up on first use
vnodethe vnode
Returns
0, -EINVAL if vcache is NULL, or -ENOMEM

Definition at line 37 of file vcache.c.

References vcache::hashmap, vnode::ino, vcache_init(), and vcache_insert().

Referenced by ext2_inode_build(), minix_inode_build(), procfs_vget(), and vcache_insert().

◆ vcache_remove()

int vcache_remove ( struct vcache * vcache,
struct vnode * vnode )

Takes a vnode out of a cache.

Parameters
vcachethe cache
vnodethe vnode
Returns
0, or -1 if the vnode wasn't in the cache

Definition at line 56 of file vcache.c.

References hashmap_node::hash, vcache::hashmap, vnode::ino, and vcache_remove().

Referenced by ext2_close(), procfs_close(), and vcache_remove().