Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
dentry.c File Reference
#include <hash.h>
#include <llist.h>
#include <str.h>
#include <string.h>
#include <type.h>
#include <vector.h>
#include <vfs/dentry.h>
#include "libk/serial.h"
#include "memory/kalloc.h"
#include "memory/slab.h"
#include "vfs/cache.h"
#include "vfs/dev.h"
#include "vfs/enum.h"
#include "vfs/rcu.h"
#include "vfs/vnode.h"
#include <spinlock.h>

Go to the source code of this file.

Functions

uint32_t hash_dentry (const char *name, dentry_ptr parent)
 
dentry_ptr __attribute__ ((used, visibility("default"), section(".export")))
 This function handles memory allocation for a new dentry using the slab allocator.
 
static void dentry_free_rcu (struct rcu_head *head)
 
void dentry_get (dentry_ptr dentry)
 
void dentry_put (dentry_ptr dentry)
 
void vxSetDentryAsRoot (dentry_ptr dentry)
 
void delete_dentry (dentry_t *node)
 
void print_dentry_tree (dentry_t *dentry, int depth)
 
int get_reffcount (dentry_ptr dentry)
 
kstring get_full_path_from_dentry (dentry_ptr dentry)
 

Variables

static struct slab_cachedentry_cache = 0
 
static dentry_troot_dentry = 0
 
static spinlock_t lock = {0}
 

Function Documentation

◆ __attribute__()

dentry_ptr __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 36 of file dentry.c.

References dentry::child_list, atomic_t::counter, hlist_node::dentry, dentry_cache, dentry::hash, hash_dentry(), dentry::hash_node, KERNEL_API, llist_init(), lock, memset(), dentry::name, name, hlist_node::next, dentry::parent, parent, hlist_node::prev, dentry::refcount, spin_acquire(), spin_release(), dentry::vnode, vxCreateSlabCache(), and vxSlabAlloc().

◆ delete_dentry()

void delete_dentry ( dentry_t * node)

◆ dentry_free_rcu()

static void dentry_free_rcu ( struct rcu_head * head)
static

Definition at line 63 of file dentry.c.

References container_of, dentry_cache, head, rcu, and slab_free().

Referenced by dentry_put().

◆ dentry_get()

void dentry_get ( dentry_ptr dentry)

Definition at line 68 of file dentry.c.

References atomic_t::counter, and dentry::refcount.

Referenced by vfs_umount().

◆ dentry_put()

◆ get_full_path_from_dentry()

kstring get_full_path_from_dentry ( dentry_ptr dentry)

◆ get_reffcount()

int get_reffcount ( dentry_ptr dentry)

Definition at line 352 of file dentry.c.

References atomic_t::counter, and dentry::refcount.

Referenced by vfs_umount_recursive().

◆ hash_dentry()

uint32_t hash_dentry ( const char * name,
dentry_ptr parent )
inline

Definition at line 24 of file dentry.c.

References h, hash32(), name, and parent.

Referenced by __attribute__(), and cache_lookup().

◆ print_dentry_tree()

◆ vxSetDentryAsRoot()

void vxSetDentryAsRoot ( dentry_ptr dentry)

Definition at line 84 of file dentry.c.

References root_dentry.

Referenced by INIT().

Variable Documentation

◆ dentry_cache

struct slab_cache* dentry_cache = 0
static

Definition at line 21 of file dentry.c.

Referenced by __attribute__(), and dentry_free_rcu().

◆ lock

spinlock_t lock = {0}
static

Definition at line 34 of file dentry.c.

◆ root_dentry

dentry_t* root_dentry = 0
static

Definition at line 22 of file dentry.c.

Referenced by vxSetDentryAsRoot().