26 buffer.parentId = parentId;
116 if (name ==
NULL || superblock ==
NULL)
123 if (nameLen >=
MAX_NAME || nameLen == 0)
228 if (dentry ==
NULL || inode ==
NULL)
328 originalBasePath[
MAX_PATH - 1] =
'\0';
403 *offset += bytesWritten;
#define MAX_NAME
Maximum length of names.
#define MAX_PATH
Maximum length of filepaths.
#define assert(expression)
static dentry_t * dentry_cache_get(map_key_t *key)
static rwlock_t dentryCacheLock
static void dentry_cache_remove(dentry_t *dentry)
static map_key_t dentry_cache_key(dentry_id_t parentId, const char *name)
static void getdents_write(getdents_ctx_t *ctx, inode_number_t number, inode_type_t type, const char *name)
static void dentry_free(dentry_t *dentry)
static void getdents_recursive_traversal(getdents_ctx_t *ctx, dentry_t *dentry)
static uint64_t dentry_cache_add(dentry_t *dentry)
void dentry_make_positive(dentry_t *dentry, inode_t *inode)
Make a dentry positive by associating it with an inode.
dentry_t * dentry_new(superblock_t *superblock, dentry_t *parent, const char *name)
Create a new dentry.
uint64_t dentry_id_t
Dentry ID type.
dentry_t * dentry_lookup(const path_t *parent, const char *name)
Lookup a dentry for the given name. Will NOT traverse mountpoints.
bool dentry_is_positive(dentry_t *dentry)
Check if a dentry is positive.
uint64_t dentry_generic_getdents(dentry_t *dentry, dirent_t *buffer, uint64_t count, uint64_t *offset, mode_t mode)
Helper function for a basic getdents.
bool dentry_is_dir(dentry_t *dentry)
Check if the inode associated with a dentry is a directory.
#define DENTRY_IS_ROOT(dentry)
Macro to check if a dentry is the root entry in its filesystem.
dentry_t * dentry_get(const dentry_t *parent, const char *name)
Get a dentry for the given name. Will NOT traverse mountpoints.
bool dentry_is_file(dentry_t *dentry)
Check if the inode associated with a dentry is a file.
@ DENTRY_NEGATIVE
Dentry is negative (no associated inode).
mode_t
Path flags and permissions.
void mutex_release(mutex_t *mtx)
Releases a mutex.
void mutex_acquire(mutex_t *mtx)
Acquires a mutex, blocking until it is available.
#define RWLOCK_READ_SCOPE(lock)
Acquires a rwlock for reading for the reminder of the current scope.
#define RWLOCK_CREATE()
Create a rwlock initializer.
#define RWLOCK_WRITE_SCOPE(lock)
Acquires a rwlock for writing for the reminder of the current scope.
static map_key_t map_key_buffer(const void *buffer, uint64_t length)
Create a map key from a buffer.
void map_entry_init(map_entry_t *entry)
Initialize a map entry.
uint64_t map_insert(map_t *map, const map_key_t *key, map_entry_t *value)
Insert a key-value pair into the map.
void map_remove(map_t *map, map_entry_t *entry)
Remove a entry from the map.
map_entry_t * map_get(map_t *map, const map_key_t *key)
Get a value from the map by key.
#define MAP_CREATE()
Create a map initializer.
static void ref_init(ref_t *ref, void *free)
Initialize a reference counter.
#define REF(ptr)
Increment reference count.
#define UNREF(ptr)
Decrement reference count.
uint64_t vfs_id_get(void)
Generates a new unique ID, to be used for any VFS object.
#define ENOENT
No such file or directory.
#define EEXIST
File exists.
#define EINVAL
Invalid argument.
#define errno
Error number variable.
inode_type_t
Inode type enum.
uint64_t inode_number_t
Inode number enum.
@ INODE_DIR
Is a directory.
#define LIST_FOR_EACH(elem, list, member)
Iterates over a list.
static void list_push_back(list_t *list, list_entry_t *entry)
Pushes an entry to the end of the list.
static void list_remove(list_t *list, list_entry_t *entry)
Removes a list entry from its current list.
static void list_entry_init(list_entry_t *entry)
Initializes a list entry.
static void list_init(list_t *list)
Initializes a list.
#define NULL
Pointer error value.
#define ERR
Integer error value.
#define CONTAINER_OF_SAFE(ptr, type, member)
Safe container of macro.
EFI_PHYSICAL_ADDRESS buffer
#define RFLAGS_INTERRUPT_ENABLE
static uint64_t rflags_read()
#define atomic_fetch_add_explicit(object, operand, order)
#define atomic_load(object)
#define atomic_fetch_and(object, operand)
#define atomic_init(obj, value)
#define atomic_fetch_sub_explicit(object, operand, order)
_PUBLIC int snprintf(char *_RESTRICT s, size_t n, const char *_RESTRICT format,...)
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
_PUBLIC char * strncpy(char *_RESTRICT s1, const char *_RESTRICT s2, size_t n)
_PUBLIC void * memset(void *s, int c, size_t n)
errno_t strncpy_s(char *_RESTRICT s1, rsize_t s1max, const char *_RESTRICT s2, rsize_t n)
size_t strnlen_s(const char *s, size_t maxsize)
void(* cleanup)(dentry_t *entry)
Called when the dentry is being freed.
Directory entry structure.
inode_t * inode
Will be NULL if the dentry is negative, once positive it will never be NULL.
char name[MAX_NAME]
Constant after creation.
list_entry_t otherEntry
Made available for use by any other subsystems for convenience.
superblock_t * superblock
list_entry_t siblingEntry
char path[MAX_PATH]
The relative path of the directory.
inode_type_t type
The type of the entries inode.
inode_number_t number
The number of the entries inode.
uint64_t(* lookup)(inode_t *dir, dentry_t *target)
Look up a dentry in a directory inode.
inode_type_t type
Constant after creation.
inode_number_t number
Constant after creation.
const inode_ops_t * ops
Constant after creation.
atomic_uint32_t count
Atomic reference counter.
Read-Write Ticket Lock structure.
const dentry_ops_t * dentryOps