]> nv-tegra.nvidia Code Review - linux-3.10.git/blob - arch/um/kernel/syscall.c
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel...
[linux-3.10.git] / arch / um / kernel / syscall.c
1 /*
2  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3  * Licensed under the GPL
4  */
5
6 #include "linux/file.h"
7 #include "linux/fs.h"
8 #include "linux/mm.h"
9 #include "linux/sched.h"
10 #include "linux/utsname.h"
11 #include "linux/syscalls.h"
12 #include "asm/current.h"
13 #include "asm/mman.h"
14 #include "asm/uaccess.h"
15 #include "asm/unistd.h"
16 #include "internal.h"
17
18 long sys_fork(void)
19 {
20         long ret;
21
22         current->thread.forking = 1;
23         ret = do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
24                       &current->thread.regs, 0, NULL, NULL);
25         current->thread.forking = 0;
26         return ret;
27 }
28
29 long sys_vfork(void)
30 {
31         long ret;
32
33         current->thread.forking = 1;
34         ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
35                       UPT_SP(&current->thread.regs.regs),
36                       &current->thread.regs, 0, NULL, NULL);
37         current->thread.forking = 0;
38         return ret;
39 }
40
41 long old_mmap(unsigned long addr, unsigned long len,
42               unsigned long prot, unsigned long flags,
43               unsigned long fd, unsigned long offset)
44 {
45         long err = -EINVAL;
46         if (offset & ~PAGE_MASK)
47                 goto out;
48
49         err = sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
50  out:
51         return err;
52 }
53
54 long sys_uname(struct old_utsname __user * name)
55 {
56         long err;
57         if (!name)
58                 return -EFAULT;
59         down_read(&uts_sem);
60         err = copy_to_user(name, utsname(), sizeof (*name));
61         up_read(&uts_sem);
62         return err?-EFAULT:0;
63 }
64
65 long sys_olduname(struct oldold_utsname __user * name)
66 {
67         long error;
68
69         if (!name)
70                 return -EFAULT;
71         if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
72                 return -EFAULT;
73
74         down_read(&uts_sem);
75
76         error = __copy_to_user(&name->sysname, &utsname()->sysname,
77                                __OLD_UTS_LEN);
78         error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
79         error |= __copy_to_user(&name->nodename, &utsname()->nodename,
80                                 __OLD_UTS_LEN);
81         error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
82         error |= __copy_to_user(&name->release, &utsname()->release,
83                                 __OLD_UTS_LEN);
84         error |= __put_user(0, name->release + __OLD_UTS_LEN);
85         error |= __copy_to_user(&name->version, &utsname()->version,
86                                 __OLD_UTS_LEN);
87         error |= __put_user(0, name->version + __OLD_UTS_LEN);
88         error |= __copy_to_user(&name->machine, &utsname()->machine,
89                                 __OLD_UTS_LEN);
90         error |= __put_user(0, name->machine + __OLD_UTS_LEN);
91
92         up_read(&uts_sem);
93
94         error = error ? -EFAULT : 0;
95
96         return error;
97 }
98
99 int kernel_execve(const char *filename, char *const argv[], char *const envp[])
100 {
101         mm_segment_t fs;
102         int ret;
103
104         fs = get_fs();
105         set_fs(KERNEL_DS);
106         ret = um_execve((char *)filename, (char __user *__user *)argv,
107                         (char __user *__user *) envp);
108         set_fs(fs);
109
110         return ret;
111 }