diff options
author | Ian Moffett <ian@osmora.org> | 2024-03-15 19:54:43 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-03-15 19:56:21 -0400 |
commit | dd0a88b94744053653a032149ba7d6eb1f392021 (patch) | |
tree | cda587d4c55153f006c108a3aa84d4de778871a2 /sys/kern/kern_sched.c | |
parent | ca74cc263f2e7cc94e0216c775a09a52a970d235 (diff) |
kernel: Add basic file descriptor support
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/kern/kern_sched.c')
-rw-r--r-- | sys/kern/kern_sched.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index bd59e41..77aab54 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -37,6 +37,7 @@ #include <sys/loader.h> #include <sys/panic.h> #include <sys/machdep.h> +#include <sys/filedesc.h> #include <fs/initramfs.h> #include <vm/dynalloc.h> #include <vm/physseg.h> @@ -268,6 +269,11 @@ sched_create_td(uintptr_t rip, char *argvp[], char *envp[], struct auxval auxv, td->is_user = is_user; processor_init_pcb(td); + /* Allocate standard file descriptors */ + __assert(fd_alloc(td) != NULL); /* STDIN */ + __assert(fd_alloc(td) != NULL); /* STDOUT */ + __assert(fd_alloc(td) != NULL); /* STDERR */ + /* Setup trapframe */ if (!is_user) { init_frame(tf, rip, (uintptr_t)stack); @@ -294,6 +300,11 @@ sched_destroy_td(struct proc *td) dynfree((void *)td->stack_base); } + /* Close all of the file descriptors */ + for (size_t i = 0; i < PROC_MAX_FDS; ++i) { + fd_close_fdnum(td, i); + } + pmap_free_vas(vm_get_ctx(), td->addrsp); dynfree(td); } |