libc: Add support for the new exec() system call

execv() is a temporary wrapper that ignores the second parameter, while execve() and execvp() still error out.
This commit is contained in:
apio 2022-10-12 17:45:58 +02:00
parent f8b3567042
commit 531afc3d6f
4 changed files with 9 additions and 5 deletions

View File

@ -21,7 +21,7 @@ void Syscall::entry(Context* context)
case SYS_read: sys_read(context, (int)context->rdi, context->rsi, (char*)context->rdx); break;
case SYS_close: sys_close(context, (int)context->rdi); break;
case SYS_seek: sys_seek(context, (int)context->rdi, (long)context->rsi, (int)context->rdx); break;
case SYS_exec: sys_exec(context, (const char*)context->rdi);
case SYS_exec: sys_exec(context, (const char*)context->rdi); break;
default: context->rax = -ENOSYS; break;
}
}

View File

@ -14,6 +14,7 @@
#define SYS_read 10
#define SYS_close 11
#define SYS_seek 12
#define SYS_exec 13
#ifndef __want_syscalls
#ifdef __cplusplus

View File

@ -9,8 +9,10 @@ extern "C"
{
#endif
/* Not implemented. */
int execv(const char*, char* const[]);
/* Executes the program program. On success, does not return. The second parameter (arguments) is not implemented
* for now. You can pass NULL to it. */
int execv(const char* program, char* const[]);
/* Not implemented. */
int execve(const char*, char* const[], char* const[]);
/* Not implemented. */

View File

@ -6,9 +6,9 @@
extern "C"
{
int execv(const char*, char* const[])
int execv(const char* program, char* const[])
{
NOT_IMPLEMENTED("execv");
return (int)syscall(SYS_exec, program);
}
int execve(const char*, char* const[], char* const[])
{
@ -36,6 +36,7 @@ extern "C"
case SYS_rand: result = __luna_syscall0(number); break;
case SYS_exit:
case SYS_close:
case SYS_exec:
case SYS_sleep: result = __luna_syscall1(number, va_arg(ap, arg)); break;
case SYS_munmap:
case SYS_open: {