OrionLibC
Barry Importing existing Orion LibC 03048a9 (2 years, 2 months ago)diff --git a/unistd/execve.c b/unistd/execve.c new file mode 100644 index 0000000..6fcf69f --- /dev/null +++ b/unistd/execve.c @@ -0,0 +1,32 @@ +#include <stddef.h> +#include <sys/syscall.h> +#include <errno.h> + +/* Execute a binary with the specified arguments and environment */ +int +execve(const char *path, char *argv[], char *envp[]) +{ + struct { + const char *path; + char **argv, **envp; + } args; + args.path = path; + args.argv = argv; + args.envp = envp; + + int ret; + asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_EXECVE), + "c" (3), "S" (&args)); + + if (ret >= 0) + return ret; + errno = -ret; + return -1; +} + +/* Execute a binary with the specified arguments */ +int +execv(const char *path, char *argv[]) +{ + return execve(path, argv, NULL); /* FIXME: environment */ +}