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 const struct xlat openmodes[];
71 extern void printsigevent(struct tcb *tcp, long arg);
73 static const struct xlat msgctl_flags[] = {
74 { IPC_RMID, "IPC_RMID" },
75 { IPC_SET, "IPC_SET" },
76 { IPC_STAT, "IPC_STAT" },
78 { IPC_INFO, "IPC_INFO" },
79 { MSG_STAT, "MSG_STAT" },
80 { MSG_INFO, "MSG_INFO" },
85 static const struct xlat semctl_flags[] = {
86 { IPC_RMID, "IPC_RMID" },
87 { IPC_SET, "IPC_SET" },
88 { IPC_STAT, "IPC_STAT" },
90 { IPC_INFO, "IPC_INFO" },
91 { SEM_STAT, "SEM_STAT" },
92 { SEM_INFO, "SEM_INFO" },
97 { GETNCNT, "GETNCNT" },
98 { GETZCNT, "GETZCNT" },
100 { SETALL, "SETALL" },
104 static const struct xlat shmctl_flags[] = {
105 { IPC_RMID, "IPC_RMID" },
106 { IPC_SET, "IPC_SET" },
107 { IPC_STAT, "IPC_STAT" },
109 { IPC_INFO, "IPC_INFO" },
110 { SHM_STAT, "SHM_STAT" },
111 { SHM_INFO, "SHM_INFO" },
114 { SHM_LOCK, "SHM_LOCK" },
117 { SHM_UNLOCK, "SHM_UNLOCK" },
122 static const struct xlat resource_flags[] = {
123 { IPC_CREAT, "IPC_CREAT" },
124 { IPC_EXCL, "IPC_EXCL" },
125 { IPC_NOWAIT, "IPC_NOWAIT" },
127 { SHM_HUGETLB, "SHM_HUGETLB" },
132 static const struct xlat shm_flags[] = {
134 { SHM_REMAP, "SHM_REMAP" },
136 { SHM_RDONLY, "SHM_RDONLY" },
137 { SHM_RND, "SHM_RND" },
141 static const struct xlat msg_flags[] = {
142 { MSG_NOERROR, "MSG_NOERROR" },
144 { MSG_EXCEPT, "MSG_EXCEPT" },
146 { IPC_NOWAIT, "IPC_NOWAIT" },
155 tprintf("%lu", tcp->u_arg[0]);
157 tprintf("IPC_PRIVATE");
159 if (printflags(resource_flags, tcp->u_arg[1] & ~0777) != 0)
161 tprintf("%#lo", tcp->u_arg[1] & 0777);
167 # define PRINTCTL(flagset, arg, dflt) \
168 if ((arg) & IPC_64) tprintf("IPC_64|"); \
169 printxval((flagset), (arg) &~ IPC_64, dflt)
171 # define PRINTCTL printxval
178 tprintf("%lu, ", tcp->u_arg[0]);
179 PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
181 tprintf(", %#lx", tcp->u_arg[3]);
183 tprintf(", %#lx", tcp->u_arg[2]);
195 tprintf("%lu", tcp->u_arg[0]);
197 umove(tcp, tcp->u_arg[3], &mtype);
198 tprintf(", {%lu, ", mtype);
199 printstr(tcp, tcp->u_arg[3] + sizeof(long),
201 tprintf("}, %lu", tcp->u_arg[1]);
203 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
206 umove(tcp, tcp->u_arg[1], &mtype);
207 tprintf(", {%lu, ", mtype);
208 printstr(tcp, tcp->u_arg[1] + sizeof(long),
210 tprintf("}, %lu", tcp->u_arg[2]);
212 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
232 tprintf("%lu", tcp->u_arg[0]);
234 umove(tcp, tcp->u_arg[3], &tmp);
235 umove(tcp, (long) tmp.msgp, &mtype);
236 tprintf(", {%lu, ", mtype);
237 printstr(tcp, (long) (tmp.msgp) + sizeof(long),
239 tprintf("}, %lu", tcp->u_arg[1]);
240 tprintf(", %ld", tmp.msgtyp);
242 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
245 umove(tcp, tcp->u_arg[1], &mtype);
246 tprintf(", {%lu, ", mtype);
247 printstr(tcp, tcp->u_arg[1] + sizeof(long),
249 tprintf("}, %lu", tcp->u_arg[2]);
250 tprintf(", %ld", tcp->u_arg[3]);
252 if (printflags(msg_flags, tcp->u_arg[4]) == 0)
263 tprintf("%lu", tcp->u_arg[0]);
265 tprintf(", %#lx", tcp->u_arg[3]);
266 tprintf(", %lu", tcp->u_arg[1]);
268 tprintf(", %#lx", tcp->u_arg[1]);
269 tprintf(", %lu", tcp->u_arg[2]);
276 int sys_semtimedop(tcp)
280 tprintf("%lu", tcp->u_arg[0]);
281 tprintf(", %#lx", tcp->u_arg[3]);
282 tprintf(", %lu, ", tcp->u_arg[1]);
283 printtv(tcp, tcp->u_arg[5]);
294 tprintf("%lu", tcp->u_arg[0]);
296 tprintf("IPC_PRIVATE");
297 tprintf(", %lu", tcp->u_arg[1]);
299 if (printflags(resource_flags, tcp->u_arg[2] & ~0777) != 0)
301 tprintf("%#lo", tcp->u_arg[2] & 0777);
310 tprintf("%lu", tcp->u_arg[0]);
311 tprintf(", %lu, ", tcp->u_arg[1]);
312 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
313 tprintf(", %#lx", tcp->u_arg[3]);
323 tprintf("%lu", tcp->u_arg[0]);
325 tprintf("IPC_PRIVATE");
326 tprintf(", %lu", tcp->u_arg[1]);
328 if (printflags(resource_flags, tcp->u_arg[2] & ~0777) != 0)
330 tprintf("%#lo", tcp->u_arg[2] & 0777);
339 tprintf("%lu, ", tcp->u_arg[0]);
340 PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???");
342 tprintf(", %#lx", tcp->u_arg[3]);
344 tprintf(", %#lx", tcp->u_arg[2]);
358 tprintf("%lu", tcp->u_arg[0]);
360 tprintf(", %#lx", tcp->u_arg[3]);
362 if (printflags(shm_flags, tcp->u_arg[1]) == 0)
365 tprintf(", %#lx", tcp->u_arg[1]);
367 if (printflags(shm_flags, tcp->u_arg[2]) == 0)
373 if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
387 tprintf("%#lx", tcp->u_arg[3]);
389 tprintf("%#lx", tcp->u_arg[0]);
394 #endif /* defined(LINUX) || defined(SUNOS4) || defined(FREEBSD) */
401 printpath(tcp, tcp->u_arg[0]);
404 printflags(openmodes, tcp->u_arg[1] + 1);
405 if (tcp->u_arg[1] & O_CREAT) {
406 # ifndef HAVE_MQUEUE_H
407 tprintf(", %lx", tcp->u_arg[2]);
411 tprintf(", %#lo, ", tcp->u_arg[2]);
412 if (umove(tcp, tcp->u_arg[3], &attr) < 0)
415 tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
416 attr.mq_maxmsg, attr.mq_msgsize);
423 int sys_mq_timedsend(tcp)
427 tprintf("%ld, ", tcp->u_arg[0]);
428 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
429 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
430 printtv(tcp, tcp->u_arg[4]);
435 int sys_mq_timedreceive(tcp)
439 tprintf("%ld, ", tcp->u_arg[0]);
441 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
442 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
443 printtv(tcp, tcp->u_arg[4]);
448 int sys_mq_notify(tcp)
452 tprintf("%ld, ", tcp->u_arg[0]);
453 printsigevent(tcp, tcp->u_arg[1]);
458 static void printmqattr(tcp, addr)
465 # ifndef HAVE_MQUEUE_H
466 tprintf("%#lx", addr);
469 if (umove(tcp, addr, &attr) < 0) {
473 tprintf("{mq_flags=");
474 printflags(openmodes, attr.mq_flags + 1);
475 tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
476 attr.mq_maxmsg, attr.mq_msgsize, attr.mq_curmsgs);
481 int sys_mq_getsetattr(tcp)
485 tprintf("%ld, ", tcp->u_arg[0]);
486 printmqattr(tcp, tcp->u_arg[1]);
489 printmqattr(tcp, tcp->u_arg[2]);