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 | |
| 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 Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 60 | #if !defined IPC_64 |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 61 | # define IPC_64 0x100 |
| 62 | #endif |
| 63 | |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 64 | extern void printsigevent(struct tcb *tcp, long arg); |
| 65 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 66 | #include "xlat/msgctl_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 67 | #include "xlat/semctl_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 68 | #include "xlat/shmctl_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 69 | #include "xlat/resource_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 70 | #include "xlat/shm_resource_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 71 | #include "xlat/shm_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 72 | #include "xlat/ipc_msg_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 73 | #include "xlat/semop_flags.h" |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame] | 74 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 75 | SYS_FUNC(msgget) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 76 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 77 | 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 85 | } |
| 86 | |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 87 | #ifdef IPC_64 |
| 88 | # define PRINTCTL(flagset, arg, dflt) \ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 89 | if ((arg) & IPC_64) tprints("IPC_64|"); \ |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 90 | printxval((flagset), (arg) &~ IPC_64, dflt) |
| 91 | #else |
| 92 | # define PRINTCTL printxval |
| 93 | #endif |
| 94 | |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 95 | static int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 96 | indirect_ipccall(struct tcb *tcp) |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 97 | { |
Dmitry V. Levin | 3b499ca | 2015-01-10 22:01:35 +0300 | [diff] [blame] | 98 | return tcp->s_ent->sys_flags & TRACE_INDIRECT_SUBCALL; |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 99 | } |
| 100 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 101 | SYS_FUNC(msgctl) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 102 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 103 | tprintf("%lu, ", tcp->u_arg[0]); |
| 104 | PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???"); |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 105 | tprints(", "); |
| 106 | printaddr(tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]); |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 107 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 108 | } |
| 109 | |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 110 | static void |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 111 | tprint_msgbuf(struct tcb *tcp, const long addr, const unsigned long count) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 112 | { |
| 113 | long mtype; |
| 114 | |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 115 | if (!umove_or_printaddr(tcp, addr, &mtype)) { |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 116 | tprintf("{%lu, ", mtype); |
| 117 | printstr(tcp, addr + sizeof(mtype), count); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 118 | tprints("}"); |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 119 | } |
| 120 | tprintf(", %lu, ", count); |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | static void |
| 124 | tprint_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. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 128 | printflags(ipc_msg_flags, flags, "MSG_???"); |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 129 | } |
| 130 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 131 | SYS_FUNC(msgsnd) |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 132 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 133 | 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 140 | } |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 141 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 144 | static void |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 145 | tprint_msgrcv(struct tcb *tcp, const long addr, const unsigned long count, |
| 146 | const long msgtyp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 147 | { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 148 | tprint_msgbuf(tcp, addr, count); |
| 149 | tprintf("%ld, ", msgtyp); |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 152 | SYS_FUNC(msgrcv) |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 153 | { |
| 154 | if (entering(tcp)) { |
| 155 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 156 | } else { |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 157 | if (indirect_ipccall(tcp)) { |
| 158 | struct ipc_wrapper { |
| 159 | struct msgbuf *msgp; |
| 160 | long msgtyp; |
| 161 | } tmp; |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 162 | |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 163 | if (umove_or_printaddr(tcp, tcp->u_arg[3], &tmp)) |
| 164 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 165 | else |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 166 | tprint_msgrcv(tcp, (long) tmp.msgp, |
| 167 | tcp->u_arg[1], tmp.msgtyp); |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 168 | printflags(ipc_msg_flags, tcp->u_arg[2], "MSG_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 169 | } else { |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 170 | tprint_msgrcv(tcp, tcp->u_arg[1], |
| 171 | tcp->u_arg[2], tcp->u_arg[3]); |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 172 | printflags(ipc_msg_flags, tcp->u_arg[4], "MSG_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 173 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 174 | } |
| 175 | return 0; |
| 176 | } |
| 177 | |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 178 | static void |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 179 | tprint_sembuf(const struct sembuf *sb) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 180 | { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 181 | tprintf("{%u, %d, ", sb->sem_num, sb->sem_op); |
| 182 | printflags(semop_flags, sb->sem_flg, "SEM_???"); |
| 183 | tprints("}"); |
| 184 | } |
| 185 | |
| 186 | static void |
| 187 | tprint_sembuf_array(struct tcb *tcp, const long addr, const unsigned long count) |
| 188 | { |
| 189 | unsigned long max_count; |
| 190 | struct sembuf sb; |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame] | 191 | |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 192 | if (abbrev(tcp)) |
| 193 | max_count = (max_strlen < count) ? max_strlen : count; |
| 194 | else |
| 195 | max_count = count; |
| 196 | |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 197 | if (!max_count) |
| 198 | printaddr(addr); |
| 199 | else if (!umove_or_printaddr(tcp, addr, &sb)) { |
| 200 | unsigned long i; |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 201 | |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 202 | tprints("["); |
| 203 | tprint_sembuf(&sb); |
| 204 | |
| 205 | for (i = 1; i < max_count; ++i) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 206 | tprints(", "); |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 207 | if (umove_or_printaddr(tcp, addr + i * sizeof(sb), &sb)) |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 208 | break; |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 209 | else |
| 210 | tprint_sembuf(&sb); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 211 | } |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 212 | |
| 213 | if (i < max_count || max_count < count) |
| 214 | tprints(", ..."); |
| 215 | |
| 216 | tprints("]"); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 217 | } |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 218 | tprintf(", %lu", count); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 219 | } |
| 220 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 221 | SYS_FUNC(semop) |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 222 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 223 | tprintf("%lu, ", tcp->u_arg[0]); |
| 224 | if (indirect_ipccall(tcp)) { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 225 | 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] | 226 | } else { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 227 | tprint_sembuf_array(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 228 | } |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 229 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 230 | } |
| 231 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 232 | SYS_FUNC(semtimedop) |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 233 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 234 | tprintf("%lu, ", tcp->u_arg[0]); |
| 235 | if (indirect_ipccall(tcp)) { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 236 | 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] | 237 | tprints(", "); |
Stanislav Brabec | beae4c7 | 2012-12-10 20:18:49 +0100 | [diff] [blame] | 238 | #if defined(S390) || defined(S390X) |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 239 | printtv(tcp, tcp->u_arg[2]); |
Heiko Carstens | e0f5fd8 | 2011-11-30 13:16:29 +0100 | [diff] [blame] | 240 | #else |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 241 | printtv(tcp, tcp->u_arg[4]); |
Heiko Carstens | e0f5fd8 | 2011-11-30 13:16:29 +0100 | [diff] [blame] | 242 | #endif |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 243 | } else { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 244 | 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] | 245 | tprints(", "); |
| 246 | printtv(tcp, tcp->u_arg[3]); |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 247 | } |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 248 | return RVAL_DECODED; |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 249 | } |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 250 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 251 | SYS_FUNC(semget) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 252 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 253 | 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 262 | } |
| 263 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 264 | SYS_FUNC(semctl) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 265 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 266 | 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. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 270 | if (current_wordsize == sizeof(int)) |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 271 | printnum_int(tcp, tcp->u_arg[3], "%#x"); |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 272 | else |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 273 | printnum_long(tcp, tcp->u_arg[3], "%#lx"); |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 274 | } else { |
| 275 | tprintf("%#lx", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 276 | } |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 277 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 278 | } |
| 279 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 280 | SYS_FUNC(shmget) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 281 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 282 | 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 291 | } |
| 292 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 293 | SYS_FUNC(shmctl) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 294 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 295 | tprintf("%lu, ", tcp->u_arg[0]); |
| 296 | PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???"); |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 297 | tprints(", "); |
| 298 | printaddr(tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]); |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 299 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 300 | } |
| 301 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 302 | SYS_FUNC(shmat) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 303 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 304 | if (entering(tcp)) { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 305 | tprintf("%lu, ", tcp->u_arg[0]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 306 | if (indirect_ipccall(tcp)) { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 307 | printaddr(tcp->u_arg[3]); |
| 308 | tprints(", "); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 309 | printflags(shm_flags, tcp->u_arg[1], "SHM_???"); |
| 310 | } else { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 311 | printaddr(tcp->u_arg[1]); |
| 312 | tprints(", "); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 313 | printflags(shm_flags, tcp->u_arg[2], "SHM_???"); |
| 314 | } |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 315 | return 0; |
| 316 | } else { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 317 | if (syserror(tcp)) |
| 318 | return 0; |
Dmitry V. Levin | 3d7b11b | 2012-03-15 21:19:36 +0000 | [diff] [blame] | 319 | 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 325 | return RVAL_HEX; |
| 326 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 327 | } |
| 328 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 329 | SYS_FUNC(shmdt) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 330 | { |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 331 | printaddr(tcp->u_arg[indirect_ipccall(tcp) ? 3 : 0]); |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 332 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 333 | } |
| 334 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 335 | SYS_FUNC(mq_open) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 336 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 337 | 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. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 342 | /* mode */ |
| 343 | tprintf(", %#lo, ", tcp->u_arg[2]); |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 344 | # 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. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 350 | tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}", |
| 351 | (long) attr.mq_maxmsg, |
| 352 | (long) attr.mq_msgsize); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 353 | # endif |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 354 | } |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 355 | return RVAL_DECODED; |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 356 | } |
| 357 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 358 | SYS_FUNC(mq_timedsend) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 359 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 360 | 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 McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 365 | } |
| 366 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 367 | SYS_FUNC(mq_timedreceive) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 368 | { |
| 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. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 379 | SYS_FUNC(mq_notify) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 380 | { |
Dmitry V. Levin | b10ae62 | 2015-07-13 21:06:48 +0000 | [diff] [blame] | 381 | tprintf("%ld, ", tcp->u_arg[0]); |
| 382 | printsigevent(tcp, tcp->u_arg[1]); |
| 383 | return RVAL_DECODED; |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 384 | } |
| 385 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 386 | static void |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 387 | printmqattr(struct tcb *tcp, const long addr) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 388 | { |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 389 | # ifndef HAVE_MQUEUE_H |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 390 | printaddr(addr); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 391 | # else |
Dmitry V. Levin | 2370d53 | 2015-07-20 10:11:33 +0000 | [diff] [blame] | 392 | 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 McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 400 | # endif |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 401 | } |
| 402 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 403 | SYS_FUNC(mq_getsetattr) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 404 | { |
| 405 | if (entering(tcp)) { |
| 406 | tprintf("%ld, ", tcp->u_arg[0]); |
| 407 | printmqattr(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 408 | tprints(", "); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 409 | } else |
| 410 | printmqattr(tcp, tcp->u_arg[2]); |
| 411 | return 0; |
| 412 | } |