2 * linux/arch/i386/kernel/sys_i386.c
4 * This file contains various random system calls that
5 * have a non-standard calling sequence on the Linux/i386
9 #include <linux/errno.h>
10 #include <linux/sched.h>
12 #include <linux/smp.h>
13 #include <linux/smp_lock.h>
14 #include <linux/sem.h>
15 #include <linux/msg.h>
16 #include <linux/shm.h>
17 #include <linux/stat.h>
18 #include <linux/syscalls.h>
19 #include <linux/mman.h>
20 #include <linux/file.h>
21 #include <linux/utsname.h>
22 #include <linux/vs_base.h>
23 #include <linux/vs_cvirt.h>
25 #include <asm/uaccess.h>
29 * sys_pipe() is the normal C calling standard for creating
30 * a pipe. It's not the way Unix traditionally does this, though.
32 asmlinkage int sys_pipe(unsigned long __user * fildes)
39 if (copy_to_user(fildes, fd, 2*sizeof(int)))
45 /* common code for old and new mmaps */
46 static inline long do_mmap2(
47 unsigned long addr, unsigned long len,
48 unsigned long prot, unsigned long flags,
49 unsigned long fd, unsigned long pgoff)
52 struct file * file = NULL;
54 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
55 if (!(flags & MAP_ANONYMOUS)) {
61 down_write(¤t->mm->mmap_sem);
62 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
63 up_write(¤t->mm->mmap_sem);
71 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
72 unsigned long prot, unsigned long flags,
73 unsigned long fd, unsigned long pgoff)
75 return do_mmap2(addr, len, prot, flags, fd, pgoff);
79 * Perform the select(nd, in, out, ex, tv) and mmap() system
80 * calls. Linux/i386 didn't use to be able to handle more than
81 * 4 system call parameters, so these system calls used a memory
82 * block for parameter passing..
85 struct mmap_arg_struct {
94 asmlinkage int old_mmap(struct mmap_arg_struct __user *arg)
96 struct mmap_arg_struct a;
99 if (copy_from_user(&a, arg, sizeof(a)))
103 if (a.offset & ~PAGE_MASK)
106 err = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
112 struct sel_arg_struct {
114 fd_set __user *inp, *outp, *exp;
115 struct timeval __user *tvp;
118 asmlinkage int old_select(struct sel_arg_struct __user *arg)
120 struct sel_arg_struct a;
122 if (copy_from_user(&a, arg, sizeof(a)))
124 /* sys_select() does the appropriate kernel locking */
125 return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
129 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
131 * This is really horribly ugly.
133 asmlinkage int sys_ipc (uint call, int first, int second,
134 int third, void __user *ptr, long fifth)
138 version = call >> 16; /* hack for backward compatibility */
143 return sys_semtimedop (first, (struct sembuf __user *)ptr, second, NULL);
145 return sys_semtimedop(first, (struct sembuf __user *)ptr, second,
146 (const struct timespec __user *)fifth);
149 return sys_semget (first, second, third);
154 if (get_user(fourth.__pad, (void __user * __user *) ptr))
156 return sys_semctl (first, second, third, fourth);
160 return sys_msgsnd (first, (struct msgbuf __user *) ptr,
165 struct ipc_kludge tmp;
169 if (copy_from_user(&tmp,
170 (struct ipc_kludge __user *) ptr,
173 return sys_msgrcv (first, tmp.msgp, second,
177 return sys_msgrcv (first,
178 (struct msgbuf __user *) ptr,
179 second, fifth, third);
182 return sys_msgget ((key_t) first, second);
184 return sys_msgctl (first, second, (struct msqid_ds __user *) ptr);
190 ret = do_shmat (first, (char __user *) ptr, second, &raddr);
193 return put_user (raddr, (ulong __user *) third);
195 case 1: /* iBCS2 emulator entry point */
196 if (!segment_eq(get_fs(), get_ds()))
198 /* The "(ulong *) third" is valid _only_ because of the kernel segment thing */
199 return do_shmat (first, (char __user *) ptr, second, (ulong *) third);
202 return sys_shmdt ((char __user *)ptr);
204 return sys_shmget (first, second, third);
206 return sys_shmctl (first, second,
207 (struct shmid_ds __user *) ptr);
216 asmlinkage int sys_uname(struct old_utsname __user * name)
222 err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
224 return err?-EFAULT:0;
227 asmlinkage int sys_olduname(struct oldold_utsname __user * name)
230 struct new_utsname *ptr;
234 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
239 ptr = vx_new_utsname();
240 error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN);
241 error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
242 error |= __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN);
243 error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
244 error |= __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN);
245 error |= __put_user(0,name->release+__OLD_UTS_LEN);
246 error |= __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN);
247 error |= __put_user(0,name->version+__OLD_UTS_LEN);
248 error |= __copy_to_user(&name->machine,ptr->machine,__OLD_UTS_LEN);
249 error |= __put_user(0,name->machine+__OLD_UTS_LEN);
253 error = error ? -EFAULT : 0;