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.
68 extern void printsigevent(struct tcb *tcp, long arg);
70 static const struct xlat msgctl_flags[] = {
71 { IPC_RMID, "IPC_RMID" },
72 { IPC_SET, "IPC_SET" },
73 { IPC_STAT, "IPC_STAT" },
74 { IPC_INFO, "IPC_INFO" },
75 { MSG_STAT, "MSG_STAT" },
76 { MSG_INFO, "MSG_INFO" },
80 static const struct xlat semctl_flags[] = {
81 { IPC_RMID, "IPC_RMID" },
82 { IPC_SET, "IPC_SET" },
83 { IPC_STAT, "IPC_STAT" },
84 { IPC_INFO, "IPC_INFO" },
85 { SEM_STAT, "SEM_STAT" },
86 { SEM_INFO, "SEM_INFO" },
90 { GETNCNT, "GETNCNT" },
91 { GETZCNT, "GETZCNT" },
97 static const struct xlat shmctl_flags[] = {
98 { IPC_RMID, "IPC_RMID" },
99 { IPC_SET, "IPC_SET" },
100 { IPC_STAT, "IPC_STAT" },
101 { IPC_INFO, "IPC_INFO" },
102 { SHM_STAT, "SHM_STAT" },
103 { SHM_INFO, "SHM_INFO" },
105 { SHM_LOCK, "SHM_LOCK" },
108 { SHM_UNLOCK, "SHM_UNLOCK" },
113 static const struct xlat resource_flags[] = {
114 { IPC_CREAT, "IPC_CREAT" },
115 { IPC_EXCL, "IPC_EXCL" },
116 { IPC_NOWAIT, "IPC_NOWAIT" },
120 static const struct xlat shm_resource_flags[] = {
121 { IPC_CREAT, "IPC_CREAT" },
122 { IPC_EXCL, "IPC_EXCL" },
124 { SHM_HUGETLB, "SHM_HUGETLB" },
129 static const struct xlat shm_flags[] = {
130 { SHM_REMAP, "SHM_REMAP" },
131 { SHM_RDONLY, "SHM_RDONLY" },
132 { SHM_RND, "SHM_RND" },
136 static const struct xlat msg_flags[] = {
137 { MSG_NOERROR, "MSG_NOERROR" },
138 { MSG_EXCEPT, "MSG_EXCEPT" },
139 { IPC_NOWAIT, "IPC_NOWAIT" },
143 static const struct xlat semop_flags[] = {
144 { SEM_UNDO, "SEM_UNDO" },
145 { IPC_NOWAIT, "IPC_NOWAIT" },
149 int sys_msgget(struct tcb *tcp)
153 tprintf("%#lx", tcp->u_arg[0]);
155 tprints("IPC_PRIVATE");
157 if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0)
159 tprintf("%#lo", tcp->u_arg[1] & 0777);
165 # define PRINTCTL(flagset, arg, dflt) \
166 if ((arg) & IPC_64) tprints("IPC_64|"); \
167 printxval((flagset), (arg) &~ IPC_64, dflt)
169 # define PRINTCTL printxval
173 indirect_ipccall(struct tcb *tcp)
176 return current_personality > 0;
179 return tcp->scno < 1024; /* ia32 emulation syscalls are low */
181 #if !defined MIPS && !defined HPPA
187 int sys_msgctl(struct tcb *tcp)
190 tprintf("%lu, ", tcp->u_arg[0]);
191 PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
192 tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
198 tprint_msgsnd(struct tcb *tcp, long addr, unsigned long count,
203 if (umove(tcp, addr, &mtype) < 0) {
204 tprintf("%#lx", addr);
206 tprintf("{%lu, ", mtype);
207 printstr(tcp, addr + sizeof(mtype), count);
210 tprintf(", %lu, ", count);
211 printflags(msg_flags, flags, "MSG_???");
214 int sys_msgsnd(struct tcb *tcp)
217 tprintf("%d, ", (int) tcp->u_arg[0]);
218 if (indirect_ipccall(tcp)) {
219 tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1],
222 tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2],
230 tprint_msgrcv(struct tcb *tcp, long addr, unsigned long count, long msgtyp)
234 if (syserror(tcp) || umove(tcp, addr, &mtype) < 0) {
235 tprintf("%#lx", addr);
237 tprintf("{%lu, ", mtype);
238 printstr(tcp, addr + sizeof(mtype), count);
241 tprintf(", %lu, %ld, ", count, msgtyp);
244 int sys_msgrcv(struct tcb *tcp)
247 tprintf("%d, ", (int) tcp->u_arg[0]);
249 if (indirect_ipccall(tcp)) {
255 if (umove(tcp, tcp->u_arg[3], &tmp) < 0) {
256 tprintf("%#lx, %lu, ",
257 tcp->u_arg[3], tcp->u_arg[1]);
259 tprint_msgrcv(tcp, (long) tmp.msgp,
260 tcp->u_arg[1], tmp.msgtyp);
262 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
264 tprint_msgrcv(tcp, tcp->u_arg[1],
265 tcp->u_arg[2], tcp->u_arg[3]);
266 printflags(msg_flags, tcp->u_arg[4], "MSG_???");
273 tprint_sembuf(struct tcb *tcp, long addr, unsigned long count)
275 unsigned long i, max_count;
278 max_count = (max_strlen < count) ? max_strlen : count;
283 tprintf("%#lx, %lu", addr, count);
287 for (i = 0; i < max_count; ++i) {
291 if (umove(tcp, addr + i * sizeof(struct sembuf), &sb) < 0) {
296 tprintf("%#lx, %lu", addr, count);
302 tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
303 printflags(semop_flags, sb.sem_flg, "SEM_???");
308 if (i < max_count || max_count < count)
311 tprintf("}, %lu", count);
314 int sys_semop(struct tcb *tcp)
317 tprintf("%lu, ", tcp->u_arg[0]);
318 if (indirect_ipccall(tcp)) {
319 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
321 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
327 int sys_semtimedop(struct tcb *tcp)
330 tprintf("%lu, ", tcp->u_arg[0]);
331 if (indirect_ipccall(tcp)) {
332 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
335 printtv(tcp, tcp->u_arg[2]);
337 printtv(tcp, tcp->u_arg[5]);
340 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
342 printtv(tcp, tcp->u_arg[3]);
348 int sys_semget(struct tcb *tcp)
352 tprintf("%#lx", tcp->u_arg[0]);
354 tprints("IPC_PRIVATE");
355 tprintf(", %lu", tcp->u_arg[1]);
357 if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
359 tprintf("%#lo", tcp->u_arg[2] & 0777);
364 int sys_semctl(struct tcb *tcp)
367 tprintf("%lu", tcp->u_arg[0]);
368 tprintf(", %lu, ", tcp->u_arg[1]);
369 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
370 tprintf(", %#lx", tcp->u_arg[3]);
375 int sys_shmget(struct tcb *tcp)
379 tprintf("%#lx", tcp->u_arg[0]);
381 tprints("IPC_PRIVATE");
382 tprintf(", %lu", tcp->u_arg[1]);
384 if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
386 tprintf("%#lo", tcp->u_arg[2] & 0777);
391 int sys_shmctl(struct tcb *tcp)
394 tprintf("%lu, ", tcp->u_arg[0]);
395 PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???");
396 if (indirect_ipccall(tcp)) {
397 tprintf(", %#lx", tcp->u_arg[3]);
399 tprintf(", %#lx", tcp->u_arg[2]);
405 int sys_shmat(struct tcb *tcp)
410 tprintf("%lu", tcp->u_arg[0]);
411 if (indirect_ipccall(tcp)) {
412 tprintf(", %#lx", tcp->u_arg[3]);
414 printflags(shm_flags, tcp->u_arg[1], "SHM_???");
416 tprintf(", %#lx", tcp->u_arg[1]);
418 printflags(shm_flags, tcp->u_arg[2], "SHM_???");
422 /* HPPA does not use an IPC multiplexer on Linux. */
424 if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
433 int sys_shmdt(struct tcb *tcp)
436 if (indirect_ipccall(tcp)) {
437 tprintf("%#lx", tcp->u_arg[3]);
439 tprintf("%#lx", tcp->u_arg[0]);
446 sys_mq_open(struct tcb *tcp)
449 printpath(tcp, tcp->u_arg[0]);
452 tprint_open_modes(tcp->u_arg[1]);
453 if (tcp->u_arg[1] & O_CREAT) {
454 # ifndef HAVE_MQUEUE_H
455 tprintf(", %lx", tcp->u_arg[2]);
459 tprintf(", %#lo, ", tcp->u_arg[2]);
460 if (umove(tcp, tcp->u_arg[3], &attr) < 0)
463 tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
464 (long) attr.mq_maxmsg,
465 (long) attr.mq_msgsize);
473 sys_mq_timedsend(struct tcb *tcp)
476 tprintf("%ld, ", tcp->u_arg[0]);
477 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
478 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
479 printtv(tcp, tcp->u_arg[4]);
485 sys_mq_timedreceive(struct tcb *tcp)
488 tprintf("%ld, ", tcp->u_arg[0]);
490 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
491 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
492 printtv(tcp, tcp->u_arg[4]);
498 sys_mq_notify(struct tcb *tcp)
501 tprintf("%ld, ", tcp->u_arg[0]);
502 printsigevent(tcp, tcp->u_arg[1]);
508 printmqattr(struct tcb *tcp, long addr)
513 # ifndef HAVE_MQUEUE_H
514 tprintf("%#lx", addr);
517 if (umove(tcp, addr, &attr) < 0) {
521 tprints("{mq_flags=");
522 tprint_open_modes(attr.mq_flags);
523 tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
524 (long) attr.mq_maxmsg, (long) attr.mq_msgsize,
525 (long) attr.mq_curmsgs);
531 sys_mq_getsetattr(struct tcb *tcp)
534 tprintf("%ld, ", tcp->u_arg[0]);
535 printmqattr(tcp, tcp->u_arg[1]);
538 printmqattr(tcp, tcp->u_arg[2]);
543 sys_ipc(struct tcb *tcp)
545 return printargs(tcp);