diff options
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, |