summaryrefslogtreecommitdiff
path: root/src/user/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/lib')
-rw-r--r--src/user/lib/include/unistd.h2
-rw-r--r--src/user/lib/stdlib.c16
2 files changed, 18 insertions, 0 deletions
diff --git a/src/user/lib/include/unistd.h b/src/user/lib/include/unistd.h
index b825e45..4f367ca 100644
--- a/src/user/lib/include/unistd.h
+++ b/src/user/lib/include/unistd.h
@@ -4,3 +4,5 @@
int fork(void);
int close(handle_t h);
_Noreturn void exit(int);
+
+int execv(const char *path, char *const argv[]);
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 <camellia/syscalls.h>
+#include <errno.h>
+#include <stdio.h>
#include <unistd.h>
+#include <user/lib/elfload.h>
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;
+}