aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/kernel/syscall_kern.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/um/kernel/syscall_kern.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/um/kernel/syscall_kern.c')
-rw-r--r--arch/um/kernel/syscall_kern.c176
1 files changed, 176 insertions, 0 deletions
diff --git a/arch/um/kernel/syscall_kern.c b/arch/um/kernel/syscall_kern.c
new file mode 100644
index 000000000000..42731e04f50f
--- /dev/null
+++ b/arch/um/kernel/syscall_kern.c
@@ -0,0 +1,176 @@
1/*
2 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
5
6#include "linux/sched.h"
7#include "linux/file.h"
8#include "linux/smp_lock.h"
9#include "linux/mm.h"
10#include "linux/utsname.h"
11#include "linux/msg.h"
12#include "linux/shm.h"
13#include "linux/sys.h"
14#include "linux/syscalls.h"
15#include "linux/unistd.h"
16#include "linux/slab.h"
17#include "linux/utime.h"
18#include "asm/mman.h"
19#include "asm/uaccess.h"
20#include "asm/ipc.h"
21#include "kern_util.h"
22#include "user_util.h"
23#include "sysdep/syscalls.h"
24#include "mode_kern.h"
25#include "choose-mode.h"
26
27/* Unlocked, I don't care if this is a bit off */
28int nsyscalls = 0;
29
30long sys_fork(void)
31{
32 long ret;
33
34 current->thread.forking = 1;
35 ret = do_fork(SIGCHLD, 0, NULL, 0, NULL, NULL);
36 current->thread.forking = 0;
37 return(ret);
38}
39
40long sys_vfork(void)
41{
42 long ret;
43
44 current->thread.forking = 1;
45 ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, NULL, 0, NULL,
46 NULL);
47 current->thread.forking = 0;
48 return(ret);
49}
50
51/* common code for old and new mmaps */
52long sys_mmap2(unsigned long addr, unsigned long len,
53 unsigned long prot, unsigned long flags,
54 unsigned long fd, unsigned long pgoff)
55{
56 long error = -EBADF;
57 struct file * file = NULL;
58
59 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
60 if (!(flags & MAP_ANONYMOUS)) {
61 file = fget(fd);
62 if (!file)
63 goto out;
64 }
65
66 down_write(&current->mm->mmap_sem);
67 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
68 up_write(&current->mm->mmap_sem);
69
70 if (file)
71 fput(file);
72 out:
73 return error;
74}
75
76long old_mmap(unsigned long addr, unsigned long len,
77 unsigned long prot, unsigned long flags,
78 unsigned long fd, unsigned long offset)
79{
80 long err = -EINVAL;
81 if (offset & ~PAGE_MASK)
82 goto out;
83
84 err = sys_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
85 out:
86 return err;
87}
88/*
89 * sys_pipe() is the normal C calling standard for creating
90 * a pipe. It's not the way unix traditionally does this, though.
91 */
92long sys_pipe(unsigned long __user * fildes)
93{
94 int fd[2];
95 long error;
96
97 error = do_pipe(fd);
98 if (!error) {
99 if (copy_to_user(fildes, fd, sizeof(fd)))
100 error = -EFAULT;
101 }
102 return error;
103}
104
105
106long sys_uname(struct old_utsname * name)
107{
108 long err;
109 if (!name)
110 return -EFAULT;
111 down_read(&uts_sem);
112 err=copy_to_user(name, &system_utsname, sizeof (*name));
113 up_read(&uts_sem);
114 return err?-EFAULT:0;
115}
116
117long sys_olduname(struct oldold_utsname * name)
118{
119 long error;
120
121 if (!name)
122 return -EFAULT;
123 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
124 return -EFAULT;
125
126 down_read(&uts_sem);
127
128 error = __copy_to_user(&name->sysname,&system_utsname.sysname,
129 __OLD_UTS_LEN);
130 error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
131 error |= __copy_to_user(&name->nodename,&system_utsname.nodename,
132 __OLD_UTS_LEN);
133 error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
134 error |= __copy_to_user(&name->release,&system_utsname.release,
135 __OLD_UTS_LEN);
136 error |= __put_user(0,name->release+__OLD_UTS_LEN);
137 error |= __copy_to_user(&name->version,&system_utsname.version,
138 __OLD_UTS_LEN);
139 error |= __put_user(0,name->version+__OLD_UTS_LEN);
140 error |= __copy_to_user(&name->machine,&system_utsname.machine,
141 __OLD_UTS_LEN);
142 error |= __put_user(0,name->machine+__OLD_UTS_LEN);
143
144 up_read(&uts_sem);
145
146 error = error ? -EFAULT : 0;
147
148 return error;
149}
150
151DEFINE_SPINLOCK(syscall_lock);
152
153static int syscall_index = 0;
154
155int next_syscall_index(int limit)
156{
157 int ret;
158
159 spin_lock(&syscall_lock);
160 ret = syscall_index;
161 if(++syscall_index == limit)
162 syscall_index = 0;
163 spin_unlock(&syscall_lock);
164 return(ret);
165}
166
167/*
168 * Overrides for Emacs so that we follow Linus's tabbing style.
169 * Emacs will notice this stuff at the end of the file and automatically
170 * adjust the settings for this buffer only. This must remain at the end
171 * of the file.
172 * ---------------------------------------------------------------------------
173 * Local variables:
174 * c-file-style: "linux"
175 * End:
176 */