diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-12-03 06:47:50 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-12-07 10:35:01 +0100 |
commit | 1e06aef681a078dbc51ec36a602c9be9735b8ab9 (patch) | |
tree | 6ddf4c6bd2fe3cd585807c985f625ed2b3c11fb5 /arch/sandbox/os | |
parent | 901aad7d73817fc7cde657b4305c4ab0005c1903 (diff) | |
download | barebox-1e06aef681a078dbc51ec36a602c9be9735b8ab9.tar.gz barebox-1e06aef681a078dbc51ec36a602c9be9735b8ab9.tar.xz |
sanbox: add linux_execve and linux_exec command
this will allow to execute a program of the host from barebox
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/sandbox/os')
-rw-r--r-- | arch/sandbox/os/common.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 9258c66156..92b7dbb2c7 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -45,6 +45,7 @@ #include <errno.h> #include <signal.h> #include <sys/select.h> +#include <sys/wait.h> /* * ...except the ones needed to connect with barebox */ @@ -185,6 +186,27 @@ off_t linux_lseek(int fd, off_t offset) return lseek(fd, offset, SEEK_SET); } +int linux_execve(const char * filename, char *const argv[], char *const envp[]) +{ + pid_t pid, tpid; + int execve_status; + + pid = fork(); + + if (pid == -1) { + perror("linux_execve"); + return pid; + } else if (pid == 0) { + exit(execve(filename, argv, envp)); + } else { + do { + tpid = wait(&execve_status); + } while(tpid != pid); + + return execve_status; + } +} + extern void start_barebox(void); extern void mem_malloc_init(void *start, void *end); |