BarryServer : Git

All the code for all my projects
// BarryServer : Git / OrionLibC / blob / ad9b6af63f1fdfcf3556c9b2fc670f72cdc60ab4 / 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 */
}