blob: 27d8c8035814e266fc9b6c0b9406311c542df576 [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
Denys Vlasenko84703742012-02-25 02:38:52 +010041#if !defined IPC_64
Roland McGrath80731792003-01-14 09:46:17 +000042# define IPC_64 0x100
43#endif
44
Roland McGrath4df13c12004-04-16 21:48:40 +000045extern void printsigevent(struct tcb *tcp, long arg);
46
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000047#include "xlat/msgctl_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000048#include "xlat/semctl_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000049#include "xlat/shmctl_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000050#include "xlat/resource_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000051#include "xlat/shm_resource_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000052#include "xlat/shm_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000053#include "xlat/ipc_msg_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000054#include "xlat/semop_flags.h"
Jakub Bogusz002e9852009-10-07 22:25:10 +020055
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000056SYS_FUNC(msgget)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000057{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +000058 if (tcp->u_arg[0])
59 tprintf("%#lx, ", tcp->u_arg[0]);
60 else
61 tprints("IPC_PRIVATE, ");
62 if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0)
63 tprints("|");
64 tprintf("%#lo", tcp->u_arg[1] & 0777);
65 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000066}
67
Roland McGrath80731792003-01-14 09:46:17 +000068#ifdef IPC_64
69# define PRINTCTL(flagset, arg, dflt) \
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020070 if ((arg) & IPC_64) tprints("IPC_64|"); \
Roland McGrath80731792003-01-14 09:46:17 +000071 printxval((flagset), (arg) &~ IPC_64, dflt)
72#else
73# define PRINTCTL printxval
74#endif
75
Roland McGrath54b90d72005-12-02 03:57:07 +000076static int
Denys Vlasenko12014262011-05-30 14:00:14 +020077indirect_ipccall(struct tcb *tcp)
Roland McGrath54b90d72005-12-02 03:57:07 +000078{
Dmitry V. Levin3b499ca2015-01-10 22:01:35 +030079 return tcp->s_ent->sys_flags & TRACE_INDIRECT_SUBCALL;
Roland McGrath54b90d72005-12-02 03:57:07 +000080}
81
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000082SYS_FUNC(msgctl)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000083{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +000084 tprintf("%lu, ", tcp->u_arg[0]);
85 PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
Dmitry V. Levin2370d532015-07-20 10:11:33 +000086 tprints(", ");
87 printaddr(tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
Dmitry V. Levinb10ae622015-07-13 21:06:48 +000088 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000089}
90
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +000091static void
Dmitry V. Levin2370d532015-07-20 10:11:33 +000092tprint_msgbuf(struct tcb *tcp, const long addr, const unsigned long count)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000093{
94 long mtype;
95
Dmitry V. Levin2370d532015-07-20 10:11:33 +000096 if (!umove_or_printaddr(tcp, addr, &mtype)) {
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +000097 tprintf("{%lu, ", mtype);
98 printstr(tcp, addr + sizeof(mtype), count);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020099 tprints("}");
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000100 }
101 tprintf(", %lu, ", count);
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000102}
103
104static void
105tprint_msgsnd(struct tcb *tcp, const long addr, const unsigned long count,
106 const unsigned long flags)
107{
108 tprint_msgbuf(tcp, addr, count);
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000109 printflags(ipc_msg_flags, flags, "MSG_???");
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000110}
111
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000112SYS_FUNC(msgsnd)
Dmitry V. Levin783f5bc2009-10-08 23:33:15 +0000113{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000114 tprintf("%d, ", (int) tcp->u_arg[0]);
115 if (indirect_ipccall(tcp)) {
116 tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1],
117 tcp->u_arg[2]);
118 } else {
119 tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2],
120 tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000121 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000122 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000123}
124
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000125static void
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000126tprint_msgrcv(struct tcb *tcp, const long addr, const unsigned long count,
127 const long msgtyp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000128{
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000129 tprint_msgbuf(tcp, addr, count);
130 tprintf("%ld, ", msgtyp);
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000131}
132
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000133SYS_FUNC(msgrcv)
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000134{
135 if (entering(tcp)) {
136 tprintf("%d, ", (int) tcp->u_arg[0]);
137 } else {
Roland McGrath54b90d72005-12-02 03:57:07 +0000138 if (indirect_ipccall(tcp)) {
139 struct ipc_wrapper {
140 struct msgbuf *msgp;
141 long msgtyp;
142 } tmp;
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000143
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000144 if (umove_or_printaddr(tcp, tcp->u_arg[3], &tmp))
145 tprintf(", %lu, ", tcp->u_arg[1]);
146 else
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000147 tprint_msgrcv(tcp, (long) tmp.msgp,
148 tcp->u_arg[1], tmp.msgtyp);
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000149 printflags(ipc_msg_flags, tcp->u_arg[2], "MSG_???");
Roland McGrath54b90d72005-12-02 03:57:07 +0000150 } else {
Dmitry V. Levin62e05962009-11-03 14:38:44 +0000151 tprint_msgrcv(tcp, tcp->u_arg[1],
152 tcp->u_arg[2], tcp->u_arg[3]);
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000153 printflags(ipc_msg_flags, tcp->u_arg[4], "MSG_???");
Roland McGrath54b90d72005-12-02 03:57:07 +0000154 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000155 }
156 return 0;
157}
158
Dmitry V. Levinef941012009-10-07 22:14:00 +0000159static void
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000160tprint_sembuf(const struct sembuf *sb)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000161{
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000162 tprintf("{%u, %d, ", sb->sem_num, sb->sem_op);
163 printflags(semop_flags, sb->sem_flg, "SEM_???");
164 tprints("}");
165}
166
167static void
168tprint_sembuf_array(struct tcb *tcp, const long addr, const unsigned long count)
169{
170 unsigned long max_count;
171 struct sembuf sb;
Jakub Bogusz002e9852009-10-07 22:25:10 +0200172
Dmitry V. Levinef941012009-10-07 22:14:00 +0000173 if (abbrev(tcp))
174 max_count = (max_strlen < count) ? max_strlen : count;
175 else
176 max_count = count;
177
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000178 if (!max_count)
179 printaddr(addr);
180 else if (!umove_or_printaddr(tcp, addr, &sb)) {
181 unsigned long i;
Dmitry V. Levinef941012009-10-07 22:14:00 +0000182
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000183 tprints("[");
184 tprint_sembuf(&sb);
185
186 for (i = 1; i < max_count; ++i) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200187 tprints(", ");
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000188 if (umove_or_printaddr(tcp, addr + i * sizeof(sb), &sb))
Dmitry V. Levinef941012009-10-07 22:14:00 +0000189 break;
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000190 else
191 tprint_sembuf(&sb);
Dmitry V. Levinef941012009-10-07 22:14:00 +0000192 }
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000193
194 if (i < max_count || max_count < count)
195 tprints(", ...");
196
197 tprints("]");
Dmitry V. Levinef941012009-10-07 22:14:00 +0000198 }
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000199 tprintf(", %lu", count);
Dmitry V. Levinef941012009-10-07 22:14:00 +0000200}
201
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000202SYS_FUNC(semop)
Dmitry V. Levinef941012009-10-07 22:14:00 +0000203{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000204 tprintf("%lu, ", tcp->u_arg[0]);
205 if (indirect_ipccall(tcp)) {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000206 tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]);
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000207 } else {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000208 tprint_sembuf_array(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000209 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000210 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000211}
212
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000213SYS_FUNC(semtimedop)
Roland McGrath84776472003-04-08 01:46:48 +0000214{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000215 tprintf("%lu, ", tcp->u_arg[0]);
216 if (indirect_ipccall(tcp)) {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000217 tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]);
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000218 tprints(", ");
Stanislav Brabecbeae4c72012-12-10 20:18:49 +0100219#if defined(S390) || defined(S390X)
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000220 printtv(tcp, tcp->u_arg[2]);
Heiko Carstense0f5fd82011-11-30 13:16:29 +0100221#else
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000222 printtv(tcp, tcp->u_arg[4]);
Heiko Carstense0f5fd82011-11-30 13:16:29 +0100223#endif
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000224 } else {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000225 tprint_sembuf_array(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000226 tprints(", ");
227 printtv(tcp, tcp->u_arg[3]);
Roland McGrath84776472003-04-08 01:46:48 +0000228 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000229 return RVAL_DECODED;
Roland McGrath84776472003-04-08 01:46:48 +0000230}
Roland McGrath84776472003-04-08 01:46:48 +0000231
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000232SYS_FUNC(semget)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000233{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000234 if (tcp->u_arg[0])
235 tprintf("%#lx", tcp->u_arg[0]);
236 else
237 tprints("IPC_PRIVATE");
238 tprintf(", %lu, ", tcp->u_arg[1]);
239 if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
240 tprints("|");
241 tprintf("%#lo", tcp->u_arg[2] & 0777);
242 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000243}
244
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000245SYS_FUNC(semctl)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000246{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000247 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
248 PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
249 tprints(", ");
250 if (indirect_ipccall(tcp)) {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000251 if (current_wordsize == sizeof(int))
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000252 printnum_int(tcp, tcp->u_arg[3], "%#x");
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000253 else
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000254 printnum_long(tcp, tcp->u_arg[3], "%#lx");
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000255 } else {
256 tprintf("%#lx", tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000257 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000258 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000259}
260
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000261SYS_FUNC(shmget)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000262{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000263 if (tcp->u_arg[0])
264 tprintf("%#lx", tcp->u_arg[0]);
265 else
266 tprints("IPC_PRIVATE");
267 tprintf(", %lu, ", tcp->u_arg[1]);
268 if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
269 tprints("|");
270 tprintf("%#lo", tcp->u_arg[2] & 0777);
271 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000272}
273
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000274SYS_FUNC(shmctl)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000275{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000276 tprintf("%lu, ", tcp->u_arg[0]);
277 PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???");
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000278 tprints(", ");
279 printaddr(tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000280 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000281}
282
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000283SYS_FUNC(shmat)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000284{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000285 if (entering(tcp)) {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000286 tprintf("%lu, ", tcp->u_arg[0]);
Roland McGrath54b90d72005-12-02 03:57:07 +0000287 if (indirect_ipccall(tcp)) {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000288 printaddr(tcp->u_arg[3]);
289 tprints(", ");
Roland McGrath54b90d72005-12-02 03:57:07 +0000290 printflags(shm_flags, tcp->u_arg[1], "SHM_???");
291 } else {
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000292 printaddr(tcp->u_arg[1]);
293 tprints(", ");
Roland McGrath54b90d72005-12-02 03:57:07 +0000294 printflags(shm_flags, tcp->u_arg[2], "SHM_???");
295 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000296 return 0;
297 } else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000298 if (syserror(tcp))
299 return 0;
Dmitry V. Levin3d7b11b2012-03-15 21:19:36 +0000300 if (indirect_ipccall(tcp)) {
301 unsigned long raddr;
302 if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
303 return RVAL_NONE;
304 tcp->u_rval = raddr;
305 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000306 return RVAL_HEX;
307 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000308}
309
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000310SYS_FUNC(shmdt)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000311{
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000312 printaddr(tcp->u_arg[indirect_ipccall(tcp) ? 3 : 0]);
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000313 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000314}
315
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000316SYS_FUNC(mq_open)
Roland McGrath4df13c12004-04-16 21:48:40 +0000317{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000318 printpath(tcp, tcp->u_arg[0]);
319 tprints(", ");
320 /* flags */
321 tprint_open_modes(tcp->u_arg[1]);
322 if (tcp->u_arg[1] & O_CREAT) {
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000323 /* mode */
324 tprintf(", %#lo, ", tcp->u_arg[2]);
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000325# ifndef HAVE_MQUEUE_H
Elliott Hughese4653432015-07-28 22:39:12 +0000326 printaddr(tcp->u_arg[3]);
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000327# else
328 struct mq_attr attr;
329
330 if (!umove_or_printaddr(tcp, tcp->u_arg[3], &attr))
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000331 tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
332 (long) attr.mq_maxmsg,
333 (long) attr.mq_msgsize);
Roland McGrath4df13c12004-04-16 21:48:40 +0000334# endif
Roland McGrath4df13c12004-04-16 21:48:40 +0000335 }
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000336 return RVAL_DECODED;
Roland McGrath4df13c12004-04-16 21:48:40 +0000337}
338
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000339SYS_FUNC(mq_timedsend)
Roland McGrath4df13c12004-04-16 21:48:40 +0000340{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000341 tprintf("%ld, ", tcp->u_arg[0]);
342 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
343 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
344 printtv(tcp, tcp->u_arg[4]);
345 return RVAL_DECODED;
Roland McGrath4df13c12004-04-16 21:48:40 +0000346}
347
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000348SYS_FUNC(mq_timedreceive)
Roland McGrath4df13c12004-04-16 21:48:40 +0000349{
350 if (entering(tcp))
351 tprintf("%ld, ", tcp->u_arg[0]);
352 else {
353 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
354 tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
355 printtv(tcp, tcp->u_arg[4]);
356 }
357 return 0;
358}
359
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000360SYS_FUNC(mq_notify)
Roland McGrath4df13c12004-04-16 21:48:40 +0000361{
Dmitry V. Levinb10ae622015-07-13 21:06:48 +0000362 tprintf("%ld, ", tcp->u_arg[0]);
363 printsigevent(tcp, tcp->u_arg[1]);
364 return RVAL_DECODED;
Roland McGrath4df13c12004-04-16 21:48:40 +0000365}
366
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000367static void
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000368printmqattr(struct tcb *tcp, const long addr)
Roland McGrath4df13c12004-04-16 21:48:40 +0000369{
Roland McGrath4df13c12004-04-16 21:48:40 +0000370# ifndef HAVE_MQUEUE_H
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000371 printaddr(addr);
Roland McGrath4df13c12004-04-16 21:48:40 +0000372# else
Dmitry V. Levin2370d532015-07-20 10:11:33 +0000373 struct mq_attr attr;
374 if (umove_or_printaddr(tcp, addr, &attr))
375 return;
376 tprints("{mq_flags=");
377 tprint_open_modes(attr.mq_flags);
378 tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
379 (long) attr.mq_maxmsg, (long) attr.mq_msgsize,
380 (long) attr.mq_curmsgs);
Roland McGrath4df13c12004-04-16 21:48:40 +0000381# endif
Roland McGrath4df13c12004-04-16 21:48:40 +0000382}
383
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000384SYS_FUNC(mq_getsetattr)
Roland McGrath4df13c12004-04-16 21:48:40 +0000385{
386 if (entering(tcp)) {
387 tprintf("%ld, ", tcp->u_arg[0]);
388 printmqattr(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200389 tprints(", ");
Roland McGrath4df13c12004-04-16 21:48:40 +0000390 } else
391 printmqattr(tcp, tcp->u_arg[2]);
392 return 0;
393}