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.
69 extern void printsigevent(struct tcb *tcp, long arg);
71 static const struct xlat msgctl_flags[] = {
72 { IPC_RMID, "IPC_RMID" },
73 { IPC_SET, "IPC_SET" },
74 { IPC_STAT, "IPC_STAT" },
75 { IPC_INFO, "IPC_INFO" },
76 { MSG_STAT, "MSG_STAT" },
77 { MSG_INFO, "MSG_INFO" },
81 static const struct xlat semctl_flags[] = {
82 { IPC_RMID, "IPC_RMID" },
83 { IPC_SET, "IPC_SET" },
84 { IPC_STAT, "IPC_STAT" },
85 { IPC_INFO, "IPC_INFO" },
86 { SEM_STAT, "SEM_STAT" },
87 { SEM_INFO, "SEM_INFO" },
91 { GETNCNT, "GETNCNT" },
92 { GETZCNT, "GETZCNT" },
98 static const struct xlat shmctl_flags[] = {
99 { IPC_RMID, "IPC_RMID" },
100 { IPC_SET, "IPC_SET" },
101 { IPC_STAT, "IPC_STAT" },
102 { IPC_INFO, "IPC_INFO" },
103 { SHM_STAT, "SHM_STAT" },
104 { SHM_INFO, "SHM_INFO" },
106 { SHM_LOCK, "SHM_LOCK" },
109 { SHM_UNLOCK, "SHM_UNLOCK" },
114 static const struct xlat resource_flags[] = {
115 { IPC_CREAT, "IPC_CREAT" },
116 { IPC_EXCL, "IPC_EXCL" },
117 { IPC_NOWAIT, "IPC_NOWAIT" },
121 static const struct xlat shm_resource_flags[] = {
122 { IPC_CREAT, "IPC_CREAT" },
123 { IPC_EXCL, "IPC_EXCL" },
125 { SHM_HUGETLB, "SHM_HUGETLB" },
130 static const struct xlat shm_flags[] = {
131 { SHM_REMAP, "SHM_REMAP" },
132 { SHM_RDONLY, "SHM_RDONLY" },
133 { SHM_RND, "SHM_RND" },
137 static const struct xlat msg_flags[] = {
138 { MSG_NOERROR, "MSG_NOERROR" },
139 { MSG_EXCEPT, "MSG_EXCEPT" },
140 { IPC_NOWAIT, "IPC_NOWAIT" },
144 static const struct xlat semop_flags[] = {
145 { SEM_UNDO, "SEM_UNDO" },
146 { IPC_NOWAIT, "IPC_NOWAIT" },
150 int sys_msgget(struct tcb *tcp)
154 tprintf("%#lx", tcp->u_arg[0]);
156 tprints("IPC_PRIVATE");
158 if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0)
160 tprintf("%#lo", tcp->u_arg[1] & 0777);
166 # define PRINTCTL(flagset, arg, dflt) \
167 if ((arg) & IPC_64) tprints("IPC_64|"); \
168 printxval((flagset), (arg) &~ IPC_64, dflt)
170 # define PRINTCTL printxval
174 indirect_ipccall(struct tcb *tcp)
177 return current_personality > 0;
180 return tcp->scno < 1024; /* ia32 emulation syscalls are low */
182 #if !defined MIPS && !defined HPPA
188 int sys_msgctl(struct tcb *tcp)
191 tprintf("%lu, ", tcp->u_arg[0]);
192 PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
193 tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
199 tprint_msgsnd(struct tcb *tcp, long addr, unsigned long count,
204 if (umove(tcp, addr, &mtype) < 0) {
205 tprintf("%#lx", addr);
207 tprintf("{%lu, ", mtype);
208 printstr(tcp, addr + sizeof(mtype), count);
211 tprintf(", %lu, ", count);
212 printflags(msg_flags, flags, "MSG_???");
215 int sys_msgsnd(struct tcb *tcp)
218 tprintf("%d, ", (int) tcp->u_arg[0]);
219 if (indirect_ipccall(tcp)) {
220 tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1],
223 tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2],
231 tprint_msgrcv(struct tcb *tcp, long addr, unsigned long count, long msgtyp)
235 if (syserror(tcp) || umove(tcp, addr, &mtype) < 0) {
236 tprintf("%#lx", addr);
238 tprintf("{%lu, ", mtype);
239 printstr(tcp, addr + sizeof(mtype), count);
242 tprintf(", %lu, %ld, ", count, msgtyp);
245 int sys_msgrcv(struct tcb *tcp)
248 tprintf("%d, ", (int) tcp->u_arg[0]);
250 if (indirect_ipccall(tcp)) {
256 if (umove(tcp, tcp->u_arg[3], &tmp) < 0) {
257 tprintf("%#lx, %lu, ",
258 tcp->u_arg[3], tcp->u_arg[1]);
260 tprint_msgrcv(tcp, (long) tmp.msgp,
261 tcp->u_arg[1], tmp.msgtyp);
263 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
265 tprint_msgrcv(tcp, tcp->u_arg[1],
266 tcp->u_arg[2], tcp->u_arg[3]);
267 printflags(msg_flags, tcp->u_arg[4], "MSG_???");
274 tprint_sembuf(struct tcb *tcp, long addr, unsigned long count)
276 unsigned long i, max_count;
279 max_count = (max_strlen < count) ? max_strlen : count;
284 tprintf("%#lx, %lu", addr, count);
288 for (i = 0; i < max_count; ++i) {
292 if (umove(tcp, addr + i * sizeof(struct sembuf), &sb) < 0) {
297 tprintf("%#lx, %lu", addr, count);
303 tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
304 printflags(semop_flags, sb.sem_flg, "SEM_???");
309 if (i < max_count || max_count < count)
312 tprintf("}, %lu", count);
315 int sys_semop(struct tcb *tcp)
318 tprintf("%lu, ", tcp->u_arg[0]);
319 if (indirect_ipccall(tcp)) {
320 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
322 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
328 int sys_semtimedop(struct tcb *tcp)
331 tprintf("%lu, ", tcp->u_arg[0]);
332 if (indirect_ipccall(tcp)) {
333 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
336 printtv(tcp, tcp->u_arg[2]);
338 printtv(tcp, tcp->u_arg[5]);
341 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
343 printtv(tcp, tcp->u_arg[3]);
349 int sys_semget(struct tcb *tcp)
353 tprintf("%#lx", tcp->u_arg[0]);
355 tprints("IPC_PRIVATE");
356 tprintf(", %lu", tcp->u_arg[1]);
358 if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
360 tprintf("%#lo", tcp->u_arg[2] & 0777);
365 int sys_semctl(struct tcb *tcp)
368 tprintf("%lu", tcp->u_arg[0]);
369 tprintf(", %lu, ", tcp->u_arg[1]);
370 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
371 tprintf(", %#lx", tcp->u_arg[3]);
376 int sys_shmget(struct tcb *tcp)
380 tprintf("%#lx", tcp->u_arg[0]);
382 tprints("IPC_PRIVATE");
383 tprintf(", %lu", tcp->u_arg[1]);
385 if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
387 tprintf("%#lo", tcp->u_arg[2] & 0777);
392 int sys_shmctl(struct tcb *tcp)
395 tprintf("%lu, ", tcp->u_arg[0]);
396 PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???");
397 if (indirect_ipccall(tcp)) {
398 tprintf(", %#lx", tcp->u_arg[3]);
400 tprintf(", %#lx", tcp->u_arg[2]);
406 int sys_shmat(struct tcb *tcp)
411 tprintf("%lu", tcp->u_arg[0]);
412 if (indirect_ipccall(tcp)) {
413 tprintf(", %#lx", tcp->u_arg[3]);
415 printflags(shm_flags, tcp->u_arg[1], "SHM_???");
417 tprintf(", %#lx", tcp->u_arg[1]);
419 printflags(shm_flags, tcp->u_arg[2], "SHM_???");
423 /* HPPA does not use an IPC multiplexer on Linux. */
425 if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
434 int sys_shmdt(struct tcb *tcp)
437 if (indirect_ipccall(tcp)) {
438 tprintf("%#lx", tcp->u_arg[3]);
440 tprintf("%#lx", tcp->u_arg[0]);
448 sys_mq_open(struct tcb *tcp)
451 printpath(tcp, tcp->u_arg[0]);
454 tprint_open_modes(tcp->u_arg[1]);
455 if (tcp->u_arg[1] & O_CREAT) {
456 # ifndef HAVE_MQUEUE_H
457 tprintf(", %lx", tcp->u_arg[2]);
461 tprintf(", %#lo, ", tcp->u_arg[2]);
462 if (umove(tcp, tcp->u_arg[3], &attr) < 0)
465 tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
466 (long) attr.mq_maxmsg,
467 (long) attr.mq_msgsize);
475 sys_mq_timedsend(struct tcb *tcp)
478 tprintf("%ld, ", tcp->u_arg[0]);
479 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
480 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
481 printtv(tcp, tcp->u_arg[4]);
487 sys_mq_timedreceive(struct tcb *tcp)
490 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_notify(struct tcb *tcp)
503 tprintf("%ld, ", tcp->u_arg[0]);
504 printsigevent(tcp, tcp->u_arg[1]);
510 printmqattr(struct tcb *tcp, long addr)
515 # ifndef HAVE_MQUEUE_H
516 tprintf("%#lx", addr);
519 if (umove(tcp, addr, &attr) < 0) {
523 tprints("{mq_flags=");
524 tprint_open_modes(attr.mq_flags);
525 tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
526 (long) attr.mq_maxmsg, (long) attr.mq_msgsize,
527 (long) attr.mq_curmsgs);
533 sys_mq_getsetattr(struct tcb *tcp)
536 tprintf("%ld, ", tcp->u_arg[0]);
537 printmqattr(tcp, tcp->u_arg[1]);
540 printmqattr(tcp, tcp->u_arg[2]);
545 sys_ipc(struct tcb *tcp)
547 return printargs(tcp);