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