blob: a97dd1a1f6b01875eaf7a31d7a47192b6c56fb46 [file] [log] [blame]
Elvira Khabirovac01ad062015-08-19 05:06:26 +03001/*
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>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 * Copyright (c) 2003-2006 Roland McGrath <roland@redhat.com>
7 * Copyright (c) 2006-2015 Dmitry V. Levin <ldv@altlinux.org>
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include "defs.h"
34#include "ipc_defs.h"
35
36#include <sys/msg.h>
Elvira Khabirovad0a61872015-08-18 02:01:26 +030037#include DEF_MPERS_TYPE(msqid_ds_t)
38typedef struct msqid_ds msqid_ds_t;
39#include MPERS_DEFS
Elvira Khabirovac01ad062015-08-19 05:06:26 +030040
41#include "xlat/msgctl_flags.h"
42
Elvira Khabirovad0a61872015-08-18 02:01:26 +030043static void
44print_msqid_ds(struct tcb *tcp, const long addr, int cmd)
45{
46 if (cmd & IPC_64)
47 cmd &= ~IPC_64;
48 msqid_ds_t msqid_ds;
49 switch (cmd) {
50 case IPC_SET:
51 case IPC_STAT:
52 if (umove_or_printaddr(tcp, addr, &msqid_ds))
53 return;
54
55 tprints("{msg_perm={");
56 printuid("uid=", msqid_ds.msg_perm.uid);
57 printuid(", gid=", msqid_ds.msg_perm.gid);
58 tprints(", mode=");
59 tprints(sprintmode(msqid_ds.msg_perm.mode));
60
61 if (cmd != IPC_STAT) {
62 tprints("}, ...}");
63 break;
64 }
65
66 tprintf(", key=%u", (unsigned) msqid_ds.msg_perm.__key);
67 printuid(", cuid=", msqid_ds.msg_perm.cuid);
68 printuid(", cgid=", msqid_ds.msg_perm.cgid);
69 tprints("}");
70 tprintf(", msg_stime=%u", (unsigned) msqid_ds.msg_stime);
71 tprintf(", msg_rtime=%u", (unsigned) msqid_ds.msg_rtime);
72 tprintf(", msg_ctime=%u", (unsigned) msqid_ds.msg_ctime);
73 tprintf(", msg_qnum=%u", (unsigned) msqid_ds.msg_qnum);
74 tprintf(", msg_qbytes=%u", (unsigned) msqid_ds.msg_qbytes);
75 tprintf(", msg_lspid=%u", (unsigned) msqid_ds.msg_lspid);
76 tprintf(", msg_lrpid=%u", (unsigned) msqid_ds.msg_lrpid);
77 tprints("}");
78 break;
79
80 default:
81 printaddr(addr);
82 break;
83 }
84}
85
Elvira Khabirovac01ad062015-08-19 05:06:26 +030086SYS_FUNC(msgctl)
87{
Elvira Khabirovad0a61872015-08-18 02:01:26 +030088 if (entering(tcp)) {
89 tprintf("%lu, ", tcp->u_arg[0]);
90 PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???");
91 tprints(", ");
92 } else {
93 const long addr = tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2];
94 print_msqid_ds(tcp, addr, tcp->u_arg[1]);
95 }
96 return 0;
Elvira Khabirovac01ad062015-08-19 05:06:26 +030097}