2 * sys_ipc() is the old de-multiplexer for the SysV IPC calls.
4 * This is really horribly ugly, and new architectures should just wire up
5 * the individual syscalls instead.
7 #include <linux/unistd.h>
8 #include <linux/syscalls.h>
10 #ifdef __ARCH_WANT_SYS_IPC
11 #include <linux/errno.h>
12 #include <linux/ipc.h>
13 #include <linux/shm.h>
14 #include <linux/uaccess.h>
16 SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second,
17 unsigned long, third, void __user *, ptr, long, fifth)
21 version = call >> 16; /* hack for backward compatibility */
26 return sys_semtimedop(first, (struct sembuf __user *)ptr,
29 return sys_semtimedop(first, (struct sembuf __user *)ptr,
31 (const struct timespec __user *)fifth);
34 return sys_semget(first, second, third);
39 if (get_user(arg, (unsigned long __user *) ptr))
41 return sys_semctl(first, second, third, arg);
45 return sys_msgsnd(first, (struct msgbuf __user *) ptr,
50 struct ipc_kludge tmp;
54 if (copy_from_user(&tmp,
55 (struct ipc_kludge __user *) ptr,
58 return sys_msgrcv(first, tmp.msgp, second,
62 return sys_msgrcv(first,
63 (struct msgbuf __user *) ptr,
64 second, fifth, third);
67 return sys_msgget((key_t) first, second);
69 return sys_msgctl(first, second, (struct msqid_ds __user *)ptr);
75 ret = do_shmat(first, (char __user *)ptr,
76 second, &raddr, SHMLBA);
79 return put_user(raddr, (unsigned long __user *) third);
83 * This was the entry point for kernel-originating calls
84 * from iBCS2 in 2.2 days.
89 return sys_shmdt((char __user *)ptr);
91 return sys_shmget(first, second, third);
93 return sys_shmctl(first, second,
94 (struct shmid_ds __user *) ptr);
102 #include <linux/compat.h>
104 #ifndef COMPAT_SHMLBA
105 #define COMPAT_SHMLBA SHMLBA
108 struct compat_ipc_kludge {
110 compat_long_t msgtyp;
113 #ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC
114 COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
115 u32, third, compat_uptr_t, ptr, u32, fifth)
120 version = call >> 16; /* hack for backward compatibility */
125 /* struct sembuf is the same on 32 and 64bit :)) */
126 return sys_semtimedop(first, compat_ptr(ptr), second, NULL);
128 return compat_sys_semtimedop(first, compat_ptr(ptr), second,
131 return sys_semget(first, second, third);
135 if (get_user(pad, (u32 __user *) compat_ptr(ptr)))
137 return compat_sys_semctl(first, second, third, pad);
140 return compat_sys_msgsnd(first, ptr, second, third);
143 void __user *uptr = compat_ptr(ptr);
145 if (first < 0 || second < 0)
149 struct compat_ipc_kludge ipck;
152 if (copy_from_user(&ipck, uptr, sizeof(ipck)))
154 return compat_sys_msgrcv(first, ipck.msgp, second,
157 return compat_sys_msgrcv(first, ptr, second, fifth, third);
160 return sys_msgget(first, second);
162 return compat_sys_msgctl(first, second, compat_ptr(ptr));
170 err = do_shmat(first, compat_ptr(ptr), second, &raddr,
174 return put_user(raddr, (compat_ulong_t *)compat_ptr(third));
177 return sys_shmdt(compat_ptr(ptr));
179 return sys_shmget(first, (unsigned)second, third);
181 return compat_sys_shmctl(first, second, compat_ptr(ptr));