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" },
161 int sys_msgget(struct tcb *tcp)
165 tprintf("%#lx", tcp->u_arg[0]);
167 tprints("IPC_PRIVATE");
169 if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0)
171 tprintf("%#lo", tcp->u_arg[1] & 0777);
177 # define PRINTCTL(flagset, arg, dflt) \
178 if ((arg) & IPC_64) tprints("IPC_64|"); \
179 printxval((flagset), (arg) &~ IPC_64, dflt)
181 # define PRINTCTL printxval
185 indirect_ipccall(struct tcb *tcp)
189 return current_personality > 0;
192 return tcp->scno < 1024; /* ia32 emulation syscalls are low */
194 #if !defined MIPS && !defined HPPA
201 int sys_msgctl(struct tcb *tcp)
204 tprintf("%lu, ", tcp->u_arg[0]);
205 PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
206 tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
212 tprint_msgsnd(struct tcb *tcp, long addr, unsigned long count,
217 if (umove(tcp, addr, &mtype) < 0) {
218 tprintf("%#lx", addr);
220 tprintf("{%lu, ", mtype);
221 printstr(tcp, addr + sizeof(mtype), count);
224 tprintf(", %lu, ", count);
225 printflags(msg_flags, flags, "MSG_???");
228 int sys_msgsnd(struct tcb *tcp)
231 tprintf("%d, ", (int) tcp->u_arg[0]);
232 if (indirect_ipccall(tcp)) {
233 tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1],
236 tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2],
244 tprint_msgrcv(struct tcb *tcp, long addr, unsigned long count, long msgtyp)
248 if (syserror(tcp) || umove(tcp, addr, &mtype) < 0) {
249 tprintf("%#lx", addr);
251 tprintf("{%lu, ", mtype);
252 printstr(tcp, addr + sizeof(mtype), count);
255 tprintf(", %lu, %ld, ", count, msgtyp);
258 int sys_msgrcv(struct tcb *tcp)
261 tprintf("%d, ", (int) tcp->u_arg[0]);
263 if (indirect_ipccall(tcp)) {
269 if (umove(tcp, tcp->u_arg[3], &tmp) < 0) {
270 tprintf("%#lx, %lu, ",
271 tcp->u_arg[3], tcp->u_arg[1]);
273 tprint_msgrcv(tcp, (long) tmp.msgp,
274 tcp->u_arg[1], tmp.msgtyp);
276 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
278 tprint_msgrcv(tcp, tcp->u_arg[1],
279 tcp->u_arg[2], tcp->u_arg[3]);
280 printflags(msg_flags, tcp->u_arg[4], "MSG_???");
287 tprint_sembuf(struct tcb *tcp, long addr, unsigned long count)
289 unsigned long i, max_count;
292 max_count = (max_strlen < count) ? max_strlen : count;
297 tprintf("%#lx, %lu", addr, count);
301 for (i = 0; i < max_count; ++i) {
305 if (umove(tcp, addr + i * sizeof(struct sembuf), &sb) < 0) {
310 tprintf("%#lx, %lu", addr, count);
316 tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
317 printflags(semop_flags, sb.sem_flg, "SEM_???");
322 if (i < max_count || max_count < count)
325 tprintf("}, %lu", count);
328 int sys_semop(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]);
335 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
342 int sys_semtimedop(struct tcb *tcp)
345 tprintf("%lu, ", tcp->u_arg[0]);
346 if (indirect_ipccall(tcp)) {
347 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
350 printtv(tcp, tcp->u_arg[2]);
352 printtv(tcp, tcp->u_arg[5]);
355 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
357 printtv(tcp, tcp->u_arg[3]);
364 int sys_semget(struct tcb *tcp)
368 tprintf("%#lx", tcp->u_arg[0]);
370 tprints("IPC_PRIVATE");
371 tprintf(", %lu", tcp->u_arg[1]);
373 if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
375 tprintf("%#lo", tcp->u_arg[2] & 0777);
380 int sys_semctl(struct tcb *tcp)
383 tprintf("%lu", tcp->u_arg[0]);
384 tprintf(", %lu, ", tcp->u_arg[1]);
385 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
386 tprintf(", %#lx", tcp->u_arg[3]);
391 int sys_shmget(struct tcb *tcp)
395 tprintf("%#lx", tcp->u_arg[0]);
397 tprints("IPC_PRIVATE");
398 tprintf(", %lu", tcp->u_arg[1]);
400 if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
402 tprintf("%#lo", tcp->u_arg[2] & 0777);
407 int sys_shmctl(struct tcb *tcp)
410 tprintf("%lu, ", tcp->u_arg[0]);
411 PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???");
412 if (indirect_ipccall(tcp)) {
413 tprintf(", %#lx", tcp->u_arg[3]);
415 tprintf(", %#lx", tcp->u_arg[2]);
421 int sys_shmat(struct tcb *tcp)
428 tprintf("%lu", tcp->u_arg[0]);
429 if (indirect_ipccall(tcp)) {
430 tprintf(", %#lx", tcp->u_arg[3]);
432 printflags(shm_flags, tcp->u_arg[1], "SHM_???");
434 tprintf(", %#lx", tcp->u_arg[1]);
436 printflags(shm_flags, tcp->u_arg[2], "SHM_???");
440 /* HPPA does not use an IPC multiplexer on Linux. */
441 #if defined(LINUX) && !defined(HPPA)
442 if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
451 int sys_shmdt(struct tcb *tcp)
454 if (indirect_ipccall(tcp)) {
455 tprintf("%#lx", tcp->u_arg[3]);
457 tprintf("%#lx", tcp->u_arg[0]);
463 #endif /* defined(LINUX) || defined(SUNOS4) || defined(FREEBSD) */
467 sys_mq_open(struct tcb *tcp)
470 printpath(tcp, tcp->u_arg[0]);
473 tprint_open_modes(tcp->u_arg[1]);
474 if (tcp->u_arg[1] & O_CREAT) {
475 # ifndef HAVE_MQUEUE_H
476 tprintf(", %lx", tcp->u_arg[2]);
480 tprintf(", %#lo, ", tcp->u_arg[2]);
481 if (umove(tcp, tcp->u_arg[3], &attr) < 0)
484 tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
485 attr.mq_maxmsg, attr.mq_msgsize);
493 sys_mq_timedsend(struct tcb *tcp)
496 tprintf("%ld, ", tcp->u_arg[0]);
497 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
498 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
499 printtv(tcp, tcp->u_arg[4]);
505 sys_mq_timedreceive(struct tcb *tcp)
508 tprintf("%ld, ", tcp->u_arg[0]);
510 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
511 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
512 printtv(tcp, tcp->u_arg[4]);
518 sys_mq_notify(struct tcb *tcp)
521 tprintf("%ld, ", tcp->u_arg[0]);
522 printsigevent(tcp, tcp->u_arg[1]);
528 printmqattr(struct tcb *tcp, long addr)
533 # ifndef HAVE_MQUEUE_H
534 tprintf("%#lx", addr);
537 if (umove(tcp, addr, &attr) < 0) {
541 tprints("{mq_flags=");
542 tprint_open_modes(attr.mq_flags);
543 tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
544 attr.mq_maxmsg, attr.mq_msgsize, attr.mq_curmsgs);
550 sys_mq_getsetattr(struct tcb *tcp)
553 tprintf("%ld, ", tcp->u_arg[0]);
554 printmqattr(tcp, tcp->u_arg[1]);
557 printmqattr(tcp, tcp->u_arg[2]);