blob: f2c064b2090c99cf38da972880c133f4acb0d195 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
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>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00006 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
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.
18 *
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.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000029 */
30
31#include "defs.h"
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010032#ifdef HAVE_MQUEUE_H
33# include <mqueue.h>
34#endif
Roland McGrath4df13c12004-04-16 21:48:40 +000035#include <fcntl.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000036#include <sys/ipc.h>
37#include <sys/sem.h>
38#include <sys/msg.h>
39#include <sys/shm.h>
40
41#ifndef MSG_STAT
42#define MSG_STAT 11
43#endif
44#ifndef MSG_INFO
45#define MSG_INFO 12
46#endif
47#ifndef SHM_STAT
48#define SHM_STAT 13
49#endif
50#ifndef SHM_INFO
51#define SHM_INFO 14
52#endif
53#ifndef SEM_STAT
54#define SEM_STAT 18
55#endif
56#ifndef SEM_INFO
57#define SEM_INFO 19
58#endif
59
Denys Vlasenko84703742012-02-25 02:38:52 +010060#if !defined IPC_64
Roland McGrath80731792003-01-14 09:46:17 +000061# define IPC_64 0x100
62#endif
63
Roland McGrath4df13c12004-04-16 21:48:40 +000064extern void printsigevent(struct tcb *tcp, long arg);
65
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000066#include "xlat/msgctl_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000067#include "xlat/semctl_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000068#include "xlat/shmctl_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000069#include "xlat/resource_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000070#include "xlat/shm_resource_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000071#include "xlat/shm_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000072#include "xlat/ipc_msg_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000073#include "xlat/semop_flags.h"
Jakub Bogusz002e9852009-10-07 22:25:10 +020074
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000075SYS_FUNC(msgget)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000076{
77 if (entering(tcp)) {
78 if (tcp->u_arg[0])
Denys Vlasenko859ea8b2013-02-23 20:07:44 +010079 tprintf("%#lx, ", tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000080 else
Denys Vlasenko859ea8b2013-02-23 20:07:44 +010081 tprints("IPC_PRIVATE, ");
Roland McGrathb2dee132005-06-01 19:02:36 +000082 if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020083 tprints("|");
Roland McGrathe2be9ab2003-07-17 09:03:04 +000084 tprintf("%#lo", tcp->u_arg[1] & 0777);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000085 }
86 return 0;
87}
88
Roland McGrath80731792003-01-14 09:46:17 +000089#ifdef IPC_64
90# define PRINTCTL(flagset, arg, dflt) \
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020091 if ((arg) & IPC_64) tprints("IPC_64|"); \
Roland McGrath80731792003-01-14 09:46:17 +000092 printxval((flagset), (arg) &~ IPC_64, dflt)
93#else
94# define PRINTCTL printxval
95#endif
96
Roland McGrath54b90d72005-12-02 03:57:07 +000097static int
Denys Vlasenko12014262011-05-30 14:00:14 +020098indirect_ipccall(struct tcb *tcp)
Roland McGrath54b90d72005-12-02 03:57:07 +000099{
Dmitry V. Levin3b499ca2015-01-10 22:01:35 +0300100 return tcp->s_ent->sys_flags & TRACE_INDIRECT_SUBCALL;
Roland McGrath54b90d72005-12-02 03:57:07 +0000101}
102
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000103SYS_FUNC(msgctl)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000104{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000105 if (entering(tcp)) {
Roland McGrath80731792003-01-14 09:46:17 +0000106 tprintf("%lu, ", tcp->u_arg[0]);
107 PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
Roland McGrath54b90d72005-12-02 03:57:07 +0000108 tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000109 }
110 return 0;
111}
112
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000113static void
Dmitry V. Levin4310a372010-03-31 22:22:01 +0000114tprint_msgsnd(struct tcb *tcp, long addr, unsigned long count,
115 unsigned long flags)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000116{
117 long mtype;
118
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000119 if (umove(tcp, addr, &mtype) < 0) {
120 tprintf("%#lx", addr);
121 } else {
122 tprintf("{%lu, ", mtype);
123 printstr(tcp, addr + sizeof(mtype), count);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200124 tprints("}");
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000125 }
126 tprintf(", %lu, ", count);
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000127 printflags(ipc_msg_flags, flags, "MSG_???");
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000128}
129
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000130SYS_FUNC(msgsnd)
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000131{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000132 if (entering(tcp)) {
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000133 tprintf("%d, ", (int) tcp->u_arg[0]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000134 if (indirect_ipccall(tcp)) {
Dmitry V. Levin4310a372010-03-31 22:22:01 +0000135 tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1],
136 tcp->u_arg[2]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000137 } else {
Dmitry V. Levin4310a372010-03-31 22:22:01 +0000138 tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2],
139 tcp->u_arg[3]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000140 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000141 }
142 return 0;
143}
144
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000145static void
146tprint_msgrcv(struct tcb *tcp, long addr, unsigned long count, long msgtyp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000147{
148 long mtype;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000149
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000150 if (syserror(tcp) || umove(tcp, addr, &mtype) < 0) {
151 tprintf("%#lx", addr);
Roland McGrathf467c002005-12-02 03:44:12 +0000152 } else {
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000153 tprintf("{%lu, ", mtype);
154 printstr(tcp, addr + sizeof(mtype), count);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200155 tprints("}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000156 }
157 tprintf(", %lu, %ld, ", count, msgtyp);
158}
159
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000160SYS_FUNC(msgrcv)
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000161{
162 if (entering(tcp)) {
163 tprintf("%d, ", (int) tcp->u_arg[0]);
164 } else {
Roland McGrath54b90d72005-12-02 03:57:07 +0000165 if (indirect_ipccall(tcp)) {
166 struct ipc_wrapper {
167 struct msgbuf *msgp;
168 long msgtyp;
169 } tmp;
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000170
171 if (umove(tcp, tcp->u_arg[3], &tmp) < 0) {
172 tprintf("%#lx, %lu, ",
173 tcp->u_arg[3], tcp->u_arg[1]);
174 } else {
175 tprint_msgrcv(tcp, (long) tmp.msgp,
176 tcp->u_arg[1], tmp.msgtyp);
177 }
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000178 printflags(ipc_msg_flags, tcp->u_arg[2], "MSG_???");
Roland McGrath54b90d72005-12-02 03:57:07 +0000179 } else {
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000180 tprint_msgrcv(tcp, tcp->u_arg[1],
181 tcp->u_arg[2], tcp->u_arg[3]);
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000182 printflags(ipc_msg_flags, tcp->u_arg[4], "MSG_???");
Roland McGrath54b90d72005-12-02 03:57:07 +0000183 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000184 }
185 return 0;
186}
187
Dmitry V. Levinef941012009-10-07 22:14:00 +0000188static void
189tprint_sembuf(struct tcb *tcp, long addr, unsigned long count)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000190{
Dmitry V. Levinef941012009-10-07 22:14:00 +0000191 unsigned long i, max_count;
Jakub Bogusz002e9852009-10-07 22:25:10 +0200192
Dmitry V. Levinef941012009-10-07 22:14:00 +0000193 if (abbrev(tcp))
194 max_count = (max_strlen < count) ? max_strlen : count;
195 else
196 max_count = count;
197
198 if (!max_count) {
199 tprintf("%#lx, %lu", addr, count);
200 return;
201 }
202
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200203 for (i = 0; i < max_count; ++i) {
Dmitry V. Levinef941012009-10-07 22:14:00 +0000204 struct sembuf sb;
205 if (i)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200206 tprints(", ");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000207 if (umove(tcp, addr + i * sizeof(struct sembuf), &sb) < 0) {
208 if (i) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200209 tprints("{???}");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000210 break;
211 } else {
212 tprintf("%#lx, %lu", addr, count);
213 return;
Jakub Bogusz002e9852009-10-07 22:25:10 +0200214 }
Roland McGrath54b90d72005-12-02 03:57:07 +0000215 } else {
Dmitry V. Levinef941012009-10-07 22:14:00 +0000216 if (!i)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200217 tprints("{");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000218 tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
219 printflags(semop_flags, sb.sem_flg, "SEM_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200220 tprints("}");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000221 }
222 }
223
224 if (i < max_count || max_count < count)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200225 tprints(", ...");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000226
227 tprintf("}, %lu", count);
228}
229
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000230SYS_FUNC(semop)
Dmitry V. Levinef941012009-10-07 22:14:00 +0000231{
232 if (entering(tcp)) {
233 tprintf("%lu, ", tcp->u_arg[0]);
234 if (indirect_ipccall(tcp)) {
235 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
236 } else {
237 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000238 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000239 }
240 return 0;
241}
242
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000243SYS_FUNC(semtimedop)
Roland McGrath84776472003-04-08 01:46:48 +0000244{
245 if (entering(tcp)) {
Dmitry V. Levinef941012009-10-07 22:14:00 +0000246 tprintf("%lu, ", tcp->u_arg[0]);
Roland McGratha079d9f2006-04-25 07:22:01 +0000247 if (indirect_ipccall(tcp)) {
Dmitry V. Levinef941012009-10-07 22:14:00 +0000248 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200249 tprints(", ");
Stanislav Brabecbeae4c72012-12-10 20:18:49 +0100250#if defined(S390) || defined(S390X)
Heiko Carstense0f5fd82011-11-30 13:16:29 +0100251 printtv(tcp, tcp->u_arg[2]);
252#else
Stanislav Brabeceff5c0e2012-12-07 21:30:51 +0100253 printtv(tcp, tcp->u_arg[4]);
Heiko Carstense0f5fd82011-11-30 13:16:29 +0100254#endif
Roland McGrath54b90d72005-12-02 03:57:07 +0000255 } else {
Dmitry V. Levinef941012009-10-07 22:14:00 +0000256 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200257 tprints(", ");
Roland McGrath54b90d72005-12-02 03:57:07 +0000258 printtv(tcp, tcp->u_arg[3]);
259 }
Roland McGrath84776472003-04-08 01:46:48 +0000260 }
261 return 0;
262}
Roland McGrath84776472003-04-08 01:46:48 +0000263
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000264SYS_FUNC(semget)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000265{
266 if (entering(tcp)) {
267 if (tcp->u_arg[0])
Roland McGrath9f130d52006-08-22 07:36:55 +0000268 tprintf("%#lx", tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000269 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200270 tprints("IPC_PRIVATE");
Denys Vlasenko859ea8b2013-02-23 20:07:44 +0100271 tprintf(", %lu, ", tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000272 if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200273 tprints("|");
Roland McGrathe2be9ab2003-07-17 09:03:04 +0000274 tprintf("%#lo", tcp->u_arg[2] & 0777);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000275 }
276 return 0;
277}
278
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000279SYS_FUNC(semctl)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000280{
281 if (entering(tcp)) {
Denys Vlasenko859ea8b2013-02-23 20:07:44 +0100282 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrath80731792003-01-14 09:46:17 +0000283 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
Dmitry V. Levin499c5aa2015-03-11 14:57:57 +0000284 tprints(", ");
285 if (indirect_ipccall(tcp)) {
286 if (current_wordsize == sizeof(int)) {
287 printnum_int(tcp, tcp->u_arg[3], "%#x");
288 } else {
289 printnum_long(tcp, tcp->u_arg[3], "%#lx");
290 }
291 } else {
292 tprintf("%#lx", tcp->u_arg[3]);
293 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000294 }
295 return 0;
296}
297
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000298SYS_FUNC(shmget)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000299{
300 if (entering(tcp)) {
301 if (tcp->u_arg[0])
Roland McGrath9f130d52006-08-22 07:36:55 +0000302 tprintf("%#lx", tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000303 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200304 tprints("IPC_PRIVATE");
Denys Vlasenko859ea8b2013-02-23 20:07:44 +0100305 tprintf(", %lu, ", tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000306 if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200307 tprints("|");
Roland McGrathe2be9ab2003-07-17 09:03:04 +0000308 tprintf("%#lo", tcp->u_arg[2] & 0777);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000309 }
310 return 0;
311}
312
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000313SYS_FUNC(shmctl)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000314{
315 if (entering(tcp)) {
316 tprintf("%lu, ", tcp->u_arg[0]);
Roland McGrath80731792003-01-14 09:46:17 +0000317 PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???");
Roland McGrath54b90d72005-12-02 03:57:07 +0000318 if (indirect_ipccall(tcp)) {
319 tprintf(", %#lx", tcp->u_arg[3]);
320 } else {
321 tprintf(", %#lx", tcp->u_arg[2]);
322 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000323 }
324 return 0;
325}
326
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000327SYS_FUNC(shmat)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000328{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000329 if (exiting(tcp)) {
330 tprintf("%lu", tcp->u_arg[0]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000331 if (indirect_ipccall(tcp)) {
Denys Vlasenko859ea8b2013-02-23 20:07:44 +0100332 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000333 printflags(shm_flags, tcp->u_arg[1], "SHM_???");
334 } else {
Denys Vlasenko859ea8b2013-02-23 20:07:44 +0100335 tprintf(", %#lx, ", tcp->u_arg[1]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000336 printflags(shm_flags, tcp->u_arg[2], "SHM_???");
337 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000338 if (syserror(tcp))
339 return 0;
Dmitry V. Levin3d7b11b2012-03-15 21:19:36 +0000340 if (indirect_ipccall(tcp)) {
341 unsigned long raddr;
342 if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
343 return RVAL_NONE;
344 tcp->u_rval = raddr;
345 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000346 return RVAL_HEX;
347 }
348 return 0;
349}
350
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000351SYS_FUNC(shmdt)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000352{
Roland McGrath54b90d72005-12-02 03:57:07 +0000353 if (entering(tcp)) {
354 if (indirect_ipccall(tcp)) {
355 tprintf("%#lx", tcp->u_arg[3]);
356 } else {
357 tprintf("%#lx", tcp->u_arg[0]);
358 }
359 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000360 return 0;
361}
362
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000363SYS_FUNC(mq_open)
Roland McGrath4df13c12004-04-16 21:48:40 +0000364{
365 if (entering(tcp)) {
366 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200367 tprints(", ");
Roland McGrath4df13c12004-04-16 21:48:40 +0000368 /* flags */
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000369 tprint_open_modes(tcp->u_arg[1]);
Roland McGrath4df13c12004-04-16 21:48:40 +0000370 if (tcp->u_arg[1] & O_CREAT) {
371# ifndef HAVE_MQUEUE_H
372 tprintf(", %lx", tcp->u_arg[2]);
373# else
374 struct mq_attr attr;
375 /* mode */
376 tprintf(", %#lo, ", tcp->u_arg[2]);
377 if (umove(tcp, tcp->u_arg[3], &attr) < 0)
Denys Vlasenko859ea8b2013-02-23 20:07:44 +0100378 tprints("{???}");
Roland McGrath4df13c12004-04-16 21:48:40 +0000379 else
380 tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
H.J. Lu0b315b62012-02-03 10:16:03 -0800381 (long) attr.mq_maxmsg,
382 (long) attr.mq_msgsize);
Roland McGrath4df13c12004-04-16 21:48:40 +0000383# endif
384 }
385 }
386 return 0;
387}
388
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000389SYS_FUNC(mq_timedsend)
Roland McGrath4df13c12004-04-16 21:48:40 +0000390{
391 if (entering(tcp)) {
392 tprintf("%ld, ", tcp->u_arg[0]);
393 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
394 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
395 printtv(tcp, tcp->u_arg[4]);
396 }
397 return 0;
398}
399
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000400SYS_FUNC(mq_timedreceive)
Roland McGrath4df13c12004-04-16 21:48:40 +0000401{
402 if (entering(tcp))
403 tprintf("%ld, ", tcp->u_arg[0]);
404 else {
405 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
406 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
407 printtv(tcp, tcp->u_arg[4]);
408 }
409 return 0;
410}
411
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000412SYS_FUNC(mq_notify)
Roland McGrath4df13c12004-04-16 21:48:40 +0000413{
414 if (entering(tcp)) {
415 tprintf("%ld, ", tcp->u_arg[0]);
416 printsigevent(tcp, tcp->u_arg[1]);
417 }
418 return 0;
419}
420
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000421static void
422printmqattr(struct tcb *tcp, long addr)
Roland McGrath4df13c12004-04-16 21:48:40 +0000423{
424 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200425 tprints("NULL");
Roland McGrath4df13c12004-04-16 21:48:40 +0000426 else {
427# ifndef HAVE_MQUEUE_H
428 tprintf("%#lx", addr);
429# else
430 struct mq_attr attr;
431 if (umove(tcp, addr, &attr) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200432 tprints("{...}");
Roland McGrath4df13c12004-04-16 21:48:40 +0000433 return;
434 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200435 tprints("{mq_flags=");
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000436 tprint_open_modes(attr.mq_flags);
Roland McGrath4df13c12004-04-16 21:48:40 +0000437 tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
H.J. Lu0b315b62012-02-03 10:16:03 -0800438 (long) attr.mq_maxmsg, (long) attr.mq_msgsize,
439 (long) attr.mq_curmsgs);
Roland McGrath4df13c12004-04-16 21:48:40 +0000440# endif
441 }
442}
443
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000444SYS_FUNC(mq_getsetattr)
Roland McGrath4df13c12004-04-16 21:48:40 +0000445{
446 if (entering(tcp)) {
447 tprintf("%ld, ", tcp->u_arg[0]);
448 printmqattr(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200449 tprints(", ");
Roland McGrath4df13c12004-04-16 21:48:40 +0000450 } else
451 printmqattr(tcp, tcp->u_arg[2]);
452 return 0;
453}
Dmitry V. Levinb5e88d42012-02-20 17:02:38 +0000454
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000455SYS_FUNC(ipc)
Dmitry V. Levinb5e88d42012-02-20 17:02:38 +0000456{
457 return printargs(tcp);
458}