Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
dentry.h File Reference
#include "llist.h"
#include "vfs/cache.h"
#include "vfs/rcu.h"
#include <string.h>
#include <type.h>
#include <vector.h>

Go to the source code of this file.

Data Structures

struct  dentry
 

Macros

#define DENTRY_PINNED   (1 << 0)
 
#define DENTRY_NEGATIVE   (1 << 1)
 
#define DENTRY_MOUNTPOINT   (1 << 2)
 

Typedefs

typedef struct dentry dentry_t
 
typedef struct dentrydentry_ptr
 
typedef struct vnodevnode_ptr_t
 

Enumerations

enum  { RESOLVE_LAST_ENTRY = (1 << 1) , CREATE_MISSING_ENTRY = (1 << 2) }
 

Functions

struct dentry __attribute__ ((aligned(64)))
 
int vxnamei (const char *path, dentry_ptr *out)
 Resolves a file path to a directory entry (dentry).
 
dentry_ptr __attribute__ ((used, visibility("default"), section(".export"))) create_dentry(kstring name
 This function handles memory allocation for a new dentry using the slab allocator.
 
void vxSetDentryAsRoot (dentry_ptr dentry)
 
dentry_ptr get_root_dentry ()
 
int resolve_dentry (char *path, dentry_ptr parent, dentry_ptr *out, uint8_t flag)
 Resolves a path to a directory entry (dentry) with configurable start point and strictness.
 
void vxFreeDentry (dentry_ptr dentry)
 
void vxFreeDentryWithChildren (dentry_ptr dentry)
 
void vxAttachDentryToVnode (dentry_ptr dentry, vnode_ptr_t vnode)
 
uint32_t hash_dentry (const char *name, dentry_ptr parent)
 
void dentry_put (dentry_ptr dentry)
 
void dentry_get (dentry_ptr dentry)
 
void delete_dentry (dentry_t *node)
 
int get_reffcount (dentry_ptr dentry)
 
void print_dentry_tree (dentry_t *node, int depth)
 
kstring get_full_path_from_dentry (dentry_ptr dentry)
 

Variables

struct llist_head child_list
 
atomic_t refcount
 
uint32_t hash
 
uint32_t flags
 
kstring name
 
struct vnode * vnode
 
dentry_ptr parent
 
struct hlist_node hash_node
 
struct rcu_head rcu
 
enum { ... }  __attribute__
 

Macro Definition Documentation

◆ DENTRY_MOUNTPOINT

#define DENTRY_MOUNTPOINT   (1 << 2)

Definition at line 13 of file dentry.h.

◆ DENTRY_NEGATIVE

#define DENTRY_NEGATIVE   (1 << 1)

Definition at line 12 of file dentry.h.

◆ DENTRY_PINNED

#define DENTRY_PINNED   (1 << 0)

Definition at line 11 of file dentry.h.

Typedef Documentation

◆ dentry_ptr

typedef struct dentry* dentry_ptr

Definition at line 20 of file dentry.h.

◆ dentry_t

typedef struct dentry dentry_t

Definition at line 19 of file dentry.h.

◆ vnode_ptr_t

typedef struct vnode* vnode_ptr_t

Definition at line 115 of file dentry.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
RESOLVE_LAST_ENTRY 
CREATE_MISSING_ENTRY 

Definition at line 79 of file dentry.h.

Function Documentation

◆ __attribute__() [1/2]

struct dentry __attribute__ ( (aligned(64)) )

Definition at line 1 of file core.h.

◆ __attribute__() [2/2]

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.

References KERNEL_API, name, and parent.

◆ delete_dentry()

void delete_dentry ( dentry_t * node)

◆ 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().

◆ get_root_dentry()

dentry_ptr get_root_dentry ( )

Referenced by execve().

◆ 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()

◆ resolve_dentry()

int resolve_dentry ( char * path,
dentry_ptr parent,
dentry_ptr * out,
uint8_t flag )

Resolves a path to a directory entry (dentry) with configurable start point and strictness.

This function traverses the filesystem path. It differs from vxNamei by allowing a specific parent dentry to start from, and it can handle cases where the final component of the path does not exist yet (controlled by flags).

Parameters
pathThe file path to resolve (can be relative or absolute).
parentThe dentry to start the search from. If NULL, starts from root_dentry.
outDouble pointer to store the resulting dentry.
flagBitmask to modify behavior.
  • If RESOLVE_LAST_ENTRY is set: If a path component is missing, the function stops, sets *out to the current directory (the parent), and returns the index of the missing component. This is useful when creating new files/directories.
Returns
int
  • VFS_OK: The full path was successfully resolved to an existing dentry.
  • VFS_ENOENT: A directory in the path was missing (and no flag was set).
  • [Index]: If RESOLVE_LAST_ENTRY was set and the target was missing, returns the index of the missing component in the path.

References parent, and path.

Referenced by __attribute__(), __attribute__(), create_process(), execve(), INIT(), library_register(), and vxVoxmoInstall().

◆ vxAttachDentryToVnode()

void vxAttachDentryToVnode ( dentry_ptr dentry,
vnode_ptr_t vnode )

References name, and parent.

◆ vxFreeDentry()

void vxFreeDentry ( dentry_ptr dentry)

◆ vxFreeDentryWithChildren()

void vxFreeDentryWithChildren ( dentry_ptr dentry)

◆ vxnamei()

int vxnamei ( const char * path,
dentry_ptr * out )

Resolves a file path to a directory entry (dentry).

This function traverses the filesystem tree starting from the root dentry. It tokenizes the input path and iterates through the directory structure.

Behavior:

  • If an intermediate directory in the path is missing, the function fails.
  • If the final component of the path is missing, a new dentry is created.
Parameters
pathThe null-terminated string representing the absolute path to resolve.
outA pointer to a dentry pointer. On success, this will be updated to point to the resolved (or newly created) dentry.
Returns
int Returns VFS_OK on success, or 0 if an intermediate directory was not found.

References path.

Referenced by __attribute__(), configure_tty(), ATAPIModule::identify(), INIT(), and INIT().

◆ vxSetDentryAsRoot()

void vxSetDentryAsRoot ( dentry_ptr dentry)

Definition at line 84 of file dentry.c.

References root_dentry.

Referenced by INIT().

Variable Documentation

◆ []

enum { ... } __attribute__

◆ child_list

struct llist_head child_list

Definition at line 0 of file dentry.h.

◆ flags

uint32_t flags

Definition at line 4 of file dentry.h.

◆ hash

◆ hash_node

struct hlist_node hash_node

Definition at line 8 of file dentry.h.

Referenced by cache_lookup().

◆ name

◆ parent

◆ rcu

struct rcu_head rcu

Definition at line 9 of file dentry.h.

Referenced by dentry_free_rcu().

◆ refcount

atomic_t refcount

Definition at line 2 of file dentry.h.

◆ vnode

dentry_ptr struct vnode * vnode

Definition at line 6 of file dentry.h.