27 panic(
NULL,
"failed to generate random key");
64 panic(
NULL,
"key: failed to initialize key map");
162 if (mapEntry ==
NULL)
#define SYSCALL_DEFINE(num, returnType,...)
Macro to define a syscall.
uint64_t rand_gen(void *buffer, uint64_t size)
Fills a buffer with random bytes.
void key_init(void)
Initializes the key subsystem.
file_t * key_claim(key_t *key)
Claims a shared file using the provided key.
uint64_t key_share(key_t *key, file_t *file, clock_t timeout)
Generates a key that can be used to retrieve the file within the specified timeout.
fd_t vfs_ctx_alloc_fd(vfs_ctx_t *ctx, file_t *file)
Allocate a new file descriptor in a VFS context.
file_t * vfs_ctx_get_file(vfs_ctx_t *ctx, fd_t fd)
Get a file from a VFS context.
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
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 thread_copy_from_user(thread_t *thread, void *dest, const void *userSrc, uint64_t length)
Safely copy data from user space.
uint64_t thread_copy_to_user(thread_t *thread, void *dest, const void *userSrc, uint64_t length)
Safely copy data to user space.
thread_t * sched_thread(void)
Retrieves the currently running thread.
#define RWLOCK_READ_SCOPE(lock)
Acquires a rwlock for reading for the reminder of the current scope.
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.
clock_t timer_uptime(void)
Time since boot.
static map_key_t map_key_buffer(const void *buffer, uint64_t length)
Create a map key from a buffer.
void map_entry_init(map_entry_t *entry)
Initialize a map entry.
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.
void map_remove(map_t *map, const map_key_t *key)
Remove a key-value pair from the map.
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 EINVAL
Invalid argument.
#define EFAULT
Bad address.
#define errno
Error number variable.
#define EBADF
Bad file number.
#define LIST_FOR_EACH(elem, list, member)
Iterates over a list.
static uint64_t list_length(list_t *list)
Gets the length of the list.
static void list_prepend(list_t *list, list_entry_t *head, list_entry_t *entry)
Prepends an entry to the 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 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.
#define CONTAINER_OF(ptr, type, member)
Container of macro.
__UINT64_TYPE__ fd_t
A file descriptor.
__UINT64_TYPE__ clock_t
A nanosecond time.
static key_t key_generate(void)
static void key_timer_handler(interrupt_frame_t *frame, cpu_t *self)
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
list_entry_t entry
Used to store the key entry in a time sorted list.
map_entry_t mapEntry
Used to store the key entry in a map for fast lookup.
Read-Write Ticket Lock structure.
Thread of execution structure.
process_t * process
The parent process that the thread executes within.