blob: e04a6189c1c227e55d885af01d2db1a0aa5ab2f3 [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
Denys Vlasenko12014262011-05-30 14:00:14 +020075int sys_msgget(struct tcb *tcp)
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{
Roland McGrath54b90d72005-12-02 03:57:07 +0000100#ifdef X86_64
H.J. Lu35be5812012-04-16 13:00:01 +0200101 return current_personality == 1;
Roland McGrath54b90d72005-12-02 03:57:07 +0000102#endif
Roland McGratha81bf4c2005-12-02 04:18:55 +0000103#if defined IA64
104 return tcp->scno < 1024; /* ia32 emulation syscalls are low */
Roland McGrath54b90d72005-12-02 03:57:07 +0000105#endif
Steve McIntyred8d3bd32012-10-24 17:58:16 +0100106#if defined(ALPHA) || defined(MIPS) || defined(HPPA) || defined(__ARM_EABI__) || defined(AARCH64)
Roland McGrath54b90d72005-12-02 03:57:07 +0000107 return 0;
Dmitry V. Levin3d7b11b2012-03-15 21:19:36 +0000108#endif
109 return 1;
Roland McGrath54b90d72005-12-02 03:57:07 +0000110}
111
Denys Vlasenko12014262011-05-30 14:00:14 +0200112int sys_msgctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000113{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000114 if (entering(tcp)) {
Roland McGrath80731792003-01-14 09:46:17 +0000115 tprintf("%lu, ", tcp->u_arg[0]);
116 PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
Roland McGrath54b90d72005-12-02 03:57:07 +0000117 tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000118 }
119 return 0;
120}
121
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000122static void
Dmitry V. Levin4310a372010-03-31 22:22:01 +0000123tprint_msgsnd(struct tcb *tcp, long addr, unsigned long count,
124 unsigned long flags)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000125{
126 long mtype;
127
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000128 if (umove(tcp, addr, &mtype) < 0) {
129 tprintf("%#lx", addr);
130 } else {
131 tprintf("{%lu, ", mtype);
132 printstr(tcp, addr + sizeof(mtype), count);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200133 tprints("}");
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000134 }
135 tprintf(", %lu, ", count);
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000136 printflags(ipc_msg_flags, flags, "MSG_???");
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000137}
138
139int sys_msgsnd(struct tcb *tcp)
140{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000141 if (entering(tcp)) {
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000142 tprintf("%d, ", (int) tcp->u_arg[0]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000143 if (indirect_ipccall(tcp)) {
Dmitry V. Levin4310a372010-03-31 22:22:01 +0000144 tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1],
145 tcp->u_arg[2]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000146 } else {
Dmitry V. Levin4310a372010-03-31 22:22:01 +0000147 tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2],
148 tcp->u_arg[3]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000149 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000150 }
151 return 0;
152}
153
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000154static void
155tprint_msgrcv(struct tcb *tcp, long addr, unsigned long count, long msgtyp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000156{
157 long mtype;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000158
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000159 if (syserror(tcp) || umove(tcp, addr, &mtype) < 0) {
160 tprintf("%#lx", addr);
Roland McGrathf467c002005-12-02 03:44:12 +0000161 } else {
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000162 tprintf("{%lu, ", mtype);
163 printstr(tcp, addr + sizeof(mtype), count);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200164 tprints("}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000165 }
166 tprintf(", %lu, %ld, ", count, msgtyp);
167}
168
169int sys_msgrcv(struct tcb *tcp)
170{
171 if (entering(tcp)) {
172 tprintf("%d, ", (int) tcp->u_arg[0]);
173 } else {
Roland McGrath54b90d72005-12-02 03:57:07 +0000174 if (indirect_ipccall(tcp)) {
175 struct ipc_wrapper {
176 struct msgbuf *msgp;
177 long msgtyp;
178 } tmp;
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000179
180 if (umove(tcp, tcp->u_arg[3], &tmp) < 0) {
181 tprintf("%#lx, %lu, ",
182 tcp->u_arg[3], tcp->u_arg[1]);
183 } else {
184 tprint_msgrcv(tcp, (long) tmp.msgp,
185 tcp->u_arg[1], tmp.msgtyp);
186 }
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000187 printflags(ipc_msg_flags, tcp->u_arg[2], "MSG_???");
Roland McGrath54b90d72005-12-02 03:57:07 +0000188 } else {
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000189 tprint_msgrcv(tcp, tcp->u_arg[1],
190 tcp->u_arg[2], tcp->u_arg[3]);
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000191 printflags(ipc_msg_flags, tcp->u_arg[4], "MSG_???");
Roland McGrath54b90d72005-12-02 03:57:07 +0000192 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000193 }
194 return 0;
195}
196
Dmitry V. Levinef941012009-10-07 22:14:00 +0000197static void
198tprint_sembuf(struct tcb *tcp, long addr, unsigned long count)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000199{
Dmitry V. Levinef941012009-10-07 22:14:00 +0000200 unsigned long i, max_count;
Jakub Bogusz002e9852009-10-07 22:25:10 +0200201
Dmitry V. Levinef941012009-10-07 22:14:00 +0000202 if (abbrev(tcp))
203 max_count = (max_strlen < count) ? max_strlen : count;
204 else
205 max_count = count;
206
207 if (!max_count) {
208 tprintf("%#lx, %lu", addr, count);
209 return;
210 }
211
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200212 for (i = 0; i < max_count; ++i) {
Dmitry V. Levinef941012009-10-07 22:14:00 +0000213 struct sembuf sb;
214 if (i)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200215 tprints(", ");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000216 if (umove(tcp, addr + i * sizeof(struct sembuf), &sb) < 0) {
217 if (i) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200218 tprints("{???}");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000219 break;
220 } else {
221 tprintf("%#lx, %lu", addr, count);
222 return;
Jakub Bogusz002e9852009-10-07 22:25:10 +0200223 }
Roland McGrath54b90d72005-12-02 03:57:07 +0000224 } else {
Dmitry V. Levinef941012009-10-07 22:14:00 +0000225 if (!i)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200226 tprints("{");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000227 tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
228 printflags(semop_flags, sb.sem_flg, "SEM_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200229 tprints("}");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000230 }
231 }
232
233 if (i < max_count || max_count < count)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200234 tprints(", ...");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000235
236 tprintf("}, %lu", count);
237}
238
239int sys_semop(struct tcb *tcp)
240{
241 if (entering(tcp)) {
242 tprintf("%lu, ", tcp->u_arg[0]);
243 if (indirect_ipccall(tcp)) {
244 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
245 } else {
246 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000247 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000248 }
249 return 0;
250}
251
Dmitry V. Levinef941012009-10-07 22:14:00 +0000252int sys_semtimedop(struct tcb *tcp)
Roland McGrath84776472003-04-08 01:46:48 +0000253{
254 if (entering(tcp)) {
Dmitry V. Levinef941012009-10-07 22:14:00 +0000255 tprintf("%lu, ", tcp->u_arg[0]);
Roland McGratha079d9f2006-04-25 07:22:01 +0000256 if (indirect_ipccall(tcp)) {
Dmitry V. Levinef941012009-10-07 22:14:00 +0000257 tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200258 tprints(", ");
Stanislav Brabecbeae4c72012-12-10 20:18:49 +0100259#if defined(S390) || defined(S390X)
Heiko Carstense0f5fd82011-11-30 13:16:29 +0100260 printtv(tcp, tcp->u_arg[2]);
261#else
Stanislav Brabeceff5c0e2012-12-07 21:30:51 +0100262 printtv(tcp, tcp->u_arg[4]);
Heiko Carstense0f5fd82011-11-30 13:16:29 +0100263#endif
Roland McGrath54b90d72005-12-02 03:57:07 +0000264 } else {
Dmitry V. Levinef941012009-10-07 22:14:00 +0000265 tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200266 tprints(", ");
Roland McGrath54b90d72005-12-02 03:57:07 +0000267 printtv(tcp, tcp->u_arg[3]);
268 }
Roland McGrath84776472003-04-08 01:46:48 +0000269 }
270 return 0;
271}
Roland McGrath84776472003-04-08 01:46:48 +0000272
Denys Vlasenko12014262011-05-30 14:00:14 +0200273int sys_semget(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000274{
275 if (entering(tcp)) {
276 if (tcp->u_arg[0])
Roland McGrath9f130d52006-08-22 07:36:55 +0000277 tprintf("%#lx", tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000278 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200279 tprints("IPC_PRIVATE");
Denys Vlasenko859ea8b2013-02-23 20:07:44 +0100280 tprintf(", %lu, ", tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000281 if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200282 tprints("|");
Roland McGrathe2be9ab2003-07-17 09:03:04 +0000283 tprintf("%#lo", tcp->u_arg[2] & 0777);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000284 }
285 return 0;
286}
287
Denys Vlasenko12014262011-05-30 14:00:14 +0200288int sys_semctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000289{
290 if (entering(tcp)) {
Denys Vlasenko859ea8b2013-02-23 20:07:44 +0100291 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrath80731792003-01-14 09:46:17 +0000292 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000293 tprintf(", %#lx", tcp->u_arg[3]);
294 }
295 return 0;
296}
297
Denys Vlasenko12014262011-05-30 14:00:14 +0200298int sys_shmget(struct tcb *tcp)
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
Denys Vlasenko12014262011-05-30 14:00:14 +0200313int sys_shmctl(struct tcb *tcp)
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
Denys Vlasenko12014262011-05-30 14:00:14 +0200327int sys_shmat(struct tcb *tcp)
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
Denys Vlasenko12014262011-05-30 14:00:14 +0200351int sys_shmdt(struct tcb *tcp)
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. Levin9b5b67e2007-01-11 23:19:55 +0000363int
364sys_mq_open(struct tcb *tcp)
Roland McGrath4df13c12004-04-16 21:48:40 +0000365{
366 if (entering(tcp)) {
367 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200368 tprints(", ");
Roland McGrath4df13c12004-04-16 21:48:40 +0000369 /* flags */
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000370 tprint_open_modes(tcp->u_arg[1]);
Roland McGrath4df13c12004-04-16 21:48:40 +0000371 if (tcp->u_arg[1] & O_CREAT) {
372# ifndef HAVE_MQUEUE_H
373 tprintf(", %lx", tcp->u_arg[2]);
374# else
375 struct mq_attr attr;
376 /* mode */
377 tprintf(", %#lo, ", tcp->u_arg[2]);
378 if (umove(tcp, tcp->u_arg[3], &attr) < 0)
Denys Vlasenko859ea8b2013-02-23 20:07:44 +0100379 tprints("{???}");
Roland McGrath4df13c12004-04-16 21:48:40 +0000380 else
381 tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
H.J. Lu0b315b62012-02-03 10:16:03 -0800382 (long) attr.mq_maxmsg,
383 (long) attr.mq_msgsize);
Roland McGrath4df13c12004-04-16 21:48:40 +0000384# endif
385 }
386 }
387 return 0;
388}
389
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000390int
391sys_mq_timedsend(struct tcb *tcp)
Roland McGrath4df13c12004-04-16 21:48:40 +0000392{
393 if (entering(tcp)) {
394 tprintf("%ld, ", tcp->u_arg[0]);
395 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
396 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
397 printtv(tcp, tcp->u_arg[4]);
398 }
399 return 0;
400}
401
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000402int
403sys_mq_timedreceive(struct tcb *tcp)
Roland McGrath4df13c12004-04-16 21:48:40 +0000404{
405 if (entering(tcp))
406 tprintf("%ld, ", tcp->u_arg[0]);
407 else {
408 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
409 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
410 printtv(tcp, tcp->u_arg[4]);
411 }
412 return 0;
413}
414
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000415int
416sys_mq_notify(struct tcb *tcp)
Roland McGrath4df13c12004-04-16 21:48:40 +0000417{
418 if (entering(tcp)) {
419 tprintf("%ld, ", tcp->u_arg[0]);
420 printsigevent(tcp, tcp->u_arg[1]);
421 }
422 return 0;
423}
424
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000425static void
426printmqattr(struct tcb *tcp, long addr)
Roland McGrath4df13c12004-04-16 21:48:40 +0000427{
428 if (addr == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200429 tprints("NULL");
Roland McGrath4df13c12004-04-16 21:48:40 +0000430 else {
431# ifndef HAVE_MQUEUE_H
432 tprintf("%#lx", addr);
433# else
434 struct mq_attr attr;
435 if (umove(tcp, addr, &attr) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200436 tprints("{...}");
Roland McGrath4df13c12004-04-16 21:48:40 +0000437 return;
438 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200439 tprints("{mq_flags=");
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000440 tprint_open_modes(attr.mq_flags);
Roland McGrath4df13c12004-04-16 21:48:40 +0000441 tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
H.J. Lu0b315b62012-02-03 10:16:03 -0800442 (long) attr.mq_maxmsg, (long) attr.mq_msgsize,
443 (long) attr.mq_curmsgs);
Roland McGrath4df13c12004-04-16 21:48:40 +0000444# endif
445 }
446}
447
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000448int
449sys_mq_getsetattr(struct tcb *tcp)
Roland McGrath4df13c12004-04-16 21:48:40 +0000450{
451 if (entering(tcp)) {
452 tprintf("%ld, ", tcp->u_arg[0]);
453 printmqattr(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200454 tprints(", ");
Roland McGrath4df13c12004-04-16 21:48:40 +0000455 } else
456 printmqattr(tcp, tcp->u_arg[2]);
457 return 0;
458}
Dmitry V. Levinb5e88d42012-02-20 17:02:38 +0000459
460int
461sys_ipc(struct tcb *tcp)
462{
463 return printargs(tcp);
464}