BarryServer : Git

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

// Related

OrionLibC

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