#define assert(expression)
#define SYSCALL_DEFINE(num, returnType,...)
Macro to define a syscall.
uint64_t namespace_get_root_path(namespace_t *ns, path_t *outPath)
Get the root path of a namespace.
void path_put(path_t *path)
Put a path.
#define PATH_DEFER(path)
Defer path put.
void path_copy(path_t *dest, const path_t *src)
Copy a path.
#define PATH_EMPTY
Helper to create an empty path.
void vfs_ctx_deinit(vfs_ctx_t *ctx)
Deinitialize a VFS context.
fd_t vfs_ctx_set_fd(vfs_ctx_t *ctx, fd_t fd, file_t *file)
Allocate a specific file descriptor in a VFS context.
fd_t vfs_ctx_dup(vfs_ctx_t *ctx, fd_t oldFd)
Duplicate a file descriptor in a VFS context.
void vfs_ctx_init(vfs_ctx_t *ctx, const path_t *cwd)
Initialize a VFS context.
uint64_t vfs_ctx_get_cwd(vfs_ctx_t *ctx, path_t *outCwd)
fd_t vfs_ctx_alloc_fd(vfs_ctx_t *ctx, file_t *file)
Allocate a new file descriptor in a VFS context.
fd_t vfs_ctx_dup2(vfs_ctx_t *ctx, fd_t oldFd, fd_t newFd)
Duplicate a file descriptor in a VFS context to a specific file descriptor.
uint64_t vfs_ctx_free_fd(vfs_ctx_t *ctx, fd_t fd)
Free a file descriptor in a VFS context.
uint64_t vfs_ctx_set_cwd(vfs_ctx_t *ctx, const path_t *cwd)
Set the current working directory of a VFS context.
file_t * vfs_ctx_get_file(vfs_ctx_t *ctx, fd_t fd)
Get a file from a VFS context.
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.
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.
process_t * sched_process(void)
Retrieves the process of the currently running thread.
thread_t * sched_thread(void)
Retrieves the currently running thread.
static void lock_init(lock_t *lock)
Initializes a lock.
#define LOCK_SCOPE(lock)
Acquires a lock for the reminder of the current scope.
#define REF(ptr)
Increment reference count.
#define DEREF(ptr)
Decrement reference count.
#define CONFIG_MAX_FD
Maximum file descriptor configuration.
#define EINVAL
Invalid argument.
#define EMFILE
Too many open files.
#define EBUSY
Device or resource busy.
#define ENOTDIR
Not a directory.
#define errno
Error number variable.
#define EBADF
Bad file number.
static uint64_t bitmap_find_first_clear(bitmap_t *map)
Find the first clear bit in the bitmap.
static void bitmap_clear(bitmap_t *map, uint64_t index)
Clear a bit in the bitmap.
static void bitmap_set(bitmap_t *map, uint64_t index)
Set a bit in the bitmap.
static void bitmap_init(bitmap_t *map, void *buffer, uint64_t length)
Initialize a bitmap.
@ INODE_DIR
Is a directory.
#define NULL
Pointer error value.
#define ERR
Integer error value.
__UINT64_TYPE__ fd_t
A file descriptor.
_PUBLIC void * memset(void *s, int c, size_t n)
inode_type_t type
Constant after creation.
Thread of execution structure.
process_t * process
The parent process that the thread executes within.
bitmap_t allocBitmap
Bitmap tracking allocated file descriptors.
file_t * files[CONFIG_MAX_FD]
uint64_t allocBitmapBuffer[BITMAP_BITS_TO_QWORDS(CONFIG_MAX_FD)]