Commit | Line | Data |
---|---|---|
5f97f7f9 HS |
1 | /* |
2 | * Copyright (C) 2004-2006 Atmel Corporation | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License version 2 as | |
6 | * published by the Free Software Foundation. | |
7 | */ | |
8 | #include <linux/errno.h> | |
9 | #include <linux/fs.h> | |
10 | #include <linux/file.h> | |
11 | #include <linux/mm.h> | |
12 | #include <linux/unistd.h> | |
13 | ||
14 | #include <asm/mman.h> | |
15 | #include <asm/uaccess.h> | |
16 | ||
17 | asmlinkage int sys_pipe(unsigned long __user *filedes) | |
18 | { | |
19 | int fd[2]; | |
20 | int error; | |
21 | ||
22 | error = do_pipe(fd); | |
23 | if (!error) { | |
24 | if (copy_to_user(filedes, fd, sizeof(fd))) | |
25 | error = -EFAULT; | |
26 | } | |
27 | return error; | |
28 | } | |
29 | ||
30 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, | |
31 | unsigned long prot, unsigned long flags, | |
32 | unsigned long fd, off_t offset) | |
33 | { | |
34 | int error = -EBADF; | |
35 | struct file *file = NULL; | |
36 | ||
37 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | |
38 | if (!(flags & MAP_ANONYMOUS)) { | |
39 | file = fget(fd); | |
40 | if (!file) | |
41 | return error; | |
42 | } | |
43 | ||
44 | down_write(¤t->mm->mmap_sem); | |
45 | error = do_mmap_pgoff(file, addr, len, prot, flags, offset); | |
46 | up_write(¤t->mm->mmap_sem); | |
47 | ||
48 | if (file) | |
49 | fput(file); | |
50 | return error; | |
51 | } | |
c5f2420a HS |
52 | |
53 | int kernel_execve(const char *file, char **argv, char **envp) | |
54 | { | |
55 | register long scno asm("r8") = __NR_execve; | |
56 | register long sc1 asm("r12") = (long)file; | |
57 | register long sc2 asm("r11") = (long)argv; | |
58 | register long sc3 asm("r10") = (long)envp; | |
59 | ||
60 | asm volatile("scall" | |
61 | : "=r"(sc1) | |
62 | : "r"(scno), "0"(sc1), "r"(sc2), "r"(sc3) | |
63 | : "cc", "memory"); | |
64 | return sc1; | |
65 | } |