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.
64 extern void printsigevent(struct tcb *tcp, long arg);
66 static const struct xlat msgctl_flags[] = {
76 static const struct xlat semctl_flags[] = {
93 static const struct xlat shmctl_flags[] = {
109 static const struct xlat resource_flags[] = {
116 static const struct xlat shm_resource_flags[] = {
125 static const struct xlat shm_flags[] = {
132 static const struct xlat msg_flags[] = {
139 static const struct xlat semop_flags[] = {
145 int sys_msgget(struct tcb *tcp)
149 tprintf("%#lx, ", tcp->u_arg[0]);
151 tprints("IPC_PRIVATE, ");
152 if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0)
154 tprintf("%#lo", tcp->u_arg[1] & 0777);
160 # define PRINTCTL(flagset, arg, dflt) \
161 if ((arg) & IPC_64) tprints("IPC_64|"); \
162 printxval((flagset), (arg) &~ IPC_64, dflt)
164 # define PRINTCTL printxval
168 indirect_ipccall(struct tcb *tcp)
171 return current_personality == 1;
174 return tcp->scno < 1024; /* ia32 emulation syscalls are low */
176 #if defined(ALPHA) || defined(MIPS) || defined(HPPA) || defined(__ARM_EABI__) || defined(AARCH64)
182 int sys_msgctl(struct tcb *tcp)
185 tprintf("%lu, ", tcp->u_arg[0]);
186 PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
187 tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
193 tprint_msgsnd(struct tcb *tcp, long addr, unsigned long count,
198 if (umove(tcp, addr, &mtype) < 0) {
199 tprintf("%#lx", addr);
201 tprintf("{%lu, ", mtype);
202 printstr(tcp, addr + sizeof(mtype), count);
205 tprintf(", %lu, ", count);
206 printflags(msg_flags, flags, "MSG_???");
209 int sys_msgsnd(struct tcb *tcp)
212 tprintf("%d, ", (int) tcp->u_arg[0]);
213 if (indirect_ipccall(tcp)) {
214 tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1],
217 tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2],
225 tprint_msgrcv(struct tcb *tcp, long addr, unsigned long count, long msgtyp)
229 if (syserror(tcp) || umove(tcp, addr, &mtype) < 0) {
230 tprintf("%#lx", addr);
232 tprintf("{%lu, ", mtype);
233 printstr(tcp, addr + sizeof(mtype), count);
236 tprintf(", %lu, %ld, ", count, msgtyp);
239 int sys_msgrcv(struct tcb *tcp)
242 tprintf("%d, ", (int) tcp->u_arg[0]);
244 if (indirect_ipccall(tcp)) {
250 if (umove(tcp, tcp->u_arg[3], &tmp) < 0) {
251 tprintf("%#lx, %lu, ",
252 tcp->u_arg[3], tcp->u_arg[1]);
254 tprint_msgrcv(tcp, (long) tmp.msgp,
255 tcp->u_arg[1], tmp.msgtyp);
257 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
259 tprint_msgrcv(tcp, tcp->u_arg[1],
260 tcp->u_arg[2], tcp->u_arg[3]);
261 printflags(msg_flags, tcp->u_arg[4], "MSG_???");
268 tprint_sembuf(struct tcb *tcp, long addr, unsigned long count)
270 unsigned long i, max_count;
273 max_count = (max_strlen < count) ? max_strlen : count;
278 tprintf("%#lx, %lu", addr, count);
282 for (i = 0; i < max_count; ++i) {
286 if (umove(tcp, addr + i * sizeof(struct sembuf), &sb) < 0) {
291 tprintf("%#lx, %lu", addr, count);
297 tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
298 printflags(semop_flags, sb.sem_flg, "SEM_???");
303 if (i < max_count || max_count < count)
306 tprintf("}, %lu", count);
309 int sys_semop(struct tcb *tcp)
312 tprintf("%lu, ", tcp->u_arg[0]);
313 if (indirect_ipccall(tcp)) {
314 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
316 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
322 int sys_semtimedop(struct tcb *tcp)
325 tprintf("%lu, ", tcp->u_arg[0]);
326 if (indirect_ipccall(tcp)) {
327 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
329 #if defined(S390) || defined(S390X)
330 printtv(tcp, tcp->u_arg[2]);
332 printtv(tcp, tcp->u_arg[4]);
335 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
337 printtv(tcp, tcp->u_arg[3]);
343 int sys_semget(struct tcb *tcp)
347 tprintf("%#lx", tcp->u_arg[0]);
349 tprints("IPC_PRIVATE");
350 tprintf(", %lu, ", tcp->u_arg[1]);
351 if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
353 tprintf("%#lo", tcp->u_arg[2] & 0777);
358 int sys_semctl(struct tcb *tcp)
361 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
362 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
363 tprintf(", %#lx", tcp->u_arg[3]);
368 int sys_shmget(struct tcb *tcp)
372 tprintf("%#lx", tcp->u_arg[0]);
374 tprints("IPC_PRIVATE");
375 tprintf(", %lu, ", tcp->u_arg[1]);
376 if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
378 tprintf("%#lo", tcp->u_arg[2] & 0777);
383 int sys_shmctl(struct tcb *tcp)
386 tprintf("%lu, ", tcp->u_arg[0]);
387 PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???");
388 if (indirect_ipccall(tcp)) {
389 tprintf(", %#lx", tcp->u_arg[3]);
391 tprintf(", %#lx", tcp->u_arg[2]);
397 int sys_shmat(struct tcb *tcp)
400 tprintf("%lu", tcp->u_arg[0]);
401 if (indirect_ipccall(tcp)) {
402 tprintf(", %#lx, ", tcp->u_arg[3]);
403 printflags(shm_flags, tcp->u_arg[1], "SHM_???");
405 tprintf(", %#lx, ", tcp->u_arg[1]);
406 printflags(shm_flags, tcp->u_arg[2], "SHM_???");
410 if (indirect_ipccall(tcp)) {
412 if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
421 int sys_shmdt(struct tcb *tcp)
424 if (indirect_ipccall(tcp)) {
425 tprintf("%#lx", tcp->u_arg[3]);
427 tprintf("%#lx", tcp->u_arg[0]);
434 sys_mq_open(struct tcb *tcp)
437 printpath(tcp, tcp->u_arg[0]);
440 tprint_open_modes(tcp->u_arg[1]);
441 if (tcp->u_arg[1] & O_CREAT) {
442 # ifndef HAVE_MQUEUE_H
443 tprintf(", %lx", tcp->u_arg[2]);
447 tprintf(", %#lo, ", tcp->u_arg[2]);
448 if (umove(tcp, tcp->u_arg[3], &attr) < 0)
451 tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
452 (long) attr.mq_maxmsg,
453 (long) attr.mq_msgsize);
461 sys_mq_timedsend(struct tcb *tcp)
464 tprintf("%ld, ", tcp->u_arg[0]);
465 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
466 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
467 printtv(tcp, tcp->u_arg[4]);
473 sys_mq_timedreceive(struct tcb *tcp)
476 tprintf("%ld, ", tcp->u_arg[0]);
478 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
479 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
480 printtv(tcp, tcp->u_arg[4]);
486 sys_mq_notify(struct tcb *tcp)
489 tprintf("%ld, ", tcp->u_arg[0]);
490 printsigevent(tcp, tcp->u_arg[1]);
496 printmqattr(struct tcb *tcp, long addr)
501 # ifndef HAVE_MQUEUE_H
502 tprintf("%#lx", addr);
505 if (umove(tcp, addr, &attr) < 0) {
509 tprints("{mq_flags=");
510 tprint_open_modes(attr.mq_flags);
511 tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
512 (long) attr.mq_maxmsg, (long) attr.mq_msgsize,
513 (long) attr.mq_curmsgs);
519 sys_mq_getsetattr(struct tcb *tcp)
522 tprintf("%ld, ", tcp->u_arg[0]);
523 printmqattr(tcp, tcp->u_arg[1]);
526 printmqattr(tcp, tcp->u_arg[2]);
531 sys_ipc(struct tcb *tcp)
533 return printargs(tcp);