Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> |
| 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" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 32 | #include <fcntl.h> |
| 33 | #include <sys/file.h> |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 34 | #ifdef HAVE_SYS_EPOLL_H |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 35 | # include <sys/epoll.h> |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 36 | #endif |
Ben Noordhuis | 88eafd8 | 2013-02-04 00:04:57 +0100 | [diff] [blame] | 37 | #ifdef HAVE_LINUX_PERF_EVENT_H |
| 38 | # include <linux/perf_event.h> |
| 39 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 40 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 41 | static const struct xlat fcntlcmds[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 42 | { F_DUPFD, "F_DUPFD" }, |
| 43 | { F_GETFD, "F_GETFD" }, |
| 44 | { F_SETFD, "F_SETFD" }, |
| 45 | { F_GETFL, "F_GETFL" }, |
| 46 | { F_SETFL, "F_SETFL" }, |
| 47 | { F_GETLK, "F_GETLK" }, |
| 48 | { F_SETLK, "F_SETLK" }, |
| 49 | { F_SETLKW, "F_SETLKW" }, |
| 50 | { F_GETOWN, "F_GETOWN" }, |
| 51 | { F_SETOWN, "F_SETOWN" }, |
| 52 | #ifdef F_RSETLK |
| 53 | { F_RSETLK, "F_RSETLK" }, |
| 54 | #endif |
| 55 | #ifdef F_RSETLKW |
| 56 | { F_RSETLKW, "F_RSETLKW" }, |
| 57 | #endif |
| 58 | #ifdef F_RGETLK |
| 59 | { F_RGETLK, "F_RGETLK" }, |
| 60 | #endif |
| 61 | #ifdef F_CNVT |
| 62 | { F_CNVT, "F_CNVT" }, |
| 63 | #endif |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 64 | #ifdef F_SETSIG |
| 65 | { F_SETSIG, "F_SETSIG" }, |
| 66 | #endif |
| 67 | #ifdef F_GETSIG |
| 68 | { F_GETSIG, "F_GETSIG" }, |
| 69 | #endif |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 70 | #ifdef F_CHKFL |
| 71 | { F_CHKFL, "F_CHKFL" }, |
| 72 | #endif |
| 73 | #ifdef F_DUP2FD |
| 74 | { F_DUP2FD, "F_DUP2FD" }, |
| 75 | #endif |
| 76 | #ifdef F_ALLOCSP |
| 77 | { F_ALLOCSP, "F_ALLOCSP" }, |
| 78 | #endif |
| 79 | #ifdef F_ISSTREAM |
| 80 | { F_ISSTREAM, "F_ISSTREAM" }, |
| 81 | #endif |
| 82 | #ifdef F_PRIV |
| 83 | { F_PRIV, "F_PRIV" }, |
| 84 | #endif |
| 85 | #ifdef F_NPRIV |
| 86 | { F_NPRIV, "F_NPRIV" }, |
| 87 | #endif |
| 88 | #ifdef F_QUOTACL |
| 89 | { F_QUOTACL, "F_QUOTACL" }, |
| 90 | #endif |
| 91 | #ifdef F_BLOCKS |
| 92 | { F_BLOCKS, "F_BLOCKS" }, |
| 93 | #endif |
| 94 | #ifdef F_BLKSIZE |
| 95 | { F_BLKSIZE, "F_BLKSIZE" }, |
| 96 | #endif |
| 97 | #ifdef F_GETOWN |
| 98 | { F_GETOWN, "F_GETOWN" }, |
| 99 | #endif |
| 100 | #ifdef F_SETOWN |
| 101 | { F_SETOWN, "F_SETOWN" }, |
| 102 | #endif |
| 103 | #ifdef F_REVOKE |
| 104 | { F_REVOKE, "F_REVOKE" }, |
| 105 | #endif |
| 106 | #ifdef F_SETLK |
| 107 | { F_SETLK, "F_SETLK" }, |
| 108 | #endif |
| 109 | #ifdef F_SETLKW |
| 110 | { F_SETLKW, "F_SETLKW" }, |
| 111 | #endif |
| 112 | #ifdef F_FREESP |
| 113 | { F_FREESP, "F_FREESP" }, |
| 114 | #endif |
| 115 | #ifdef F_GETLK |
| 116 | { F_GETLK, "F_GETLK" }, |
| 117 | #endif |
| 118 | #ifdef F_SETLK64 |
| 119 | { F_SETLK64, "F_SETLK64" }, |
| 120 | #endif |
| 121 | #ifdef F_SETLKW64 |
| 122 | { F_SETLKW64, "F_SETLKW64" }, |
| 123 | #endif |
| 124 | #ifdef F_FREESP64 |
| 125 | { F_FREESP64, "F_FREESP64" }, |
| 126 | #endif |
| 127 | #ifdef F_GETLK64 |
| 128 | { F_GETLK64, "F_GETLK64" }, |
| 129 | #endif |
| 130 | #ifdef F_SHARE |
| 131 | { F_SHARE, "F_SHARE" }, |
| 132 | #endif |
| 133 | #ifdef F_UNSHARE |
| 134 | { F_UNSHARE, "F_UNSHARE" }, |
| 135 | #endif |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 136 | #ifdef F_SETLEASE |
| 137 | { F_SETLEASE, "F_SETLEASE" }, |
| 138 | #endif |
| 139 | #ifdef F_GETLEASE |
| 140 | { F_GETLEASE, "F_GETLEASE" }, |
| 141 | #endif |
| 142 | #ifdef F_NOTIFY |
| 143 | { F_NOTIFY, "F_NOTIFY" }, |
| 144 | #endif |
| 145 | #ifdef F_DUPFD_CLOEXEC |
| 146 | { F_DUPFD_CLOEXEC,"F_DUPFD_CLOEXEC"}, |
| 147 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 148 | { 0, NULL }, |
| 149 | }; |
| 150 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 151 | static const struct xlat fdflags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 152 | #ifdef FD_CLOEXEC |
| 153 | { FD_CLOEXEC, "FD_CLOEXEC" }, |
| 154 | #endif |
| 155 | { 0, NULL }, |
| 156 | }; |
| 157 | |
| 158 | #ifdef LOCK_SH |
| 159 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 160 | static const struct xlat flockcmds[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 161 | { LOCK_SH, "LOCK_SH" }, |
| 162 | { LOCK_EX, "LOCK_EX" }, |
| 163 | { LOCK_NB, "LOCK_NB" }, |
| 164 | { LOCK_UN, "LOCK_UN" }, |
| 165 | { 0, NULL }, |
| 166 | }; |
| 167 | |
| 168 | #endif /* LOCK_SH */ |
| 169 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 170 | static const struct xlat lockfcmds[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 171 | { F_RDLCK, "F_RDLCK" }, |
| 172 | { F_WRLCK, "F_WRLCK" }, |
| 173 | { F_UNLCK, "F_UNLCK" }, |
| 174 | #ifdef F_EXLCK |
| 175 | { F_EXLCK, "F_EXLCK" }, |
| 176 | #endif |
| 177 | #ifdef F_SHLCK |
| 178 | { F_SHLCK, "F_SHLCK" }, |
| 179 | #endif |
| 180 | { 0, NULL }, |
| 181 | }; |
| 182 | |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 183 | #ifdef F_NOTIFY |
| 184 | static const struct xlat notifyflags[] = { |
| 185 | #ifdef DN_ACCESS |
| 186 | { DN_ACCESS, "DN_ACCESS" }, |
| 187 | #endif |
| 188 | #ifdef DN_MODIFY |
| 189 | { DN_MODIFY, "DN_MODIFY" }, |
| 190 | #endif |
| 191 | #ifdef DN_CREATE |
| 192 | { DN_CREATE, "DN_CREATE" }, |
| 193 | #endif |
| 194 | #ifdef DN_DELETE |
| 195 | { DN_DELETE, "DN_DELETE" }, |
| 196 | #endif |
| 197 | #ifdef DN_RENAME |
| 198 | { DN_RENAME, "DN_RENAME" }, |
| 199 | #endif |
| 200 | #ifdef DN_ATTRIB |
| 201 | { DN_ATTRIB, "DN_ATTRIB" }, |
| 202 | #endif |
| 203 | #ifdef DN_MULTISHOT |
| 204 | { DN_MULTISHOT, "DN_MULTISHOT" }, |
| 205 | #endif |
| 206 | { 0, NULL }, |
| 207 | }; |
| 208 | #endif |
| 209 | |
Ben Noordhuis | 88eafd8 | 2013-02-04 00:04:57 +0100 | [diff] [blame] | 210 | static const struct xlat perf_event_open_flags[] = { |
| 211 | #ifdef PERF_FLAG_FD_NO_GROUP |
| 212 | { PERF_FLAG_FD_NO_GROUP, "PERF_FLAG_FD_NO_GROUP" }, |
| 213 | #endif |
| 214 | #ifdef PERF_FLAG_FD_OUTPUT |
| 215 | { PERF_FLAG_FD_OUTPUT, "PERF_FLAG_FD_OUTPUT" }, |
| 216 | #endif |
| 217 | #ifdef PERF_FLAG_PID_CGROUP |
| 218 | { PERF_FLAG_PID_CGROUP, "PERF_FLAG_PID_CGROUP" }, |
| 219 | #endif |
| 220 | { 0, NULL }, |
| 221 | }; |
| 222 | |
Dmitry V. Levin | 594eb8f | 2013-11-12 21:49:03 +0000 | [diff] [blame] | 223 | #if defined(F_SETLK64) && F_SETLK64 + 0 != F_SETLK |
| 224 | # define HAVE_F_SETLK64 1 |
| 225 | #else |
| 226 | # define HAVE_F_SETLK64 0 |
| 227 | #endif |
| 228 | |
| 229 | #if defined(F_SETLKW64) && F_SETLKW64 + 0 != F_SETLKW |
| 230 | # define HAVE_F_SETLKW64 1 |
| 231 | #else |
| 232 | # define HAVE_F_SETLKW64 0 |
| 233 | #endif |
| 234 | |
| 235 | #if defined(F_GETLK64) && F_GETLK64+0 != F_GETLK |
| 236 | # define HAVE_F_GETLK64 1 |
| 237 | #else |
| 238 | # define HAVE_F_GETLK64 0 |
| 239 | #endif |
| 240 | |
| 241 | #if defined(X32) || defined(F_FREESP64) || \ |
| 242 | HAVE_F_SETLK64 || HAVE_F_SETLKW64 || HAVE_F_GETLK64 |
| 243 | |
| 244 | #ifndef HAVE_STRUCT_FLOCK64 |
| 245 | struct flock64 { |
| 246 | short int l_type, l_whence; |
| 247 | int64_t l_start, l_len; |
| 248 | int l_pid; |
| 249 | }; |
| 250 | #endif |
| 251 | |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 252 | /* fcntl/lockf */ |
| 253 | static void |
| 254 | printflock64(struct tcb *tcp, long addr, int getlk) |
| 255 | { |
| 256 | struct flock64 fl; |
| 257 | |
| 258 | if (umove(tcp, addr, &fl) < 0) { |
| 259 | tprints("{...}"); |
| 260 | return; |
| 261 | } |
| 262 | tprints("{type="); |
| 263 | printxval(lockfcmds, fl.l_type, "F_???"); |
| 264 | tprints(", whence="); |
| 265 | printxval(whence_codes, fl.l_whence, "SEEK_???"); |
| 266 | tprintf(", start=%lld, len=%lld", (long long) fl.l_start, (long long) fl.l_len); |
| 267 | if (getlk) |
| 268 | tprintf(", pid=%lu}", (unsigned long) fl.l_pid); |
| 269 | else |
| 270 | tprints("}"); |
| 271 | } |
| 272 | #endif |
| 273 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 274 | /* fcntl/lockf */ |
| 275 | static void |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 276 | printflock(struct tcb *tcp, long addr, int getlk) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 277 | { |
| 278 | struct flock fl; |
| 279 | |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 280 | #if SUPPORTED_PERSONALITIES > 1 |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 281 | # ifdef X32 |
| 282 | if (current_personality == 0) { |
| 283 | printflock64(tcp, addr, getlk); |
| 284 | return; |
| 285 | } |
| 286 | # endif |
Denys Vlasenko | 9fd4f96 | 2012-03-19 09:36:42 +0100 | [diff] [blame] | 287 | if (current_wordsize != sizeof(fl.l_start)) { |
| 288 | if (current_wordsize == 4) { |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 289 | /* 32-bit x86 app on x86_64 and similar cases */ |
| 290 | struct { |
| 291 | short int l_type; |
| 292 | short int l_whence; |
| 293 | int32_t l_start; /* off_t */ |
| 294 | int32_t l_len; /* off_t */ |
| 295 | int32_t l_pid; /* pid_t */ |
| 296 | } fl32; |
| 297 | if (umove(tcp, addr, &fl32) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 298 | tprints("{...}"); |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 299 | return; |
| 300 | } |
| 301 | fl.l_type = fl32.l_type; |
| 302 | fl.l_whence = fl32.l_whence; |
| 303 | fl.l_start = fl32.l_start; |
| 304 | fl.l_len = fl32.l_len; |
| 305 | fl.l_pid = fl32.l_pid; |
| 306 | } else { |
| 307 | /* let people know we have a problem here */ |
Denys Vlasenko | 751acb3 | 2013-02-08 15:34:46 +0100 | [diff] [blame] | 308 | tprintf("<decode error: unsupported wordsize %d>", |
Denys Vlasenko | 9fd4f96 | 2012-03-19 09:36:42 +0100 | [diff] [blame] | 309 | current_wordsize); |
Denys Vlasenko | 7a862d7 | 2009-04-15 13:22:59 +0000 | [diff] [blame] | 310 | return; |
| 311 | } |
| 312 | } else |
| 313 | #endif |
| 314 | { |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 315 | if (umove(tcp, addr, &fl) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 316 | tprints("{...}"); |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 317 | return; |
| 318 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 319 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 320 | tprints("{type="); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 321 | printxval(lockfcmds, fl.l_type, "F_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 322 | tprints(", whence="); |
Denys Vlasenko | 86738a2 | 2013-02-17 14:31:55 +0100 | [diff] [blame] | 323 | printxval(whence_codes, fl.l_whence, "SEEK_???"); |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 324 | #ifdef X32 |
| 325 | tprintf(", start=%lld, len=%lld", fl.l_start, fl.l_len); |
| 326 | #else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 327 | tprintf(", start=%ld, len=%ld", fl.l_start, fl.l_len); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 328 | #endif |
Dmitry V. Levin | 0eeda2c | 2013-05-01 16:37:08 +0000 | [diff] [blame] | 329 | if (getlk) |
| 330 | tprintf(", pid=%lu}", (unsigned long) fl.l_pid); |
| 331 | else |
| 332 | tprints("}"); |
| 333 | } |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 334 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 335 | int |
| 336 | sys_fcntl(struct tcb *tcp) |
| 337 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 338 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 339 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 340 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 341 | printxval(fcntlcmds, tcp->u_arg[1], "F_???"); |
| 342 | switch (tcp->u_arg[1]) { |
| 343 | case F_SETFD: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 344 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 345 | printflags(fdflags, tcp->u_arg[2], "FD_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 346 | break; |
| 347 | case F_SETOWN: case F_DUPFD: |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 348 | #ifdef F_DUPFD_CLOEXEC |
| 349 | case F_DUPFD_CLOEXEC: |
| 350 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 351 | tprintf(", %ld", tcp->u_arg[2]); |
| 352 | break; |
| 353 | case F_SETFL: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 354 | tprints(", "); |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 355 | tprint_open_modes(tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 356 | break; |
| 357 | case F_SETLK: case F_SETLKW: |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 358 | #ifdef F_FREESP |
| 359 | case F_FREESP: |
| 360 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 361 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 362 | printflock(tcp, tcp->u_arg[2], 0); |
| 363 | break; |
Dmitry V. Levin | 594eb8f | 2013-11-12 21:49:03 +0000 | [diff] [blame] | 364 | #if defined(F_FREESP64) || HAVE_F_SETLK64 || HAVE_F_SETLKW64 |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 365 | #ifdef F_FREESP64 |
| 366 | case F_FREESP64: |
| 367 | #endif |
Roland McGrath | e948faf | 2002-12-15 23:58:18 +0000 | [diff] [blame] | 368 | /* Linux glibc defines SETLK64 as SETLK, |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 369 | even though the kernel has different values - as does Solaris. */ |
Dmitry V. Levin | 594eb8f | 2013-11-12 21:49:03 +0000 | [diff] [blame] | 370 | #if HAVE_F_SETLK64 |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 371 | case F_SETLK64: |
| 372 | #endif |
Dmitry V. Levin | 594eb8f | 2013-11-12 21:49:03 +0000 | [diff] [blame] | 373 | #if HAVE_F_SETLKW64 |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 374 | case F_SETLKW64: |
| 375 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 376 | tprints(", "); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 377 | printflock64(tcp, tcp->u_arg[2], 0); |
| 378 | break; |
Dmitry V. Levin | 594eb8f | 2013-11-12 21:49:03 +0000 | [diff] [blame] | 379 | #endif /* defined(F_FREESP64) || HAVE_F_SETLK64 || HAVE_F_SETLKW64 */ |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 380 | #ifdef F_NOTIFY |
| 381 | case F_NOTIFY: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 382 | tprints(", "); |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 383 | printflags(notifyflags, tcp->u_arg[2], "DN_???"); |
| 384 | break; |
| 385 | #endif |
| 386 | #ifdef F_SETLEASE |
| 387 | case F_SETLEASE: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 388 | tprints(", "); |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 389 | printxval(lockfcmds, tcp->u_arg[2], "F_???"); |
| 390 | break; |
| 391 | #endif |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 392 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 393 | } |
| 394 | else { |
| 395 | switch (tcp->u_arg[1]) { |
| 396 | case F_DUPFD: |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 397 | #ifdef F_DUPFD_CLOEXEC |
| 398 | case F_DUPFD_CLOEXEC: |
| 399 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 400 | case F_SETFD: case F_SETFL: |
| 401 | case F_SETLK: case F_SETLKW: |
| 402 | case F_SETOWN: case F_GETOWN: |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 403 | #ifdef F_NOTIFY |
| 404 | case F_NOTIFY: |
| 405 | #endif |
| 406 | #ifdef F_SETLEASE |
| 407 | case F_SETLEASE: |
| 408 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 409 | break; |
| 410 | case F_GETFD: |
Dmitry V. Levin | 21a7534 | 2008-09-03 01:22:18 +0000 | [diff] [blame] | 411 | if (syserror(tcp) || tcp->u_rval == 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 412 | return 0; |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 413 | tcp->auxstr = sprintflags("flags ", fdflags, tcp->u_rval); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 414 | return RVAL_HEX|RVAL_STR; |
| 415 | case F_GETFL: |
Dmitry V. Levin | 21a7534 | 2008-09-03 01:22:18 +0000 | [diff] [blame] | 416 | if (syserror(tcp)) |
| 417 | return 0; |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 418 | tcp->auxstr = sprint_open_modes(tcp->u_rval); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 419 | return RVAL_HEX|RVAL_STR; |
| 420 | case F_GETLK: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 421 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 422 | printflock(tcp, tcp->u_arg[2], 1); |
| 423 | break; |
Dmitry V. Levin | 594eb8f | 2013-11-12 21:49:03 +0000 | [diff] [blame] | 424 | #if HAVE_F_GETLK64 |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 425 | case F_GETLK64: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 426 | tprints(", "); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 427 | printflock64(tcp, tcp->u_arg[2], 1); |
| 428 | break; |
| 429 | #endif |
Denys Vlasenko | eedaac7 | 2009-03-10 20:41:58 +0000 | [diff] [blame] | 430 | #ifdef F_GETLEASE |
| 431 | case F_GETLEASE: |
| 432 | if (syserror(tcp)) |
| 433 | return 0; |
| 434 | tcp->auxstr = xlookup(lockfcmds, tcp->u_rval); |
| 435 | return RVAL_HEX|RVAL_STR; |
| 436 | #endif |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 437 | default: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 438 | tprintf(", %#lx", tcp->u_arg[2]); |
| 439 | break; |
| 440 | } |
| 441 | } |
| 442 | return 0; |
| 443 | } |
| 444 | |
| 445 | #ifdef LOCK_SH |
| 446 | |
| 447 | int |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 448 | sys_flock(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 449 | { |
| 450 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 451 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 452 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 453 | printflags(flockcmds, tcp->u_arg[1], "LOCK_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 454 | } |
| 455 | return 0; |
| 456 | } |
| 457 | #endif /* LOCK_SH */ |
| 458 | |
| 459 | int |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 460 | sys_close(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 461 | { |
| 462 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 463 | printfd(tcp, tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 464 | } |
| 465 | return 0; |
| 466 | } |
| 467 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 468 | static int |
| 469 | do_dup2(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 470 | { |
| 471 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 472 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 473 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 474 | printfd(tcp, tcp->u_arg[1]); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 475 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 476 | tprints(", "); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 477 | printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); |
| 478 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 479 | } |
| 480 | return 0; |
| 481 | } |
| 482 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 483 | int |
| 484 | sys_dup2(struct tcb *tcp) |
| 485 | { |
| 486 | return do_dup2(tcp, -1); |
| 487 | } |
| 488 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 489 | int |
| 490 | sys_dup3(struct tcb *tcp) |
| 491 | { |
| 492 | return do_dup2(tcp, 2); |
| 493 | } |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 494 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 495 | #if defined(ALPHA) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 496 | int |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 497 | sys_getdtablesize(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 498 | { |
| 499 | return 0; |
| 500 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 501 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 502 | |
Dmitry V. Levin | c2982b5 | 2013-11-05 23:00:22 +0000 | [diff] [blame] | 503 | static int |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 504 | decode_select(struct tcb *tcp, long *args, enum bitness_t bitness) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 505 | { |
Denys Vlasenko | ad5155a | 2011-09-01 18:18:04 +0200 | [diff] [blame] | 506 | int i, j; |
Denys Vlasenko | 1f65c3c | 2013-11-05 16:20:16 +0100 | [diff] [blame] | 507 | int nfds, fdsize; |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 508 | fd_set *fds; |
Dmitry V. Levin | 30145dd | 2010-09-06 22:08:24 +0000 | [diff] [blame] | 509 | const char *sep; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 510 | long arg; |
| 511 | |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 512 | /* Kernel truncates arg[0] to int, we do the same. */ |
| 513 | nfds = (int) args[0]; |
| 514 | |
| 515 | /* Kernel rejects negative nfds, so we don't parse it either. */ |
| 516 | if (nfds < 0) { |
| 517 | nfds = 0; |
| 518 | fds = NULL; |
| 519 | } |
Denys Vlasenko | 79a79ea | 2011-09-01 16:35:44 +0200 | [diff] [blame] | 520 | /* Beware of select(2^31-1, NULL, NULL, NULL) and similar... */ |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 521 | if (nfds > 1024*1024) |
| 522 | nfds = 1024*1024; |
| 523 | |
| 524 | /* |
| 525 | * We had bugs a-la "while (j < args[0])" and "umoven(args[0])" below. |
Dr. David Alan Gilbert | 025f108 | 2013-11-05 11:54:51 +0100 | [diff] [blame] | 526 | * Instead of args[0], use nfds for fd count, fdsize for array lengths. |
| 527 | */ |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 528 | fdsize = (((nfds + 7) / 8) + current_wordsize-1) & -current_wordsize; |
Denys Vlasenko | 79a79ea | 2011-09-01 16:35:44 +0200 | [diff] [blame] | 529 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 530 | if (entering(tcp)) { |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 531 | tprintf("%d", (int) args[0]); |
| 532 | |
| 533 | if (fdsize > 0) { |
| 534 | fds = malloc(fdsize); |
| 535 | if (!fds) |
| 536 | die_out_of_memory(); |
| 537 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 538 | for (i = 0; i < 3; i++) { |
| 539 | arg = args[i+1]; |
| 540 | if (arg == 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 541 | tprints(", NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 542 | continue; |
| 543 | } |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 544 | if (!verbose(tcp) || !fds) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 545 | tprintf(", %#lx", arg); |
| 546 | continue; |
| 547 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 548 | if (umoven(tcp, arg, fdsize, (char *) fds) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 549 | tprints(", [?]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 550 | continue; |
| 551 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 552 | tprints(", ["); |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 553 | for (j = 0, sep = "";; j++) { |
| 554 | j = next_set_bit(fds, j, nfds); |
| 555 | if (j < 0) |
| 556 | break; |
| 557 | tprints(sep); |
| 558 | printfd(tcp, j); |
| 559 | sep = " "; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 560 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 561 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 562 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 563 | free(fds); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 564 | tprints(", "); |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 565 | printtv_bitness(tcp, args[4], bitness, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 566 | } |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 567 | else { |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 568 | static char outstr[1024]; |
| 569 | char *outptr; |
| 570 | #define end_outstr (outstr + sizeof(outstr)) |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 571 | int ready_fds; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 572 | |
| 573 | if (syserror(tcp)) |
| 574 | return 0; |
| 575 | |
Dr. David Alan Gilbert | 025f108 | 2013-11-05 11:54:51 +0100 | [diff] [blame] | 576 | ready_fds = tcp->u_rval; |
| 577 | if (ready_fds == 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 578 | tcp->auxstr = "Timeout"; |
| 579 | return RVAL_STR; |
| 580 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 581 | |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 582 | fds = malloc(fdsize); |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 583 | if (!fds) |
| 584 | die_out_of_memory(); |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 585 | |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 586 | outptr = outstr; |
| 587 | sep = ""; |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 588 | for (i = 0; i < 3 && ready_fds > 0; i++) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 589 | int first = 1; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 590 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 591 | arg = args[i+1]; |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 592 | if (!arg || umoven(tcp, arg, fdsize, (char *) fds) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 593 | continue; |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 594 | for (j = 0;; j++) { |
| 595 | j = next_set_bit(fds, j, nfds); |
| 596 | if (j < 0) |
| 597 | break; |
| 598 | /* +2 chars needed at the end: ']',NUL */ |
| 599 | if (outptr < end_outstr - (sizeof(", except [") + sizeof(int)*3 + 2)) { |
| 600 | if (first) { |
| 601 | outptr += sprintf(outptr, "%s%s [%u", |
| 602 | sep, |
| 603 | i == 0 ? "in" : i == 1 ? "out" : "except", |
| 604 | j |
| 605 | ); |
| 606 | first = 0; |
| 607 | sep = ", "; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 608 | } |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 609 | else { |
| 610 | outptr += sprintf(outptr, " %u", j); |
| 611 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 612 | } |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 613 | if (--ready_fds == 0) |
| 614 | break; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 615 | } |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 616 | if (outptr != outstr) |
| 617 | *outptr++ = ']'; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 618 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 619 | free(fds); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 620 | /* This contains no useful information on SunOS. */ |
| 621 | if (args[4]) { |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 622 | if (outptr < end_outstr - (10 + TIMEVAL_TEXT_BUFSIZE)) { |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 623 | outptr += sprintf(outptr, "%sleft ", sep); |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 624 | outptr = sprinttv(outptr, tcp, args[4], bitness, /*special:*/ 0); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 625 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 626 | } |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 627 | *outptr = '\0'; |
Denys Vlasenko | 1161725 | 2011-09-01 11:27:37 +0200 | [diff] [blame] | 628 | tcp->auxstr = outstr; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 629 | return RVAL_STR; |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 630 | #undef end_outstr |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 631 | } |
| 632 | return 0; |
| 633 | } |
| 634 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 635 | int |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 636 | sys_oldselect(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 637 | { |
| 638 | long args[5]; |
| 639 | |
| 640 | if (umoven(tcp, tcp->u_arg[0], sizeof args, (char *) args) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 641 | tprints("[...]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 642 | return 0; |
| 643 | } |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 644 | return decode_select(tcp, args, BITNESS_CURRENT); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 645 | } |
| 646 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 647 | #ifdef ALPHA |
Roland McGrath | e948faf | 2002-12-15 23:58:18 +0000 | [diff] [blame] | 648 | int |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 649 | sys_osf_select(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 650 | { |
| 651 | long *args = tcp->u_arg; |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 652 | return decode_select(tcp, args, BITNESS_32); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 653 | } |
| 654 | #endif |
| 655 | |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 656 | static const struct xlat epollctls[] = { |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 657 | #ifdef EPOLL_CTL_ADD |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 658 | { EPOLL_CTL_ADD, "EPOLL_CTL_ADD" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 659 | #endif |
| 660 | #ifdef EPOLL_CTL_MOD |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 661 | { EPOLL_CTL_MOD, "EPOLL_CTL_MOD" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 662 | #endif |
| 663 | #ifdef EPOLL_CTL_DEL |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 664 | { EPOLL_CTL_DEL, "EPOLL_CTL_DEL" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 665 | #endif |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 666 | { 0, NULL } |
| 667 | }; |
| 668 | |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 669 | static const struct xlat epollevents[] = { |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 670 | #ifdef EPOLLIN |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 671 | { EPOLLIN, "EPOLLIN" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 672 | #endif |
| 673 | #ifdef EPOLLPRI |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 674 | { EPOLLPRI, "EPOLLPRI" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 675 | #endif |
| 676 | #ifdef EPOLLOUT |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 677 | { EPOLLOUT, "EPOLLOUT" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 678 | #endif |
| 679 | #ifdef EPOLLRDNORM |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 680 | { EPOLLRDNORM, "EPOLLRDNORM" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 681 | #endif |
| 682 | #ifdef EPOLLRDBAND |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 683 | { EPOLLRDBAND, "EPOLLRDBAND" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 684 | #endif |
| 685 | #ifdef EPOLLWRNORM |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 686 | { EPOLLWRNORM, "EPOLLWRNORM" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 687 | #endif |
| 688 | #ifdef EPOLLWRBAND |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 689 | { EPOLLWRBAND, "EPOLLWRBAND" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 690 | #endif |
| 691 | #ifdef EPOLLMSG |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 692 | { EPOLLMSG, "EPOLLMSG" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 693 | #endif |
| 694 | #ifdef EPOLLERR |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 695 | { EPOLLERR, "EPOLLERR" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 696 | #endif |
| 697 | #ifdef EPOLLHUP |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 698 | { EPOLLHUP, "EPOLLHUP" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 699 | #endif |
Dmitry V. Levin | 5967c1a | 2011-10-11 15:55:40 +0000 | [diff] [blame] | 700 | #ifdef EPOLLRDHUP |
| 701 | { EPOLLRDHUP, "EPOLLRDHUP" }, |
| 702 | #endif |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 703 | #ifdef EPOLLONESHOT |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 704 | { EPOLLONESHOT, "EPOLLONESHOT" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 705 | #endif |
| 706 | #ifdef EPOLLET |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 707 | { EPOLLET, "EPOLLET" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 708 | #endif |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 709 | { 0, NULL } |
| 710 | }; |
| 711 | |
Denys Vlasenko | 72879c6 | 2012-02-27 14:18:02 +0100 | [diff] [blame] | 712 | /* Not aliased to printargs_ld: we want it to have a distinct address */ |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 713 | int |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 714 | sys_epoll_create(struct tcb *tcp) |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 715 | { |
Denys Vlasenko | 72879c6 | 2012-02-27 14:18:02 +0100 | [diff] [blame] | 716 | return printargs_ld(tcp); |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 717 | } |
| 718 | |
Mike Frysinger | aed334c | 2011-10-13 22:33:45 -0400 | [diff] [blame] | 719 | static const struct xlat epollflags[] = { |
| 720 | #ifdef EPOLL_CLOEXEC |
| 721 | { EPOLL_CLOEXEC, "EPOLL_CLOEXEC" }, |
| 722 | #endif |
| 723 | #ifdef EPOLL_NONBLOCK |
| 724 | { EPOLL_NONBLOCK, "EPOLL_NONBLOCK" }, |
| 725 | #endif |
| 726 | { 0, NULL } |
| 727 | }; |
| 728 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 729 | int |
| 730 | sys_epoll_create1(struct tcb *tcp) |
| 731 | { |
| 732 | if (entering(tcp)) |
Mike Frysinger | aed334c | 2011-10-13 22:33:45 -0400 | [diff] [blame] | 733 | printflags(epollflags, tcp->u_arg[0], "EPOLL_???"); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 734 | return 0; |
| 735 | } |
| 736 | |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 737 | #ifdef HAVE_SYS_EPOLL_H |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 738 | static void |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 739 | print_epoll_event(struct epoll_event *ev) |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 740 | { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 741 | tprints("{"); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 742 | printflags(epollevents, ev->events, "EPOLL???"); |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 743 | /* We cannot know what format the program uses, so print u32 and u64 |
| 744 | which will cover every value. */ |
| 745 | tprintf(", {u32=%" PRIu32 ", u64=%" PRIu64 "}}", |
| 746 | ev->data.u32, ev->data.u64); |
| 747 | } |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 748 | #endif |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 749 | |
| 750 | int |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 751 | sys_epoll_ctl(struct tcb *tcp) |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 752 | { |
| 753 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 754 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 755 | tprints(", "); |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 756 | printxval(epollctls, tcp->u_arg[1], "EPOLL_CTL_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 757 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 758 | printfd(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 759 | tprints(", "); |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 760 | if (tcp->u_arg[3] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 761 | tprints("NULL"); |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 762 | else { |
| 763 | #ifdef HAVE_SYS_EPOLL_H |
| 764 | struct epoll_event ev; |
Roland McGrath | 6e52d23 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 765 | if (umove(tcp, tcp->u_arg[3], &ev) == 0) |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 766 | print_epoll_event(&ev); |
| 767 | else |
| 768 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 769 | tprints("{...}"); |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 770 | } |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 771 | } |
| 772 | return 0; |
| 773 | } |
| 774 | |
Roland McGrath | f240005 | 2007-08-02 01:13:26 +0000 | [diff] [blame] | 775 | static void |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 776 | epoll_wait_common(struct tcb *tcp) |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 777 | { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 778 | if (entering(tcp)) { |
| 779 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 780 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 781 | } else { |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 782 | if (syserror(tcp)) |
| 783 | tprintf("%lx", tcp->u_arg[1]); |
| 784 | else if (tcp->u_rval == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 785 | tprints("{}"); |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 786 | else { |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 787 | #ifdef HAVE_SYS_EPOLL_H |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 788 | struct epoll_event ev, *start, *cur, *end; |
| 789 | int failed = 0; |
| 790 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 791 | tprints("{"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 792 | start = (struct epoll_event *) tcp->u_arg[1]; |
| 793 | end = start + tcp->u_rval; |
| 794 | for (cur = start; cur < end; ++cur) { |
| 795 | if (cur > start) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 796 | tprints(", "); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 797 | if (umove(tcp, (long) cur, &ev) == 0) |
| 798 | print_epoll_event(&ev); |
| 799 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 800 | tprints("?"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 801 | failed = 1; |
| 802 | break; |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 803 | } |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 804 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 805 | tprints("}"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 806 | if (failed) |
| 807 | tprintf(" %#lx", (long) start); |
| 808 | #else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 809 | tprints("{...}"); |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 810 | #endif |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 811 | } |
Dmitry V. Levin | c327d71 | 2011-10-11 16:05:57 +0000 | [diff] [blame] | 812 | tprintf(", %d, %d", (int) tcp->u_arg[2], (int) tcp->u_arg[3]); |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 813 | } |
Roland McGrath | f240005 | 2007-08-02 01:13:26 +0000 | [diff] [blame] | 814 | } |
| 815 | |
| 816 | int |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 817 | sys_epoll_wait(struct tcb *tcp) |
Roland McGrath | f240005 | 2007-08-02 01:13:26 +0000 | [diff] [blame] | 818 | { |
| 819 | epoll_wait_common(tcp); |
| 820 | return 0; |
| 821 | } |
| 822 | |
| 823 | int |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 824 | sys_epoll_pwait(struct tcb *tcp) |
Roland McGrath | f240005 | 2007-08-02 01:13:26 +0000 | [diff] [blame] | 825 | { |
| 826 | epoll_wait_common(tcp); |
Dmitry V. Levin | 9676499 | 2010-04-06 23:54:18 +0000 | [diff] [blame] | 827 | if (exiting(tcp)) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 828 | tprints(", "); |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 829 | /* NB: kernel requires arg[5] == NSIG / 8 */ |
| 830 | print_sigset_addr_len(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
| 831 | tprintf(", %lu", tcp->u_arg[5]); |
Dmitry V. Levin | 9676499 | 2010-04-06 23:54:18 +0000 | [diff] [blame] | 832 | } |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 833 | return 0; |
| 834 | } |
Roland McGrath | 37b9f84 | 2005-05-09 08:02:00 +0000 | [diff] [blame] | 835 | |
| 836 | int |
Denys Vlasenko | 30b5e5a | 2009-01-06 15:12:52 +0000 | [diff] [blame] | 837 | sys_select(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 838 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 839 | return decode_select(tcp, tcp->u_arg, BITNESS_CURRENT); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 840 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 841 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 842 | int |
| 843 | sys_pselect6(struct tcb *tcp) |
| 844 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 845 | int rc = decode_select(tcp, tcp->u_arg, BITNESS_CURRENT); |
Roland McGrath | fe10aa7 | 2007-11-01 21:52:20 +0000 | [diff] [blame] | 846 | if (entering(tcp)) { |
Denys Vlasenko | 8a1ebbb | 2013-07-18 18:10:13 +0200 | [diff] [blame] | 847 | long r; |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 848 | struct { |
Denys Vlasenko | 8a1ebbb | 2013-07-18 18:10:13 +0200 | [diff] [blame] | 849 | unsigned long ptr; |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 850 | unsigned long len; |
| 851 | } data; |
Denys Vlasenko | 8a1ebbb | 2013-07-18 18:10:13 +0200 | [diff] [blame] | 852 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
| 853 | if (current_wordsize == 4) { |
| 854 | struct { |
| 855 | uint32_t ptr; |
| 856 | uint32_t len; |
| 857 | } data32; |
| 858 | r = umove(tcp, tcp->u_arg[5], &data32); |
| 859 | data.ptr = data32.ptr; |
| 860 | data.len = data32.len; |
| 861 | } else |
| 862 | #endif |
| 863 | r = umove(tcp, tcp->u_arg[5], &data); |
| 864 | if (r < 0) |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 865 | tprintf(", %#lx", tcp->u_arg[5]); |
| 866 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 867 | tprints(", {"); |
Denys Vlasenko | 5e133aa | 2013-07-18 17:02:21 +0200 | [diff] [blame] | 868 | /* NB: kernel requires data.len == NSIG / 8 */ |
Denys Vlasenko | 8a1ebbb | 2013-07-18 18:10:13 +0200 | [diff] [blame] | 869 | print_sigset_addr_len(tcp, data.ptr, data.len); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 870 | tprintf(", %lu}", data.len); |
| 871 | } |
| 872 | } |
| 873 | return rc; |
| 874 | } |
Roland McGrath | e7c3967 | 2007-08-02 01:32:17 +0000 | [diff] [blame] | 875 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 876 | static int |
| 877 | do_eventfd(struct tcb *tcp, int flags_arg) |
Roland McGrath | e7c3967 | 2007-08-02 01:32:17 +0000 | [diff] [blame] | 878 | { |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 879 | if (entering(tcp)) { |
Roland McGrath | e7c3967 | 2007-08-02 01:32:17 +0000 | [diff] [blame] | 880 | tprintf("%lu", tcp->u_arg[0]); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 881 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 882 | tprints(", "); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 883 | printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); |
| 884 | } |
| 885 | } |
Roland McGrath | e7c3967 | 2007-08-02 01:32:17 +0000 | [diff] [blame] | 886 | return 0; |
| 887 | } |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 888 | |
| 889 | int |
| 890 | sys_eventfd(struct tcb *tcp) |
| 891 | { |
| 892 | return do_eventfd(tcp, -1); |
| 893 | } |
| 894 | |
| 895 | int |
| 896 | sys_eventfd2(struct tcb *tcp) |
| 897 | { |
| 898 | return do_eventfd(tcp, 1); |
| 899 | } |
Ben Noordhuis | 88eafd8 | 2013-02-04 00:04:57 +0100 | [diff] [blame] | 900 | |
| 901 | int |
| 902 | sys_perf_event_open(struct tcb *tcp) |
| 903 | { |
| 904 | if (entering(tcp)) { |
| 905 | tprintf("%#lx, %d, %d, %d, ", |
| 906 | tcp->u_arg[0], |
| 907 | (int) tcp->u_arg[1], |
| 908 | (int) tcp->u_arg[2], |
| 909 | (int) tcp->u_arg[3]); |
| 910 | printflags(perf_event_open_flags, tcp->u_arg[4], |
| 911 | "PERF_FLAG_???"); |
| 912 | } |
| 913 | return 0; |
| 914 | } |