diff options
author | Freya Murphy <freya@freyacat.org> | 2025-04-28 17:28:02 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-04-28 17:28:02 -0400 |
commit | d28c5ba100cbc8a4ea6e4f4da16f5c8319a02a72 (patch) | |
tree | ce096652da2f8f9889bb377b80f6aafc9bf05788 /kernel/syscall.c | |
parent | clone pgdir (diff) | |
download | comus-d28c5ba100cbc8a4ea6e4f4da16f5c8319a02a72.tar.gz comus-d28c5ba100cbc8a4ea6e4f4da16f5c8319a02a72.tar.bz2 comus-d28c5ba100cbc8a4ea6e4f4da16f5c8319a02a72.zip |
fork syscall
Diffstat (limited to 'kernel/syscall.c')
-rw-r--r-- | kernel/syscall.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/kernel/syscall.c b/kernel/syscall.c index dd9bc16..2dd6460 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -1,4 +1,4 @@ -#include "lib/kio.h" +#include <comus/user.h> #include <comus/cpu.h> #include <comus/syscalls.h> #include <comus/drivers/acpi.h> @@ -44,6 +44,20 @@ static int sys_waitpid(void) dispatch(); } +static int sys_fork(void) +{ + struct pcb *child; + + child = user_clone(pcb); + if (child == NULL) + return -1; + + child->regs.rax = 0; + pcb->regs.rax = child->pid; + schedule(child); + return 0; +} + static int sys_write(void) { ARG1(int, fd); @@ -313,7 +327,7 @@ static int sys_ticks(void) static int (*syscall_tbl[N_SYSCALLS])(void) = { [SYS_exit] = sys_exit, [SYS_waitpid] = sys_waitpid, - [SYS_fork] = NULL, [SYS_exec] = NULL, + [SYS_fork] = sys_fork, [SYS_exec] = NULL, [SYS_open] = NULL, [SYS_close] = NULL, [SYS_read] = NULL, [SYS_write] = sys_write, [SYS_getpid] = sys_getpid, [SYS_getppid] = sys_getppid, |