Kernel: Add SYS_EXEC syscall
This commit is contained in:
@@ -19,6 +19,7 @@ __BEGIN_DECLS
|
||||
#define SYS_SET_TERMIOS 12
|
||||
#define SYS_FORK 13
|
||||
#define SYS_SLEEP 14
|
||||
#define SYS_EXEC 15
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
#include <kernel/Syscall.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -121,6 +122,14 @@ long syscall(long syscall, ...)
|
||||
ret = Kernel::syscall(SYS_SLEEP, seconds);
|
||||
break;
|
||||
}
|
||||
case SYS_EXEC:
|
||||
{
|
||||
const char* pathname = va_arg(args, const char*);
|
||||
const char* const* argv = va_arg(args, const char* const*);
|
||||
const char* const* envp = va_arg(args, const char* const*);
|
||||
ret = Kernel::syscall(SYS_EXEC, (uintptr_t)pathname, (uintptr_t)argv, (uintptr_t)envp);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
puts("LibC: Unhandeled syscall");
|
||||
ret = -ENOSYS;
|
||||
@@ -138,6 +147,11 @@ long syscall(long syscall, ...)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int execv(const char* pathname, char* const argv[])
|
||||
{
|
||||
return syscall(SYS_EXEC, pathname, argv, nullptr);
|
||||
}
|
||||
|
||||
pid_t fork(void)
|
||||
{
|
||||
return syscall(SYS_FORK);
|
||||
|
||||
Reference in New Issue
Block a user