OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [posix/] [libposix/] [execve.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * l4/posix glue for execve()
3
 *
4
 * Copyright (C) 2007 Bahadir Balban
5
 */
6
#include <errno.h>
7
#include <stdio.h>
8
#include <stdarg.h>
9
#include <string.h>
10
#include <sys/shm.h>
11
#include <sys/types.h>
12
#include <sys/stat.h>
13
#include <l4lib/ipcdefs.h>
14
#include <l4lib/utcb.h>
15
#include <fcntl.h>
16
#include <l4/macros.h>
17
#include INC_GLUE(memory.h)
18
#include <libposix.h>
19
 
20
 
21
struct sys_execve_args {
22
        char *path;
23
        char **argv;
24
        char **envp;
25
};
26
 
27
static inline int l4_execve(const char *pathname, char *const argv[], char *const envp[])
28
{
29
        int err = 0;
30
 
31
        write_mr(L4SYS_ARG0, (unsigned long)pathname);
32
        write_mr(L4SYS_ARG1, (unsigned long)argv);
33
        write_mr(L4SYS_ARG2, (unsigned long)envp);
34
 
35
 
36
        /* Call pager with open() request. Check ipc error. */
37
        if ((err = l4_sendrecv(pagerid, pagerid, L4_IPC_TAG_EXECVE)) < 0) {
38
                print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
39
                return err;
40
        }
41
        /* Check if syscall itself was successful */
42
        if ((err = l4_get_retval()) < 0) {
43
                print_err("%s: OPEN Error: %d.\n", __FUNCTION__, err);
44
                return err;
45
        }
46
 
47
        return err;
48
}
49
 
50
int execve(const char *pathname, char *const argv[], char *const envp[])
51
{
52
        int ret;
53
 
54
        ret = l4_execve(pathname, argv, envp);
55
 
56
        /* If error, return positive error code */
57
        if (ret < 0) {
58
                errno = -ret;
59
                return -1;
60
        }
61
        /* else return value */
62
        return ret;
63
 
64
}
65
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.