blob: dc72151b9085012a42fa538a0a6c946158b0fe61 [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{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +000077 if (tcp->u_arg[0])
78 tprintf("%#lx, ", tcp->u_arg[0]);
79 else
80 tprints("IPC_PRIVATE, ");
81 if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0)
82 tprints("|");
83 tprintf("%#lo", tcp->u_arg[1] & 0777);
84 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000085}
86
Roland McGrath80731792003-01-14 09:46:17 +000087#ifdef IPC_64
88# define PRINTCTL(flagset, arg, dflt) \
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020089 if ((arg) & IPC_64) tprints("IPC_64|"); \
Roland McGrath80731792003-01-14 09:46:17 +000090 printxval((flagset), (arg) &~ IPC_64, dflt)
91#else
92# define PRINTCTL printxval
93#endif
94
Roland McGrath54b90d72005-12-02 03:57:07 +000095static int
Denys Vlasenko12014262011-05-30 14:00:14 +020096indirect_ipccall(struct tcb *tcp)
Roland McGrath54b90d72005-12-02 03:57:07 +000097{
Dmitry V. Levin3b499ca2015-01-10 22:01:35 +030098 return tcp->s_ent->sys_flags & TRACE_INDIRECT_SUBCALL;
Roland McGrath54b90d72005-12-02 03:57:07 +000099}
100
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000101SYS_FUNC(msgctl)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000102{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000103 tprintf("%lu, ", tcp->u_arg[0]);
104 PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
105 tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
106 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000107}
108
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000109static void
Dmitry V. Levin4310a372010-03-31 22:22:01 +0000110tprint_msgsnd(struct tcb *tcp, long addr, unsigned long count,
111 unsigned long flags)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000112{
113 long mtype;
114
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000115 if (umove(tcp, addr, &mtype) < 0) {
116 tprintf("%#lx", addr);
117 } else {
118 tprintf("{%lu, ", mtype);
119 printstr(tcp, addr + sizeof(mtype), count);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200120 tprints("}");
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000121 }
122 tprintf(", %lu, ", count);
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000123 printflags(ipc_msg_flags, flags, "MSG_???");
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000124}
125
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000126SYS_FUNC(msgsnd)
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000127{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000128 tprintf("%d, ", (int) tcp->u_arg[0]);
129 if (indirect_ipccall(tcp)) {
130 tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1],
131 tcp->u_arg[2]);
132 } else {
133 tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2],
134 tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000135 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000136 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000137}
138
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000139static void
140tprint_msgrcv(struct tcb *tcp, long addr, unsigned long count, long msgtyp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000141{
142 long mtype;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000143
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000144 if (syserror(tcp) || umove(tcp, addr, &mtype) < 0) {
145 tprintf("%#lx", addr);
Roland McGrathf467c002005-12-02 03:44:12 +0000146 } else {
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000147 tprintf("{%lu, ", mtype);
148 printstr(tcp, addr + sizeof(mtype), count);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200149 tprints("}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000150 }
151 tprintf(", %lu, %ld, ", count, msgtyp);
152}
153
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000154SYS_FUNC(msgrcv)
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000155{
156 if (entering(tcp)) {
157 tprintf("%d, ", (int) tcp->u_arg[0]);
158 } else {
Roland McGrath54b90d72005-12-02 03:57:07 +0000159 if (indirect_ipccall(tcp)) {
160 struct ipc_wrapper {
161 struct msgbuf *msgp;
162 long msgtyp;
163 } tmp;
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000164
165 if (umove(tcp, tcp->u_arg[3], &tmp) < 0) {
166 tprintf("%#lx, %lu, ",
167 tcp->u_arg[3], tcp->u_arg[1]);
168 } else {
169 tprint_msgrcv(tcp, (long) tmp.msgp,
170 tcp->u_arg[1], tmp.msgtyp);
171 }
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000172 printflags(ipc_msg_flags, tcp->u_arg[2], "MSG_???");
Roland McGrath54b90d72005-12-02 03:57:07 +0000173 } else {
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000174 tprint_msgrcv(tcp, tcp->u_arg[1],
175 tcp->u_arg[2], tcp->u_arg[3]);
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000176 printflags(ipc_msg_flags, tcp->u_arg[4], "MSG_???");
Roland McGrath54b90d72005-12-02 03:57:07 +0000177 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000178 }
179 return 0;
180}
181
Dmitry V. Levinef941012009-10-07 22:14:00 +0000182static void
183tprint_sembuf(struct tcb *tcp, long addr, unsigned long count)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000184{
Dmitry V. Levinef941012009-10-07 22:14:00 +0000185 unsigned long i, max_count;
Jakub Bogusz002e9852009-10-07 22:25:10 +0200186
Dmitry V. Levinef941012009-10-07 22:14:00 +0000187 if (abbrev(tcp))
188 max_count = (max_strlen < count) ? max_strlen : count;
189 else
190 max_count = count;
191
192 if (!max_count) {
193 tprintf("%#lx, %lu", addr, count);
194 return;
195 }
196
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200197 for (i = 0; i < max_count; ++i) {
Dmitry V. Levinef941012009-10-07 22:14:00 +0000198 struct sembuf sb;
199 if (i)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200200 tprints(", ");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000201 if (umove(tcp, addr + i * sizeof(struct sembuf), &sb) < 0) {
202 if (i) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200203 tprints("{???}");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000204 break;
205 } else {
206 tprintf("%#lx, %lu", addr, count);
207 return;
Jakub Bogusz002e9852009-10-07 22:25:10 +0200208 }
Roland McGrath54b90d72005-12-02 03:57:07 +0000209 } else {
Dmitry V. Levinef941012009-10-07 22:14:00 +0000210 if (!i)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200211 tprints("{");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000212 tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
213 printflags(semop_flags, sb.sem_flg, "SEM_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200214 tprints("}");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000215 }
216 }
217
218 if (i < max_count || max_count < count)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200219 tprints(", ...");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000220
221 tprintf("}, %lu", count);
222}
223
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000224SYS_FUNC(semop)
Dmitry V. Levinef941012009-10-07 22:14:00 +0000225{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000226 tprintf("%lu, ", tcp->u_arg[0]);
227 if (indirect_ipccall(tcp)) {
228 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
229 } else {
230 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000231 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000232 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000233}
234
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000235SYS_FUNC(semtimedop)
Roland McGrath84776472003-04-08 01:46:48 +0000236{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000237 tprintf("%lu, ", tcp->u_arg[0]);
238 if (indirect_ipccall(tcp)) {
239 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
240 tprints(", ");
Stanislav Brabecbeae4c72012-12-10 20:18:49 +0100241#if defined(S390) || defined(S390X)
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000242 printtv(tcp, tcp->u_arg[2]);
Heiko Carstense0f5fd82011-11-30 13:16:29 +0100243#else
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000244 printtv(tcp, tcp->u_arg[4]);
Heiko Carstense0f5fd82011-11-30 13:16:29 +0100245#endif
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000246 } else {
247 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
248 tprints(", ");
249 printtv(tcp, tcp->u_arg[3]);
Roland McGrath84776472003-04-08 01:46:48 +0000250 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000251 return RVAL_DECODED;
Roland McGrath84776472003-04-08 01:46:48 +0000252}
Roland McGrath84776472003-04-08 01:46:48 +0000253
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000254SYS_FUNC(semget)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000255{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000256 if (tcp->u_arg[0])
257 tprintf("%#lx", tcp->u_arg[0]);
258 else
259 tprints("IPC_PRIVATE");
260 tprintf(", %lu, ", tcp->u_arg[1]);
261 if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
262 tprints("|");
263 tprintf("%#lo", tcp->u_arg[2] & 0777);
264 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000265}
266
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000267SYS_FUNC(semctl)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000268{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000269 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
270 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
271 tprints(", ");
272 if (indirect_ipccall(tcp)) {
273 if (current_wordsize == sizeof(int)) {
274 printnum_int(tcp, tcp->u_arg[3], "%#x");
Dmitry V. Levin499c5aa2015-03-11 14:57:57 +0000275 } else {
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000276 printnum_long(tcp, tcp->u_arg[3], "%#lx");
Dmitry V. Levin499c5aa2015-03-11 14:57:57 +0000277 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000278 } else {
279 tprintf("%#lx", tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000280 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000281 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000282}
283
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000284SYS_FUNC(shmget)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000285{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000286 if (tcp->u_arg[0])
287 tprintf("%#lx", tcp->u_arg[0]);
288 else
289 tprints("IPC_PRIVATE");
290 tprintf(", %lu, ", tcp->u_arg[1]);
291 if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
292 tprints("|");
293 tprintf("%#lo", tcp->u_arg[2] & 0777);
294 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000295}
296
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000297SYS_FUNC(shmctl)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000298{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000299 tprintf("%lu, ", tcp->u_arg[0]);
300 PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???");
301 tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
302 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000303}
304
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000305SYS_FUNC(shmat)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000306{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000307 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000308 tprintf("%lu", tcp->u_arg[0]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000309 if (indirect_ipccall(tcp)) {
Denys Vlasenko859ea8b2013-02-23 20:07:44 +0100310 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000311 printflags(shm_flags, tcp->u_arg[1], "SHM_???");
312 } else {
Denys Vlasenko859ea8b2013-02-23 20:07:44 +0100313 tprintf(", %#lx, ", tcp->u_arg[1]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000314 printflags(shm_flags, tcp->u_arg[2], "SHM_???");
315 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000316 return 0;
317 } else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000318 if (syserror(tcp))
319 return 0;
Dmitry V. Levin3d7b11b2012-03-15 21:19:36 +0000320 if (indirect_ipccall(tcp)) {
321 unsigned long raddr;
322 if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
323 return RVAL_NONE;
324 tcp->u_rval = raddr;
325 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000326 return RVAL_HEX;
327 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000328}
329
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000330SYS_FUNC(shmdt)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000331{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000332 tprintf("%#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 0]);
333 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000334}
335
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000336SYS_FUNC(mq_open)
Roland McGrath4df13c12004-04-16 21:48:40 +0000337{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000338 printpath(tcp, tcp->u_arg[0]);
339 tprints(", ");
340 /* flags */
341 tprint_open_modes(tcp->u_arg[1]);
342 if (tcp->u_arg[1] & O_CREAT) {
Roland McGrath4df13c12004-04-16 21:48:40 +0000343# ifndef HAVE_MQUEUE_H
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000344 tprintf(", %lx", tcp->u_arg[2]);
Roland McGrath4df13c12004-04-16 21:48:40 +0000345# else
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000346 struct mq_attr attr;
347 /* mode */
348 tprintf(", %#lo, ", tcp->u_arg[2]);
349 if (umove(tcp, tcp->u_arg[3], &attr) < 0)
350 tprints("{???}");
351 else
352 tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
353 (long) attr.mq_maxmsg,
354 (long) attr.mq_msgsize);
Roland McGrath4df13c12004-04-16 21:48:40 +0000355# endif
Roland McGrath4df13c12004-04-16 21:48:40 +0000356 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000357 return RVAL_DECODED;
Roland McGrath4df13c12004-04-16 21:48:40 +0000358}
359
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000360SYS_FUNC(mq_timedsend)
Roland McGrath4df13c12004-04-16 21:48:40 +0000361{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000362 tprintf("%ld, ", tcp->u_arg[0]);
363 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
364 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
365 printtv(tcp, tcp->u_arg[4]);
366 return RVAL_DECODED;
Roland McGrath4df13c12004-04-16 21:48:40 +0000367}
368
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000369SYS_FUNC(mq_timedreceive)
Roland McGrath4df13c12004-04-16 21:48:40 +0000370{
371 if (entering(tcp))
372 tprintf("%ld, ", tcp->u_arg[0]);
373 else {
374 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
375 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
376 printtv(tcp, tcp->u_arg[4]);
377 }
378 return 0;
379}
380
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000381SYS_FUNC(mq_notify)
Roland McGrath4df13c12004-04-16 21:48:40 +0000382{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000383 tprintf("%ld, ", tcp->u_arg[0]);
384 printsigevent(tcp, tcp->u_arg[1]);
385 return RVAL_DECODED;
Roland McGrath4df13c12004-04-16 21:48:40 +0000386}
387
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000388static void
389printmqattr(struct tcb *tcp, long addr)
Roland McGrath4df13c12004-04-16 21:48:40 +0000390{
391 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200392 tprints("NULL");
Roland McGrath4df13c12004-04-16 21:48:40 +0000393 else {
394# ifndef HAVE_MQUEUE_H
395 tprintf("%#lx", addr);
396# else
397 struct mq_attr attr;
398 if (umove(tcp, addr, &attr) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200399 tprints("{...}");
Roland McGrath4df13c12004-04-16 21:48:40 +0000400 return;
401 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200402 tprints("{mq_flags=");
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000403 tprint_open_modes(attr.mq_flags);
Roland McGrath4df13c12004-04-16 21:48:40 +0000404 tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
H.J. Lu0b315b62012-02-03 10:16:03 -0800405 (long) attr.mq_maxmsg, (long) attr.mq_msgsize,
406 (long) attr.mq_curmsgs);
Roland McGrath4df13c12004-04-16 21:48:40 +0000407# endif
408 }
409}
410
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000411SYS_FUNC(mq_getsetattr)
Roland McGrath4df13c12004-04-16 21:48:40 +0000412{
413 if (entering(tcp)) {
414 tprintf("%ld, ", tcp->u_arg[0]);
415 printmqattr(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200416 tprints(", ");
Roland McGrath4df13c12004-04-16 21:48:40 +0000417 } else
418 printmqattr(tcp, tcp->u_arg[2]);
419 return 0;
420}