2 * This file contains various random system calls that
3 * have a non-standard calling sequence on the Linux/i386
7 #include <linux/errno.h>
8 #include <linux/sched.h>
11 #include <linux/smp.h>
12 #include <linux/sem.h>
13 #include <linux/msg.h>
14 #include <linux/shm.h>
15 #include <linux/stat.h>
16 #include <linux/syscalls.h>
17 #include <linux/mman.h>
18 #include <linux/file.h>
19 #include <linux/utsname.h>
20 #include <linux/ipc.h>
22 #include <linux/uaccess.h>
23 #include <linux/unistd.h>
25 #include <asm/syscalls.h>
28 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
30 * This is really horribly ugly.
32 asmlinkage int sys_ipc(uint call, int first, int second,
33 int third, void __user *ptr, long fifth)
37 version = call >> 16; /* hack for backward compatibility */
42 return sys_semtimedop(first, (struct sembuf __user *)ptr, second, NULL);
44 return sys_semtimedop(first, (struct sembuf __user *)ptr, second,
45 (const struct timespec __user *)fifth);
48 return sys_semget(first, second, third);
53 if (get_user(fourth.__pad, (void __user * __user *) ptr))
55 return sys_semctl(first, second, third, fourth);
59 return sys_msgsnd(first, (struct msgbuf __user *) ptr,
64 struct ipc_kludge tmp;
68 if (copy_from_user(&tmp,
69 (struct ipc_kludge __user *) ptr,
72 return sys_msgrcv(first, tmp.msgp, second,
76 return sys_msgrcv(first,
77 (struct msgbuf __user *) ptr,
78 second, fifth, third);
81 return sys_msgget((key_t) first, second);
83 return sys_msgctl(first, second, (struct msqid_ds __user *) ptr);
89 ret = do_shmat(first, (char __user *) ptr, second, &raddr);
92 return put_user(raddr, (ulong __user *) third);
94 case 1: /* iBCS2 emulator entry point */
95 if (!segment_eq(get_fs(), get_ds()))
97 /* The "(ulong *) third" is valid _only_ because of the kernel segment thing */
98 return do_shmat(first, (char __user *) ptr, second, (ulong *) third);
101 return sys_shmdt((char __user *)ptr);
103 return sys_shmget(first, second, third);
105 return sys_shmctl(first, second,
106 (struct shmid_ds __user *) ptr);
115 asmlinkage int sys_uname(struct old_utsname __user *name)
121 err = copy_to_user(name, utsname(), sizeof(*name));
123 return err? -EFAULT:0;
126 asmlinkage int sys_olduname(struct oldold_utsname __user *name)
132 if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname)))
137 error = __copy_to_user(&name->sysname, &utsname()->sysname,
139 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
140 error |= __copy_to_user(&name->nodename, &utsname()->nodename,
142 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
143 error |= __copy_to_user(&name->release, &utsname()->release,
145 error |= __put_user(0, name->release + __OLD_UTS_LEN);
146 error |= __copy_to_user(&name->version, &utsname()->version,
148 error |= __put_user(0, name->version + __OLD_UTS_LEN);
149 error |= __copy_to_user(&name->machine, &utsname()->machine,
151 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
155 error = error ? -EFAULT : 0;
162 * Do a system call from kernel instead of calling sys_execve so we
163 * end up with proper pt_regs.
165 int kernel_execve(const char *filename, char *const argv[], char *const envp[])
168 asm volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx"
170 : "0" (__NR_execve), "ri" (filename), "c" (argv), "d" (envp) : "memory");