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 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 161 | int sys_msgget(tcp) |
| 162 | struct tcb *tcp; |
| 163 | { |
| 164 | if (entering(tcp)) { |
| 165 | if (tcp->u_arg[0]) |
Roland McGrath | 9f130d5 | 2006-08-22 07:36:55 +0000 | [diff] [blame] | 166 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 167 | else |
| 168 | tprintf("IPC_PRIVATE"); |
| 169 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 170 | if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 171 | tprintf("|"); |
Roland McGrath | e2be9ab | 2003-07-17 09:03:04 +0000 | [diff] [blame] | 172 | tprintf("%#lo", tcp->u_arg[1] & 0777); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 173 | } |
| 174 | return 0; |
| 175 | } |
| 176 | |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 177 | #ifdef IPC_64 |
| 178 | # define PRINTCTL(flagset, arg, dflt) \ |
| 179 | if ((arg) & IPC_64) tprintf("IPC_64|"); \ |
| 180 | printxval((flagset), (arg) &~ IPC_64, dflt) |
| 181 | #else |
| 182 | # define PRINTCTL printxval |
| 183 | #endif |
| 184 | |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 185 | static int |
| 186 | indirect_ipccall(tcp) |
| 187 | struct tcb *tcp; |
| 188 | { |
| 189 | #ifdef LINUX |
| 190 | #ifdef X86_64 |
| 191 | return current_personality > 0; |
| 192 | #endif |
Roland McGrath | a81bf4c | 2005-12-02 04:18:55 +0000 | [diff] [blame] | 193 | #if defined IA64 |
| 194 | return tcp->scno < 1024; /* ia32 emulation syscalls are low */ |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 195 | #endif |
Roland McGrath | e1ebaab | 2005-12-02 04:34:09 +0000 | [diff] [blame] | 196 | #if !defined MIPS && !defined HPPA |
| 197 | return 1; |
| 198 | #endif |
| 199 | #endif /* LINUX */ |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 200 | return 0; |
| 201 | } |
| 202 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 203 | int sys_msgctl(tcp) |
| 204 | struct tcb *tcp; |
| 205 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 206 | if (entering(tcp)) { |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 207 | tprintf("%lu, ", tcp->u_arg[0]); |
| 208 | PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 209 | tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 210 | } |
| 211 | return 0; |
| 212 | } |
| 213 | |
| 214 | int sys_msgsnd(tcp) |
| 215 | struct tcb *tcp; |
| 216 | { |
| 217 | long mtype; |
| 218 | |
| 219 | if (entering(tcp)) { |
| 220 | tprintf("%lu", tcp->u_arg[0]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 221 | if (indirect_ipccall(tcp)) { |
| 222 | umove(tcp, tcp->u_arg[3], &mtype); |
| 223 | tprintf(", {%lu, ", mtype); |
| 224 | printstr(tcp, tcp->u_arg[3] + sizeof(long), |
| 225 | tcp->u_arg[1]); |
| 226 | tprintf("}, %lu", tcp->u_arg[1]); |
| 227 | tprintf(", "); |
| 228 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
| 229 | } else { |
| 230 | umove(tcp, tcp->u_arg[1], &mtype); |
| 231 | tprintf(", {%lu, ", mtype); |
| 232 | printstr(tcp, tcp->u_arg[1] + sizeof(long), |
| 233 | tcp->u_arg[2]); |
| 234 | tprintf("}, %lu", tcp->u_arg[2]); |
| 235 | tprintf(", "); |
| 236 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 237 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 238 | } |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | int sys_msgrcv(tcp) |
| 243 | struct tcb *tcp; |
| 244 | { |
| 245 | long mtype; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 246 | |
Roland McGrath | f467c00 | 2005-12-02 03:44:12 +0000 | [diff] [blame] | 247 | if (entering(tcp)) { |
| 248 | tprintf("%lu, ", tcp->u_arg[0]); |
| 249 | } else { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 250 | tprintf("%lu", tcp->u_arg[0]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 251 | if (indirect_ipccall(tcp)) { |
| 252 | struct ipc_wrapper { |
| 253 | struct msgbuf *msgp; |
| 254 | long msgtyp; |
| 255 | } tmp; |
| 256 | umove(tcp, tcp->u_arg[3], &tmp); |
| 257 | umove(tcp, (long) tmp.msgp, &mtype); |
| 258 | tprintf(", {%lu, ", mtype); |
| 259 | printstr(tcp, (long) (tmp.msgp) + sizeof(long), |
| 260 | tcp->u_arg[1]); |
| 261 | tprintf("}, %lu", tcp->u_arg[1]); |
| 262 | tprintf(", %ld", tmp.msgtyp); |
| 263 | tprintf(", "); |
| 264 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
| 265 | } else { |
| 266 | umove(tcp, tcp->u_arg[1], &mtype); |
| 267 | tprintf("{%lu, ", mtype); |
| 268 | printstr(tcp, tcp->u_arg[1] + sizeof(long), |
| 269 | tcp->u_arg[2]); |
| 270 | tprintf("}, %lu", tcp->u_arg[2]); |
| 271 | tprintf(", %ld", tcp->u_arg[3]); |
| 272 | tprintf(", "); |
| 273 | printflags(msg_flags, tcp->u_arg[4], "MSG_???"); |
| 274 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 275 | } |
| 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | int sys_semop(tcp) |
| 280 | struct tcb *tcp; |
| 281 | { |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame^] | 282 | int i; |
| 283 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 284 | if (entering(tcp)) { |
| 285 | tprintf("%lu", tcp->u_arg[0]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 286 | if (indirect_ipccall(tcp)) { |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame^] | 287 | tprintf(", %#lx {", tcp->u_arg[3]); |
| 288 | for(i = 0; i < tcp->u_arg[1]; i++) { |
| 289 | struct sembuf sb; |
| 290 | if(i != 0) |
| 291 | tprintf(", "); |
| 292 | if (umove(tcp, tcp->u_arg[3]+i*sizeof(struct sembuf), &sb) < 0) |
| 293 | tprintf("{???}"); |
| 294 | else { |
| 295 | tprintf("{%u, %d, ", sb.sem_num, sb.sem_op); |
| 296 | printflags(semop_flags, sb.sem_flg, "SEM_???"); |
| 297 | tprintf("}"); |
| 298 | } |
| 299 | } |
| 300 | tprintf("}, %lu", tcp->u_arg[1]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 301 | } else { |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame^] | 302 | tprintf(", %#lx {", tcp->u_arg[1]); |
| 303 | for(i = 0; i < tcp->u_arg[2]; i++) { |
| 304 | struct sembuf sb; |
| 305 | if(i != 0) |
| 306 | tprintf(", "); |
| 307 | if(umove(tcp, tcp->u_arg[1]+i*sizeof(struct sembuf), &sb) < 0) |
| 308 | tprintf("{???}"); |
| 309 | else { |
| 310 | tprintf("{%u, %d, ", sb.sem_num, sb.sem_op); |
| 311 | printflags(semop_flags, sb.sem_flg, "SEM_???"); |
| 312 | tprintf("}"); |
| 313 | } |
| 314 | } |
| 315 | tprintf("}, %lu", tcp->u_arg[2]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 316 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 317 | } |
| 318 | return 0; |
| 319 | } |
| 320 | |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 321 | #ifdef LINUX |
| 322 | int sys_semtimedop(tcp) |
| 323 | struct tcb *tcp; |
| 324 | { |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame^] | 325 | int i; |
| 326 | |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 327 | if (entering(tcp)) { |
| 328 | tprintf("%lu", tcp->u_arg[0]); |
Roland McGrath | a079d9f | 2006-04-25 07:22:01 +0000 | [diff] [blame] | 329 | if (indirect_ipccall(tcp)) { |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame^] | 330 | tprintf(", %#lx {", tcp->u_arg[3]); |
| 331 | for(i = 0; i < tcp->u_arg[1]; i++) { |
| 332 | struct sembuf sb; |
| 333 | if(i != 0) |
| 334 | tprintf(", "); |
| 335 | if(umove(tcp, tcp->u_arg[3]+i*sizeof(struct sembuf), &sb) < 0) |
| 336 | tprintf("{???}"); |
| 337 | else { |
| 338 | tprintf("{%u, %d, ", sb.sem_num, sb.sem_op); |
| 339 | printflags(semop_flags, sb.sem_flg, "SEM_???"); |
| 340 | tprintf("}"); |
| 341 | } |
| 342 | } |
| 343 | tprintf("}, %lu, ", tcp->u_arg[1]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 344 | printtv(tcp, tcp->u_arg[5]); |
| 345 | } else { |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame^] | 346 | tprintf(", %#lx {", tcp->u_arg[1]); |
| 347 | for(i = 0; i < tcp->u_arg[2]; i++) { |
| 348 | struct sembuf sb; |
| 349 | if(i != 0) |
| 350 | tprintf(", "); |
| 351 | if(umove(tcp, tcp->u_arg[1]+i*sizeof(struct sembuf), &sb) < 0) |
| 352 | tprintf("{???}"); |
| 353 | else { |
| 354 | tprintf("{%u, %d, ", sb.sem_num, sb.sem_op); |
| 355 | printflags(semop_flags, sb.sem_flg, "SEM_???"); |
| 356 | tprintf("}"); |
| 357 | } |
| 358 | } |
| 359 | tprintf("}, %lu, ", tcp->u_arg[2]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 360 | printtv(tcp, tcp->u_arg[3]); |
| 361 | } |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 362 | } |
| 363 | return 0; |
| 364 | } |
| 365 | #endif |
| 366 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 367 | int sys_semget(tcp) |
| 368 | struct tcb *tcp; |
| 369 | { |
| 370 | if (entering(tcp)) { |
| 371 | if (tcp->u_arg[0]) |
Roland McGrath | 9f130d5 | 2006-08-22 07:36:55 +0000 | [diff] [blame] | 372 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 373 | else |
| 374 | tprintf("IPC_PRIVATE"); |
| 375 | tprintf(", %lu", tcp->u_arg[1]); |
| 376 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 377 | if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 378 | tprintf("|"); |
Roland McGrath | e2be9ab | 2003-07-17 09:03:04 +0000 | [diff] [blame] | 379 | tprintf("%#lo", tcp->u_arg[2] & 0777); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 380 | } |
| 381 | return 0; |
| 382 | } |
| 383 | |
| 384 | int sys_semctl(tcp) |
| 385 | struct tcb *tcp; |
| 386 | { |
| 387 | if (entering(tcp)) { |
| 388 | tprintf("%lu", tcp->u_arg[0]); |
| 389 | tprintf(", %lu, ", tcp->u_arg[1]); |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 390 | PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 391 | tprintf(", %#lx", tcp->u_arg[3]); |
| 392 | } |
| 393 | return 0; |
| 394 | } |
| 395 | |
| 396 | int sys_shmget(tcp) |
| 397 | struct tcb *tcp; |
| 398 | { |
| 399 | if (entering(tcp)) { |
| 400 | if (tcp->u_arg[0]) |
Roland McGrath | 9f130d5 | 2006-08-22 07:36:55 +0000 | [diff] [blame] | 401 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 402 | else |
| 403 | tprintf("IPC_PRIVATE"); |
| 404 | tprintf(", %lu", tcp->u_arg[1]); |
| 405 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 406 | if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 407 | tprintf("|"); |
Roland McGrath | e2be9ab | 2003-07-17 09:03:04 +0000 | [diff] [blame] | 408 | tprintf("%#lo", tcp->u_arg[2] & 0777); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 409 | } |
| 410 | return 0; |
| 411 | } |
| 412 | |
| 413 | int sys_shmctl(tcp) |
| 414 | struct tcb *tcp; |
| 415 | { |
| 416 | if (entering(tcp)) { |
| 417 | tprintf("%lu, ", tcp->u_arg[0]); |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 418 | PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 419 | if (indirect_ipccall(tcp)) { |
| 420 | tprintf(", %#lx", tcp->u_arg[3]); |
| 421 | } else { |
| 422 | tprintf(", %#lx", tcp->u_arg[2]); |
| 423 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 424 | } |
| 425 | return 0; |
| 426 | } |
| 427 | |
| 428 | int sys_shmat(tcp) |
| 429 | struct tcb *tcp; |
| 430 | { |
| 431 | #ifdef LINUX |
| 432 | unsigned long raddr; |
| 433 | #endif /* LINUX */ |
| 434 | |
| 435 | if (exiting(tcp)) { |
| 436 | tprintf("%lu", tcp->u_arg[0]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 437 | if (indirect_ipccall(tcp)) { |
| 438 | tprintf(", %#lx", tcp->u_arg[3]); |
| 439 | tprintf(", "); |
| 440 | printflags(shm_flags, tcp->u_arg[1], "SHM_???"); |
| 441 | } else { |
| 442 | tprintf(", %#lx", tcp->u_arg[1]); |
| 443 | tprintf(", "); |
| 444 | printflags(shm_flags, tcp->u_arg[2], "SHM_???"); |
| 445 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 446 | if (syserror(tcp)) |
| 447 | return 0; |
Dmitry V. Levin | c0124e6 | 2009-10-05 23:31:54 +0000 | [diff] [blame] | 448 | /* HPPA does not use an IPC multiplexer on Linux. */ |
| 449 | #if defined(LINUX) && !defined(HPPA) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 450 | if (umove(tcp, tcp->u_arg[2], &raddr) < 0) |
| 451 | return RVAL_NONE; |
| 452 | tcp->u_rval = raddr; |
| 453 | #endif /* LINUX */ |
| 454 | return RVAL_HEX; |
| 455 | } |
| 456 | return 0; |
| 457 | } |
| 458 | |
| 459 | int sys_shmdt(tcp) |
| 460 | struct tcb *tcp; |
| 461 | { |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 462 | if (entering(tcp)) { |
| 463 | if (indirect_ipccall(tcp)) { |
| 464 | tprintf("%#lx", tcp->u_arg[3]); |
| 465 | } else { |
| 466 | tprintf("%#lx", tcp->u_arg[0]); |
| 467 | } |
| 468 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 469 | return 0; |
| 470 | } |
| 471 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 472 | #endif /* defined(LINUX) || defined(SUNOS4) || defined(FREEBSD) */ |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 473 | |
| 474 | #ifdef LINUX |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 475 | int |
| 476 | sys_mq_open(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 477 | { |
| 478 | if (entering(tcp)) { |
| 479 | printpath(tcp, tcp->u_arg[0]); |
| 480 | tprintf(", "); |
| 481 | /* flags */ |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 482 | tprint_open_modes(tcp->u_arg[1]); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 483 | if (tcp->u_arg[1] & O_CREAT) { |
| 484 | # ifndef HAVE_MQUEUE_H |
| 485 | tprintf(", %lx", tcp->u_arg[2]); |
| 486 | # else |
| 487 | struct mq_attr attr; |
| 488 | /* mode */ |
| 489 | tprintf(", %#lo, ", tcp->u_arg[2]); |
| 490 | if (umove(tcp, tcp->u_arg[3], &attr) < 0) |
| 491 | tprintf("{ ??? }"); |
| 492 | else |
| 493 | tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}", |
| 494 | attr.mq_maxmsg, attr.mq_msgsize); |
| 495 | # endif |
| 496 | } |
| 497 | } |
| 498 | return 0; |
| 499 | } |
| 500 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 501 | int |
| 502 | sys_mq_timedsend(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 503 | { |
| 504 | if (entering(tcp)) { |
| 505 | tprintf("%ld, ", tcp->u_arg[0]); |
| 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_timedreceive(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 | else { |
| 519 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 520 | tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 521 | printtv(tcp, tcp->u_arg[4]); |
| 522 | } |
| 523 | return 0; |
| 524 | } |
| 525 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 526 | int |
| 527 | sys_mq_notify(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 528 | { |
| 529 | if (entering(tcp)) { |
| 530 | tprintf("%ld, ", tcp->u_arg[0]); |
| 531 | printsigevent(tcp, tcp->u_arg[1]); |
| 532 | } |
| 533 | return 0; |
| 534 | } |
| 535 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 536 | static void |
| 537 | printmqattr(struct tcb *tcp, long addr) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 538 | { |
| 539 | if (addr == 0) |
| 540 | tprintf("NULL"); |
| 541 | else { |
| 542 | # ifndef HAVE_MQUEUE_H |
| 543 | tprintf("%#lx", addr); |
| 544 | # else |
| 545 | struct mq_attr attr; |
| 546 | if (umove(tcp, addr, &attr) < 0) { |
| 547 | tprintf("{...}"); |
| 548 | return; |
| 549 | } |
| 550 | tprintf("{mq_flags="); |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 551 | tprint_open_modes(attr.mq_flags); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 552 | tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}", |
| 553 | attr.mq_maxmsg, attr.mq_msgsize, attr.mq_curmsgs); |
| 554 | # endif |
| 555 | } |
| 556 | } |
| 557 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 558 | int |
| 559 | sys_mq_getsetattr(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 560 | { |
| 561 | if (entering(tcp)) { |
| 562 | tprintf("%ld, ", tcp->u_arg[0]); |
| 563 | printmqattr(tcp, tcp->u_arg[1]); |
| 564 | tprintf(", "); |
| 565 | } else |
| 566 | printmqattr(tcp, tcp->u_arg[2]); |
| 567 | return 0; |
| 568 | } |
| 569 | #endif |