176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman/*
276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * Copyright (c) 1993 Ulrich Pegelow <pegelow@moorea.uni-muenster.de>
376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
54dc8a2aec63e4fb5ee2688544c4de323ed5de3efWichert Akkerman * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * All rights reserved.
776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *
876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * Redistribution and use in source and binary forms, with or without
976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * modification, are permitted provided that the following conditions
1076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * are met:
1176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * 1. Redistributions of source code must retain the above copyright
1276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *    notice, this list of conditions and the following disclaimer.
1376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * 2. Redistributions in binary form must reproduce the above copyright
1476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *    notice, this list of conditions and the following disclaimer in the
1576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *    documentation and/or other materials provided with the distribution.
1676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * 3. The name of the author may not be used to endorse or promote products
1776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *    derived from this software without specific prior written permission.
1876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *
1976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman */
3076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
3176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include "defs.h"
32a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#ifdef HAVE_MQUEUE_H
33a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# include <mqueue.h>
34a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#endif
354df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath#include <fcntl.h>
3676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/ipc.h>
3776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/sem.h>
3876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/msg.h>
3976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/shm.h>
4076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
4176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifndef MSG_STAT
4276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define MSG_STAT 11
4376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
4476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifndef MSG_INFO
4576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define MSG_INFO 12
4676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
4776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifndef SHM_STAT
4876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define SHM_STAT 13
4976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
5076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifndef SHM_INFO
5176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define SHM_INFO 14
5276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
5376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifndef SEM_STAT
5476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define SEM_STAT 18
5576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
5676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifndef SEM_INFO
5776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define SEM_INFO 19
5876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
5976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
608470374cba7df0e70653d95c4f336a4082c68d82Denys Vlasenko#if !defined IPC_64
618073179e985bdf460926cbaa91737d844e201f8cRoland McGrath# define IPC_64 0x100
628073179e985bdf460926cbaa91737d844e201f8cRoland McGrath#endif
638073179e985bdf460926cbaa91737d844e201f8cRoland McGrath
644df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrathextern void printsigevent(struct tcb *tcp, long arg);
654df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath
660ed617bd66624cec6138102545d73b2e2346f1f6Dmitry V. Levin#include "xlat/msgctl_flags.h"
670ed617bd66624cec6138102545d73b2e2346f1f6Dmitry V. Levin#include "xlat/semctl_flags.h"
680ed617bd66624cec6138102545d73b2e2346f1f6Dmitry V. Levin#include "xlat/shmctl_flags.h"
690ed617bd66624cec6138102545d73b2e2346f1f6Dmitry V. Levin#include "xlat/resource_flags.h"
700ed617bd66624cec6138102545d73b2e2346f1f6Dmitry V. Levin#include "xlat/shm_resource_flags.h"
710ed617bd66624cec6138102545d73b2e2346f1f6Dmitry V. Levin#include "xlat/shm_flags.h"
720ed617bd66624cec6138102545d73b2e2346f1f6Dmitry V. Levin#include "xlat/ipc_msg_flags.h"
730ed617bd66624cec6138102545d73b2e2346f1f6Dmitry V. Levin#include "xlat/semop_flags.h"
74002e985526a6e6451f8cdaca88e34f4777377848Jakub Bogusz
751201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkoint sys_msgget(struct tcb *tcp)
7676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
7776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
7876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (tcp->u_arg[0])
79859ea8b8ccfbfe234b84d5c4f42798f1b8e660a6Denys Vlasenko			tprintf("%#lx, ", tcp->u_arg[0]);
8076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
81859ea8b8ccfbfe234b84d5c4f42798f1b8e660a6Denys Vlasenko			tprints("IPC_PRIVATE, ");
82b2dee13345a62c80a677f3342cd525d611fbc632Roland McGrath		if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0)
8360fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("|");
84e2be9ab3d36c43926c2b64ef3f15ee26159d7330Roland McGrath		tprintf("%#lo", tcp->u_arg[1] & 0777);
8576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
8676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
8776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
8876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
898073179e985bdf460926cbaa91737d844e201f8cRoland McGrath#ifdef IPC_64
908073179e985bdf460926cbaa91737d844e201f8cRoland McGrath# define PRINTCTL(flagset, arg, dflt) \
9160fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	if ((arg) & IPC_64) tprints("IPC_64|"); \
928073179e985bdf460926cbaa91737d844e201f8cRoland McGrath	printxval((flagset), (arg) &~ IPC_64, dflt)
938073179e985bdf460926cbaa91737d844e201f8cRoland McGrath#else
948073179e985bdf460926cbaa91737d844e201f8cRoland McGrath# define PRINTCTL printxval
958073179e985bdf460926cbaa91737d844e201f8cRoland McGrath#endif
968073179e985bdf460926cbaa91737d844e201f8cRoland McGrath
9754b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrathstatic int
981201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkoindirect_ipccall(struct tcb *tcp)
9954b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath{
10054b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath#ifdef X86_64
10135be58119e3727a694d8c9f9b83f372401fcc4c0H.J. Lu	return current_personality == 1;
10254b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath#endif
103a81bf4c79f9f2706cd1bea0082fb8d63f08e8a5bRoland McGrath#if defined IA64
104a81bf4c79f9f2706cd1bea0082fb8d63f08e8a5bRoland McGrath	return tcp->scno < 1024; /* ia32 emulation syscalls are low */
10554b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath#endif
106d8d3bd3709eb52581c8ce86cec5a7a9c43c3c5b9Steve McIntyre#if defined(ALPHA) || defined(MIPS) || defined(HPPA) || defined(__ARM_EABI__) || defined(AARCH64)
10754b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath	return 0;
1083d7b11bf5514ccf91f55f8068a14b160cd6d031dDmitry V. Levin#endif
1093d7b11bf5514ccf91f55f8068a14b160cd6d031dDmitry V. Levin	return 1;
11054b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath}
11154b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath
1121201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkoint sys_msgctl(struct tcb *tcp)
11376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
11476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
1158073179e985bdf460926cbaa91737d844e201f8cRoland McGrath		tprintf("%lu, ", tcp->u_arg[0]);
1168073179e985bdf460926cbaa91737d844e201f8cRoland McGrath		PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
11754b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]);
11876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
11976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
12076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
12176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
122783f5bc24c7ce99739f1e1cd71060fda26aa43e3Dmitry V. Levinstatic void
1234310a375e905840481862c6c351152fe29df81c9Dmitry V. Levintprint_msgsnd(struct tcb *tcp, long addr, unsigned long count,
1244310a375e905840481862c6c351152fe29df81c9Dmitry V. Levin	      unsigned long flags)
12576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
12676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	long mtype;
12776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
128783f5bc24c7ce99739f1e1cd71060fda26aa43e3Dmitry V. Levin	if (umove(tcp, addr, &mtype) < 0) {
129783f5bc24c7ce99739f1e1cd71060fda26aa43e3Dmitry V. Levin		tprintf("%#lx", addr);
130783f5bc24c7ce99739f1e1cd71060fda26aa43e3Dmitry V. Levin	} else {
131783f5bc24c7ce99739f1e1cd71060fda26aa43e3Dmitry V. Levin		tprintf("{%lu, ", mtype);
132783f5bc24c7ce99739f1e1cd71060fda26aa43e3Dmitry V. Levin		printstr(tcp, addr + sizeof(mtype), count);
13360fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints("}");
134783f5bc24c7ce99739f1e1cd71060fda26aa43e3Dmitry V. Levin	}
135783f5bc24c7ce99739f1e1cd71060fda26aa43e3Dmitry V. Levin	tprintf(", %lu, ", count);
136297b59401c998a2154b2fd1af7b234e2fa3a9305Dmitry V. Levin	printflags(ipc_msg_flags, flags, "MSG_???");
137783f5bc24c7ce99739f1e1cd71060fda26aa43e3Dmitry V. Levin}
138783f5bc24c7ce99739f1e1cd71060fda26aa43e3Dmitry V. Levin
139783f5bc24c7ce99739f1e1cd71060fda26aa43e3Dmitry V. Levinint sys_msgsnd(struct tcb *tcp)
140783f5bc24c7ce99739f1e1cd71060fda26aa43e3Dmitry V. Levin{
14176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
14262e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin		tprintf("%d, ", (int) tcp->u_arg[0]);
14354b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		if (indirect_ipccall(tcp)) {
1444310a375e905840481862c6c351152fe29df81c9Dmitry V. Levin			tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1],
1454310a375e905840481862c6c351152fe29df81c9Dmitry V. Levin				      tcp->u_arg[2]);
14654b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		} else {
1474310a375e905840481862c6c351152fe29df81c9Dmitry V. Levin			tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2],
1484310a375e905840481862c6c351152fe29df81c9Dmitry V. Levin				      tcp->u_arg[3]);
14954b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		}
15076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
15176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
15276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
15376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
15462e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levinstatic void
15562e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levintprint_msgrcv(struct tcb *tcp, long addr, unsigned long count, long msgtyp)
15676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
15776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	long mtype;
15876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
15962e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin	if (syserror(tcp) || umove(tcp, addr, &mtype) < 0) {
16062e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin		tprintf("%#lx", addr);
16162e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin	} else {
16262e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin		tprintf("{%lu, ", mtype);
16362e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin		printstr(tcp, addr + sizeof(mtype), count);
16460fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints("}");
16562e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin	}
16662e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin	tprintf(", %lu, %ld, ", count, msgtyp);
16762e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin}
16862e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin
16962e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levinint sys_msgrcv(struct tcb *tcp)
17062e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin{
171f467c0078a197fa9ab23706bef5479d43bd6cc7eRoland McGrath	if (entering(tcp)) {
17262e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin		tprintf("%d, ", (int) tcp->u_arg[0]);
173f467c0078a197fa9ab23706bef5479d43bd6cc7eRoland McGrath	} else {
17454b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		if (indirect_ipccall(tcp)) {
17554b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath			struct ipc_wrapper {
17654b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath				struct msgbuf *msgp;
17754b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath				long msgtyp;
17854b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath			} tmp;
17962e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin
18062e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin			if (umove(tcp, tcp->u_arg[3], &tmp) < 0) {
18162e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin				tprintf("%#lx, %lu, ",
18262e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin					tcp->u_arg[3], tcp->u_arg[1]);
18362e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin			} else {
18462e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin				tprint_msgrcv(tcp, (long) tmp.msgp,
18562e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin					tcp->u_arg[1], tmp.msgtyp);
18662e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin			}
187297b59401c998a2154b2fd1af7b234e2fa3a9305Dmitry V. Levin			printflags(ipc_msg_flags, tcp->u_arg[2], "MSG_???");
18854b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		} else {
18962e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin			tprint_msgrcv(tcp, tcp->u_arg[1],
19062e0596dbda6831f7f7a976c183373d5ff7a7584Dmitry V. Levin				tcp->u_arg[2], tcp->u_arg[3]);
191297b59401c998a2154b2fd1af7b234e2fa3a9305Dmitry V. Levin			printflags(ipc_msg_flags, tcp->u_arg[4], "MSG_???");
19254b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		}
19376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
19476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
19576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
19676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
197ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levinstatic void
198ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levintprint_sembuf(struct tcb *tcp, long addr, unsigned long count)
19976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
200ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin	unsigned long i, max_count;
201ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin
202ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin	if (abbrev(tcp))
203ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin		max_count = (max_strlen < count) ? max_strlen : count;
204ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin	else
205ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin		max_count = count;
206ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin
207ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin	if (!max_count) {
208ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin		tprintf("%#lx, %lu", addr, count);
209ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin		return;
210ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin	}
211ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin
212b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko	for (i = 0; i < max_count; ++i) {
213ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin		struct sembuf sb;
214ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin		if (i)
21560fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints(", ");
216ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin		if (umove(tcp, addr + i * sizeof(struct sembuf), &sb) < 0) {
217ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin			if (i) {
21860fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko				tprints("{???}");
219ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin				break;
220ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin			} else {
221ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin				tprintf("%#lx, %lu", addr, count);
222ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin				return;
223ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin			}
224ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin		} else {
225ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin			if (!i)
22660fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko				tprints("{");
227ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin			tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
228ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin			printflags(semop_flags, sb.sem_flg, "SEM_???");
22960fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("}");
230ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin		}
231ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin	}
232ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin
233ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin	if (i < max_count || max_count < count)
23460fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ...");
235002e985526a6e6451f8cdaca88e34f4777377848Jakub Bogusz
236ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin	tprintf("}, %lu", count);
237ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin}
238ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin
239ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levinint sys_semop(struct tcb *tcp)
240ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin{
24176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
242ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin		tprintf("%lu, ", tcp->u_arg[0]);
24354b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		if (indirect_ipccall(tcp)) {
244ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin			tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
24554b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		} else {
246ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin			tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
24754b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		}
24876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
24976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
25076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
25176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
252ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levinint sys_semtimedop(struct tcb *tcp)
2538477647c4b3c04c6fc4adb0dc76221d319008296Roland McGrath{
2548477647c4b3c04c6fc4adb0dc76221d319008296Roland McGrath	if (entering(tcp)) {
255ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin		tprintf("%lu, ", tcp->u_arg[0]);
256a079d9f95a9afcdf3621ab02defc90045c72ae89Roland McGrath		if (indirect_ipccall(tcp)) {
257ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin			tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]);
25860fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints(", ");
259beae4c7182d8204a0d9fa9db2295c42744f7f377Stanislav Brabec#if defined(S390) || defined(S390X)
260e0f5fd87da61c6123467a8701e9c0dc5b528f3bfHeiko Carstens			printtv(tcp, tcp->u_arg[2]);
261e0f5fd87da61c6123467a8701e9c0dc5b528f3bfHeiko Carstens#else
262eff5c0e60c35d852a97a26cd8c6be50fed75a1a0Stanislav Brabec			printtv(tcp, tcp->u_arg[4]);
263e0f5fd87da61c6123467a8701e9c0dc5b528f3bfHeiko Carstens#endif
26454b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		} else {
265ef941013d2f2e441ee155dfc26fa7ea1345eb926Dmitry V. Levin			tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]);
26660fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints(", ");
26754b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath			printtv(tcp, tcp->u_arg[3]);
26854b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		}
2698477647c4b3c04c6fc4adb0dc76221d319008296Roland McGrath	}
2708477647c4b3c04c6fc4adb0dc76221d319008296Roland McGrath	return 0;
2718477647c4b3c04c6fc4adb0dc76221d319008296Roland McGrath}
2728477647c4b3c04c6fc4adb0dc76221d319008296Roland McGrath
2731201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkoint sys_semget(struct tcb *tcp)
27476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
27576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
27676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (tcp->u_arg[0])
2779f130d5114b4c8e83330bcd254d1c78dd70e1371Roland McGrath			tprintf("%#lx", tcp->u_arg[0]);
27876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
27960fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("IPC_PRIVATE");
280859ea8b8ccfbfe234b84d5c4f42798f1b8e660a6Denys Vlasenko		tprintf(", %lu, ", tcp->u_arg[1]);
281b2dee13345a62c80a677f3342cd525d611fbc632Roland McGrath		if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
28260fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("|");
283e2be9ab3d36c43926c2b64ef3f15ee26159d7330Roland McGrath		tprintf("%#lo", tcp->u_arg[2] & 0777);
28476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
28576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
28676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
28776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
2881201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkoint sys_semctl(struct tcb *tcp)
28976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
29076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
291859ea8b8ccfbfe234b84d5c4f42798f1b8e660a6Denys Vlasenko		tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2928073179e985bdf460926cbaa91737d844e201f8cRoland McGrath		PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
29376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %#lx", tcp->u_arg[3]);
29476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
29576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
29676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
29776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
2981201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkoint sys_shmget(struct tcb *tcp)
29976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
30076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
30176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (tcp->u_arg[0])
3029f130d5114b4c8e83330bcd254d1c78dd70e1371Roland McGrath			tprintf("%#lx", tcp->u_arg[0]);
30376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
30460fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("IPC_PRIVATE");
305859ea8b8ccfbfe234b84d5c4f42798f1b8e660a6Denys Vlasenko		tprintf(", %lu, ", tcp->u_arg[1]);
306b2dee13345a62c80a677f3342cd525d611fbc632Roland McGrath		if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
30760fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("|");
308e2be9ab3d36c43926c2b64ef3f15ee26159d7330Roland McGrath		tprintf("%#lo", tcp->u_arg[2] & 0777);
30976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
31076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
31176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
31276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
3131201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkoint sys_shmctl(struct tcb *tcp)
31476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
31576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
31676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%lu, ", tcp->u_arg[0]);
3178073179e985bdf460926cbaa91737d844e201f8cRoland McGrath		PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???");
31854b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		if (indirect_ipccall(tcp)) {
31954b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath			tprintf(", %#lx", tcp->u_arg[3]);
32054b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		} else {
32154b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath			tprintf(", %#lx", tcp->u_arg[2]);
32254b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		}
32376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
32476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
32576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
32676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
3271201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkoint sys_shmat(struct tcb *tcp)
32876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
32976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (exiting(tcp)) {
33076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%lu", tcp->u_arg[0]);
33154b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		if (indirect_ipccall(tcp)) {
332859ea8b8ccfbfe234b84d5c4f42798f1b8e660a6Denys Vlasenko			tprintf(", %#lx, ", tcp->u_arg[3]);
33354b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath			printflags(shm_flags, tcp->u_arg[1], "SHM_???");
33454b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		} else {
335859ea8b8ccfbfe234b84d5c4f42798f1b8e660a6Denys Vlasenko			tprintf(", %#lx, ", tcp->u_arg[1]);
33654b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath			printflags(shm_flags, tcp->u_arg[2], "SHM_???");
33754b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		}
33876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp))
33976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
3403d7b11bf5514ccf91f55f8068a14b160cd6d031dDmitry V. Levin		if (indirect_ipccall(tcp)) {
3413d7b11bf5514ccf91f55f8068a14b160cd6d031dDmitry V. Levin			unsigned long raddr;
3423d7b11bf5514ccf91f55f8068a14b160cd6d031dDmitry V. Levin			if (umove(tcp, tcp->u_arg[2], &raddr) < 0)
3433d7b11bf5514ccf91f55f8068a14b160cd6d031dDmitry V. Levin				return RVAL_NONE;
3443d7b11bf5514ccf91f55f8068a14b160cd6d031dDmitry V. Levin			tcp->u_rval = raddr;
3453d7b11bf5514ccf91f55f8068a14b160cd6d031dDmitry V. Levin		}
34676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		return RVAL_HEX;
34776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
34876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
34976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
35076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
3511201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkoint sys_shmdt(struct tcb *tcp)
35276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
35354b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath	if (entering(tcp)) {
35454b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		if (indirect_ipccall(tcp)) {
35554b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath			tprintf("%#lx", tcp->u_arg[3]);
35654b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		} else {
35754b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath			tprintf("%#lx", tcp->u_arg[0]);
35854b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath		}
35954b90d784234deb727fd02fdde57ddaa9d51354dRoland McGrath	}
36076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
36176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
36276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
3639b5b67eb43bf90e83834126dfde4472e5a721080Dmitry V. Levinint
3649b5b67eb43bf90e83834126dfde4472e5a721080Dmitry V. Levinsys_mq_open(struct tcb *tcp)
3654df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath{
3664df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	if (entering(tcp)) {
3674df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		printpath(tcp, tcp->u_arg[0]);
36860fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
3694df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		/* flags */
370eedaac768dcb55346292495440f1201bd7b2b1b4Denys Vlasenko		tprint_open_modes(tcp->u_arg[1]);
3714df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		if (tcp->u_arg[1] & O_CREAT) {
3724df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath# ifndef HAVE_MQUEUE_H
3734df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath			tprintf(", %lx", tcp->u_arg[2]);
3744df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath# else
3754df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath			struct mq_attr attr;
3764df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath			/* mode */
3774df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath			tprintf(", %#lo, ", tcp->u_arg[2]);
3784df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath			if (umove(tcp, tcp->u_arg[3], &attr) < 0)
379859ea8b8ccfbfe234b84d5c4f42798f1b8e660a6Denys Vlasenko				tprints("{???}");
3804df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath			else
3814df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath				tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
3820b315b65432cda20c7e5608c5124289036522fa7H.J. Lu					(long) attr.mq_maxmsg,
3830b315b65432cda20c7e5608c5124289036522fa7H.J. Lu					(long) attr.mq_msgsize);
3844df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath# endif
3854df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		}
3864df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	}
3874df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	return 0;
3884df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath}
3894df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath
3909b5b67eb43bf90e83834126dfde4472e5a721080Dmitry V. Levinint
3919b5b67eb43bf90e83834126dfde4472e5a721080Dmitry V. Levinsys_mq_timedsend(struct tcb *tcp)
3924df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath{
3934df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	if (entering(tcp)) {
3944df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		tprintf("%ld, ", tcp->u_arg[0]);
3954df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
3964df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
3974df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		printtv(tcp, tcp->u_arg[4]);
3984df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	}
3994df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	return 0;
4004df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath}
4014df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath
4029b5b67eb43bf90e83834126dfde4472e5a721080Dmitry V. Levinint
4039b5b67eb43bf90e83834126dfde4472e5a721080Dmitry V. Levinsys_mq_timedreceive(struct tcb *tcp)
4044df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath{
4054df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	if (entering(tcp))
4064df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		tprintf("%ld, ", tcp->u_arg[0]);
4074df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	else {
4084df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
4094df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]);
4104df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		printtv(tcp, tcp->u_arg[4]);
4114df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	}
4124df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	return 0;
4134df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath}
4144df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath
4159b5b67eb43bf90e83834126dfde4472e5a721080Dmitry V. Levinint
4169b5b67eb43bf90e83834126dfde4472e5a721080Dmitry V. Levinsys_mq_notify(struct tcb *tcp)
4174df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath{
4184df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	if (entering(tcp)) {
4194df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		tprintf("%ld, ", tcp->u_arg[0]);
4204df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		printsigevent(tcp, tcp->u_arg[1]);
4214df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	}
4224df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	return 0;
4234df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath}
4244df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath
4259b5b67eb43bf90e83834126dfde4472e5a721080Dmitry V. Levinstatic void
4269b5b67eb43bf90e83834126dfde4472e5a721080Dmitry V. Levinprintmqattr(struct tcb *tcp, long addr)
4274df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath{
4284df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	if (addr == 0)
42960fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints("NULL");
4304df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	else {
4314df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath# ifndef HAVE_MQUEUE_H
4324df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		tprintf("%#lx", addr);
4334df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath# else
4344df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		struct mq_attr attr;
4354df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		if (umove(tcp, addr, &attr) < 0) {
43660fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("{...}");
4374df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath			return;
4384df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		}
43960fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints("{mq_flags=");
440eedaac768dcb55346292495440f1201bd7b2b1b4Denys Vlasenko		tprint_open_modes(attr.mq_flags);
4414df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
4420b315b65432cda20c7e5608c5124289036522fa7H.J. Lu			(long) attr.mq_maxmsg, (long) attr.mq_msgsize,
4430b315b65432cda20c7e5608c5124289036522fa7H.J. Lu			(long) attr.mq_curmsgs);
4444df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath# endif
4454df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	}
4464df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath}
4474df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath
4489b5b67eb43bf90e83834126dfde4472e5a721080Dmitry V. Levinint
4499b5b67eb43bf90e83834126dfde4472e5a721080Dmitry V. Levinsys_mq_getsetattr(struct tcb *tcp)
4504df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath{
4514df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	if (entering(tcp)) {
4524df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		tprintf("%ld, ", tcp->u_arg[0]);
4534df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		printmqattr(tcp, tcp->u_arg[1]);
45460fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
4554df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	} else
4564df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath		printmqattr(tcp, tcp->u_arg[2]);
4574df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath	return 0;
4584df13c169dae7f9fac4719a4d3df7bcd0bf8a2caRoland McGrath}
459b5e88d43a80dad1c7af987d40edef14f69cff8edDmitry V. Levin
460b5e88d43a80dad1c7af987d40edef14f69cff8edDmitry V. Levinint
461b5e88d43a80dad1c7af987d40edef14f69cff8edDmitry V. Levinsys_ipc(struct tcb *tcp)
462b5e88d43a80dad1c7af987d40edef14f69cff8edDmitry V. Levin{
463b5e88d43a80dad1c7af987d40edef14f69cff8edDmitry V. Levin	return printargs(tcp);
464b5e88d43a80dad1c7af987d40edef14f69cff8edDmitry V. Levin}
465