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),
8 * Derived from "arch/i386/kernel/sys_i386.c"
10 * This file contains various random system calls that
11 * have a non-standard calling sequence on the Linux/s390
15 #include <linux/errno.h>
16 #include <linux/sched.h>
18 #include <linux/smp.h>
19 #include <linux/smp_lock.h>
20 #include <linux/sem.h>
21 #include <linux/msg.h>
22 #include <linux/shm.h>
23 #include <linux/stat.h>
24 #include <linux/mman.h>
25 #include <linux/file.h>
26 #include <linux/utsname.h>
28 #include <asm/uaccess.h>
32 * sys_pipe() is the normal C calling standard for creating
33 * a pipe. It's not the way Unix traditionally does this, though.
35 asmlinkage int sys_pipe(unsigned long * fildes)
42 if (copy_to_user(fildes, fd, 2*sizeof(int)))
48 /* common code for old and new mmaps */
49 static inline long do_mmap2(
50 unsigned long addr, unsigned long len,
51 unsigned long prot, unsigned long flags,
52 unsigned long fd, unsigned long pgoff)
55 struct file * file = NULL;
57 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
58 if (!(flags & MAP_ANONYMOUS)) {
64 down_write(¤t->mm->mmap_sem);
65 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
66 up_write(¤t->mm->mmap_sem);
75 * Perform the select(nd, in, out, ex, tv) and mmap() system
76 * calls. Linux for S/390 isn't able to handle more than 5
77 * system call parameters, so these system calls used a memory
78 * block for parameter passing..
81 struct mmap_arg_struct {
90 asmlinkage long sys_mmap2(struct mmap_arg_struct *arg)
92 struct mmap_arg_struct a;
95 if (copy_from_user(&a, arg, sizeof(a)))
97 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
102 asmlinkage int old_mmap(struct mmap_arg_struct *arg)
104 struct mmap_arg_struct a;
107 if (copy_from_user(&a, arg, sizeof(a)))
111 if (a.offset & ~PAGE_MASK)
114 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
119 extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
121 struct sel_arg_struct {
123 fd_set *inp, *outp, *exp;
127 asmlinkage int old_select(struct sel_arg_struct *arg)
129 struct sel_arg_struct a;
131 if (copy_from_user(&a, arg, sizeof(a)))
133 /* sys_select() does the appropriate kernel locking */
134 return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
138 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
140 * This is really horribly ugly.
142 asmlinkage int sys_ipc (uint call, int first, int second,
143 int third, void *ptr)
145 struct ipc_kludge tmp;
150 return sys_semop (first, (struct sembuf *)ptr, second);
152 return sys_semget (first, second, third);
157 if (get_user(fourth.__pad, (void **) ptr))
159 return sys_semctl (first, second, third, fourth);
162 return sys_msgsnd (first, (struct msgbuf *) ptr,
168 if (copy_from_user (&tmp, (struct ipc_kludge *) ptr,
169 sizeof (struct ipc_kludge)))
171 return sys_msgrcv (first, tmp.msgp,
172 second, tmp.msgtyp, third);
174 return sys_msgget ((key_t) first, second);
176 return sys_msgctl (first, second, (struct msqid_ds *) ptr);
180 ret = sys_shmat (first, (char *) ptr, second, &raddr);
183 return put_user (raddr, (ulong *) third);
187 return sys_shmdt ((char *)ptr);
189 return sys_shmget (first, second, third);
191 return sys_shmctl (first, second,
192 (struct shmid_ds *) ptr);
204 asmlinkage int sys_uname(struct old_utsname * name)
210 err=copy_to_user(name, &system_utsname, sizeof (*name));
212 return err?-EFAULT:0;
215 asmlinkage int sys_olduname(struct oldold_utsname * name)
221 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
226 error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
227 error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
228 error |= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
229 error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
230 error |= __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN);
231 error |= __put_user(0,name->release+__OLD_UTS_LEN);
232 error |= __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN);
233 error |= __put_user(0,name->version+__OLD_UTS_LEN);
234 error |= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN);
235 error |= __put_user(0,name->machine+__OLD_UTS_LEN);
239 error = error ? -EFAULT : 0;
244 asmlinkage int sys_pause(void)
246 set_current_state(TASK_INTERRUPTIBLE);
248 return -ERESTARTNOHAND;
251 asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on)