Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
cache.c File Reference
#include "autoconf.h"
#include "init/init.h"
#include "libk/serial.h"
#include "llist.h"
#include "type.h"
#include <hash.h>
#include <str.h>
#include <vfs/cache.h>
#include <vfs/dentry.h>

Go to the source code of this file.

Functions

 INIT (VfsCache)
 
struct vfs_cachecreate_vfs_cache ()
 
void hlist_add_head (struct hlist_node *n, struct hlist_head *h)
 
static void hlist_del (struct hlist_node *n, struct hlist_head *h)
 
 __attribute__ ((always_inline))
 
struct dentrycache_lookup (struct vfs_cache *cache, struct dentry *parent, const char *name)
 
void cache_remove (struct vfs_cache *cache, struct dentry *dentry)
 
 __attribute__ ((used, visibility("default"), section(".export")))
 This function handles memory allocation for a new dentry using the slab allocator.
 

Variables

static struct vfs_cachecache_ = 0
 

Function Documentation

◆ __attribute__() [1/2]

◆ __attribute__() [2/2]

__attribute__ ( (used, visibility("default"), section(".export")) )

This function handles memory allocation for a new dentry using the slab allocator.

It also links the dentry to its corresponding VNode (if provided).

Note
This function performs lazy initialization of the dentry slab cache if it does not exist yet.
Parameters
nameThe name of the file or directory.
vnodePointer to the associated VNode (inode data). Pass NULL if the VNode is not yet available.
Returns
dentry_ptr A pointer to the newly allocated and initialized dentry.

Definition at line 127 of file cache.c.

References cache_, and KERNEL_API.

◆ cache_lookup()

struct dentry * cache_lookup ( struct vfs_cache * cache,
struct dentry * parent,
const char * name )

◆ cache_remove()

void cache_remove ( struct vfs_cache * cache,
struct dentry * dentry )

Definition at line 116 of file cache.c.

References cache, dentry::hash, dentry::hash_node, hlist_del(), idx, and VFS_CACHE_SIZE.

Referenced by delete_dentry(), and vfs_umount_recursive().

◆ create_vfs_cache()

struct vfs_cache * create_vfs_cache ( )

Definition at line 39 of file cache.c.

References cache, kalloc(), memset(), and serial2_printf().

Referenced by INIT().

◆ hlist_add_head()

void hlist_add_head ( struct hlist_node * n,
struct hlist_head * h )

Definition at line 49 of file cache.c.

References h, hlist_node::next, NULL, and hlist_node::prev.

Referenced by __attribute__().

◆ hlist_del()

static void hlist_del ( struct hlist_node * n,
struct hlist_head * h )
static

Definition at line 58 of file cache.c.

References h, hlist_node::next, NULL, and hlist_node::prev.

Referenced by cache_remove().

◆ INIT()

INIT ( VfsCache )

Definition at line 34 of file cache.c.

References cache_, create_vfs_cache(), and serial2_printf().

Variable Documentation

◆ cache_

struct vfs_cache* cache_ = 0
static

Definition at line 32 of file cache.c.

Referenced by __attribute__(), and INIT().