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