2 * Copyright (c) 1993 Ulrich Pegelow <pegelow@moorea.uni-muenster.de>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #if defined(LINUX) || defined(SUNOS4) || defined(FREEBSD)
66 #if defined LINUX && !defined IPC_64
70 extern const struct xlat openmodes[];
71 extern void printsigevent(struct tcb *tcp, long arg);
73 static const struct xlat msgctl_flags[] = {
74 { IPC_RMID, "IPC_RMID" },
75 { IPC_SET, "IPC_SET" },
76 { IPC_STAT, "IPC_STAT" },
78 { IPC_INFO, "IPC_INFO" },
79 { MSG_STAT, "MSG_STAT" },
80 { MSG_INFO, "MSG_INFO" },
85 static const struct xlat semctl_flags[] = {
86 { IPC_RMID, "IPC_RMID" },
87 { IPC_SET, "IPC_SET" },
88 { IPC_STAT, "IPC_STAT" },
90 { IPC_INFO, "IPC_INFO" },
91 { SEM_STAT, "SEM_STAT" },
92 { SEM_INFO, "SEM_INFO" },
97 { GETNCNT, "GETNCNT" },
98 { GETZCNT, "GETZCNT" },
100 { SETALL, "SETALL" },
104 static const struct xlat shmctl_flags[] = {
105 { IPC_RMID, "IPC_RMID" },
106 { IPC_SET, "IPC_SET" },
107 { IPC_STAT, "IPC_STAT" },
109 { IPC_INFO, "IPC_INFO" },
110 { SHM_STAT, "SHM_STAT" },
111 { SHM_INFO, "SHM_INFO" },
114 { SHM_LOCK, "SHM_LOCK" },
117 { SHM_UNLOCK, "SHM_UNLOCK" },
122 static const struct xlat resource_flags[] = {
123 { IPC_CREAT, "IPC_CREAT" },
124 { IPC_EXCL, "IPC_EXCL" },
125 { IPC_NOWAIT, "IPC_NOWAIT" },
129 static const struct xlat shm_resource_flags[] = {
130 { IPC_CREAT, "IPC_CREAT" },
131 { IPC_EXCL, "IPC_EXCL" },
133 { SHM_HUGETLB, "SHM_HUGETLB" },
138 static const struct xlat shm_flags[] = {
140 { SHM_REMAP, "SHM_REMAP" },
142 { SHM_RDONLY, "SHM_RDONLY" },
143 { SHM_RND, "SHM_RND" },
147 static const struct xlat msg_flags[] = {
148 { MSG_NOERROR, "MSG_NOERROR" },
150 { MSG_EXCEPT, "MSG_EXCEPT" },
152 { IPC_NOWAIT, "IPC_NOWAIT" },
161 tprintf("%lu", tcp->u_arg[0]);
163 tprintf("IPC_PRIVATE");
165 if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0)
167 tprintf("%#lo", tcp->u_arg[1] & 0777);
173 # define PRINTCTL(flagset, arg, dflt) \
174 if ((arg) & IPC_64) tprintf("IPC_64|"); \
175 printxval((flagset), (arg) &~ IPC_64, dflt)
177 # define PRINTCTL printxval
181 indirect_ipccall(tcp)
186 return current_personality > 0;
189 return tcp->scno < 1024; /* ia32 emulation syscalls are low */
191 #if !defined MIPS && !defined HPPA
202 tprintf("%lu, ", tcp->u_arg[0]);
203 PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
204 tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
215 tprintf("%lu", tcp->u_arg[0]);
216 if (indirect_ipccall(tcp)) {
217 umove(tcp, tcp->u_arg[3], &mtype);
218 tprintf(", {%lu, ", mtype);
219 printstr(tcp, tcp->u_arg[3] + sizeof(long),
221 tprintf("}, %lu", tcp->u_arg[1]);
223 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
225 umove(tcp, tcp->u_arg[1], &mtype);
226 tprintf(", {%lu, ", mtype);
227 printstr(tcp, tcp->u_arg[1] + sizeof(long),
229 tprintf("}, %lu", tcp->u_arg[2]);
231 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
243 tprintf("%lu, ", tcp->u_arg[0]);
245 tprintf("%lu", tcp->u_arg[0]);
246 if (indirect_ipccall(tcp)) {
251 umove(tcp, tcp->u_arg[3], &tmp);
252 umove(tcp, (long) tmp.msgp, &mtype);
253 tprintf(", {%lu, ", mtype);
254 printstr(tcp, (long) (tmp.msgp) + sizeof(long),
256 tprintf("}, %lu", tcp->u_arg[1]);
257 tprintf(", %ld", tmp.msgtyp);
259 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
261 umove(tcp, tcp->u_arg[1], &mtype);
262 tprintf("{%lu, ", mtype);
263 printstr(tcp, tcp->u_arg[1] + sizeof(long),
265 tprintf("}, %lu", tcp->u_arg[2]);
266 tprintf(", %ld", tcp->u_arg[3]);
268 printflags(msg_flags, tcp->u_arg[4], "MSG_???");
278 tprintf("%lu", tcp->u_arg[0]);
279 if (indirect_ipccall(tcp)) {
280 tprintf(", %#lx", tcp->u_arg[3]);
281 tprintf(", %lu", tcp->u_arg[1]);
283 tprintf(", %#lx", tcp->u_arg[1]);
284 tprintf(", %lu", tcp->u_arg[2]);
291 int sys_semtimedop(tcp)
295 tprintf("%lu", tcp->u_arg[0]);
296 if (!indirect_ipccall(tcp)) {
297 tprintf(", %#lx", tcp->u_arg[3]);
298 tprintf(", %lu, ", tcp->u_arg[1]);
299 printtv(tcp, tcp->u_arg[5]);
301 tprintf(", %#lx", tcp->u_arg[1]);
302 tprintf(", %lu, ", tcp->u_arg[2]);
303 printtv(tcp, tcp->u_arg[3]);
315 tprintf("%lu", tcp->u_arg[0]);
317 tprintf("IPC_PRIVATE");
318 tprintf(", %lu", tcp->u_arg[1]);
320 if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
322 tprintf("%#lo", tcp->u_arg[2] & 0777);
331 tprintf("%lu", tcp->u_arg[0]);
332 tprintf(", %lu, ", tcp->u_arg[1]);
333 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
334 tprintf(", %#lx", tcp->u_arg[3]);
344 tprintf("%lu", tcp->u_arg[0]);
346 tprintf("IPC_PRIVATE");
347 tprintf(", %lu", tcp->u_arg[1]);
349 if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
351 tprintf("%#lo", tcp->u_arg[2] & 0777);
360 tprintf("%lu, ", tcp->u_arg[0]);
361 PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???");
362 if (indirect_ipccall(tcp)) {
363 tprintf(", %#lx", tcp->u_arg[3]);
365 tprintf(", %#lx", tcp->u_arg[2]);
379 tprintf("%lu", tcp->u_arg[0]);
380 if (indirect_ipccall(tcp)) {
381 tprintf(", %#lx", tcp->u_arg[3]);
383 printflags(shm_flags, tcp->u_arg[1], "SHM_???");
385 tprintf(", %#lx", tcp->u_arg[1]);
387 printflags(shm_flags, tcp->u_arg[2], "SHM_???");
392 if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
405 if (indirect_ipccall(tcp)) {
406 tprintf("%#lx", tcp->u_arg[3]);
408 tprintf("%#lx", tcp->u_arg[0]);
414 #endif /* defined(LINUX) || defined(SUNOS4) || defined(FREEBSD) */
421 printpath(tcp, tcp->u_arg[0]);
424 printflags(openmodes, tcp->u_arg[1] + 1, "O_???");
425 if (tcp->u_arg[1] & O_CREAT) {
426 # ifndef HAVE_MQUEUE_H
427 tprintf(", %lx", tcp->u_arg[2]);
431 tprintf(", %#lo, ", tcp->u_arg[2]);
432 if (umove(tcp, tcp->u_arg[3], &attr) < 0)
435 tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
436 attr.mq_maxmsg, attr.mq_msgsize);
443 int sys_mq_timedsend(tcp)
447 tprintf("%ld, ", tcp->u_arg[0]);
448 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
449 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
450 printtv(tcp, tcp->u_arg[4]);
455 int sys_mq_timedreceive(tcp)
459 tprintf("%ld, ", tcp->u_arg[0]);
461 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
462 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
463 printtv(tcp, tcp->u_arg[4]);
468 int sys_mq_notify(tcp)
472 tprintf("%ld, ", tcp->u_arg[0]);
473 printsigevent(tcp, tcp->u_arg[1]);
478 static void printmqattr(tcp, addr)
485 # ifndef HAVE_MQUEUE_H
486 tprintf("%#lx", addr);
489 if (umove(tcp, addr, &attr) < 0) {
493 tprintf("{mq_flags=");
494 printflags(openmodes, attr.mq_flags + 1, "O_???");
495 tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
496 attr.mq_maxmsg, attr.mq_msgsize, attr.mq_curmsgs);
501 int sys_mq_getsetattr(tcp)
505 tprintf("%ld, ", tcp->u_arg[0]);
506 printmqattr(tcp, tcp->u_arg[1]);
509 printmqattr(tcp, tcp->u_arg[2]);