aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/sys-i386/syscalls.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/sys-i386/syscalls.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/sys-i386/syscalls.c')
-rw-r--r--arch/um/sys-i386/syscalls.c210
1 files changed, 210 insertions, 0 deletions
diff --git a/arch/um/sys-i386/syscalls.c b/arch/um/sys-i386/syscalls.c
new file mode 100644
index 000000000000..335e2d89504d
--- /dev/null
+++ b/arch/um/sys-i386/syscalls.c
@@ -0,0 +1,210 @@
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/shm.h"
8#include "asm/ipc.h"
9#include "asm/mman.h"
10#include "asm/uaccess.h"
11#include "asm/unistd.h"
12
13/*
14 * Perform the select(nd, in, out, ex, tv) and mmap() system
15 * calls. Linux/i386 didn't use to be able to handle more than
16 * 4 system call parameters, so these system calls used a memory
17 * block for parameter passing..
18 */
19
20struct mmap_arg_struct {
21 unsigned long addr;
22 unsigned long len;
23 unsigned long prot;
24 unsigned long flags;
25 unsigned long fd;
26 unsigned long offset;
27};
28
29extern int old_mmap(unsigned long addr, unsigned long len,
30 unsigned long prot, unsigned long flags,
31 unsigned long fd, unsigned long offset);
32
33long old_mmap_i386(struct mmap_arg_struct __user *arg)
34{
35 struct mmap_arg_struct a;
36 int err = -EFAULT;
37
38 if (copy_from_user(&a, arg, sizeof(a)))
39 goto out;
40
41 err = old_mmap(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
42 out:
43 return err;
44}
45
46struct sel_arg_struct {
47 unsigned long n;
48 fd_set __user *inp;
49 fd_set __user *outp;
50 fd_set __user *exp;
51 struct timeval __user *tvp;
52};
53
54long old_select(struct sel_arg_struct __user *arg)
55{
56 struct sel_arg_struct a;
57
58 if (copy_from_user(&a, arg, sizeof(a)))
59 return -EFAULT;
60 /* sys_select() does the appropriate kernel locking */
61 return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
62}
63
64/* The i386 version skips reading from %esi, the fourth argument. So we must do
65 * this, too.
66 */
67long sys_clone(unsigned long clone_flags, unsigned long newsp,
68 int __user *parent_tid, int unused, int __user *child_tid)
69{
70 long ret;
71
72 /* XXX: normal arch do here this pass, and also pass the regs to
73 * do_fork, instead of NULL. Currently the arch-independent code
74 * ignores these values, while the UML code (actually it's
75 * copy_thread) does the right thing. But this should change,
76 probably. */
77 /*if (!newsp)
78 newsp = UPT_SP(current->thread.regs);*/
79 current->thread.forking = 1;
80 ret = do_fork(clone_flags, newsp, NULL, 0, parent_tid, child_tid);
81 current->thread.forking = 0;
82 return(ret);
83}
84
85/*
86 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
87 *
88 * This is really horribly ugly.
89 */
90long sys_ipc (uint call, int first, int second,
91 int third, void __user *ptr, long fifth)
92{
93 int version, ret;
94
95 version = call >> 16; /* hack for backward compatibility */
96 call &= 0xffff;
97
98 switch (call) {
99 case SEMOP:
100 return sys_semtimedop(first, (struct sembuf *) ptr, second,
101 NULL);
102 case SEMTIMEDOP:
103 return sys_semtimedop(first, (struct sembuf *) ptr, second,
104 (const struct timespec *) fifth);
105 case SEMGET:
106 return sys_semget (first, second, third);
107 case SEMCTL: {
108 union semun fourth;
109 if (!ptr)
110 return -EINVAL;
111 if (get_user(fourth.__pad, (void **) ptr))
112 return -EFAULT;
113 return sys_semctl (first, second, third, fourth);
114 }
115
116 case MSGSND:
117 return sys_msgsnd (first, (struct msgbuf *) ptr,
118 second, third);
119 case MSGRCV:
120 switch (version) {
121 case 0: {
122 struct ipc_kludge tmp;
123 if (!ptr)
124 return -EINVAL;
125
126 if (copy_from_user(&tmp,
127 (struct ipc_kludge *) ptr,
128 sizeof (tmp)))
129 return -EFAULT;
130 return sys_msgrcv (first, tmp.msgp, second,
131 tmp.msgtyp, third);
132 }
133 default:
134 panic("msgrcv with version != 0");
135 return sys_msgrcv (first,
136 (struct msgbuf *) ptr,
137 second, fifth, third);
138 }
139 case MSGGET:
140 return sys_msgget ((key_t) first, second);
141 case MSGCTL:
142 return sys_msgctl (first, second, (struct msqid_ds *) ptr);
143
144 case SHMAT:
145 switch (version) {
146 default: {
147 ulong raddr;
148 ret = do_shmat (first, (char *) ptr, second, &raddr);
149 if (ret)
150 return ret;
151 return put_user (raddr, (ulong *) third);
152 }
153 case 1: /* iBCS2 emulator entry point */
154 if (!segment_eq(get_fs(), get_ds()))
155 return -EINVAL;
156 return do_shmat (first, (char *) ptr, second, (ulong *) third);
157 }
158 case SHMDT:
159 return sys_shmdt ((char *)ptr);
160 case SHMGET:
161 return sys_shmget (first, second, third);
162 case SHMCTL:
163 return sys_shmctl (first, second,
164 (struct shmid_ds *) ptr);
165 default:
166 return -ENOSYS;
167 }
168}
169
170long sys_sigaction(int sig, const struct old_sigaction __user *act,
171 struct old_sigaction __user *oact)
172{
173 struct k_sigaction new_ka, old_ka;
174 int ret;
175
176 if (act) {
177 old_sigset_t mask;
178 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
179 __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
180 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
181 return -EFAULT;
182 __get_user(new_ka.sa.sa_flags, &act->sa_flags);
183 __get_user(mask, &act->sa_mask);
184 siginitset(&new_ka.sa.sa_mask, mask);
185 }
186
187 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
188
189 if (!ret && oact) {
190 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
191 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
192 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
193 return -EFAULT;
194 __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
195 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
196 }
197
198 return ret;
199}
200
201/*
202 * Overrides for Emacs so that we follow Linus's tabbing style.
203 * Emacs will notice this stuff at the end of the file and automatically
204 * adjust the settings for this buffer only. This must remain at the end
205 * of the file.
206 * ---------------------------------------------------------------------------
207 * Local variables:
208 * c-file-style: "linux"
209 * End:
210 */