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 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 75 | int sys_msgget(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 76 | { |
| 77 | if (entering(tcp)) { |
| 78 | if (tcp->u_arg[0]) |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 79 | tprintf("%#lx, ", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 80 | else |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 81 | tprints("IPC_PRIVATE, "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 82 | if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 83 | tprints("|"); |
Roland McGrath | e2be9ab | 2003-07-17 09:03:04 +0000 | [diff] [blame] | 84 | tprintf("%#lo", tcp->u_arg[1] & 0777); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 85 | } |
| 86 | return 0; |
| 87 | } |
| 88 | |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 89 | #ifdef IPC_64 |
| 90 | # define PRINTCTL(flagset, arg, dflt) \ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 91 | if ((arg) & IPC_64) tprints("IPC_64|"); \ |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 92 | printxval((flagset), (arg) &~ IPC_64, dflt) |
| 93 | #else |
| 94 | # define PRINTCTL printxval |
| 95 | #endif |
| 96 | |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 97 | static int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 98 | indirect_ipccall(struct tcb *tcp) |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 99 | { |
Dmitry V. Levin | 3b499ca | 2015-01-10 22:01:35 +0300 | [diff] [blame] | 100 | return tcp->s_ent->sys_flags & TRACE_INDIRECT_SUBCALL; |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 101 | } |
| 102 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 103 | int sys_msgctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 104 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 105 | if (entering(tcp)) { |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 106 | tprintf("%lu, ", tcp->u_arg[0]); |
| 107 | PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 108 | tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 109 | } |
| 110 | return 0; |
| 111 | } |
| 112 | |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 113 | static void |
Dmitry V. Levin | 4310a37 | 2010-03-31 22:22:01 +0000 | [diff] [blame] | 114 | tprint_msgsnd(struct tcb *tcp, long addr, unsigned long count, |
| 115 | unsigned long flags) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 116 | { |
| 117 | long mtype; |
| 118 | |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 119 | if (umove(tcp, addr, &mtype) < 0) { |
| 120 | tprintf("%#lx", addr); |
| 121 | } else { |
| 122 | tprintf("{%lu, ", mtype); |
| 123 | printstr(tcp, addr + sizeof(mtype), count); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 124 | tprints("}"); |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 125 | } |
| 126 | tprintf(", %lu, ", count); |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 127 | printflags(ipc_msg_flags, flags, "MSG_???"); |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | int sys_msgsnd(struct tcb *tcp) |
| 131 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 132 | if (entering(tcp)) { |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 133 | tprintf("%d, ", (int) tcp->u_arg[0]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 134 | if (indirect_ipccall(tcp)) { |
Dmitry V. Levin | 4310a37 | 2010-03-31 22:22:01 +0000 | [diff] [blame] | 135 | tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1], |
| 136 | tcp->u_arg[2]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 137 | } else { |
Dmitry V. Levin | 4310a37 | 2010-03-31 22:22:01 +0000 | [diff] [blame] | 138 | tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2], |
| 139 | tcp->u_arg[3]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 140 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 141 | } |
| 142 | return 0; |
| 143 | } |
| 144 | |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 145 | static void |
| 146 | tprint_msgrcv(struct tcb *tcp, long addr, unsigned long count, long msgtyp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 147 | { |
| 148 | long mtype; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 149 | |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 150 | if (syserror(tcp) || umove(tcp, addr, &mtype) < 0) { |
| 151 | tprintf("%#lx", addr); |
Roland McGrath | f467c00 | 2005-12-02 03:44:12 +0000 | [diff] [blame] | 152 | } else { |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 153 | tprintf("{%lu, ", mtype); |
| 154 | printstr(tcp, addr + sizeof(mtype), count); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 155 | tprints("}"); |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 156 | } |
| 157 | tprintf(", %lu, %ld, ", count, msgtyp); |
| 158 | } |
| 159 | |
| 160 | int sys_msgrcv(struct tcb *tcp) |
| 161 | { |
| 162 | if (entering(tcp)) { |
| 163 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 164 | } else { |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 165 | if (indirect_ipccall(tcp)) { |
| 166 | struct ipc_wrapper { |
| 167 | struct msgbuf *msgp; |
| 168 | long msgtyp; |
| 169 | } tmp; |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 170 | |
| 171 | if (umove(tcp, tcp->u_arg[3], &tmp) < 0) { |
| 172 | tprintf("%#lx, %lu, ", |
| 173 | tcp->u_arg[3], tcp->u_arg[1]); |
| 174 | } else { |
| 175 | tprint_msgrcv(tcp, (long) tmp.msgp, |
| 176 | tcp->u_arg[1], tmp.msgtyp); |
| 177 | } |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 178 | printflags(ipc_msg_flags, tcp->u_arg[2], "MSG_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 179 | } else { |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 180 | tprint_msgrcv(tcp, tcp->u_arg[1], |
| 181 | tcp->u_arg[2], tcp->u_arg[3]); |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 182 | printflags(ipc_msg_flags, tcp->u_arg[4], "MSG_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 183 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 184 | } |
| 185 | return 0; |
| 186 | } |
| 187 | |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 188 | static void |
| 189 | tprint_sembuf(struct tcb *tcp, long addr, unsigned long count) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 190 | { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 191 | unsigned long i, max_count; |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame] | 192 | |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 193 | if (abbrev(tcp)) |
| 194 | max_count = (max_strlen < count) ? max_strlen : count; |
| 195 | else |
| 196 | max_count = count; |
| 197 | |
| 198 | if (!max_count) { |
| 199 | tprintf("%#lx, %lu", addr, count); |
| 200 | return; |
| 201 | } |
| 202 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 203 | for (i = 0; i < max_count; ++i) { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 204 | struct sembuf sb; |
| 205 | if (i) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 206 | tprints(", "); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 207 | if (umove(tcp, addr + i * sizeof(struct sembuf), &sb) < 0) { |
| 208 | if (i) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 209 | tprints("{???}"); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 210 | break; |
| 211 | } else { |
| 212 | tprintf("%#lx, %lu", addr, count); |
| 213 | return; |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame] | 214 | } |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 215 | } else { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 216 | if (!i) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 217 | tprints("{"); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 218 | tprintf("{%u, %d, ", sb.sem_num, sb.sem_op); |
| 219 | printflags(semop_flags, sb.sem_flg, "SEM_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 220 | tprints("}"); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 221 | } |
| 222 | } |
| 223 | |
| 224 | if (i < max_count || max_count < count) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 225 | tprints(", ..."); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 226 | |
| 227 | tprintf("}, %lu", count); |
| 228 | } |
| 229 | |
| 230 | int sys_semop(struct tcb *tcp) |
| 231 | { |
| 232 | if (entering(tcp)) { |
| 233 | tprintf("%lu, ", tcp->u_arg[0]); |
| 234 | if (indirect_ipccall(tcp)) { |
| 235 | tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]); |
| 236 | } else { |
| 237 | tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 238 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 239 | } |
| 240 | return 0; |
| 241 | } |
| 242 | |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 243 | int sys_semtimedop(struct tcb *tcp) |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 244 | { |
| 245 | if (entering(tcp)) { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 246 | tprintf("%lu, ", tcp->u_arg[0]); |
Roland McGrath | a079d9f | 2006-04-25 07:22:01 +0000 | [diff] [blame] | 247 | if (indirect_ipccall(tcp)) { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 248 | tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 249 | tprints(", "); |
Stanislav Brabec | beae4c7 | 2012-12-10 20:18:49 +0100 | [diff] [blame] | 250 | #if defined(S390) || defined(S390X) |
Heiko Carstens | e0f5fd8 | 2011-11-30 13:16:29 +0100 | [diff] [blame] | 251 | printtv(tcp, tcp->u_arg[2]); |
| 252 | #else |
Stanislav Brabec | eff5c0e | 2012-12-07 21:30:51 +0100 | [diff] [blame] | 253 | printtv(tcp, tcp->u_arg[4]); |
Heiko Carstens | e0f5fd8 | 2011-11-30 13:16:29 +0100 | [diff] [blame] | 254 | #endif |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 255 | } else { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 256 | tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 257 | tprints(", "); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 258 | printtv(tcp, tcp->u_arg[3]); |
| 259 | } |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 260 | } |
| 261 | return 0; |
| 262 | } |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 263 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 264 | int sys_semget(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 265 | { |
| 266 | if (entering(tcp)) { |
| 267 | if (tcp->u_arg[0]) |
Roland McGrath | 9f130d5 | 2006-08-22 07:36:55 +0000 | [diff] [blame] | 268 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 269 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 270 | tprints("IPC_PRIVATE"); |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 271 | tprintf(", %lu, ", tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 272 | if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 273 | tprints("|"); |
Roland McGrath | e2be9ab | 2003-07-17 09:03:04 +0000 | [diff] [blame] | 274 | tprintf("%#lo", tcp->u_arg[2] & 0777); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 275 | } |
| 276 | return 0; |
| 277 | } |
| 278 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 279 | int sys_semctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 280 | { |
| 281 | if (entering(tcp)) { |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 282 | tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 283 | PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 284 | tprintf(", %#lx", tcp->u_arg[3]); |
| 285 | } |
| 286 | return 0; |
| 287 | } |
| 288 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 289 | int sys_shmget(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 290 | { |
| 291 | if (entering(tcp)) { |
| 292 | if (tcp->u_arg[0]) |
Roland McGrath | 9f130d5 | 2006-08-22 07:36:55 +0000 | [diff] [blame] | 293 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 294 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 295 | tprints("IPC_PRIVATE"); |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 296 | tprintf(", %lu, ", tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 297 | if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 298 | tprints("|"); |
Roland McGrath | e2be9ab | 2003-07-17 09:03:04 +0000 | [diff] [blame] | 299 | tprintf("%#lo", tcp->u_arg[2] & 0777); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 300 | } |
| 301 | return 0; |
| 302 | } |
| 303 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 304 | int sys_shmctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 305 | { |
| 306 | if (entering(tcp)) { |
| 307 | tprintf("%lu, ", tcp->u_arg[0]); |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 308 | PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 309 | if (indirect_ipccall(tcp)) { |
| 310 | tprintf(", %#lx", tcp->u_arg[3]); |
| 311 | } else { |
| 312 | tprintf(", %#lx", tcp->u_arg[2]); |
| 313 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 314 | } |
| 315 | return 0; |
| 316 | } |
| 317 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 318 | int sys_shmat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 319 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 320 | if (exiting(tcp)) { |
| 321 | tprintf("%lu", tcp->u_arg[0]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 322 | if (indirect_ipccall(tcp)) { |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 323 | tprintf(", %#lx, ", tcp->u_arg[3]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 324 | printflags(shm_flags, tcp->u_arg[1], "SHM_???"); |
| 325 | } else { |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 326 | tprintf(", %#lx, ", tcp->u_arg[1]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 327 | printflags(shm_flags, tcp->u_arg[2], "SHM_???"); |
| 328 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 329 | if (syserror(tcp)) |
| 330 | return 0; |
Dmitry V. Levin | 3d7b11b | 2012-03-15 21:19:36 +0000 | [diff] [blame] | 331 | if (indirect_ipccall(tcp)) { |
| 332 | unsigned long raddr; |
| 333 | if (umove(tcp, tcp->u_arg[2], &raddr) < 0) |
| 334 | return RVAL_NONE; |
| 335 | tcp->u_rval = raddr; |
| 336 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 337 | return RVAL_HEX; |
| 338 | } |
| 339 | return 0; |
| 340 | } |
| 341 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 342 | int sys_shmdt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 343 | { |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 344 | if (entering(tcp)) { |
| 345 | if (indirect_ipccall(tcp)) { |
| 346 | tprintf("%#lx", tcp->u_arg[3]); |
| 347 | } else { |
| 348 | tprintf("%#lx", tcp->u_arg[0]); |
| 349 | } |
| 350 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 351 | return 0; |
| 352 | } |
| 353 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 354 | int |
| 355 | sys_mq_open(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 356 | { |
| 357 | if (entering(tcp)) { |
| 358 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 359 | tprints(", "); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 360 | /* flags */ |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 361 | tprint_open_modes(tcp->u_arg[1]); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 362 | if (tcp->u_arg[1] & O_CREAT) { |
| 363 | # ifndef HAVE_MQUEUE_H |
| 364 | tprintf(", %lx", tcp->u_arg[2]); |
| 365 | # else |
| 366 | struct mq_attr attr; |
| 367 | /* mode */ |
| 368 | tprintf(", %#lo, ", tcp->u_arg[2]); |
| 369 | if (umove(tcp, tcp->u_arg[3], &attr) < 0) |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 370 | tprints("{???}"); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 371 | else |
| 372 | tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}", |
H.J. Lu | 0b315b6 | 2012-02-03 10:16:03 -0800 | [diff] [blame] | 373 | (long) attr.mq_maxmsg, |
| 374 | (long) attr.mq_msgsize); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 375 | # endif |
| 376 | } |
| 377 | } |
| 378 | return 0; |
| 379 | } |
| 380 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 381 | int |
| 382 | sys_mq_timedsend(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 383 | { |
| 384 | if (entering(tcp)) { |
| 385 | tprintf("%ld, ", tcp->u_arg[0]); |
| 386 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 387 | tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 388 | printtv(tcp, tcp->u_arg[4]); |
| 389 | } |
| 390 | return 0; |
| 391 | } |
| 392 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 393 | int |
| 394 | sys_mq_timedreceive(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 395 | { |
| 396 | if (entering(tcp)) |
| 397 | tprintf("%ld, ", tcp->u_arg[0]); |
| 398 | else { |
| 399 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 400 | tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 401 | printtv(tcp, tcp->u_arg[4]); |
| 402 | } |
| 403 | return 0; |
| 404 | } |
| 405 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 406 | int |
| 407 | sys_mq_notify(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 408 | { |
| 409 | if (entering(tcp)) { |
| 410 | tprintf("%ld, ", tcp->u_arg[0]); |
| 411 | printsigevent(tcp, tcp->u_arg[1]); |
| 412 | } |
| 413 | return 0; |
| 414 | } |
| 415 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 416 | static void |
| 417 | printmqattr(struct tcb *tcp, long addr) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 418 | { |
| 419 | if (addr == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 420 | tprints("NULL"); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 421 | else { |
| 422 | # ifndef HAVE_MQUEUE_H |
| 423 | tprintf("%#lx", addr); |
| 424 | # else |
| 425 | struct mq_attr attr; |
| 426 | if (umove(tcp, addr, &attr) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 427 | tprints("{...}"); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 428 | return; |
| 429 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 430 | tprints("{mq_flags="); |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 431 | tprint_open_modes(attr.mq_flags); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 432 | tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}", |
H.J. Lu | 0b315b6 | 2012-02-03 10:16:03 -0800 | [diff] [blame] | 433 | (long) attr.mq_maxmsg, (long) attr.mq_msgsize, |
| 434 | (long) attr.mq_curmsgs); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 435 | # endif |
| 436 | } |
| 437 | } |
| 438 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 439 | int |
| 440 | sys_mq_getsetattr(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 441 | { |
| 442 | if (entering(tcp)) { |
| 443 | tprintf("%ld, ", tcp->u_arg[0]); |
| 444 | printmqattr(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 445 | tprints(", "); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 446 | } else |
| 447 | printmqattr(tcp, tcp->u_arg[2]); |
| 448 | return 0; |
| 449 | } |
Dmitry V. Levin | b5e88d4 | 2012-02-20 17:02:38 +0000 | [diff] [blame] | 450 | |
| 451 | int |
| 452 | sys_ipc(struct tcb *tcp) |
| 453 | { |
| 454 | return printargs(tcp); |
| 455 | } |