2 * arch/s390/kernel/sys_s390.c
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)
9 * Derived from "arch/i386/kernel/sys_i386.c"
11 * This file contains various random system calls that
12 * have a non-standard calling sequence on the Linux/s390
16 #include <linux/errno.h>
17 #include <linux/sched.h>
19 #include <linux/smp.h>
20 #include <linux/sem.h>
21 #include <linux/msg.h>
22 #include <linux/shm.h>
23 #include <linux/stat.h>
24 #include <linux/syscalls.h>
25 #include <linux/mman.h>
26 #include <linux/file.h>
27 #include <linux/utsname.h>
28 #include <linux/personality.h>
29 #include <linux/unistd.h>
31 #include <asm/uaccess.h>
35 * sys_pipe() is the normal C calling standard for creating
36 * a pipe. It's not the way Unix traditionally does this, though.
38 asmlinkage long sys_pipe(unsigned long __user *fildes)
45 if (copy_to_user(fildes, fd, 2*sizeof(int)))
51 /* common code for old and new mmaps */
52 static inline long do_mmap2(
53 unsigned long addr, unsigned long len,
54 unsigned long prot, unsigned long flags,
55 unsigned long fd, unsigned long pgoff)
58 struct file * file = NULL;
60 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
61 if (!(flags & MAP_ANONYMOUS)) {
67 down_write(¤t->mm->mmap_sem);
68 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
69 up_write(¤t->mm->mmap_sem);
78 * Perform the select(nd, in, out, ex, tv) and mmap() system
79 * calls. Linux for S/390 isn't able to handle more than 5
80 * system call parameters, so these system calls used a memory
81 * block for parameter passing..
84 struct mmap_arg_struct {
93 asmlinkage long sys_mmap2(struct mmap_arg_struct __user *arg)
95 struct mmap_arg_struct a;
98 if (copy_from_user(&a, arg, sizeof(a)))
100 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
105 asmlinkage long old_mmap(struct mmap_arg_struct __user *arg)
107 struct mmap_arg_struct a;
108 long error = -EFAULT;
110 if (copy_from_user(&a, arg, sizeof(a)))
114 if (a.offset & ~PAGE_MASK)
117 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
123 struct sel_arg_struct {
125 fd_set __user *inp, *outp, *exp;
126 struct timeval __user *tvp;
129 asmlinkage long old_select(struct sel_arg_struct __user *arg)
131 struct sel_arg_struct a;
133 if (copy_from_user(&a, arg, sizeof(a)))
135 /* sys_select() does the appropriate kernel locking */
136 return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
139 #endif /* CONFIG_64BIT */
142 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
144 * This is really horribly ugly.
146 asmlinkage long sys_ipc(uint call, int first, unsigned long second,
147 unsigned long third, void __user *ptr)
149 struct ipc_kludge tmp;
154 return sys_semtimedop(first, (struct sembuf __user *)ptr,
155 (unsigned)second, NULL);
157 return sys_semtimedop(first, (struct sembuf __user *)ptr,
159 (const struct timespec __user *) third);
161 return sys_semget(first, (int)second, third);
166 if (get_user(fourth.__pad, (void __user * __user *) ptr))
168 return sys_semctl(first, (int)second, third, fourth);
171 return sys_msgsnd (first, (struct msgbuf __user *) ptr,
172 (size_t)second, third);
177 if (copy_from_user (&tmp, (struct ipc_kludge __user *) ptr,
178 sizeof (struct ipc_kludge)))
180 return sys_msgrcv (first, tmp.msgp,
181 (size_t)second, tmp.msgtyp, third);
183 return sys_msgget((key_t)first, (int)second);
185 return sys_msgctl(first, (int)second,
186 (struct msqid_ds __user *)ptr);
190 ret = do_shmat(first, (char __user *)ptr,
191 (int)second, &raddr);
194 return put_user (raddr, (ulong __user *) third);
198 return sys_shmdt ((char __user *)ptr);
200 return sys_shmget(first, (size_t)second, third);
202 return sys_shmctl(first, (int)second,
203 (struct shmid_ds __user *) ptr);
213 asmlinkage long s390x_newuname(struct new_utsname __user *name)
215 int ret = sys_newuname(name);
217 if (current->personality == PER_LINUX32 && !ret) {
218 ret = copy_to_user(name->machine, "s390\0\0\0\0", 8);
219 if (ret) ret = -EFAULT;
224 asmlinkage long s390x_personality(unsigned long personality)
228 if (current->personality == PER_LINUX32 && personality == PER_LINUX)
229 personality = PER_LINUX32;
230 ret = sys_personality(personality);
231 if (ret == PER_LINUX32)
236 #endif /* CONFIG_64BIT */
239 * Wrapper function for sys_fadvise64/fadvise64_64
244 s390_fadvise64(int fd, u32 offset_high, u32 offset_low, size_t len, int advice)
246 return sys_fadvise64(fd, (u64) offset_high << 32 | offset_low,
252 struct fadvise64_64_args {
260 s390_fadvise64_64(struct fadvise64_64_args __user *args)
262 struct fadvise64_64_args a;
264 if ( copy_from_user(&a, args, sizeof(a)) )
266 return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice);