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