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[] = {
67 { IPC_RMID, "IPC_RMID" },
68 { IPC_SET, "IPC_SET" },
69 { IPC_STAT, "IPC_STAT" },
70 { IPC_INFO, "IPC_INFO" },
71 { MSG_STAT, "MSG_STAT" },
72 { MSG_INFO, "MSG_INFO" },
76 static const struct xlat semctl_flags[] = {
77 { IPC_RMID, "IPC_RMID" },
78 { IPC_SET, "IPC_SET" },
79 { IPC_STAT, "IPC_STAT" },
80 { IPC_INFO, "IPC_INFO" },
81 { SEM_STAT, "SEM_STAT" },
82 { SEM_INFO, "SEM_INFO" },
86 { GETNCNT, "GETNCNT" },
87 { GETZCNT, "GETZCNT" },
93 static const struct xlat shmctl_flags[] = {
94 { IPC_RMID, "IPC_RMID" },
95 { IPC_SET, "IPC_SET" },
96 { IPC_STAT, "IPC_STAT" },
97 { IPC_INFO, "IPC_INFO" },
98 { SHM_STAT, "SHM_STAT" },
99 { SHM_INFO, "SHM_INFO" },
101 { SHM_LOCK, "SHM_LOCK" },
104 { SHM_UNLOCK, "SHM_UNLOCK" },
109 static const struct xlat resource_flags[] = {
110 { IPC_CREAT, "IPC_CREAT" },
111 { IPC_EXCL, "IPC_EXCL" },
112 { IPC_NOWAIT, "IPC_NOWAIT" },
116 static const struct xlat shm_resource_flags[] = {
117 { IPC_CREAT, "IPC_CREAT" },
118 { IPC_EXCL, "IPC_EXCL" },
120 { SHM_HUGETLB, "SHM_HUGETLB" },
125 static const struct xlat shm_flags[] = {
126 { SHM_REMAP, "SHM_REMAP" },
127 { SHM_RDONLY, "SHM_RDONLY" },
128 { SHM_RND, "SHM_RND" },
132 static const struct xlat msg_flags[] = {
133 { MSG_NOERROR, "MSG_NOERROR" },
134 { MSG_EXCEPT, "MSG_EXCEPT" },
135 { IPC_NOWAIT, "IPC_NOWAIT" },
139 static const struct xlat semop_flags[] = {
140 { SEM_UNDO, "SEM_UNDO" },
141 { IPC_NOWAIT, "IPC_NOWAIT" },
145 int sys_msgget(struct tcb *tcp)
149 tprintf("%#lx", tcp->u_arg[0]);
151 tprints("IPC_PRIVATE");
153 if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0)
155 tprintf("%#lo", tcp->u_arg[1] & 0777);
161 # define PRINTCTL(flagset, arg, dflt) \
162 if ((arg) & IPC_64) tprints("IPC_64|"); \
163 printxval((flagset), (arg) &~ IPC_64, dflt)
165 # define PRINTCTL printxval
169 indirect_ipccall(struct tcb *tcp)
172 return current_personality == 1;
175 return tcp->scno < 1024; /* ia32 emulation syscalls are low */
177 #if defined(ALPHA) || defined(MIPS) || defined(HPPA) || defined(__ARM_EABI__)
183 int sys_msgctl(struct tcb *tcp)
186 tprintf("%lu, ", tcp->u_arg[0]);
187 PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
188 tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
194 tprint_msgsnd(struct tcb *tcp, long addr, unsigned long count,
199 if (umove(tcp, addr, &mtype) < 0) {
200 tprintf("%#lx", addr);
202 tprintf("{%lu, ", mtype);
203 printstr(tcp, addr + sizeof(mtype), count);
206 tprintf(", %lu, ", count);
207 printflags(msg_flags, flags, "MSG_???");
210 int sys_msgsnd(struct tcb *tcp)
213 tprintf("%d, ", (int) tcp->u_arg[0]);
214 if (indirect_ipccall(tcp)) {
215 tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1],
218 tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2],
226 tprint_msgrcv(struct tcb *tcp, long addr, unsigned long count, long msgtyp)
230 if (syserror(tcp) || umove(tcp, addr, &mtype) < 0) {
231 tprintf("%#lx", addr);
233 tprintf("{%lu, ", mtype);
234 printstr(tcp, addr + sizeof(mtype), count);
237 tprintf(", %lu, %ld, ", count, msgtyp);
240 int sys_msgrcv(struct tcb *tcp)
243 tprintf("%d, ", (int) tcp->u_arg[0]);
245 if (indirect_ipccall(tcp)) {
251 if (umove(tcp, tcp->u_arg[3], &tmp) < 0) {
252 tprintf("%#lx, %lu, ",
253 tcp->u_arg[3], tcp->u_arg[1]);
255 tprint_msgrcv(tcp, (long) tmp.msgp,
256 tcp->u_arg[1], tmp.msgtyp);
258 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
260 tprint_msgrcv(tcp, tcp->u_arg[1],
261 tcp->u_arg[2], tcp->u_arg[3]);
262 printflags(msg_flags, tcp->u_arg[4], "MSG_???");
269 tprint_sembuf(struct tcb *tcp, long addr, unsigned long count)
271 unsigned long i, max_count;
274 max_count = (max_strlen < count) ? max_strlen : count;
279 tprintf("%#lx, %lu", addr, count);
283 for (i = 0; i < max_count; ++i) {
287 if (umove(tcp, addr + i * sizeof(struct sembuf), &sb) < 0) {
292 tprintf("%#lx, %lu", addr, count);
298 tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
299 printflags(semop_flags, sb.sem_flg, "SEM_???");
304 if (i < max_count || max_count < count)
307 tprintf("}, %lu", count);
310 int sys_semop(struct tcb *tcp)
313 tprintf("%lu, ", tcp->u_arg[0]);
314 if (indirect_ipccall(tcp)) {
315 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
317 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
323 int sys_semtimedop(struct tcb *tcp)
326 tprintf("%lu, ", tcp->u_arg[0]);
327 if (indirect_ipccall(tcp)) {
328 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
331 printtv(tcp, tcp->u_arg[2]);
333 printtv(tcp, tcp->u_arg[5]);
336 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
338 printtv(tcp, tcp->u_arg[3]);
344 int sys_semget(struct tcb *tcp)
348 tprintf("%#lx", tcp->u_arg[0]);
350 tprints("IPC_PRIVATE");
351 tprintf(", %lu", tcp->u_arg[1]);
353 if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
355 tprintf("%#lo", tcp->u_arg[2] & 0777);
360 int sys_semctl(struct tcb *tcp)
363 tprintf("%lu", tcp->u_arg[0]);
364 tprintf(", %lu, ", tcp->u_arg[1]);
365 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
366 tprintf(", %#lx", tcp->u_arg[3]);
371 int sys_shmget(struct tcb *tcp)
375 tprintf("%#lx", tcp->u_arg[0]);
377 tprints("IPC_PRIVATE");
378 tprintf(", %lu", tcp->u_arg[1]);
380 if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
382 tprintf("%#lo", tcp->u_arg[2] & 0777);
387 int sys_shmctl(struct tcb *tcp)
390 tprintf("%lu, ", tcp->u_arg[0]);
391 PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???");
392 if (indirect_ipccall(tcp)) {
393 tprintf(", %#lx", tcp->u_arg[3]);
395 tprintf(", %#lx", tcp->u_arg[2]);
401 int sys_shmat(struct tcb *tcp)
404 tprintf("%lu", tcp->u_arg[0]);
405 if (indirect_ipccall(tcp)) {
406 tprintf(", %#lx", tcp->u_arg[3]);
408 printflags(shm_flags, tcp->u_arg[1], "SHM_???");
410 tprintf(", %#lx", tcp->u_arg[1]);
412 printflags(shm_flags, tcp->u_arg[2], "SHM_???");
416 if (indirect_ipccall(tcp)) {
418 if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
427 int sys_shmdt(struct tcb *tcp)
430 if (indirect_ipccall(tcp)) {
431 tprintf("%#lx", tcp->u_arg[3]);
433 tprintf("%#lx", tcp->u_arg[0]);
440 sys_mq_open(struct tcb *tcp)
443 printpath(tcp, tcp->u_arg[0]);
446 tprint_open_modes(tcp->u_arg[1]);
447 if (tcp->u_arg[1] & O_CREAT) {
448 # ifndef HAVE_MQUEUE_H
449 tprintf(", %lx", tcp->u_arg[2]);
453 tprintf(", %#lo, ", tcp->u_arg[2]);
454 if (umove(tcp, tcp->u_arg[3], &attr) < 0)
457 tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
458 (long) attr.mq_maxmsg,
459 (long) attr.mq_msgsize);
467 sys_mq_timedsend(struct tcb *tcp)
470 tprintf("%ld, ", tcp->u_arg[0]);
471 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
472 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
473 printtv(tcp, tcp->u_arg[4]);
479 sys_mq_timedreceive(struct tcb *tcp)
482 tprintf("%ld, ", tcp->u_arg[0]);
484 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
485 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
486 printtv(tcp, tcp->u_arg[4]);
492 sys_mq_notify(struct tcb *tcp)
495 tprintf("%ld, ", tcp->u_arg[0]);
496 printsigevent(tcp, tcp->u_arg[1]);
502 printmqattr(struct tcb *tcp, long addr)
507 # ifndef HAVE_MQUEUE_H
508 tprintf("%#lx", addr);
511 if (umove(tcp, addr, &attr) < 0) {
515 tprints("{mq_flags=");
516 tprint_open_modes(attr.mq_flags);
517 tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
518 (long) attr.mq_maxmsg, (long) attr.mq_msgsize,
519 (long) attr.mq_curmsgs);
525 sys_mq_getsetattr(struct tcb *tcp)
528 tprintf("%ld, ", tcp->u_arg[0]);
529 printmqattr(tcp, tcp->u_arg[1]);
532 printmqattr(tcp, tcp->u_arg[2]);
537 sys_ipc(struct tcb *tcp)
539 return printargs(tcp);