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. |
| 29 | * |
| 30 | * $Id$ |
| 31 | */ |
| 32 | |
| 33 | #include "defs.h" |
| 34 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 35 | #if defined(LINUX) || defined(SUNOS4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 36 | |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 37 | # ifdef HAVE_MQUEUE_H |
| 38 | # include <mqueue.h> |
| 39 | # endif |
| 40 | |
| 41 | #include <fcntl.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 42 | #include <sys/ipc.h> |
| 43 | #include <sys/sem.h> |
| 44 | #include <sys/msg.h> |
| 45 | #include <sys/shm.h> |
| 46 | |
| 47 | #ifndef MSG_STAT |
| 48 | #define MSG_STAT 11 |
| 49 | #endif |
| 50 | #ifndef MSG_INFO |
| 51 | #define MSG_INFO 12 |
| 52 | #endif |
| 53 | #ifndef SHM_STAT |
| 54 | #define SHM_STAT 13 |
| 55 | #endif |
| 56 | #ifndef SHM_INFO |
| 57 | #define SHM_INFO 14 |
| 58 | #endif |
| 59 | #ifndef SEM_STAT |
| 60 | #define SEM_STAT 18 |
| 61 | #endif |
| 62 | #ifndef SEM_INFO |
| 63 | #define SEM_INFO 19 |
| 64 | #endif |
| 65 | |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 66 | #if defined LINUX && !defined IPC_64 |
| 67 | # define IPC_64 0x100 |
| 68 | #endif |
| 69 | |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 70 | extern void printsigevent(struct tcb *tcp, long arg); |
| 71 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 72 | static const struct xlat msgctl_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 73 | { IPC_RMID, "IPC_RMID" }, |
| 74 | { IPC_SET, "IPC_SET" }, |
| 75 | { IPC_STAT, "IPC_STAT" }, |
| 76 | #ifdef LINUX |
| 77 | { IPC_INFO, "IPC_INFO" }, |
| 78 | { MSG_STAT, "MSG_STAT" }, |
| 79 | { MSG_INFO, "MSG_INFO" }, |
| 80 | #endif /* LINUX */ |
| 81 | { 0, NULL }, |
| 82 | }; |
| 83 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 84 | static const struct xlat semctl_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 85 | { IPC_RMID, "IPC_RMID" }, |
| 86 | { IPC_SET, "IPC_SET" }, |
| 87 | { IPC_STAT, "IPC_STAT" }, |
| 88 | #ifdef LINUX |
| 89 | { IPC_INFO, "IPC_INFO" }, |
| 90 | { SEM_STAT, "SEM_STAT" }, |
| 91 | { SEM_INFO, "SEM_INFO" }, |
| 92 | #endif /* LINUX */ |
| 93 | { GETPID, "GETPID" }, |
| 94 | { GETVAL, "GETVAL" }, |
| 95 | { GETALL, "GETALL" }, |
| 96 | { GETNCNT, "GETNCNT" }, |
| 97 | { GETZCNT, "GETZCNT" }, |
| 98 | { SETVAL, "SETVAL" }, |
| 99 | { SETALL, "SETALL" }, |
| 100 | { 0, NULL }, |
| 101 | }; |
| 102 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 103 | static const struct xlat shmctl_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 104 | { IPC_RMID, "IPC_RMID" }, |
| 105 | { IPC_SET, "IPC_SET" }, |
| 106 | { IPC_STAT, "IPC_STAT" }, |
| 107 | #ifdef LINUX |
| 108 | { IPC_INFO, "IPC_INFO" }, |
| 109 | { SHM_STAT, "SHM_STAT" }, |
| 110 | { SHM_INFO, "SHM_INFO" }, |
| 111 | #endif /* LINUX */ |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 112 | #ifdef SHM_LOCK |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 113 | { SHM_LOCK, "SHM_LOCK" }, |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 114 | #endif |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 115 | #ifdef SHM_UNLOCK |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 116 | { SHM_UNLOCK, "SHM_UNLOCK" }, |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 117 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 118 | { 0, NULL }, |
| 119 | }; |
| 120 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 121 | static const struct xlat resource_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 122 | { IPC_CREAT, "IPC_CREAT" }, |
| 123 | { IPC_EXCL, "IPC_EXCL" }, |
| 124 | { IPC_NOWAIT, "IPC_NOWAIT" }, |
Roland McGrath | 802b8f4 | 2005-05-09 07:40:33 +0000 | [diff] [blame] | 125 | { 0, NULL }, |
| 126 | }; |
| 127 | |
| 128 | static const struct xlat shm_resource_flags[] = { |
| 129 | { IPC_CREAT, "IPC_CREAT" }, |
| 130 | { IPC_EXCL, "IPC_EXCL" }, |
Roland McGrath | e2be9ab | 2003-07-17 09:03:04 +0000 | [diff] [blame] | 131 | #ifdef SHM_HUGETLB |
| 132 | { SHM_HUGETLB, "SHM_HUGETLB" }, |
| 133 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 134 | { 0, NULL }, |
| 135 | }; |
| 136 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 137 | static const struct xlat shm_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 138 | #ifdef LINUX |
| 139 | { SHM_REMAP, "SHM_REMAP" }, |
| 140 | #endif /* LINUX */ |
| 141 | { SHM_RDONLY, "SHM_RDONLY" }, |
| 142 | { SHM_RND, "SHM_RND" }, |
| 143 | { 0, NULL }, |
| 144 | }; |
| 145 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 146 | static const struct xlat msg_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 147 | { MSG_NOERROR, "MSG_NOERROR" }, |
| 148 | #ifdef LINUX |
| 149 | { MSG_EXCEPT, "MSG_EXCEPT" }, |
| 150 | #endif /* LINUX */ |
| 151 | { IPC_NOWAIT, "IPC_NOWAIT" }, |
| 152 | { 0, NULL }, |
| 153 | }; |
| 154 | |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame] | 155 | static const struct xlat semop_flags[] = { |
| 156 | { SEM_UNDO, "SEM_UNDO" }, |
| 157 | { IPC_NOWAIT, "IPC_NOWAIT" }, |
| 158 | { 0, NULL }, |
| 159 | }; |
| 160 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 161 | int sys_msgget(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 162 | { |
| 163 | if (entering(tcp)) { |
| 164 | if (tcp->u_arg[0]) |
Roland McGrath | 9f130d5 | 2006-08-22 07:36:55 +0000 | [diff] [blame] | 165 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 166 | else |
| 167 | tprintf("IPC_PRIVATE"); |
| 168 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 169 | if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 170 | tprintf("|"); |
Roland McGrath | e2be9ab | 2003-07-17 09:03:04 +0000 | [diff] [blame] | 171 | tprintf("%#lo", tcp->u_arg[1] & 0777); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 172 | } |
| 173 | return 0; |
| 174 | } |
| 175 | |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 176 | #ifdef IPC_64 |
| 177 | # define PRINTCTL(flagset, arg, dflt) \ |
| 178 | if ((arg) & IPC_64) tprintf("IPC_64|"); \ |
| 179 | printxval((flagset), (arg) &~ IPC_64, dflt) |
| 180 | #else |
| 181 | # define PRINTCTL printxval |
| 182 | #endif |
| 183 | |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 184 | static int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 185 | indirect_ipccall(struct tcb *tcp) |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 186 | { |
| 187 | #ifdef LINUX |
| 188 | #ifdef X86_64 |
| 189 | return current_personality > 0; |
| 190 | #endif |
Roland McGrath | a81bf4c | 2005-12-02 04:18:55 +0000 | [diff] [blame] | 191 | #if defined IA64 |
| 192 | return tcp->scno < 1024; /* ia32 emulation syscalls are low */ |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 193 | #endif |
Roland McGrath | e1ebaab | 2005-12-02 04:34:09 +0000 | [diff] [blame] | 194 | #if !defined MIPS && !defined HPPA |
| 195 | return 1; |
| 196 | #endif |
| 197 | #endif /* LINUX */ |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 198 | return 0; |
| 199 | } |
| 200 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 201 | int sys_msgctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 202 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 203 | if (entering(tcp)) { |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 204 | tprintf("%lu, ", tcp->u_arg[0]); |
| 205 | PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 206 | tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 207 | } |
| 208 | return 0; |
| 209 | } |
| 210 | |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 211 | static void |
Dmitry V. Levin | 4310a37 | 2010-03-31 22:22:01 +0000 | [diff] [blame] | 212 | tprint_msgsnd(struct tcb *tcp, long addr, unsigned long count, |
| 213 | unsigned long flags) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 214 | { |
| 215 | long mtype; |
| 216 | |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 217 | if (umove(tcp, addr, &mtype) < 0) { |
| 218 | tprintf("%#lx", addr); |
| 219 | } else { |
| 220 | tprintf("{%lu, ", mtype); |
| 221 | printstr(tcp, addr + sizeof(mtype), count); |
| 222 | tprintf("}"); |
| 223 | } |
| 224 | tprintf(", %lu, ", count); |
Dmitry V. Levin | 4310a37 | 2010-03-31 22:22:01 +0000 | [diff] [blame] | 225 | printflags(msg_flags, flags, "MSG_???"); |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | int sys_msgsnd(struct tcb *tcp) |
| 229 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 230 | if (entering(tcp)) { |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 231 | tprintf("%d, ", (int) tcp->u_arg[0]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 232 | if (indirect_ipccall(tcp)) { |
Dmitry V. Levin | 4310a37 | 2010-03-31 22:22:01 +0000 | [diff] [blame] | 233 | tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1], |
| 234 | tcp->u_arg[2]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 235 | } else { |
Dmitry V. Levin | 4310a37 | 2010-03-31 22:22:01 +0000 | [diff] [blame] | 236 | tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2], |
| 237 | tcp->u_arg[3]); |
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 | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 243 | static void |
| 244 | tprint_msgrcv(struct tcb *tcp, long addr, unsigned long count, long msgtyp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 245 | { |
| 246 | long mtype; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 247 | |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 248 | if (syserror(tcp) || umove(tcp, addr, &mtype) < 0) { |
| 249 | tprintf("%#lx", addr); |
Roland McGrath | f467c00 | 2005-12-02 03:44:12 +0000 | [diff] [blame] | 250 | } else { |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 251 | tprintf("{%lu, ", mtype); |
| 252 | printstr(tcp, addr + sizeof(mtype), count); |
| 253 | tprintf("}"); |
| 254 | } |
| 255 | tprintf(", %lu, %ld, ", count, msgtyp); |
| 256 | } |
| 257 | |
| 258 | int sys_msgrcv(struct tcb *tcp) |
| 259 | { |
| 260 | if (entering(tcp)) { |
| 261 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 262 | } else { |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 263 | if (indirect_ipccall(tcp)) { |
| 264 | struct ipc_wrapper { |
| 265 | struct msgbuf *msgp; |
| 266 | long msgtyp; |
| 267 | } tmp; |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 268 | |
| 269 | if (umove(tcp, tcp->u_arg[3], &tmp) < 0) { |
| 270 | tprintf("%#lx, %lu, ", |
| 271 | tcp->u_arg[3], tcp->u_arg[1]); |
| 272 | } else { |
| 273 | tprint_msgrcv(tcp, (long) tmp.msgp, |
| 274 | tcp->u_arg[1], tmp.msgtyp); |
| 275 | } |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 276 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
| 277 | } else { |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 278 | tprint_msgrcv(tcp, tcp->u_arg[1], |
| 279 | tcp->u_arg[2], tcp->u_arg[3]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 280 | printflags(msg_flags, tcp->u_arg[4], "MSG_???"); |
| 281 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 282 | } |
| 283 | return 0; |
| 284 | } |
| 285 | |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 286 | static void |
| 287 | tprint_sembuf(struct tcb *tcp, long addr, unsigned long count) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 288 | { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 289 | unsigned long i, max_count; |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame] | 290 | |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 291 | if (abbrev(tcp)) |
| 292 | max_count = (max_strlen < count) ? max_strlen : count; |
| 293 | else |
| 294 | max_count = count; |
| 295 | |
| 296 | if (!max_count) { |
| 297 | tprintf("%#lx, %lu", addr, count); |
| 298 | return; |
| 299 | } |
| 300 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 301 | for (i = 0; i < max_count; ++i) { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 302 | struct sembuf sb; |
| 303 | if (i) |
| 304 | tprintf(", "); |
| 305 | if (umove(tcp, addr + i * sizeof(struct sembuf), &sb) < 0) { |
| 306 | if (i) { |
| 307 | tprintf("{???}"); |
| 308 | break; |
| 309 | } else { |
| 310 | tprintf("%#lx, %lu", addr, count); |
| 311 | return; |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame] | 312 | } |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 313 | } else { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 314 | if (!i) |
| 315 | tprintf("{"); |
| 316 | tprintf("{%u, %d, ", sb.sem_num, sb.sem_op); |
| 317 | printflags(semop_flags, sb.sem_flg, "SEM_???"); |
| 318 | tprintf("}"); |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | if (i < max_count || max_count < count) |
| 323 | tprintf(", ..."); |
| 324 | |
| 325 | tprintf("}, %lu", count); |
| 326 | } |
| 327 | |
| 328 | int sys_semop(struct tcb *tcp) |
| 329 | { |
| 330 | if (entering(tcp)) { |
| 331 | tprintf("%lu, ", tcp->u_arg[0]); |
| 332 | if (indirect_ipccall(tcp)) { |
| 333 | tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]); |
| 334 | } else { |
| 335 | tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 336 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 337 | } |
| 338 | return 0; |
| 339 | } |
| 340 | |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 341 | #ifdef LINUX |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 342 | int sys_semtimedop(struct tcb *tcp) |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 343 | { |
| 344 | if (entering(tcp)) { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 345 | tprintf("%lu, ", tcp->u_arg[0]); |
Roland McGrath | a079d9f | 2006-04-25 07:22:01 +0000 | [diff] [blame] | 346 | if (indirect_ipccall(tcp)) { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 347 | tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]); |
| 348 | tprintf(", "); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 349 | printtv(tcp, tcp->u_arg[5]); |
| 350 | } else { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 351 | tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 352 | tprintf(", "); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 353 | printtv(tcp, tcp->u_arg[3]); |
| 354 | } |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 355 | } |
| 356 | return 0; |
| 357 | } |
| 358 | #endif |
| 359 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 360 | int sys_semget(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 361 | { |
| 362 | if (entering(tcp)) { |
| 363 | if (tcp->u_arg[0]) |
Roland McGrath | 9f130d5 | 2006-08-22 07:36:55 +0000 | [diff] [blame] | 364 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 365 | else |
| 366 | tprintf("IPC_PRIVATE"); |
| 367 | tprintf(", %lu", tcp->u_arg[1]); |
| 368 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 369 | if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 370 | tprintf("|"); |
Roland McGrath | e2be9ab | 2003-07-17 09:03:04 +0000 | [diff] [blame] | 371 | tprintf("%#lo", tcp->u_arg[2] & 0777); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 372 | } |
| 373 | return 0; |
| 374 | } |
| 375 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 376 | int sys_semctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 377 | { |
| 378 | if (entering(tcp)) { |
| 379 | tprintf("%lu", tcp->u_arg[0]); |
| 380 | tprintf(", %lu, ", tcp->u_arg[1]); |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 381 | PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 382 | tprintf(", %#lx", tcp->u_arg[3]); |
| 383 | } |
| 384 | return 0; |
| 385 | } |
| 386 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 387 | int sys_shmget(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 388 | { |
| 389 | if (entering(tcp)) { |
| 390 | if (tcp->u_arg[0]) |
Roland McGrath | 9f130d5 | 2006-08-22 07:36:55 +0000 | [diff] [blame] | 391 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 392 | else |
| 393 | tprintf("IPC_PRIVATE"); |
| 394 | tprintf(", %lu", tcp->u_arg[1]); |
| 395 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 396 | if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 397 | tprintf("|"); |
Roland McGrath | e2be9ab | 2003-07-17 09:03:04 +0000 | [diff] [blame] | 398 | tprintf("%#lo", tcp->u_arg[2] & 0777); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 399 | } |
| 400 | return 0; |
| 401 | } |
| 402 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 403 | int sys_shmctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 404 | { |
| 405 | if (entering(tcp)) { |
| 406 | tprintf("%lu, ", tcp->u_arg[0]); |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 407 | PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 408 | if (indirect_ipccall(tcp)) { |
| 409 | tprintf(", %#lx", tcp->u_arg[3]); |
| 410 | } else { |
| 411 | tprintf(", %#lx", tcp->u_arg[2]); |
| 412 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 413 | } |
| 414 | return 0; |
| 415 | } |
| 416 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 417 | int sys_shmat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 418 | { |
| 419 | #ifdef LINUX |
| 420 | unsigned long raddr; |
| 421 | #endif /* LINUX */ |
| 422 | |
| 423 | if (exiting(tcp)) { |
| 424 | tprintf("%lu", tcp->u_arg[0]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 425 | if (indirect_ipccall(tcp)) { |
| 426 | tprintf(", %#lx", tcp->u_arg[3]); |
| 427 | tprintf(", "); |
| 428 | printflags(shm_flags, tcp->u_arg[1], "SHM_???"); |
| 429 | } else { |
| 430 | tprintf(", %#lx", tcp->u_arg[1]); |
| 431 | tprintf(", "); |
| 432 | printflags(shm_flags, tcp->u_arg[2], "SHM_???"); |
| 433 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 434 | if (syserror(tcp)) |
| 435 | return 0; |
Dmitry V. Levin | c0124e6 | 2009-10-05 23:31:54 +0000 | [diff] [blame] | 436 | /* HPPA does not use an IPC multiplexer on Linux. */ |
| 437 | #if defined(LINUX) && !defined(HPPA) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 438 | if (umove(tcp, tcp->u_arg[2], &raddr) < 0) |
| 439 | return RVAL_NONE; |
| 440 | tcp->u_rval = raddr; |
| 441 | #endif /* LINUX */ |
| 442 | return RVAL_HEX; |
| 443 | } |
| 444 | return 0; |
| 445 | } |
| 446 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 447 | int sys_shmdt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 448 | { |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 449 | if (entering(tcp)) { |
| 450 | if (indirect_ipccall(tcp)) { |
| 451 | tprintf("%#lx", tcp->u_arg[3]); |
| 452 | } else { |
| 453 | tprintf("%#lx", tcp->u_arg[0]); |
| 454 | } |
| 455 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 456 | return 0; |
| 457 | } |
| 458 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 459 | #endif /* defined(LINUX) || defined(SUNOS4) || defined(FREEBSD) */ |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 460 | |
| 461 | #ifdef LINUX |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 462 | int |
| 463 | sys_mq_open(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 464 | { |
| 465 | if (entering(tcp)) { |
| 466 | printpath(tcp, tcp->u_arg[0]); |
| 467 | tprintf(", "); |
| 468 | /* flags */ |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 469 | tprint_open_modes(tcp->u_arg[1]); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 470 | if (tcp->u_arg[1] & O_CREAT) { |
| 471 | # ifndef HAVE_MQUEUE_H |
| 472 | tprintf(", %lx", tcp->u_arg[2]); |
| 473 | # else |
| 474 | struct mq_attr attr; |
| 475 | /* mode */ |
| 476 | tprintf(", %#lo, ", tcp->u_arg[2]); |
| 477 | if (umove(tcp, tcp->u_arg[3], &attr) < 0) |
| 478 | tprintf("{ ??? }"); |
| 479 | else |
| 480 | tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}", |
| 481 | attr.mq_maxmsg, attr.mq_msgsize); |
| 482 | # endif |
| 483 | } |
| 484 | } |
| 485 | return 0; |
| 486 | } |
| 487 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 488 | int |
| 489 | sys_mq_timedsend(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 490 | { |
| 491 | if (entering(tcp)) { |
| 492 | tprintf("%ld, ", tcp->u_arg[0]); |
| 493 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 494 | tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 495 | printtv(tcp, tcp->u_arg[4]); |
| 496 | } |
| 497 | return 0; |
| 498 | } |
| 499 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 500 | int |
| 501 | sys_mq_timedreceive(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 502 | { |
| 503 | if (entering(tcp)) |
| 504 | tprintf("%ld, ", tcp->u_arg[0]); |
| 505 | else { |
| 506 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 507 | tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 508 | printtv(tcp, tcp->u_arg[4]); |
| 509 | } |
| 510 | return 0; |
| 511 | } |
| 512 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 513 | int |
| 514 | sys_mq_notify(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 515 | { |
| 516 | if (entering(tcp)) { |
| 517 | tprintf("%ld, ", tcp->u_arg[0]); |
| 518 | printsigevent(tcp, tcp->u_arg[1]); |
| 519 | } |
| 520 | return 0; |
| 521 | } |
| 522 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 523 | static void |
| 524 | printmqattr(struct tcb *tcp, long addr) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 525 | { |
| 526 | if (addr == 0) |
| 527 | tprintf("NULL"); |
| 528 | else { |
| 529 | # ifndef HAVE_MQUEUE_H |
| 530 | tprintf("%#lx", addr); |
| 531 | # else |
| 532 | struct mq_attr attr; |
| 533 | if (umove(tcp, addr, &attr) < 0) { |
| 534 | tprintf("{...}"); |
| 535 | return; |
| 536 | } |
| 537 | tprintf("{mq_flags="); |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 538 | tprint_open_modes(attr.mq_flags); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 539 | tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}", |
| 540 | attr.mq_maxmsg, attr.mq_msgsize, attr.mq_curmsgs); |
| 541 | # endif |
| 542 | } |
| 543 | } |
| 544 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 545 | int |
| 546 | sys_mq_getsetattr(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 547 | { |
| 548 | if (entering(tcp)) { |
| 549 | tprintf("%ld, ", tcp->u_arg[0]); |
| 550 | printmqattr(tcp, tcp->u_arg[1]); |
| 551 | tprintf(", "); |
| 552 | } else |
| 553 | printmqattr(tcp, tcp->u_arg[2]); |
| 554 | return 0; |
| 555 | } |
| 556 | #endif |