225 panic(
NULL,
"Failed to create tmpfs file dentry");
234 panic(
NULL,
"Failed to create tmpfs file inode");
250 panic(
NULL,
"Failed to create tmpfs dentry");
257 panic(
NULL,
"Failed to create tmpfs inode");
284 if (superblock ==
NULL)
334 superblock->
root = dentry;
388 panic(
NULL,
"Failed to get process namespace");
#define assert(expression)
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_generic_iterate(dentry_t *dentry, dir_ctx_t *ctx)
Helper function for a basic iterate.
void dentry_remove(dentry_t *dentry)
Remove a dentry from the filesystem hierarchy.
size_t file_generic_seek(file_t *file, ssize_t offset, seek_origin_t origin)
Helper function for basic seeking.
uint64_t filesystem_register(filesystem_t *fs)
Registers a filesystem.
inode_t * inode_new(superblock_t *superblock, ino_t number, itype_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 *target, filesystem_t *fs, const char *deviceName, mode_t mode, void *private)
Mount a filesystem in a namespace.
mode_t
Path flags and permissions.
superblock_t * superblock_new(filesystem_t *fs, block_device_t *device, const superblock_ops_t *ops, const dentry_ops_t *dentryOps)
Create a new superblock.
void tmpfs_init(void)
Registers the tmpfs filesystem and mounts an instance of it containing the boot ram disk as root.
#define TMPFS_NAME
The name of the tmpfs filesystem.
boot_info_t * boot_info_get(void)
Gets the boot info structure.
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
#define LOG_INFO(format,...)
namespace_t * process_get_ns(process_t *process)
Gets the namespace of a process.
process_t * sched_process(void)
Retrieves the process of the currently running thread.
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 UNREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define REF(ptr)
Increment reference count.
#define UNREF(ptr)
Decrement reference count.
#define BUFFER_WRITE(buffer, count, offset, dest, size)
Helper macro for implementing file operations dealing with simple buffer writes.
#define BUFFER_READ(buffer, count, offset, src, size)
Helper macros for implementing file operations dealing with simple buffers.
uint64_t vfs_id_get(void)
Generates a new unique ID, to be used for any VFS object.
#define EINVAL
Invalid argument.
#define ENOTEMPTY
Directory not empty.
#define errno
Error number variable.
#define UNUSED(x)
Mark a variable as unused.
@ INODE_DIR
Is a directory.
@ INODE_SYMLINK
Is a symbolic link.
#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 bool list_is_empty(list_t *list)
Checks if a list is empty.
static void list_init(list_t *list)
Initializes a list.
#define NULL
Pointer error value.
#define ERR
Integer error value.
EFI_PHYSICAL_ADDRESS buffer
_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 size_t strlen(const char *s)
_PUBLIC void * memset(void *s, int c, size_t n)
Dentry operations structure.
uint64_t(* iterate)(dentry_t *dentry, dir_ctx_t *ctx)
Iterate over the entries in a directory dentry.
Directory entry structure.
inode_t * inode
Will be NULL if the dentry is negative, once positive it will never be modified.
char name[MAX_NAME]
Constant after creation.
list_entry_t otherEntry
Made available for use by any other subsystems for convenience.
superblock_t * superblock
File operations structure.
size_t(* read)(file_t *file, void *buffer, size_t count, size_t *offset)
Filesystem structure, represents a filesystem type, e.g. fat32, tmpfs, devfs, etc.
Inode operations structure.
uint64_t(* create)(inode_t *dir, dentry_t *target, mode_t mode)
Handles both directories and files depending on mode.
Superblock operations structure.
void(* cleanup)(superblock_t *superblock)
dentry_t * root
Root dentry of the filesystem, should not take a reference.
Superblock private data for tmpfs.
static inode_ops_t inodeOps
static dentry_t * tmpfs_load_file(superblock_t *superblock, dentry_t *parent, const char *name, const boot_file_t *in)
static dentry_ops_t dentryOps
static void tmpfs_inode_cleanup(inode_t *inode)
static dentry_t * tmpfs_load_dir(superblock_t *superblock, dentry_t *parent, const char *name, const boot_dir_t *in)
static filesystem_t tmpfs
static void tmpfs_dentry_remove(dentry_t *dentry)
static dentry_t * tmpfs_mount(filesystem_t *fs, block_device_t *device, void *private)
static uint64_t tmpfs_readlink(inode_t *inode, char *buffer, uint64_t count)
static uint64_t tmpfs_symlink(inode_t *dir, dentry_t *target, const char *dest)
static uint64_t tmpfs_remove(inode_t *dir, dentry_t *target)
static size_t tmpfs_read(file_t *file, void *buffer, size_t count, size_t *offset)
static void tmpfs_truncate(inode_t *inode)
static void tmpfs_superblock_cleanup(superblock_t *superblock)
static uint64_t tmpfs_create(inode_t *dir, dentry_t *target, mode_t mode)
static void tmpfs_dentry_add(dentry_t *dentry)
static uint64_t tmpfs_link(inode_t *dir, dentry_t *old, dentry_t *target)
static size_t tmpfs_write(file_t *file, const void *buffer, size_t count, size_t *offset)
static superblock_ops_t superOps
static inode_t * tmpfs_inode_new(superblock_t *superblock, itype_t type, void *buffer, uint64_t size)
static file_ops_t fileOps