blob: 33f487200e577c921421c3d0e473209ea5278a15 [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_???");
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000105 tprints(", ");
106 printaddr(tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000107 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000108}
109
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000110static void
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000111tprint_msgbuf(struct tcb *tcp, const long addr, const unsigned long count)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000112{
113 long mtype;
114
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000115 if (!umove_or_printaddr(tcp, addr, &mtype)) {
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000116 tprintf("{%lu, ", mtype);
117 printstr(tcp, addr + sizeof(mtype), count);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200118 tprints("}");
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000119 }
120 tprintf(", %lu, ", count);
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000121}
122
123static void
124tprint_msgsnd(struct tcb *tcp, const long addr, const unsigned long count,
125 const unsigned long flags)
126{
127 tprint_msgbuf(tcp, addr, count);
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000128 printflags(ipc_msg_flags, flags, "MSG_???");
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000129}
130
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000131SYS_FUNC(msgsnd)
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000132{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000133 tprintf("%d, ", (int) tcp->u_arg[0]);
134 if (indirect_ipccall(tcp)) {
135 tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1],
136 tcp->u_arg[2]);
137 } else {
138 tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2],
139 tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000140 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000141 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000142}
143
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000144static void
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000145tprint_msgrcv(struct tcb *tcp, const long addr, const unsigned long count,
146 const long msgtyp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000147{
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000148 tprint_msgbuf(tcp, addr, count);
149 tprintf("%ld, ", msgtyp);
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000150}
151
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000152SYS_FUNC(msgrcv)
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000153{
154 if (entering(tcp)) {
155 tprintf("%d, ", (int) tcp->u_arg[0]);
156 } else {
Roland McGrath54b90d72005-12-02 03:57:07 +0000157 if (indirect_ipccall(tcp)) {
158 struct ipc_wrapper {
159 struct msgbuf *msgp;
160 long msgtyp;
161 } tmp;
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000162
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000163 if (umove_or_printaddr(tcp, tcp->u_arg[3], &tmp))
164 tprintf(", %lu, ", tcp->u_arg[1]);
165 else
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000166 tprint_msgrcv(tcp, (long) tmp.msgp,
167 tcp->u_arg[1], tmp.msgtyp);
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000168 printflags(ipc_msg_flags, tcp->u_arg[2], "MSG_???");
Roland McGrath54b90d72005-12-02 03:57:07 +0000169 } else {
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000170 tprint_msgrcv(tcp, tcp->u_arg[1],
171 tcp->u_arg[2], tcp->u_arg[3]);
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000172 printflags(ipc_msg_flags, tcp->u_arg[4], "MSG_???");
Roland McGrath54b90d72005-12-02 03:57:07 +0000173 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000174 }
175 return 0;
176}
177
Dmitry V. Levinef941012009-10-07 22:14:00 +0000178static void
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000179tprint_sembuf(const struct sembuf *sb)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000180{
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000181 tprintf("{%u, %d, ", sb->sem_num, sb->sem_op);
182 printflags(semop_flags, sb->sem_flg, "SEM_???");
183 tprints("}");
184}
185
186static void
187tprint_sembuf_array(struct tcb *tcp, const long addr, const unsigned long count)
188{
189 unsigned long max_count;
190 struct sembuf sb;
Jakub Bogusz002e9852009-10-07 22:25:10 +0200191
Dmitry V. Levinef941012009-10-07 22:14:00 +0000192 if (abbrev(tcp))
193 max_count = (max_strlen < count) ? max_strlen : count;
194 else
195 max_count = count;
196
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000197 if (!max_count)
198 printaddr(addr);
199 else if (!umove_or_printaddr(tcp, addr, &sb)) {
200 unsigned long i;
Dmitry V. Levinef941012009-10-07 22:14:00 +0000201
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000202 tprints("[");
203 tprint_sembuf(&sb);
204
205 for (i = 1; i < max_count; ++i) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200206 tprints(", ");
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000207 if (umove_or_printaddr(tcp, addr + i * sizeof(sb), &sb))
Dmitry V. Levinef941012009-10-07 22:14:00 +0000208 break;
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000209 else
210 tprint_sembuf(&sb);
Dmitry V. Levinef941012009-10-07 22:14:00 +0000211 }
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000212
213 if (i < max_count || max_count < count)
214 tprints(", ...");
215
216 tprints("]");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000217 }
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000218 tprintf(", %lu", count);
Dmitry V. Levinef941012009-10-07 22:14:00 +0000219}
220
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000221SYS_FUNC(semop)
Dmitry V. Levinef941012009-10-07 22:14:00 +0000222{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000223 tprintf("%lu, ", tcp->u_arg[0]);
224 if (indirect_ipccall(tcp)) {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000225 tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]);
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000226 } else {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000227 tprint_sembuf_array(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000228 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000229 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000230}
231
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000232SYS_FUNC(semtimedop)
Roland McGrath84776472003-04-08 01:46:48 +0000233{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000234 tprintf("%lu, ", tcp->u_arg[0]);
235 if (indirect_ipccall(tcp)) {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000236 tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]);
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000237 tprints(", ");
Stanislav Brabecbeae4c72012-12-10 20:18:49 +0100238#if defined(S390) || defined(S390X)
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000239 printtv(tcp, tcp->u_arg[2]);
Heiko Carstense0f5fd82011-11-30 13:16:29 +0100240#else
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000241 printtv(tcp, tcp->u_arg[4]);
Heiko Carstense0f5fd82011-11-30 13:16:29 +0100242#endif
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000243 } else {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000244 tprint_sembuf_array(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000245 tprints(", ");
246 printtv(tcp, tcp->u_arg[3]);
Roland McGrath84776472003-04-08 01:46:48 +0000247 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000248 return RVAL_DECODED;
Roland McGrath84776472003-04-08 01:46:48 +0000249}
Roland McGrath84776472003-04-08 01:46:48 +0000250
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000251SYS_FUNC(semget)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000252{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000253 if (tcp->u_arg[0])
254 tprintf("%#lx", tcp->u_arg[0]);
255 else
256 tprints("IPC_PRIVATE");
257 tprintf(", %lu, ", tcp->u_arg[1]);
258 if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
259 tprints("|");
260 tprintf("%#lo", tcp->u_arg[2] & 0777);
261 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000262}
263
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000264SYS_FUNC(semctl)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000265{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000266 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
267 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
268 tprints(", ");
269 if (indirect_ipccall(tcp)) {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000270 if (current_wordsize == sizeof(int))
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000271 printnum_int(tcp, tcp->u_arg[3], "%#x");
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000272 else
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000273 printnum_long(tcp, tcp->u_arg[3], "%#lx");
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000274 } else {
275 tprintf("%#lx", tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000276 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000277 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000278}
279
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000280SYS_FUNC(shmget)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000281{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000282 if (tcp->u_arg[0])
283 tprintf("%#lx", tcp->u_arg[0]);
284 else
285 tprints("IPC_PRIVATE");
286 tprintf(", %lu, ", tcp->u_arg[1]);
287 if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
288 tprints("|");
289 tprintf("%#lo", tcp->u_arg[2] & 0777);
290 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000291}
292
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000293SYS_FUNC(shmctl)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000294{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000295 tprintf("%lu, ", tcp->u_arg[0]);
296 PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???");
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000297 tprints(", ");
298 printaddr(tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000299 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000300}
301
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000302SYS_FUNC(shmat)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000303{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000304 if (entering(tcp)) {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000305 tprintf("%lu, ", tcp->u_arg[0]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000306 if (indirect_ipccall(tcp)) {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000307 printaddr(tcp->u_arg[3]);
308 tprints(", ");
Roland McGrath54b90d72005-12-02 03:57:07 +0000309 printflags(shm_flags, tcp->u_arg[1], "SHM_???");
310 } else {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000311 printaddr(tcp->u_arg[1]);
312 tprints(", ");
Roland McGrath54b90d72005-12-02 03:57:07 +0000313 printflags(shm_flags, tcp->u_arg[2], "SHM_???");
314 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000315 return 0;
316 } else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000317 if (syserror(tcp))
318 return 0;
Dmitry V. Levin3d7b11b2012-03-15 21:19:36 +0000319 if (indirect_ipccall(tcp)) {
320 unsigned long raddr;
321 if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
322 return RVAL_NONE;
323 tcp->u_rval = raddr;
324 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000325 return RVAL_HEX;
326 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000327}
328
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000329SYS_FUNC(shmdt)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000330{
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000331 printaddr(tcp->u_arg[indirect_ipccall(tcp) ? 3 : 0]);
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000332 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000333}
334
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000335SYS_FUNC(mq_open)
Roland McGrath4df13c12004-04-16 21:48:40 +0000336{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000337 printpath(tcp, tcp->u_arg[0]);
338 tprints(", ");
339 /* flags */
340 tprint_open_modes(tcp->u_arg[1]);
341 if (tcp->u_arg[1] & O_CREAT) {
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000342 /* mode */
343 tprintf(", %#lo, ", tcp->u_arg[2]);
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000344# ifndef HAVE_MQUEUE_H
345 printaddr(tcp, tcp->u_arg[3]);
346# else
347 struct mq_attr attr;
348
349 if (!umove_or_printaddr(tcp, tcp->u_arg[3], &attr))
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000350 tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
351 (long) attr.mq_maxmsg,
352 (long) attr.mq_msgsize);
Roland McGrath4df13c12004-04-16 21:48:40 +0000353# endif
Roland McGrath4df13c12004-04-16 21:48:40 +0000354 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000355 return RVAL_DECODED;
Roland McGrath4df13c12004-04-16 21:48:40 +0000356}
357
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000358SYS_FUNC(mq_timedsend)
Roland McGrath4df13c12004-04-16 21:48:40 +0000359{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000360 tprintf("%ld, ", tcp->u_arg[0]);
361 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
362 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
363 printtv(tcp, tcp->u_arg[4]);
364 return RVAL_DECODED;
Roland McGrath4df13c12004-04-16 21:48:40 +0000365}
366
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000367SYS_FUNC(mq_timedreceive)
Roland McGrath4df13c12004-04-16 21:48:40 +0000368{
369 if (entering(tcp))
370 tprintf("%ld, ", tcp->u_arg[0]);
371 else {
372 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
373 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
374 printtv(tcp, tcp->u_arg[4]);
375 }
376 return 0;
377}
378
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000379SYS_FUNC(mq_notify)
Roland McGrath4df13c12004-04-16 21:48:40 +0000380{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000381 tprintf("%ld, ", tcp->u_arg[0]);
382 printsigevent(tcp, tcp->u_arg[1]);
383 return RVAL_DECODED;
Roland McGrath4df13c12004-04-16 21:48:40 +0000384}
385
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000386static void
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000387printmqattr(struct tcb *tcp, const long addr)
Roland McGrath4df13c12004-04-16 21:48:40 +0000388{
Roland McGrath4df13c12004-04-16 21:48:40 +0000389# ifndef HAVE_MQUEUE_H
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000390 printaddr(addr);
Roland McGrath4df13c12004-04-16 21:48:40 +0000391# else
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000392 struct mq_attr attr;
393 if (umove_or_printaddr(tcp, addr, &attr))
394 return;
395 tprints("{mq_flags=");
396 tprint_open_modes(attr.mq_flags);
397 tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
398 (long) attr.mq_maxmsg, (long) attr.mq_msgsize,
399 (long) attr.mq_curmsgs);
Roland McGrath4df13c12004-04-16 21:48:40 +0000400# endif
Roland McGrath4df13c12004-04-16 21:48:40 +0000401}
402
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000403SYS_FUNC(mq_getsetattr)
Roland McGrath4df13c12004-04-16 21:48:40 +0000404{
405 if (entering(tcp)) {
406 tprintf("%ld, ", tcp->u_arg[0]);
407 printmqattr(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200408 tprints(", ");
Roland McGrath4df13c12004-04-16 21:48:40 +0000409 } else
410 printmqattr(tcp, tcp->u_arg[2]);
411 return 0;
412}