From e9e2a0bd01d8c5ef4732a0f3a6f6bb4eee01bf31 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 3 Mar 2011 09:47:14 +0100 Subject: [PATCH] add the support of the system call "execve" in our libgloss --- include/metalsvm/syscall.h | 1 + newlib/src/libgloss/metalsvm/execve.c | 12 ++++++++++-- newlib/src/libgloss/metalsvm/syscall.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/metalsvm/syscall.h b/include/metalsvm/syscall.h index 71863ade..0d47bedb 100644 --- a/include/metalsvm/syscall.h +++ b/include/metalsvm/syscall.h @@ -40,6 +40,7 @@ extern "C" { #define __NR_sbrk 11 #define __NR_fork 12 #define __NR_wait 13 +#define __NR_execve 14 #ifdef __cplusplus } diff --git a/newlib/src/libgloss/metalsvm/execve.c b/newlib/src/libgloss/metalsvm/execve.c index ebdb4656..285b8248 100644 --- a/newlib/src/libgloss/metalsvm/execve.c +++ b/newlib/src/libgloss/metalsvm/execve.c @@ -24,6 +24,7 @@ #undef errno extern int errno; #include "warning.h" +#include "syscall.h" int _DEFUN (_execve, (name, argv, env), @@ -31,6 +32,13 @@ _DEFUN (_execve, (name, argv, env), char **argv _AND char **env) { - errno=ENOMEM; - return -1; + int ret; + + ret = SYSCALL3(__NR_execve, name, argv, env); + if (ret < 0) { + errno = -ret; + ret = -1; + } + + return ret; } diff --git a/newlib/src/libgloss/metalsvm/syscall.h b/newlib/src/libgloss/metalsvm/syscall.h index 478447ed..5390a27b 100644 --- a/newlib/src/libgloss/metalsvm/syscall.h +++ b/newlib/src/libgloss/metalsvm/syscall.h @@ -37,6 +37,7 @@ extern "C" { #define __NR_sbrk 11 #define __NR_fork 12 #define __NR_wait 13 +#define __NR_execve 14 #define _STR(token) #token #define _SYSCALLSTR(x) "int $" _STR(x) " "