35 if (dentryData ==
NULL)
117 if (newInode ==
NULL)
123 if (ramfs_dentry_init(target) ==
ERR)
150 if (ramfs_dentry_init(target) ==
ERR)
249 panic(
NULL,
"Failed to create ramfs file dentry");
253 if (ramfs_dentry_init(dentry) ==
ERR)
255 panic(
NULL,
"Failed to initialize ramfs dentry");
261 panic(
NULL,
"Failed to create ramfs file inode");
267 panic(
NULL,
"Failed to make ramfs file dentry positive");
280 panic(
NULL,
"Failed to create ramfs dentry");
284 if (ramfs_dentry_init(dentry) ==
ERR)
286 panic(
NULL,
"Failed to initialize ramfs dentry");
292 panic(
NULL,
"Failed to create ramfs inode");
298 panic(
NULL,
"Failed to make ramfs dentry positive");
321 if (superblock ==
NULL)
#define assert(expression)
dentry_t * dentry_new(superblock_t *superblock, dentry_t *parent, const char *name)
Create a new dentry.
uint64_t dentry_make_positive(dentry_t *dentry, inode_t *inode)
Make a dentry positive by associating it with an inode.
uint64_t dentry_generic_getdents(dentry_t *dentry, dirent_t *buffer, uint64_t count, uint64_t *offset, path_flags_t flags)
Helper function for a basic getdents.
uint64_t file_generic_seek(file_t *file, int64_t offset, seek_origin_t origin)
Helper function for basic seeking.
inode_t * inode_new(superblock_t *superblock, inode_number_t number, inode_type_t type, const inode_ops_t *ops, const file_ops_t *fileOps)
Create a new inode.
mount_t * namespace_mount(namespace_t *ns, path_t *mountpoint, const char *deviceName, const char *fsName, void *private)
Mount a filesystem in a namespace.
#define RAMFS_NAME
The name of the ramfs filesystem.
void ramfs_init(const boot_disk_t *disk)
Registers the ramfs filesystem and mounts it as the root filesystem.
superblock_t * superblock_new(const filesystem_t *fs, const char *deviceName, const superblock_ops_t *ops, const dentry_ops_t *dentryOps)
Create a new superblock.
uint64_t vfs_register_fs(filesystem_t *fs)
Registers a filesystem.
#define VFS_ROOT_ENTRY_NAME
The name of the root entry.
#define VFS_DEVICE_NAME_NONE
The name used to indicate no device.
#define BUFFER_READ(buffer, count, offset, src, size)
Helper macros for implementing file operations dealing with simple buffers.
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
#define LOG_INFO(format,...)
static void lock_init(lock_t *lock)
Initializes a lock.
static void lock_release(lock_t *lock)
Releases a lock.
static void lock_acquire(lock_t *lock)
Acquires a lock, blocking until it is available.
#define MUTEX_SCOPE(mutex)
Acquires a mutex for the reminder of the current scope.
#define DEREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define REF(ptr)
Increment reference count.
#define DEREF(ptr)
Decrement reference count.
#define ENOTEMPTY
Directory not empty.
#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.
#define LIST_FOR_EACH_SAFE(elem, temp, list, member)
Safely iterates over a list, allowing for element removal during iteration.
static void list_remove(list_t *list, list_entry_t *entry)
Removes a list entry from its current list.
static void list_push(list_t *list, list_entry_t *entry)
Pushes an entry to the end of the list.
static bool list_is_empty(list_t *list)
Checks if a list is empty.
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.
EFI_PHYSICAL_ADDRESS buffer
static inode_ops_t inodeOps
static void ramfs_superblock_cleanup(superblock_t *superblock)
static dentry_t * ramfs_load_file(superblock_t *superblock, dentry_t *parent, const char *name, const boot_file_t *in)
static dentry_ops_t dentryOps
static void ramfs_truncate(inode_t *inode)
static dentry_t * ramfs_mount(filesystem_t *fs, const char *devName, void *private)
static dentry_t * ramfs_load_dir(superblock_t *superblock, dentry_t *parent, const char *name, const boot_dir_t *in)
static filesystem_t ramfs
static void ramfs_inode_cleanup(inode_t *inode)
static uint64_t ramfs_link(dentry_t *old, inode_t *dir, dentry_t *target)
static uint64_t ramfs_remove(inode_t *parent, dentry_t *target, path_flags_t flags)
static uint64_t ramfs_remove_file(inode_t *parent, dentry_t *target)
static inode_t * ramfs_inode_new(superblock_t *superblock, inode_type_t type, void *buffer, uint64_t size)
static void ramfs_dentry_deinit(dentry_t *dentry)
static uint64_t ramfs_write(file_t *file, const void *buffer, uint64_t count, uint64_t *offset)
static uint64_t ramfs_create(inode_t *dir, dentry_t *target, path_flags_t flags)
static superblock_ops_t superOps
static uint64_t ramfs_lookup(inode_t *dir, dentry_t *target)
static uint64_t ramfs_read(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
static file_ops_t fileOps
static uint64_t ramfs_remove_directory(inode_t *parent, dentry_t *target)
#define ATOMIC_VAR_INIT(value)
#define atomic_fetch_add(object, operand)
_PUBLIC void * realloc(void *ptr, size_t size)
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
_PUBLIC void * memcpy(void *_RESTRICT s1, const void *_RESTRICT s2, size_t n)
_PUBLIC void * memset(void *s, int c, size_t n)
Dentry operations structure.
uint64_t(* getdents)(dentry_t *dentry, dirent_t *buffer, uint64_t count, uint64_t *offset, path_flags_t flags)
Used to now what is in a directory.
Directory entry structure.
superblock_t * superblock
File operations structure.
uint64_t(* read)(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
Filesystem structure, represents a filesystem type, e.g. fat32, ramfs, sysfs, etc.
uint64_t(* lookup)(inode_t *dir, dentry_t *target)
Should set the target dentry to be positive (give it an inode), if the entry does not exist the opera...
inode_type_t type
Constant after creation.
superblock_t * superblock
Constant after creation.
Dentry private data for ramfs.
Superblock private data for ramfs.
Superblock operations structure.
void(* cleanup)(superblock_t *superblock)