Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
dev.c File Reference
#include "vfs/dev.h"
#include <hash.h>
#include <libk/serial.h>
#include <memory/memory_utils.h>
#include <memory/phys_base_allocator.h>
#include <memory/slab.h>
#include <str.h>
#include <type.h>

Go to the source code of this file.

Data Structures

struct  minor_map
 

Functions

static int32_t alloc_minor (uint32_t major)
 
 __attribute__ ((used, visibility("default"), section(".export")))
 This function handles memory allocation for a new dentry using the slab allocator.
 

Variables

static cdev_ptr_t dev_chain = 0
 
static struct slab_cacheblock_device_cache = 0
 
static struct minor_map major_map [256] = {0}
 

Function Documentation

◆ __attribute__()

__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 62 of file dev.c.

References alloc_minor(), block_device_cache, dev_chain, KERNEL_API, cdev::major, major, cdev::minor, minor, cdev::ops, ops, slab_free(), vxCreateSlabCache(), and vxSlabAlloc().

◆ alloc_minor()

static int32_t alloc_minor ( uint32_t major)
static

Definition at line 39 of file dev.c.

References DEV_MINOR_BITMAP_COUNT, major, and major_map.

Referenced by __attribute__().

Variable Documentation

◆ block_device_cache

struct slab_cache* block_device_cache = 0
static

Definition at line 31 of file dev.c.

Referenced by __attribute__().

◆ dev_chain

cdev_ptr_t dev_chain = 0
static

Definition at line 30 of file dev.c.

Referenced by __attribute__().

◆ major_map

struct minor_map major_map[256] = {0}
static

Definition at line 37 of file dev.c.

Referenced by alloc_minor().