aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/sys_s390.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/s390/kernel/sys_s390.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/s390/kernel/sys_s390.c')
-rw-r--r--arch/s390/kernel/sys_s390.c270
1 files changed, 270 insertions, 0 deletions
diff --git a/arch/s390/kernel/sys_s390.c b/arch/s390/kernel/sys_s390.c
new file mode 100644
index 000000000000..efe6b83b53f7
--- /dev/null
+++ b/arch/s390/kernel/sys_s390.c
@@ -0,0 +1,270 @@
1/*
2 * arch/s390/kernel/sys_s390.c
3 *
4 * S390 version
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 * Thomas Spatzier (tspat@de.ibm.com)
8 *
9 * Derived from "arch/i386/kernel/sys_i386.c"
10 *
11 * This file contains various random system calls that
12 * have a non-standard calling sequence on the Linux/s390
13 * platform.
14 */
15
16#include <linux/errno.h>
17#include <linux/sched.h>
18#include <linux/mm.h>
19#include <linux/smp.h>
20#include <linux/smp_lock.h>
21#include <linux/sem.h>
22#include <linux/msg.h>
23#include <linux/shm.h>
24#include <linux/stat.h>
25#include <linux/syscalls.h>
26#include <linux/mman.h>
27#include <linux/file.h>
28#include <linux/utsname.h>
29#ifdef CONFIG_ARCH_S390X
30#include <linux/personality.h>
31#endif /* CONFIG_ARCH_S390X */
32
33#include <asm/uaccess.h>
34#include <asm/ipc.h>
35
36/*
37 * sys_pipe() is the normal C calling standard for creating
38 * a pipe. It's not the way Unix traditionally does this, though.
39 */
40asmlinkage long sys_pipe(unsigned long __user *fildes)
41{
42 int fd[2];
43 int error;
44
45 error = do_pipe(fd);
46 if (!error) {
47 if (copy_to_user(fildes, fd, 2*sizeof(int)))
48 error = -EFAULT;
49 }
50 return error;
51}
52
53/* common code for old and new mmaps */
54static inline long do_mmap2(
55 unsigned long addr, unsigned long len,
56 unsigned long prot, unsigned long flags,
57 unsigned long fd, unsigned long pgoff)
58{
59 long error = -EBADF;
60 struct file * file = NULL;
61
62 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
63 if (!(flags & MAP_ANONYMOUS)) {
64 file = fget(fd);
65 if (!file)
66 goto out;
67 }
68
69 down_write(&current->mm->mmap_sem);
70 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
71 up_write(&current->mm->mmap_sem);
72
73 if (file)
74 fput(file);
75out:
76 return error;
77}
78
79/*
80 * Perform the select(nd, in, out, ex, tv) and mmap() system
81 * calls. Linux for S/390 isn't able to handle more than 5
82 * system call parameters, so these system calls used a memory
83 * block for parameter passing..
84 */
85
86struct mmap_arg_struct {
87 unsigned long addr;
88 unsigned long len;
89 unsigned long prot;
90 unsigned long flags;
91 unsigned long fd;
92 unsigned long offset;
93};
94
95asmlinkage long sys_mmap2(struct mmap_arg_struct __user *arg)
96{
97 struct mmap_arg_struct a;
98 int error = -EFAULT;
99
100 if (copy_from_user(&a, arg, sizeof(a)))
101 goto out;
102 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
103out:
104 return error;
105}
106
107asmlinkage long old_mmap(struct mmap_arg_struct __user *arg)
108{
109 struct mmap_arg_struct a;
110 long error = -EFAULT;
111
112 if (copy_from_user(&a, arg, sizeof(a)))
113 goto out;
114
115 error = -EINVAL;
116 if (a.offset & ~PAGE_MASK)
117 goto out;
118
119 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
120out:
121 return error;
122}
123
124#ifndef CONFIG_ARCH_S390X
125struct sel_arg_struct {
126 unsigned long n;
127 fd_set *inp, *outp, *exp;
128 struct timeval *tvp;
129};
130
131asmlinkage long old_select(struct sel_arg_struct __user *arg)
132{
133 struct sel_arg_struct a;
134
135 if (copy_from_user(&a, arg, sizeof(a)))
136 return -EFAULT;
137 /* sys_select() does the appropriate kernel locking */
138 return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
139
140}
141#endif /* CONFIG_ARCH_S390X */
142
143/*
144 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
145 *
146 * This is really horribly ugly.
147 */
148asmlinkage long sys_ipc(uint call, int first, unsigned long second,
149 unsigned long third, void __user *ptr)
150{
151 struct ipc_kludge tmp;
152 int ret;
153
154 switch (call) {
155 case SEMOP:
156 return sys_semtimedop(first, (struct sembuf __user *)ptr,
157 (unsigned)second, NULL);
158 case SEMTIMEDOP:
159 return sys_semtimedop(first, (struct sembuf __user *)ptr,
160 (unsigned)second,
161 (const struct timespec __user *) third);
162 case SEMGET:
163 return sys_semget(first, (int)second, third);
164 case SEMCTL: {
165 union semun fourth;
166 if (!ptr)
167 return -EINVAL;
168 if (get_user(fourth.__pad, (void __user * __user *) ptr))
169 return -EFAULT;
170 return sys_semctl(first, (int)second, third, fourth);
171 }
172 case MSGSND:
173 return sys_msgsnd (first, (struct msgbuf __user *) ptr,
174 (size_t)second, third);
175 break;
176 case MSGRCV:
177 if (!ptr)
178 return -EINVAL;
179 if (copy_from_user (&tmp, (struct ipc_kludge __user *) ptr,
180 sizeof (struct ipc_kludge)))
181 return -EFAULT;
182 return sys_msgrcv (first, tmp.msgp,
183 (size_t)second, tmp.msgtyp, third);
184 case MSGGET:
185 return sys_msgget((key_t)first, (int)second);
186 case MSGCTL:
187 return sys_msgctl(first, (int)second,
188 (struct msqid_ds __user *)ptr);
189
190 case SHMAT: {
191 ulong raddr;
192 ret = do_shmat(first, (char __user *)ptr,
193 (int)second, &raddr);
194 if (ret)
195 return ret;
196 return put_user (raddr, (ulong __user *) third);
197 break;
198 }
199 case SHMDT:
200 return sys_shmdt ((char __user *)ptr);
201 case SHMGET:
202 return sys_shmget(first, (size_t)second, third);
203 case SHMCTL:
204 return sys_shmctl(first, (int)second,
205 (struct shmid_ds __user *) ptr);
206 default:
207 return -ENOSYS;
208
209 }
210
211 return -EINVAL;
212}
213
214#ifdef CONFIG_ARCH_S390X
215asmlinkage long s390x_newuname(struct new_utsname __user *name)
216{
217 int ret = sys_newuname(name);
218
219 if (current->personality == PER_LINUX32 && !ret) {
220 ret = copy_to_user(name->machine, "s390\0\0\0\0", 8);
221 if (ret) ret = -EFAULT;
222 }
223 return ret;
224}
225
226asmlinkage long s390x_personality(unsigned long personality)
227{
228 int ret;
229
230 if (current->personality == PER_LINUX32 && personality == PER_LINUX)
231 personality = PER_LINUX32;
232 ret = sys_personality(personality);
233 if (ret == PER_LINUX32)
234 ret = PER_LINUX;
235
236 return ret;
237}
238#endif /* CONFIG_ARCH_S390X */
239
240/*
241 * Wrapper function for sys_fadvise64/fadvise64_64
242 */
243#ifndef CONFIG_ARCH_S390X
244
245asmlinkage long
246s390_fadvise64(int fd, u32 offset_high, u32 offset_low, size_t len, int advice)
247{
248 return sys_fadvise64(fd, (u64) offset_high << 32 | offset_low,
249 len, advice);
250}
251
252#endif
253
254struct fadvise64_64_args {
255 int fd;
256 long long offset;
257 long long len;
258 int advice;
259};
260
261asmlinkage long
262s390_fadvise64_64(struct fadvise64_64_args __user *args)
263{
264 struct fadvise64_64_args a;
265
266 if ( copy_from_user(&a, args, sizeof(a)) )
267 return -EFAULT;
268 return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice);
269}
270