From 08619630e9c7b638354323b443937701811b11d4 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 14 Oct 2022 15:33:00 +0300 Subject: add spawn syscall + Prefer over unixy fork/exec for speed since I don't want to support cow. Shell redirection should be done with env server and cooperating libc. --- common/uapi/dispatch.c | 1 + common/uapi/proc.c | 12 ++++++++++++ include/apos/syscalls.h | 3 +++ include/apos/uapi.h | 15 +++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/common/uapi/dispatch.c b/common/uapi/dispatch.c index f2a12d6..db15b62 100644 --- a/common/uapi/dispatch.c +++ b/common/uapi/dispatch.c @@ -42,6 +42,7 @@ static const sys_t syscall_table[] = { [SYS_CREATE] = sys_create, [SYS_FORK] = sys_fork, [SYS_EXEC] = sys_exec, + [SYS_SPAWN] = sys_spawn, [SYS_SWAP] = sys_swap, [SYS_ASSIGN] = sys_assign, diff --git a/common/uapi/proc.c b/common/uapi/proc.c index c8078db..d1d2bd7 100644 --- a/common/uapi/proc.c +++ b/common/uapi/proc.c @@ -82,6 +82,18 @@ SYSCALL_DEFINE2(exec)(sys_arg_t bin, sys_arg_t interp){ return (struct sys_ret){ prepare_proc(r, bin, interp), 0, 0, 0, 0, 0 }; } +/** + * Spawn syscall handler. + * + * @param bin Binary to execute. + * @param interp Optional interpreter binary. + * @return \see prepare_proc() and 0. + */ +SYSCALL_DEFINE2(spawn)(sys_arg_t bin, sys_arg_t interp) +{ + /* @todo implement */ +} + /** * Kill syscall handler. * diff --git a/include/apos/syscalls.h b/include/apos/syscalls.h index 5a3f2eb..a5b7e18 100644 --- a/include/apos/syscalls.h +++ b/include/apos/syscalls.h @@ -95,6 +95,9 @@ enum { /** Execute new binary in process space. */ SYS_EXEC, + /** Execute new binary in new process space. */ + SYS_SPAWN, + /** Kill thread. */ SYS_KILL, diff --git a/include/apos/uapi.h b/include/apos/uapi.h index cca728b..02e8816 100644 --- a/include/apos/uapi.h +++ b/include/apos/uapi.h @@ -534,6 +534,21 @@ SYSCALL_DECLARE0(fork); */ SYSCALL_DECLARE2(exec, bin, interp); +/** + * Spawn binary syscall. Try to prefer over unixy fork/exec. + * + * Executes a new binary in new process space. + * + * @param bin Address of binary. + * @param interp Optional address of interpreter. + * @param c Unused. + * @param d Unused. + * @param e Unused. + * @return \ref OK and 0. + * \todo Check other return codes. + */ +SYSCALL_DECLARE2(spawn, bin, interp); + /** * Kill syscall. * -- cgit v1.3