Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1993 Ulrich Pegelow <pegelow@moorea.uni-muenster.de> |
| 3 | * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> |
| 4 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 6 | * All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. The name of the author may not be used to endorse or promote products |
| 17 | * derived from this software without specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 29 | */ |
| 30 | |
| 31 | #include "defs.h" |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 32 | #ifdef HAVE_MQUEUE_H |
| 33 | # include <mqueue.h> |
| 34 | #endif |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 35 | #include <fcntl.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 36 | #include <sys/ipc.h> |
| 37 | #include <sys/sem.h> |
| 38 | #include <sys/msg.h> |
| 39 | #include <sys/shm.h> |
| 40 | |
| 41 | #ifndef MSG_STAT |
| 42 | #define MSG_STAT 11 |
| 43 | #endif |
| 44 | #ifndef MSG_INFO |
| 45 | #define MSG_INFO 12 |
| 46 | #endif |
| 47 | #ifndef SHM_STAT |
| 48 | #define SHM_STAT 13 |
| 49 | #endif |
| 50 | #ifndef SHM_INFO |
| 51 | #define SHM_INFO 14 |
| 52 | #endif |
| 53 | #ifndef SEM_STAT |
| 54 | #define SEM_STAT 18 |
| 55 | #endif |
| 56 | #ifndef SEM_INFO |
| 57 | #define SEM_INFO 19 |
| 58 | #endif |
| 59 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 60 | #if !defined IPC_64 |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 61 | # define IPC_64 0x100 |
| 62 | #endif |
| 63 | |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 64 | extern void printsigevent(struct tcb *tcp, long arg); |
| 65 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 66 | #include "xlat/msgctl_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 67 | #include "xlat/semctl_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 68 | #include "xlat/shmctl_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 69 | #include "xlat/resource_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 70 | #include "xlat/shm_resource_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 71 | #include "xlat/shm_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 72 | #include "xlat/ipc_msg_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 73 | #include "xlat/semop_flags.h" |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame] | 74 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 75 | int sys_msgget(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 76 | { |
| 77 | if (entering(tcp)) { |
| 78 | if (tcp->u_arg[0]) |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 79 | tprintf("%#lx, ", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 80 | else |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 81 | tprints("IPC_PRIVATE, "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 82 | if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 83 | tprints("|"); |
Roland McGrath | e2be9ab | 2003-07-17 09:03:04 +0000 | [diff] [blame] | 84 | tprintf("%#lo", tcp->u_arg[1] & 0777); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 85 | } |
| 86 | return 0; |
| 87 | } |
| 88 | |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 89 | #ifdef IPC_64 |
| 90 | # define PRINTCTL(flagset, arg, dflt) \ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 91 | if ((arg) & IPC_64) tprints("IPC_64|"); \ |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 92 | printxval((flagset), (arg) &~ IPC_64, dflt) |
| 93 | #else |
| 94 | # define PRINTCTL printxval |
| 95 | #endif |
| 96 | |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 97 | static int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 98 | indirect_ipccall(struct tcb *tcp) |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 99 | { |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 100 | #ifdef X86_64 |
H.J. Lu | 35be581 | 2012-04-16 13:00:01 +0200 | [diff] [blame] | 101 | return current_personality == 1; |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 102 | #endif |
Roland McGrath | a81bf4c | 2005-12-02 04:18:55 +0000 | [diff] [blame] | 103 | #if defined IA64 |
| 104 | return tcp->scno < 1024; /* ia32 emulation syscalls are low */ |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 105 | #endif |
Steve McIntyre | d8d3bd3 | 2012-10-24 17:58:16 +0100 | [diff] [blame] | 106 | #if defined(ALPHA) || defined(MIPS) || defined(HPPA) || defined(__ARM_EABI__) || defined(AARCH64) |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 107 | return 0; |
Dmitry V. Levin | 3d7b11b | 2012-03-15 21:19:36 +0000 | [diff] [blame] | 108 | #endif |
| 109 | return 1; |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 112 | int sys_msgctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 113 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 114 | if (entering(tcp)) { |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 115 | tprintf("%lu, ", tcp->u_arg[0]); |
| 116 | PRINTCTL(msgctl_flags, tcp->u_arg[1], "MSG_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 117 | tprintf(", %#lx", tcp->u_arg[indirect_ipccall(tcp) ? 3 : 2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 118 | } |
| 119 | return 0; |
| 120 | } |
| 121 | |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 122 | static void |
Dmitry V. Levin | 4310a37 | 2010-03-31 22:22:01 +0000 | [diff] [blame] | 123 | tprint_msgsnd(struct tcb *tcp, long addr, unsigned long count, |
| 124 | unsigned long flags) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 125 | { |
| 126 | long mtype; |
| 127 | |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 128 | if (umove(tcp, addr, &mtype) < 0) { |
| 129 | tprintf("%#lx", addr); |
| 130 | } else { |
| 131 | tprintf("{%lu, ", mtype); |
| 132 | printstr(tcp, addr + sizeof(mtype), count); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 133 | tprints("}"); |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 134 | } |
| 135 | tprintf(", %lu, ", count); |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 136 | printflags(ipc_msg_flags, flags, "MSG_???"); |
Dmitry V. Levin | 783f5bc | 2009-10-08 23:33:15 +0000 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | int sys_msgsnd(struct tcb *tcp) |
| 140 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 141 | if (entering(tcp)) { |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 142 | tprintf("%d, ", (int) tcp->u_arg[0]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 143 | if (indirect_ipccall(tcp)) { |
Dmitry V. Levin | 4310a37 | 2010-03-31 22:22:01 +0000 | [diff] [blame] | 144 | tprint_msgsnd(tcp, tcp->u_arg[3], tcp->u_arg[1], |
| 145 | tcp->u_arg[2]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 146 | } else { |
Dmitry V. Levin | 4310a37 | 2010-03-31 22:22:01 +0000 | [diff] [blame] | 147 | tprint_msgsnd(tcp, tcp->u_arg[1], tcp->u_arg[2], |
| 148 | tcp->u_arg[3]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 149 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 150 | } |
| 151 | return 0; |
| 152 | } |
| 153 | |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 154 | static void |
| 155 | tprint_msgrcv(struct tcb *tcp, long addr, unsigned long count, long msgtyp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 156 | { |
| 157 | long mtype; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 158 | |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 159 | if (syserror(tcp) || umove(tcp, addr, &mtype) < 0) { |
| 160 | tprintf("%#lx", addr); |
Roland McGrath | f467c00 | 2005-12-02 03:44:12 +0000 | [diff] [blame] | 161 | } else { |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 162 | tprintf("{%lu, ", mtype); |
| 163 | printstr(tcp, addr + sizeof(mtype), count); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 164 | tprints("}"); |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 165 | } |
| 166 | tprintf(", %lu, %ld, ", count, msgtyp); |
| 167 | } |
| 168 | |
| 169 | int sys_msgrcv(struct tcb *tcp) |
| 170 | { |
| 171 | if (entering(tcp)) { |
| 172 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 173 | } else { |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 174 | if (indirect_ipccall(tcp)) { |
| 175 | struct ipc_wrapper { |
| 176 | struct msgbuf *msgp; |
| 177 | long msgtyp; |
| 178 | } tmp; |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 179 | |
| 180 | if (umove(tcp, tcp->u_arg[3], &tmp) < 0) { |
| 181 | tprintf("%#lx, %lu, ", |
| 182 | tcp->u_arg[3], tcp->u_arg[1]); |
| 183 | } else { |
| 184 | tprint_msgrcv(tcp, (long) tmp.msgp, |
| 185 | tcp->u_arg[1], tmp.msgtyp); |
| 186 | } |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 187 | printflags(ipc_msg_flags, tcp->u_arg[2], "MSG_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 188 | } else { |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 189 | tprint_msgrcv(tcp, tcp->u_arg[1], |
| 190 | tcp->u_arg[2], tcp->u_arg[3]); |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 191 | printflags(ipc_msg_flags, tcp->u_arg[4], "MSG_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 192 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 193 | } |
| 194 | return 0; |
| 195 | } |
| 196 | |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 197 | static void |
| 198 | tprint_sembuf(struct tcb *tcp, long addr, unsigned long count) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 199 | { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 200 | unsigned long i, max_count; |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame] | 201 | |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 202 | if (abbrev(tcp)) |
| 203 | max_count = (max_strlen < count) ? max_strlen : count; |
| 204 | else |
| 205 | max_count = count; |
| 206 | |
| 207 | if (!max_count) { |
| 208 | tprintf("%#lx, %lu", addr, count); |
| 209 | return; |
| 210 | } |
| 211 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 212 | for (i = 0; i < max_count; ++i) { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 213 | struct sembuf sb; |
| 214 | if (i) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 215 | tprints(", "); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 216 | if (umove(tcp, addr + i * sizeof(struct sembuf), &sb) < 0) { |
| 217 | if (i) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 218 | tprints("{???}"); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 219 | break; |
| 220 | } else { |
| 221 | tprintf("%#lx, %lu", addr, count); |
| 222 | return; |
Jakub Bogusz | 002e985 | 2009-10-07 22:25:10 +0200 | [diff] [blame] | 223 | } |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 224 | } else { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 225 | if (!i) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 226 | tprints("{"); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 227 | tprintf("{%u, %d, ", sb.sem_num, sb.sem_op); |
| 228 | printflags(semop_flags, sb.sem_flg, "SEM_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 229 | tprints("}"); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 230 | } |
| 231 | } |
| 232 | |
| 233 | if (i < max_count || max_count < count) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 234 | tprints(", ..."); |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 235 | |
| 236 | tprintf("}, %lu", count); |
| 237 | } |
| 238 | |
| 239 | int sys_semop(struct tcb *tcp) |
| 240 | { |
| 241 | if (entering(tcp)) { |
| 242 | tprintf("%lu, ", tcp->u_arg[0]); |
| 243 | if (indirect_ipccall(tcp)) { |
| 244 | tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]); |
| 245 | } else { |
| 246 | tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 247 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 248 | } |
| 249 | return 0; |
| 250 | } |
| 251 | |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 252 | int sys_semtimedop(struct tcb *tcp) |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 253 | { |
| 254 | if (entering(tcp)) { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 255 | tprintf("%lu, ", tcp->u_arg[0]); |
Roland McGrath | a079d9f | 2006-04-25 07:22:01 +0000 | [diff] [blame] | 256 | if (indirect_ipccall(tcp)) { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 257 | tprint_sembuf(tcp, tcp->u_arg[3], tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 258 | tprints(", "); |
Stanislav Brabec | beae4c7 | 2012-12-10 20:18:49 +0100 | [diff] [blame] | 259 | #if defined(S390) || defined(S390X) |
Heiko Carstens | e0f5fd8 | 2011-11-30 13:16:29 +0100 | [diff] [blame] | 260 | printtv(tcp, tcp->u_arg[2]); |
| 261 | #else |
Stanislav Brabec | eff5c0e | 2012-12-07 21:30:51 +0100 | [diff] [blame] | 262 | printtv(tcp, tcp->u_arg[4]); |
Heiko Carstens | e0f5fd8 | 2011-11-30 13:16:29 +0100 | [diff] [blame] | 263 | #endif |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 264 | } else { |
Dmitry V. Levin | ef94101 | 2009-10-07 22:14:00 +0000 | [diff] [blame] | 265 | tprint_sembuf(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 266 | tprints(", "); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 267 | printtv(tcp, tcp->u_arg[3]); |
| 268 | } |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 269 | } |
| 270 | return 0; |
| 271 | } |
Roland McGrath | 8477647 | 2003-04-08 01:46:48 +0000 | [diff] [blame] | 272 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 273 | int sys_semget(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 274 | { |
| 275 | if (entering(tcp)) { |
| 276 | if (tcp->u_arg[0]) |
Roland McGrath | 9f130d5 | 2006-08-22 07:36:55 +0000 | [diff] [blame] | 277 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 278 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 279 | tprints("IPC_PRIVATE"); |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 280 | tprintf(", %lu, ", tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 281 | if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 282 | tprints("|"); |
Roland McGrath | e2be9ab | 2003-07-17 09:03:04 +0000 | [diff] [blame] | 283 | tprintf("%#lo", tcp->u_arg[2] & 0777); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 284 | } |
| 285 | return 0; |
| 286 | } |
| 287 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 288 | int sys_semctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 289 | { |
| 290 | if (entering(tcp)) { |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 291 | tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 292 | PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 293 | tprintf(", %#lx", tcp->u_arg[3]); |
| 294 | } |
| 295 | return 0; |
| 296 | } |
| 297 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 298 | int sys_shmget(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 299 | { |
| 300 | if (entering(tcp)) { |
| 301 | if (tcp->u_arg[0]) |
Roland McGrath | 9f130d5 | 2006-08-22 07:36:55 +0000 | [diff] [blame] | 302 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 303 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 304 | tprints("IPC_PRIVATE"); |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 305 | tprintf(", %lu, ", tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 306 | if (printflags(shm_resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 307 | tprints("|"); |
Roland McGrath | e2be9ab | 2003-07-17 09:03:04 +0000 | [diff] [blame] | 308 | tprintf("%#lo", tcp->u_arg[2] & 0777); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 309 | } |
| 310 | return 0; |
| 311 | } |
| 312 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 313 | int sys_shmctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 314 | { |
| 315 | if (entering(tcp)) { |
| 316 | tprintf("%lu, ", tcp->u_arg[0]); |
Roland McGrath | 8073179 | 2003-01-14 09:46:17 +0000 | [diff] [blame] | 317 | PRINTCTL(shmctl_flags, tcp->u_arg[1], "SHM_???"); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 318 | if (indirect_ipccall(tcp)) { |
| 319 | tprintf(", %#lx", tcp->u_arg[3]); |
| 320 | } else { |
| 321 | tprintf(", %#lx", tcp->u_arg[2]); |
| 322 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 323 | } |
| 324 | return 0; |
| 325 | } |
| 326 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 327 | int sys_shmat(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 328 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 329 | if (exiting(tcp)) { |
| 330 | tprintf("%lu", tcp->u_arg[0]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 331 | if (indirect_ipccall(tcp)) { |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 332 | tprintf(", %#lx, ", tcp->u_arg[3]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 333 | printflags(shm_flags, tcp->u_arg[1], "SHM_???"); |
| 334 | } else { |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 335 | tprintf(", %#lx, ", tcp->u_arg[1]); |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 336 | printflags(shm_flags, tcp->u_arg[2], "SHM_???"); |
| 337 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 338 | if (syserror(tcp)) |
| 339 | return 0; |
Dmitry V. Levin | 3d7b11b | 2012-03-15 21:19:36 +0000 | [diff] [blame] | 340 | if (indirect_ipccall(tcp)) { |
| 341 | unsigned long raddr; |
| 342 | if (umove(tcp, tcp->u_arg[2], &raddr) < 0) |
| 343 | return RVAL_NONE; |
| 344 | tcp->u_rval = raddr; |
| 345 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 346 | return RVAL_HEX; |
| 347 | } |
| 348 | return 0; |
| 349 | } |
| 350 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 351 | int sys_shmdt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 352 | { |
Roland McGrath | 54b90d7 | 2005-12-02 03:57:07 +0000 | [diff] [blame] | 353 | if (entering(tcp)) { |
| 354 | if (indirect_ipccall(tcp)) { |
| 355 | tprintf("%#lx", tcp->u_arg[3]); |
| 356 | } else { |
| 357 | tprintf("%#lx", tcp->u_arg[0]); |
| 358 | } |
| 359 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 360 | return 0; |
| 361 | } |
| 362 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 363 | int |
| 364 | sys_mq_open(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 365 | { |
| 366 | if (entering(tcp)) { |
| 367 | printpath(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 368 | tprints(", "); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 369 | /* flags */ |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 370 | tprint_open_modes(tcp->u_arg[1]); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 371 | if (tcp->u_arg[1] & O_CREAT) { |
| 372 | # ifndef HAVE_MQUEUE_H |
| 373 | tprintf(", %lx", tcp->u_arg[2]); |
| 374 | # else |
| 375 | struct mq_attr attr; |
| 376 | /* mode */ |
| 377 | tprintf(", %#lo, ", tcp->u_arg[2]); |
| 378 | if (umove(tcp, tcp->u_arg[3], &attr) < 0) |
Denys Vlasenko | 859ea8b | 2013-02-23 20:07:44 +0100 | [diff] [blame] | 379 | tprints("{???}"); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 380 | else |
| 381 | tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}", |
H.J. Lu | 0b315b6 | 2012-02-03 10:16:03 -0800 | [diff] [blame] | 382 | (long) attr.mq_maxmsg, |
| 383 | (long) attr.mq_msgsize); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 384 | # endif |
| 385 | } |
| 386 | } |
| 387 | return 0; |
| 388 | } |
| 389 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 390 | int |
| 391 | sys_mq_timedsend(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 392 | { |
| 393 | if (entering(tcp)) { |
| 394 | tprintf("%ld, ", tcp->u_arg[0]); |
| 395 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 396 | tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 397 | printtv(tcp, tcp->u_arg[4]); |
| 398 | } |
| 399 | return 0; |
| 400 | } |
| 401 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 402 | int |
| 403 | sys_mq_timedreceive(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 404 | { |
| 405 | if (entering(tcp)) |
| 406 | tprintf("%ld, ", tcp->u_arg[0]); |
| 407 | else { |
| 408 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 409 | tprintf(", %lu, %ld, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 410 | printtv(tcp, tcp->u_arg[4]); |
| 411 | } |
| 412 | return 0; |
| 413 | } |
| 414 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 415 | int |
| 416 | sys_mq_notify(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 417 | { |
| 418 | if (entering(tcp)) { |
| 419 | tprintf("%ld, ", tcp->u_arg[0]); |
| 420 | printsigevent(tcp, tcp->u_arg[1]); |
| 421 | } |
| 422 | return 0; |
| 423 | } |
| 424 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 425 | static void |
| 426 | printmqattr(struct tcb *tcp, long addr) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 427 | { |
| 428 | if (addr == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 429 | tprints("NULL"); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 430 | else { |
| 431 | # ifndef HAVE_MQUEUE_H |
| 432 | tprintf("%#lx", addr); |
| 433 | # else |
| 434 | struct mq_attr attr; |
| 435 | if (umove(tcp, addr, &attr) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 436 | tprints("{...}"); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 437 | return; |
| 438 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 439 | tprints("{mq_flags="); |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 440 | tprint_open_modes(attr.mq_flags); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 441 | tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}", |
H.J. Lu | 0b315b6 | 2012-02-03 10:16:03 -0800 | [diff] [blame] | 442 | (long) attr.mq_maxmsg, (long) attr.mq_msgsize, |
| 443 | (long) attr.mq_curmsgs); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 444 | # endif |
| 445 | } |
| 446 | } |
| 447 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 448 | int |
| 449 | sys_mq_getsetattr(struct tcb *tcp) |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 450 | { |
| 451 | if (entering(tcp)) { |
| 452 | tprintf("%ld, ", tcp->u_arg[0]); |
| 453 | printmqattr(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 454 | tprints(", "); |
Roland McGrath | 4df13c1 | 2004-04-16 21:48:40 +0000 | [diff] [blame] | 455 | } else |
| 456 | printmqattr(tcp, tcp->u_arg[2]); |
| 457 | return 0; |
| 458 | } |
Dmitry V. Levin | b5e88d4 | 2012-02-20 17:02:38 +0000 | [diff] [blame] | 459 | |
| 460 | int |
| 461 | sys_ipc(struct tcb *tcp) |
| 462 | { |
| 463 | return printargs(tcp); |
| 464 | } |