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 void printsigevent(struct tcb *tcp, long arg);
72 static const struct xlat msgctl_flags[] = {
73 { IPC_RMID, "IPC_RMID" },
74 { IPC_SET, "IPC_SET" },
75 { IPC_STAT, "IPC_STAT" },
77 { IPC_INFO, "IPC_INFO" },
78 { MSG_STAT, "MSG_STAT" },
79 { MSG_INFO, "MSG_INFO" },
84 static const struct xlat semctl_flags[] = {
85 { IPC_RMID, "IPC_RMID" },
86 { IPC_SET, "IPC_SET" },
87 { IPC_STAT, "IPC_STAT" },
89 { IPC_INFO, "IPC_INFO" },
90 { SEM_STAT, "SEM_STAT" },
91 { SEM_INFO, "SEM_INFO" },
96 { GETNCNT, "GETNCNT" },
97 { GETZCNT, "GETZCNT" },
103 static const struct xlat shmctl_flags[] = {
104 { IPC_RMID, "IPC_RMID" },
105 { IPC_SET, "IPC_SET" },
106 { IPC_STAT, "IPC_STAT" },
108 { IPC_INFO, "IPC_INFO" },
109 { SHM_STAT, "SHM_STAT" },
110 { SHM_INFO, "SHM_INFO" },
113 { SHM_LOCK, "SHM_LOCK" },
116 { SHM_UNLOCK, "SHM_UNLOCK" },
121 static const struct xlat resource_flags[] = {
122 { IPC_CREAT, "IPC_CREAT" },
123 { IPC_EXCL, "IPC_EXCL" },
124 { IPC_NOWAIT, "IPC_NOWAIT" },
128 static const struct xlat shm_resource_flags[] = {
129 { IPC_CREAT, "IPC_CREAT" },
130 { IPC_EXCL, "IPC_EXCL" },
132 { SHM_HUGETLB, "SHM_HUGETLB" },
137 static const struct xlat shm_flags[] = {
139 { SHM_REMAP, "SHM_REMAP" },
141 { SHM_RDONLY, "SHM_RDONLY" },
142 { SHM_RND, "SHM_RND" },
146 static const struct xlat msg_flags[] = {
147 { MSG_NOERROR, "MSG_NOERROR" },
149 { MSG_EXCEPT, "MSG_EXCEPT" },
151 { IPC_NOWAIT, "IPC_NOWAIT" },
155 static const struct xlat semop_flags[] = {
156 { SEM_UNDO, "SEM_UNDO" },
157 { IPC_NOWAIT, "IPC_NOWAIT" },
166 tprintf("%#lx", tcp->u_arg[0]);
168 tprintf("IPC_PRIVATE");
170 if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0)
172 tprintf("%#lo", tcp->u_arg[1] & 0777);
178 # define PRINTCTL(flagset, arg, dflt) \
179 if ((arg) & IPC_64) tprintf("IPC_64|"); \
180 printxval((flagset), (arg) &~ IPC_64, dflt)
182 # define PRINTCTL printxval
186 indirect_ipccall(tcp)
191 return current_personality > 0;
194 return tcp->scno < 1024; /* ia32 emulation syscalls are low */
196 #if !defined MIPS && !defined HPPA
207 tprintf("%lu, ", tcp->u_arg[0]);
208 PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
209 tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
220 tprintf("%lu", tcp->u_arg[0]);
221 if (indirect_ipccall(tcp)) {
222 umove(tcp, tcp->u_arg[3], &mtype);
223 tprintf(", {%lu, ", mtype);
224 printstr(tcp, tcp->u_arg[3] + sizeof(long),
226 tprintf("}, %lu", tcp->u_arg[1]);
228 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
230 umove(tcp, tcp->u_arg[1], &mtype);
231 tprintf(", {%lu, ", mtype);
232 printstr(tcp, tcp->u_arg[1] + sizeof(long),
234 tprintf("}, %lu", tcp->u_arg[2]);
236 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
248 tprintf("%lu, ", tcp->u_arg[0]);
250 tprintf("%lu", tcp->u_arg[0]);
251 if (indirect_ipccall(tcp)) {
256 umove(tcp, tcp->u_arg[3], &tmp);
257 umove(tcp, (long) tmp.msgp, &mtype);
258 tprintf(", {%lu, ", mtype);
259 printstr(tcp, (long) (tmp.msgp) + sizeof(long),
261 tprintf("}, %lu", tcp->u_arg[1]);
262 tprintf(", %ld", tmp.msgtyp);
264 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
266 umove(tcp, tcp->u_arg[1], &mtype);
267 tprintf("{%lu, ", mtype);
268 printstr(tcp, tcp->u_arg[1] + sizeof(long),
270 tprintf("}, %lu", tcp->u_arg[2]);
271 tprintf(", %ld", tcp->u_arg[3]);
273 printflags(msg_flags, tcp->u_arg[4], "MSG_???");
280 tprint_sembuf(struct tcb *tcp, long addr, unsigned long count)
282 unsigned long i, max_count;
285 max_count = (max_strlen < count) ? max_strlen : count;
290 tprintf("%#lx, %lu", addr, count);
294 for(i = 0; i < max_count; ++i) {
298 if (umove(tcp, addr + i * sizeof(struct sembuf), &sb) < 0) {
303 tprintf("%#lx, %lu", addr, count);
309 tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
310 printflags(semop_flags, sb.sem_flg, "SEM_???");
315 if (i < max_count || max_count < count)
318 tprintf("}, %lu", count);
321 int sys_semop(struct tcb *tcp)
324 tprintf("%lu, ", tcp->u_arg[0]);
325 if (indirect_ipccall(tcp)) {
326 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
328 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
335 int sys_semtimedop(struct tcb *tcp)
338 tprintf("%lu, ", tcp->u_arg[0]);
339 if (indirect_ipccall(tcp)) {
340 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
342 printtv(tcp, tcp->u_arg[5]);
344 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
346 printtv(tcp, tcp->u_arg[3]);
358 tprintf("%#lx", tcp->u_arg[0]);
360 tprintf("IPC_PRIVATE");
361 tprintf(", %lu", tcp->u_arg[1]);
363 if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
365 tprintf("%#lo", tcp->u_arg[2] & 0777);
374 tprintf("%lu", tcp->u_arg[0]);
375 tprintf(", %lu, ", tcp->u_arg[1]);
376 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
377 tprintf(", %#lx", tcp->u_arg[3]);
387 tprintf("%#lx", tcp->u_arg[0]);
389 tprintf("IPC_PRIVATE");
390 tprintf(", %lu", tcp->u_arg[1]);
392 if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
394 tprintf("%#lo", tcp->u_arg[2] & 0777);
403 tprintf("%lu, ", tcp->u_arg[0]);
404 PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???");
405 if (indirect_ipccall(tcp)) {
406 tprintf(", %#lx", tcp->u_arg[3]);
408 tprintf(", %#lx", tcp->u_arg[2]);
422 tprintf("%lu", tcp->u_arg[0]);
423 if (indirect_ipccall(tcp)) {
424 tprintf(", %#lx", tcp->u_arg[3]);
426 printflags(shm_flags, tcp->u_arg[1], "SHM_???");
428 tprintf(", %#lx", tcp->u_arg[1]);
430 printflags(shm_flags, tcp->u_arg[2], "SHM_???");
434 /* HPPA does not use an IPC multiplexer on Linux. */
435 #if defined(LINUX) && !defined(HPPA)
436 if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
449 if (indirect_ipccall(tcp)) {
450 tprintf("%#lx", tcp->u_arg[3]);
452 tprintf("%#lx", tcp->u_arg[0]);
458 #endif /* defined(LINUX) || defined(SUNOS4) || defined(FREEBSD) */
462 sys_mq_open(struct tcb *tcp)
465 printpath(tcp, tcp->u_arg[0]);
468 tprint_open_modes(tcp->u_arg[1]);
469 if (tcp->u_arg[1] & O_CREAT) {
470 # ifndef HAVE_MQUEUE_H
471 tprintf(", %lx", tcp->u_arg[2]);
475 tprintf(", %#lo, ", tcp->u_arg[2]);
476 if (umove(tcp, tcp->u_arg[3], &attr) < 0)
479 tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
480 attr.mq_maxmsg, attr.mq_msgsize);
488 sys_mq_timedsend(struct tcb *tcp)
491 tprintf("%ld, ", tcp->u_arg[0]);
492 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
493 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
494 printtv(tcp, tcp->u_arg[4]);
500 sys_mq_timedreceive(struct tcb *tcp)
503 tprintf("%ld, ", tcp->u_arg[0]);
505 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
506 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
507 printtv(tcp, tcp->u_arg[4]);
513 sys_mq_notify(struct tcb *tcp)
516 tprintf("%ld, ", tcp->u_arg[0]);
517 printsigevent(tcp, tcp->u_arg[1]);
523 printmqattr(struct tcb *tcp, long addr)
528 # ifndef HAVE_MQUEUE_H
529 tprintf("%#lx", addr);
532 if (umove(tcp, addr, &attr) < 0) {
536 tprintf("{mq_flags=");
537 tprint_open_modes(attr.mq_flags);
538 tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
539 attr.mq_maxmsg, attr.mq_msgsize, attr.mq_curmsgs);
545 sys_mq_getsetattr(struct tcb *tcp)
548 tprintf("%ld, ", tcp->u_arg[0]);
549 printmqattr(tcp, tcp->u_arg[1]);
552 printmqattr(tcp, tcp->u_arg[2]);