From 57152f6a03d857118fa82e0a28657d869f4c7110 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 26 Jul 2022 23:04:49 +0200 Subject: user/libc: execv() --- src/user/lib/stdlib.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/user/lib/stdlib.c') diff --git a/src/user/lib/stdlib.c b/src/user/lib/stdlib.c index 068635b..179bd8f 100644 --- a/src/user/lib/stdlib.c +++ b/src/user/lib/stdlib.c @@ -1,5 +1,8 @@ #include +#include +#include #include +#include int errno = 0; @@ -14,3 +17,16 @@ int close(handle_t h) { _Noreturn void exit(int c) { _syscall_exit(c); } + +int execv(const char *path, char *const argv[]) { + (void)argv; + + FILE *file = fopen(path, "r"); + if (!file) + return -1; + + elf_execf(file); + fclose(file); + errno = EINVAL; + return -1; +} -- cgit v1.2.3