diff options
Diffstat (limited to 'arch/sandbox')
-rw-r--r-- | arch/sandbox/mach-sandbox/include/mach/linux.h | 2 | ||||
-rw-r--r-- | arch/sandbox/os/common.c | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h index 7c2386d247..5917fe93de 100644 --- a/arch/sandbox/mach-sandbox/include/mach/linux.h +++ b/arch/sandbox/mach-sandbox/include/mach/linux.h @@ -10,6 +10,8 @@ ssize_t linux_write(int fd, const void *buf, size_t count); off_t linux_lseek(int fildes, off_t offset); int linux_tstc(int fd); +int linux_execve(const char * filename, char *const argv[], char *const envp[]); + int barebox_register_console(char *name_template, int stdinfd, int stdoutfd); struct linux_console_data { 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); |