Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 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 Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 6 | * 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 29 | */ |
| 30 | |
| 31 | #include "defs.h" |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 32 | #ifdef HAVE_MQUEUE_H |
| 33 | # include <mqueue.h> |
| 34 | #endif |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 35 | #include <fcntl.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 36 | #include <sys/ipc.h> |
| 37 | #include <sys/sem.h> |
| 38 | #include <sys/msg.h> |
| 39 | #include <sys/shm.h> |
| 40 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 41 | #if !defined IPC_64 |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 42 | # define IPC_64 0x100 |
| 43 | #endif |
| 44 | |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 45 | extern void printsigevent(struct tcb *tcp, long arg); |
| 46 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 47 | #include "xlat/msgctl_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 48 | #include "xlat/semctl_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 49 | #include "xlat/shmctl_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 50 | #include "xlat/resource_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 51 | #include "xlat/shm_resource_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 52 | #include "xlat/shm_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 53 | #include "xlat/ipc_msg_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 54 | #include "xlat/semop_flags.h" |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame] | 55 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 56 | SYS_FUNC(msgget) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 57 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 58 | 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 66 | } |
| 67 | |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 68 | #ifdef IPC_64 |
| 69 | # define PRINTCTL(flagset, arg, dflt) \ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 70 | if ((arg) & IPC_64) tprints("IPC_64|"); \ |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 71 | printxval((flagset), (arg) &~ IPC_64, dflt) |
| 72 | #else |
| 73 | # define PRINTCTL printxval |
| 74 | #endif |
| 75 | |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 76 | static int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 77 | indirect_ipccall(struct tcb *tcp) |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 78 | { |
Dmitry V. Levin | 3b499ca | 2015-01-10 22:01:35 +0300 | [diff] [blame] | 79 | return tcp->s_ent->sys_flags & TRACE_INDIRECT_SUBCALL; |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 80 | } |
| 81 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 82 | SYS_FUNC(msgctl) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 83 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 84 | tprintf("%lu, ", tcp->u_arg[0]); |
| 85 | PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???"); |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 86 | tprints(", "); |
| 87 | printaddr(tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]); |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 88 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 89 | } |
| 90 | |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 91 | static void |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 92 | tprint_msgbuf(struct tcb *tcp, const long addr, const unsigned long count) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 93 | { |
| 94 | long mtype; |
| 95 | |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 96 | if (!umove_or_printaddr(tcp, addr, &mtype)) { |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 97 | tprintf("{%lu, ", mtype); |
| 98 | printstr(tcp, addr + sizeof(mtype), count); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 99 | tprints("}"); |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 100 | } |
| 101 | tprintf(", %lu, ", count); |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | static void |
| 105 | tprint_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. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 109 | printflags(ipc_msg_flags, flags, "MSG_???"); |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 112 | SYS_FUNC(msgsnd) |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 113 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 114 | 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 121 | } |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 122 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 123 | } |
| 124 | |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 125 | static void |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 126 | tprint_msgrcv(struct tcb *tcp, const long addr, const unsigned long count, |
| 127 | const long msgtyp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 128 | { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 129 | tprint_msgbuf(tcp, addr, count); |
| 130 | tprintf("%ld, ", msgtyp); |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 131 | } |
| 132 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 133 | SYS_FUNC(msgrcv) |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 134 | { |
| 135 | if (entering(tcp)) { |
| 136 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 137 | } else { |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 138 | if (indirect_ipccall(tcp)) { |
| 139 | struct ipc_wrapper { |
| 140 | struct msgbuf *msgp; |
| 141 | long msgtyp; |
| 142 | } tmp; |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 143 | |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 144 | if (umove_or_printaddr(tcp, tcp->u_arg[3], &tmp)) |
| 145 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 146 | else |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 147 | tprint_msgrcv(tcp, (long) tmp.msgp, |
| 148 | tcp->u_arg[1], tmp.msgtyp); |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 149 | printflags(ipc_msg_flags, tcp->u_arg[2], "MSG_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 150 | } else { |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 151 | tprint_msgrcv(tcp, tcp->u_arg[1], |
| 152 | tcp->u_arg[2], tcp->u_arg[3]); |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 153 | printflags(ipc_msg_flags, tcp->u_arg[4], "MSG_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 154 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 155 | } |
| 156 | return 0; |
| 157 | } |
| 158 | |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 159 | static void |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 160 | tprint_sembuf(const struct sembuf *sb) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 161 | { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 162 | tprintf("{%u, %d, ", sb->sem_num, sb->sem_op); |
| 163 | printflags(semop_flags, sb->sem_flg, "SEM_???"); |
| 164 | tprints("}"); |
| 165 | } |
| 166 | |
| 167 | static void |
| 168 | tprint_sembuf_array(struct tcb *tcp, const long addr, const unsigned long count) |
| 169 | { |
| 170 | unsigned long max_count; |
| 171 | struct sembuf sb; |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame] | 172 | |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 173 | if (abbrev(tcp)) |
| 174 | max_count = (max_strlen < count) ? max_strlen : count; |
| 175 | else |
| 176 | max_count = count; |
| 177 | |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 178 | if (!max_count) |
| 179 | printaddr(addr); |
| 180 | else if (!umove_or_printaddr(tcp, addr, &sb)) { |
| 181 | unsigned long i; |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 182 | |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 183 | tprints("["); |
| 184 | tprint_sembuf(&sb); |
| 185 | |
| 186 | for (i = 1; i < max_count; ++i) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 187 | tprints(", "); |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 188 | if (umove_or_printaddr(tcp, addr + i * sizeof(sb), &sb)) |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 189 | break; |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 190 | else |
| 191 | tprint_sembuf(&sb); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 192 | } |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 193 | |
| 194 | if (i < max_count || max_count < count) |
| 195 | tprints(", ..."); |
| 196 | |
| 197 | tprints("]"); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 198 | } |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 199 | tprintf(", %lu", count); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 200 | } |
| 201 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 202 | SYS_FUNC(semop) |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 203 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 204 | tprintf("%lu, ", tcp->u_arg[0]); |
| 205 | if (indirect_ipccall(tcp)) { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 206 | tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]); |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 207 | } else { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 208 | tprint_sembuf_array(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 209 | } |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 210 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 213 | SYS_FUNC(semtimedop) |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 214 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 215 | tprintf("%lu, ", tcp->u_arg[0]); |
| 216 | if (indirect_ipccall(tcp)) { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 217 | tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]); |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 218 | tprints(", "); |
Stanislav Brabec | beae4c7 | 2012-12-10 20:18:49 +0100 | [diff] [blame] | 219 | #if defined(S390) || defined(S390X) |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 220 | printtv(tcp, tcp->u_arg[2]); |
Heiko Carstens | e0f5fd8 | 2011-11-30 13:16:29 +0100 | [diff] [blame] | 221 | #else |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 222 | printtv(tcp, tcp->u_arg[4]); |
Heiko Carstens | e0f5fd8 | 2011-11-30 13:16:29 +0100 | [diff] [blame] | 223 | #endif |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 224 | } else { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 225 | tprint_sembuf_array(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 226 | tprints(", "); |
| 227 | printtv(tcp, tcp->u_arg[3]); |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 228 | } |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 229 | return RVAL_DECODED; |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 230 | } |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 231 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 232 | SYS_FUNC(semget) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 233 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 234 | 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 243 | } |
| 244 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 245 | SYS_FUNC(semctl) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 246 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 247 | 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. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 251 | if (current_wordsize == sizeof(int)) |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 252 | printnum_int(tcp, tcp->u_arg[3], "%#x"); |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 253 | else |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 254 | printnum_long(tcp, tcp->u_arg[3], "%#lx"); |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 255 | } else { |
| 256 | tprintf("%#lx", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 257 | } |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 258 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 259 | } |
| 260 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 261 | SYS_FUNC(shmget) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 262 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 263 | 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 272 | } |
| 273 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 274 | SYS_FUNC(shmctl) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 275 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 276 | tprintf("%lu, ", tcp->u_arg[0]); |
| 277 | PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???"); |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 278 | tprints(", "); |
| 279 | printaddr(tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]); |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 280 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 283 | SYS_FUNC(shmat) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 284 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 285 | if (entering(tcp)) { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 286 | tprintf("%lu, ", tcp->u_arg[0]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 287 | if (indirect_ipccall(tcp)) { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 288 | printaddr(tcp->u_arg[3]); |
| 289 | tprints(", "); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 290 | printflags(shm_flags, tcp->u_arg[1], "SHM_???"); |
| 291 | } else { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 292 | printaddr(tcp->u_arg[1]); |
| 293 | tprints(", "); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 294 | printflags(shm_flags, tcp->u_arg[2], "SHM_???"); |
| 295 | } |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 296 | return 0; |
| 297 | } else { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 298 | if (syserror(tcp)) |
| 299 | return 0; |
Dmitry V. Levin | 3d7b11b | 2012-03-15 21:19:36 +0000 | [diff] [blame] | 300 | 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 306 | return RVAL_HEX; |
| 307 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 308 | } |
| 309 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 310 | SYS_FUNC(shmdt) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 311 | { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 312 | printaddr(tcp->u_arg[indirect_ipccall(tcp) ? 3 : 0]); |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 313 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 314 | } |
| 315 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 316 | SYS_FUNC(mq_open) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 317 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 318 | 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. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 323 | /* mode */ |
| 324 | tprintf(", %#lo, ", tcp->u_arg[2]); |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 325 | # ifndef HAVE_MQUEUE_H |
Elliott Hughes | e465343 | 2015-07-28 22:39:12 +0000 | [diff] [blame] | 326 | printaddr(tcp->u_arg[3]); |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 327 | # else |
| 328 | struct mq_attr attr; |
| 329 | |
| 330 | if (!umove_or_printaddr(tcp, tcp->u_arg[3], &attr)) |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 331 | tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}", |
| 332 | (long) attr.mq_maxmsg, |
| 333 | (long) attr.mq_msgsize); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 334 | # endif |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 335 | } |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 336 | return RVAL_DECODED; |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 337 | } |
| 338 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 339 | SYS_FUNC(mq_timedsend) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 340 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 341 | 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 McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 346 | } |
| 347 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 348 | SYS_FUNC(mq_timedreceive) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 349 | { |
| 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. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 360 | SYS_FUNC(mq_notify) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 361 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 362 | tprintf("%ld, ", tcp->u_arg[0]); |
| 363 | printsigevent(tcp, tcp->u_arg[1]); |
| 364 | return RVAL_DECODED; |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 365 | } |
| 366 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 367 | static void |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 368 | printmqattr(struct tcb *tcp, const long addr) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 369 | { |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 370 | # ifndef HAVE_MQUEUE_H |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 371 | printaddr(addr); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 372 | # else |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 373 | 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 McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 381 | # endif |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 382 | } |
| 383 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 384 | SYS_FUNC(mq_getsetattr) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 385 | { |
| 386 | if (entering(tcp)) { |
| 387 | tprintf("%ld, ", tcp->u_arg[0]); |
| 388 | printmqattr(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 389 | tprints(", "); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 390 | } else |
| 391 | printmqattr(tcp, tcp->u_arg[2]); |
| 392 | return 0; |
| 393 | } |