BarryServer : Git

All the code for all my projects
// BarryServer : Git / OrionLibC / blob / master / unistd / execve.c

// Related

OrionLibC

Barry Importing existing Orion LibC 03048a9 (2 years, 3 months ago)
#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 */
}