377 for (
uint64_t i = 0; i < amount; i++)
390 if (ctx->
queues[j] == queue)
413 for (
uint64_t i = 0; i < amount; i++)
448 for (
uint64_t i = 0; i < amount; i++)
490 if (readyCount ==
ERR)
496 if (readyCount > 0 ||
uptime >= deadline)
820 if (fdsLocal[0] ==
ERR)
825 if (fdsLocal[1] ==
ERR)
856 if (fromFile ==
NULL)
1010 for (
uint64_t i = 0; i < amount; i++)
1034 for (
uint64_t i = 0; i < amount; i++)
1041 for (
uint64_t i = 0; i < amount; i++)
1107 return vfs_link(&oldPathname, &newPathname, process);
#define MAX_NAME
Maximum length of names.
#define assert(expression)
#define SYSCALL_DEFINE(num, returnType,...)
Macro to define a syscall.
path_t cwd_get(cwd_t *cwd)
Get the current working directory.
bool dentry_is_positive(dentry_t *dentry)
Check if a dentry is positive.
bool dentry_is_dir(dentry_t *dentry)
Check if the inode associated with a dentry is a directory.
bool dentry_is_file(dentry_t *dentry)
Check if the inode associated with a dentry is a file.
uint64_t file_table_free(file_table_t *table, fd_t fd)
Free a file descriptor.
file_t * file_table_get(file_table_t *table, fd_t fd)
Get a file from its file descriptor.
fd_t file_table_alloc(file_table_t *table, file_t *file)
Allocate a new file descriptor for a file.
file_t * file_new(const path_t *path, mode_t mode)
Create a new file structure.
void inode_notify_change(inode_t *inode)
Notify the inode that its metadata has changed.
void inode_notify_modify(inode_t *inode)
Notify the inode that its content has been modified.
void inode_notify_access(inode_t *inode)
Notify the inode that it has been accessed.
void inode_truncate(inode_t *inode)
Truncate the inode.
void path_put(path_t *path)
Put a path.
#define PATH_CREATE(inMount, inDentry)
Helper to create a path.
#define PATH_DEFER(path)
Defer path put.
#define PATHNAME_IS_VALID(pathname)
Check if a pathname is valid.
uint64_t path_walk_parent_and_child(const path_t *from, path_t *outParent, path_t *outChild, const pathname_t *pathname, namespace_t *ns)
Traverse a pathname to its parent and child paths.
uint64_t path_walk(path_t *path, const pathname_t *pathname, namespace_t *ns)
Walk a pathname to a path.
void path_copy(path_t *dest, const path_t *src)
Copy a path.
#define PATH_EMPTY
Helper to create an empty path.
void space_unpin(space_t *space, const void *address, uint64_t length)
Unpins pages in a region previously pinned with space_pin() or space_pin_string().
uint64_t space_check_access(space_t *space, const void *addr, uint64_t length)
Checks if a virtual memory region is within the allowed address range of the space.
uint64_t space_pin(space_t *space, const void *address, uint64_t length, stack_pointer_t *userStack)
Pins pages within a region of the address space.
pml_flags_t vmm_prot_to_flags(prot_t prot)
Converts the user space memory protection flags to page table entry flags.
clock_t clock_uptime(void)
Retrieve the time in nanoseconds since boot.
uint64_t thread_copy_to_user(thread_t *thread, void *dest, const void *userSrc, uint64_t length)
Safely copy data to user space.
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.
uint64_t wait_block_prepare(wait_queue_t **waitQueues, uint64_t amount, clock_t timeout)
Prepare to block the currently running thread.
uint64_t wait_block_commit(void)
Block the currently running thread.
void wait_block_cancel(void)
Cancels blocking of the currently running thread.
process_t * sched_process(void)
Retrieves the process of the currently running thread.
thread_t * sched_thread(void)
Retrieves the currently running thread.
void mutex_release(mutex_t *mtx)
Releases a mutex.
void mutex_acquire(mutex_t *mtx)
Acquires a mutex, blocking until it is available.
#define UNREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define UNREF(ptr)
Decrement reference count.
uint64_t vfs_ioctl(file_t *file, uint64_t request, void *argp, uint64_t size)
Perform an ioctl operation on a file.
uint64_t vfs_seek(file_t *file, int64_t offset, seek_origin_t origin)
Seek in a file.
void * vfs_mmap(file_t *file, void *address, uint64_t length, pml_flags_t flags)
Memory map a file.
uint64_t vfs_poll(poll_file_t *files, uint64_t amount, clock_t timeout)
Poll multiple files.
uint64_t vfs_getdents(file_t *file, dirent_t *buffer, uint64_t count)
Get directory entries from a directory file.
uint64_t vfs_write(file_t *file, const void *buffer, uint64_t count)
Write to a file.
file_t * vfs_open(const pathname_t *pathname, process_t *process)
Open a file.
uint64_t vfs_remove(const pathname_t *pathname, process_t *process)
Remove a file or directory.
uint64_t vfs_stat(const pathname_t *pathname, stat_t *buffer, process_t *process)
Get file information.
uint64_t vfs_read(file_t *file, void *buffer, uint64_t count)
Read from a file.
file_t * vfs_openat(const path_t *from, const pathname_t *pathname, process_t *process)
Open a file relative to another path.
uint64_t vfs_link(const pathname_t *oldPathname, const pathname_t *newPathname, process_t *process)
Make the same file appear twice in the filesystem.
uint64_t vfs_open2(const pathname_t *pathname, file_t *files[2], process_t *process)
Open one file, returning two file handles.
uint64_t vfs_id_get(void)
Generates a new unique ID, to be used for any VFS object.
#define CONFIG_MAX_FD
Maximum file descriptor configuration.
#define ENOENT
No such file or directory.
#define EEXIST
File exists.
#define ESPIPE
Illegal seek.
#define EINVAL
Invalid argument.
#define EXDEV
Cross-device link.
#define EFAULT
Bad address.
#define ENOSYS
Function not implemented.
#define ETIMEDOUT
Connection timed out.
#define ENOTDIR
Not a directory.
#define errno
Error number variable.
#define EACCES
Permission denied.
#define ENOTTY
Not a typewriter.
#define EBADF
Bad file number.
#define EISDIR
Is a directory.
uint8_t seek_origin_t
Type for the seek() origin argument.
poll_events_t
Poll events type.
#define POLL_SPECIAL
Poll event values that will always be checked and included even if not specified.
@ INODE_DIR
Is a directory.
@ POLLNVAL
Invalid file descriptor.
clock_t uptime(void)
System call for retreving the time since boot.
prot_t
Memory protection flags.
@ PROT_READ
Readable memory.
@ PROT_EXECUTE
Executable memory.
@ PROT_WRITE
Writable memory.
#define NULL
Pointer error value.
#define FD_NONE
No file descriptor constant.
#define ERR
Integer error value.
#define CLOCKS_REMAINING(deadline, uptime)
Safely calculate remaining time until deadline.
__UINT64_TYPE__ fd_t
A file descriptor.
#define CLOCKS_DEADLINE(timeout, uptime)
Safely calculate deadline from timeout.
__UINT64_TYPE__ clock_t
A nanosecond time.
static uintptr_t address
Mapped virtual address of the HPET registers.
EFI_PHYSICAL_ADDRESS buffer
static socket_family_ops_t ops
static const path_flag_t flags[]
#define RFLAGS_INTERRUPT_ENABLE
static uint64_t rflags_read()
#define atomic_load(object)
#define ATOMIC_VAR_INIT(value)
#define atomic_fetch_add(object, operand)
_PUBLIC char * strncpy(char *_RESTRICT s1, const char *_RESTRICT s2, size_t n)
_PUBLIC void * memset(void *s, int c, size_t n)
uint64_t(* getdents)(dentry_t *dentry, dirent_t *buffer, uint64_t count, uint64_t *offset, mode_t mode)
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.
superblock_t * superblock
uint64_t(* remove)(inode_t *dir, dentry_t *target, mode_t mode)
Remove a file or directory.
uint64_t(* create)(inode_t *dir, dentry_t *target, mode_t mode)
Handles both directories and files depending on mode.
uint64_t(* link)(inode_t *dir, dentry_t *old, dentry_t *new)
Make the same file inode appear twice in the filesystem.
time_t accessTime
Unix time stamp for the last inode access.
time_t createTime
Unix time stamp for the inode creation.
time_t modifyTime
Unix time stamp for last file content alteration.
inode_type_t type
Constant after creation.
inode_number_t number
Constant after creation.
const inode_ops_t * ops
Constant after creation.
time_t changeTime
Unix time stamp for the last file metadata alteration.
mode_t mode
Specifies the maximum permissions for this mount and if it is a directory or a file.
A entry in a page table without a specified address or callback ID.
Structure for polling multiple files.
Poll file descriptor structure.
poll_events_t revents
The events that occurred.
poll_events_t events
The events to wait for.
fd_t fd
The file descriptor to poll.
Virtual address space structure.
Thread of execution structure.
process_t * process
The parent process that the thread executes within.
stack_pointer_t userStack
The user stack of the thread.
uint16_t lookupTable[CONFIG_MAX_FD]
wait_queue_t * queues[CONFIG_MAX_FD]
The primitive that threads block on.
static uint64_t vfs_open_lookup(path_t *path, const pathname_t *pathname, namespace_t *namespace)
static uint64_t vfs_create(path_t *path, const pathname_t *pathname, namespace_t *ns)
static uint64_t vfs_poll_ctx_check_events(vfs_poll_ctx_t *ctx, poll_file_t *files, uint64_t amount)
static uint64_t vfs_poll_ctx_init(vfs_poll_ctx_t *ctx, poll_file_t *files, uint64_t amount)