sanbox: add linux_execve and linux_exec command
PATCH v2 1/1 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 <[email protected]>
---
v2:
fix missing free
Best Regards,
J.
arch/sandbox/mach-sandbox/include/mach/linux.h | 2 + arch/sandbox/os/common.c | 22 +++++++++ commands/Kconfig | 4 ++ commands/Makefile | 1 + commands/linux_exec.c | 60 ++++++++++++++++++++++++ 5 files changed, 89 insertions(+), 0 deletions(-) create mode 100644 commands/linux_exec.c
arch/sandbox/mach-sandbox/include/mach/linux.h +2 -0
@@ -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 {
arch/sandbox/os/common.c +22 -0
@@ -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);
commands/Kconfig +4 -0
@@ -107,6 +107,10 @@ config CMD_TIME checking for ctrl-c, so the time command can be used with commands which are interruptible with ctrl-c. +config CMD_LINUX_EXEC + bool "linux exec" + depends on LINUX + endmenu menu "file commands "
commands/Makefile +1 -0
@@ -60,3 +60,4 @@ obj-$(CONFIG_CMD_USB) += usb.o obj-$(CONFIG_CMD_TIME) += time.o obj-$(CONFIG_CMD_OFTREE) += oftree.o obj-$(CONFIG_CMD_MAGICVAR) += magicvar.o +obj-$(CONFIG_CMD_LINUX_EXEC) += linux_exec.o
commands/linux_exec.c new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH v2 1/1 sanbox: add linux_execve and linux_exec command
Le Sat, 3 Dec 2011 06:42:02 +0100,
Jean-Christophe PLAGNIOL-VILLARD <[email protected]> a ?crit :
Quoted 3 lines
this will allow to execute a program of the host from barebox
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
I guess your intention was to send this patch to the Barebox mailing list and not to the Linux ARM kernel mailing list, no?
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com