22 buffer.parentId = parentId;
23 buffer.mountpointId = mountpointId;
83 while (currentNs !=
NULL)
100 currentNs = currentNs->
parent;
109 if (deviceName ==
NULL || fsName ==
NULL)
142 if (mountpoint ==
NULL)
157 LOG_INFO(
"mounted %s as root with %s\n", deviceName, fsName);
191 LOG_DEBUG(
"mounted %s with %s\n", deviceName, fsName);
237 if (mountpointString ==
NULL)
259 if (sourceFile ==
NULL)
#define assert(expression)
static map_key_t mount_cache_key(mount_id_t parentId, dentry_id_t mountpointId)
#define SYSCALL_DEFINE(num, returnType,...)
Macro to define a syscall.
uint64_t dentry_id_t
Dentry ID type.
uint64_t mount_id_t
Mount ID type.
mount_t * mount_new(superblock_t *superblock, dentry_t *root, dentry_t *mountpoint, mount_t *parent)
Create a new mount.
uint64_t namespace_get_root_path(namespace_t *ns, path_t *outPath)
Get the root path of a namespace.
uint64_t namespace_traverse_mount(namespace_t *ns, const path_t *mountpoint, path_t *outRoot)
Traverse a mountpoint path to the root of the mounted filesystem.
void namespace_deinit(namespace_t *ns)
Deinitializes a namespace.
mount_t * namespace_bind(namespace_t *ns, dentry_t *source, path_t *mountpoint)
Bind a directory to a mountpoint in a namespace.
mount_t * namespace_mount(namespace_t *ns, path_t *mountpoint, const char *deviceName, const char *fsName, void *private)
Mount a filesystem in a namespace.
uint64_t namespace_init(namespace_t *ns, namespace_t *parent, process_t *owner)
Initializes a namespace.
void path_set(path_t *path, mount_t *mount, dentry_t *dentry)
Set a path.
void path_copy(path_t *dest, const path_t *src)
Copy a path.
file_t * vfs_ctx_get_file(vfs_ctx_t *ctx, fd_t fd)
Get a file from a VFS context.
filesystem_t * vfs_get_fs(const char *name)
Gets a filesystem by name.
uint64_t vfs_walk(path_t *outPath, const pathname_t *pathname, walk_flags_t flags, process_t *process)
Walk a pathname to a path, starting from the current process's working directory.
#define LOG_INFO(format,...)
#define LOG_DEBUG(format,...)
process_t * process_get_kernel(void)
Gets the kernel process.
uint64_t thread_copy_from_user_pathname(thread_t *thread, pathname_t *pathname, const char *userPath)
Safely copy a string from user space and use it to initialize a pathname.
thread_t * sched_thread(void)
Retrieves the currently running thread.
void rwlock_write_acquire(rwlock_t *lock)
Acquires a rwlock for writing, blocking until it is available.
void rwlock_read_acquire(rwlock_t *lock)
Acquires a rwlock for reading, blocking until it is available.
#define RWLOCK_READ_SCOPE(lock)
Acquires a rwlock for reading for the reminder of the current scope.
void rwlock_read_release(rwlock_t *lock)
Releases a rwlock from reading.
void rwlock_write_release(rwlock_t *lock)
Releases a rwlock from writing.
void rwlock_init(rwlock_t *lock)
Initializes a rwlock.
#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_deinit(map_t *map)
Deinitialize a map.
uint64_t map_insert(map_t *map, const map_key_t *key, map_entry_t *value)
Insert a key-value pair into the map.
uint64_t map_init(map_t *map)
Initialize a map.
#define MAP_ENTRY_PTR_IS_VALID(entryPtr)
Check if a map entry pointer is valid (not NULL or tombstone).
map_entry_t * map_get(map_t *map, const map_key_t *key)
Get a value from the map by key.
#define DEREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define REF(ptr)
Increment reference count.
#define DEREF(ptr)
Decrement reference count.
#define ENOENT
No such file or directory.
#define ESTALE
Stale NFS file handle.
#define EINVAL
Invalid argument.
#define EBUSY
Device or resource busy.
#define errno
Error number variable.
#define ENODEV
No such device.
uint64_t bind(fd_t source, const char *mountpoint)
System call for binding a file descriptor to a mountpoint.
#define NULL
Pointer error value.
#define ERR
Integer error value.
#define CONTAINER_OF(ptr, type, member)
Container of macro.
__UINT64_TYPE__ fd_t
A file descriptor.
#define CONTAINER_OF_SAFE(ptr, type, member)
Safe container of macro.
EFI_PHYSICAL_ADDRESS buffer
static process_t kernelProcess
#define atomic_load(object)
Directory entry structure.
superblock_t * superblock
Filesystem structure, represents a filesystem type, e.g. fat32, ramfs, sysfs, etc.
dentry_t *(* mount)(filesystem_t *fs, const char *devName, void *private)
superblock_t * superblock
The superblock of the mounted filesystem.
dentry_t * root
The root dentry of the mounted filesystem.
process_t * owner
The process that owns this namespace, will not take a reference.
mount_t * rootMount
The root mount of the namespace, will be inherited from the parent namespace.
Thread of execution structure.
process_t * process
The parent process that the thread executes within.