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 | ab9008b | 2007-01-11 22:05:04 +0000 | [diff] [blame] | 245 | static const char * |
| 246 | sprintflags(const struct xlat *xlat, int flags) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 247 | { |
| 248 | static char outstr[1024]; |
Dmitry V. Levin | ab9008b | 2007-01-11 22:05:04 +0000 | [diff] [blame] | 249 | const char *sep; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 250 | |
| 251 | strcpy(outstr, "flags "); |
| 252 | sep = ""; |
| 253 | for (; xlat->str; xlat++) { |
| 254 | if ((flags & xlat->val) == xlat->val) { |
| 255 | sprintf(outstr + strlen(outstr), |
| 256 | "%s%s", sep, xlat->str); |
| 257 | sep = "|"; |
| 258 | flags &= ~xlat->val; |
| 259 | } |
| 260 | } |
| 261 | if (flags) |
| 262 | sprintf(outstr + strlen(outstr), |
| 263 | "%s%#x", sep, flags); |
| 264 | return outstr; |
| 265 | } |
| 266 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 267 | /* |
| 268 | * low bits of the open(2) flags define access mode, |
| 269 | * other bits are real flags. |
| 270 | */ |
| 271 | static const char * |
| 272 | sprint_open_modes(mode_t flags) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 273 | { |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 274 | extern const struct xlat open_access_modes[]; |
| 275 | extern const struct xlat open_mode_flags[]; |
| 276 | static char outstr[1024]; |
| 277 | const char *str = xlookup(open_access_modes, flags & 3); |
| 278 | const char *sep = ""; |
| 279 | const struct xlat *x; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 280 | |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 281 | strcpy(outstr, "flags "); |
| 282 | if (str) |
| 283 | { |
| 284 | strcat(outstr, str); |
| 285 | flags &= ~3; |
| 286 | if (!flags) |
| 287 | return outstr; |
| 288 | strcat(outstr, "|"); |
| 289 | } |
| 290 | |
| 291 | for (x = open_mode_flags; x->str; x++) |
| 292 | { |
| 293 | if ((flags & x->val) == x->val) |
| 294 | { |
| 295 | sprintf(outstr + strlen(outstr), |
| 296 | "%s%s", sep, x->str); |
| 297 | sep = "|"; |
| 298 | flags &= ~x->val; |
| 299 | } |
| 300 | } |
| 301 | if (flags) |
| 302 | sprintf(outstr + strlen(outstr), "%s%#x", sep, flags); |
| 303 | return outstr; |
| 304 | } |
| 305 | |
| 306 | int |
| 307 | sys_fcntl(struct tcb *tcp) |
| 308 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 309 | if (entering(tcp)) { |
| 310 | tprintf("%ld, ", tcp->u_arg[0]); |
| 311 | printxval(fcntlcmds, tcp->u_arg[1], "F_???"); |
| 312 | switch (tcp->u_arg[1]) { |
| 313 | case F_SETFD: |
| 314 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 315 | printflags(fdflags, tcp->u_arg[2], "FD_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 316 | break; |
| 317 | case F_SETOWN: case F_DUPFD: |
| 318 | tprintf(", %ld", tcp->u_arg[2]); |
| 319 | break; |
| 320 | case F_SETFL: |
| 321 | tprintf(", "); |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 322 | tprint_open_modes(tcp, tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 323 | break; |
| 324 | case F_SETLK: case F_SETLKW: |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 325 | #ifdef F_FREESP |
| 326 | case F_FREESP: |
| 327 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 328 | tprintf(", "); |
| 329 | printflock(tcp, tcp->u_arg[2], 0); |
| 330 | break; |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 331 | #if _LFS64_LARGEFILE |
| 332 | #ifdef F_FREESP64 |
| 333 | case F_FREESP64: |
| 334 | #endif |
Roland McGrath | e948faf | 2002-12-15 23:58:18 +0000 | [diff] [blame] | 335 | /* Linux glibc defines SETLK64 as SETLK, |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 336 | even though the kernel has different values - as does Solaris. */ |
| 337 | #if defined(F_SETLK64) && F_SETLK64+0!=F_SETLK |
| 338 | case F_SETLK64: |
| 339 | #endif |
| 340 | #if defined(F_SETLKW64) && F_SETLKW64+0!=F_SETLKW |
| 341 | case F_SETLKW64: |
| 342 | #endif |
| 343 | tprintf(", "); |
| 344 | printflock64(tcp, tcp->u_arg[2], 0); |
| 345 | break; |
| 346 | #endif |
| 347 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 348 | } |
| 349 | else { |
| 350 | switch (tcp->u_arg[1]) { |
| 351 | case F_DUPFD: |
| 352 | case F_SETFD: case F_SETFL: |
| 353 | case F_SETLK: case F_SETLKW: |
| 354 | case F_SETOWN: case F_GETOWN: |
| 355 | break; |
| 356 | case F_GETFD: |
| 357 | if (tcp->u_rval == 0) |
| 358 | return 0; |
| 359 | tcp->auxstr = sprintflags(fdflags, tcp->u_rval); |
| 360 | return RVAL_HEX|RVAL_STR; |
| 361 | case F_GETFL: |
Dmitry V. Levin | 9b5b67e | 2007-01-11 23:19:55 +0000 | [diff] [blame] | 362 | tcp->auxstr = sprint_open_modes(tcp->u_rval); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 363 | return RVAL_HEX|RVAL_STR; |
| 364 | case F_GETLK: |
| 365 | tprintf(", "); |
| 366 | printflock(tcp, tcp->u_arg[2], 1); |
| 367 | break; |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 368 | #if _LFS64_LARGEFILE |
| 369 | #if defined(F_GETLK64) && F_GETLK64+0!=F_GETLK |
| 370 | case F_GETLK64: |
| 371 | #endif |
| 372 | tprintf(", "); |
| 373 | printflock64(tcp, tcp->u_arg[2], 1); |
| 374 | break; |
| 375 | #endif |
| 376 | default: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 377 | tprintf(", %#lx", tcp->u_arg[2]); |
| 378 | break; |
| 379 | } |
| 380 | } |
| 381 | return 0; |
| 382 | } |
| 383 | |
| 384 | #ifdef LOCK_SH |
| 385 | |
| 386 | int |
| 387 | sys_flock(tcp) |
| 388 | struct tcb *tcp; |
| 389 | { |
| 390 | if (entering(tcp)) { |
| 391 | tprintf("%ld, ", tcp->u_arg[0]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 392 | printflags(flockcmds, tcp->u_arg[1], "LOCK_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 393 | } |
| 394 | return 0; |
| 395 | } |
| 396 | #endif /* LOCK_SH */ |
| 397 | |
| 398 | int |
| 399 | sys_close(tcp) |
| 400 | struct tcb *tcp; |
| 401 | { |
| 402 | if (entering(tcp)) { |
| 403 | tprintf("%ld", tcp->u_arg[0]); |
| 404 | } |
| 405 | return 0; |
| 406 | } |
| 407 | |
| 408 | int |
| 409 | sys_dup(tcp) |
| 410 | struct tcb *tcp; |
| 411 | { |
| 412 | if (entering(tcp)) { |
| 413 | tprintf("%ld", tcp->u_arg[0]); |
| 414 | } |
| 415 | return 0; |
| 416 | } |
| 417 | |
| 418 | int |
| 419 | sys_dup2(tcp) |
| 420 | struct tcb *tcp; |
| 421 | { |
| 422 | if (entering(tcp)) { |
| 423 | tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]); |
| 424 | } |
| 425 | return 0; |
| 426 | } |
| 427 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 428 | #if defined(ALPHA) || defined(FREEBSD) || defined(SUNOS4) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 429 | int |
| 430 | sys_getdtablesize(tcp) |
| 431 | struct tcb *tcp; |
| 432 | { |
| 433 | return 0; |
| 434 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 435 | #endif /* ALPHA || FREEBSD || SUNOS4 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 436 | |
| 437 | static int |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 438 | decode_select(struct tcb *tcp, long *args, enum bitness_t bitness) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 439 | { |
| 440 | int i, j, nfds; |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 441 | unsigned int fdsize = ((((args[0] + 7) / 8) + sizeof(long) - 1) |
| 442 | & -sizeof(long)); |
| 443 | fd_set *fds; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 444 | static char outstr[1024]; |
| 445 | char *sep; |
| 446 | long arg; |
| 447 | |
| 448 | if (entering(tcp)) { |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 449 | fds = (fd_set *) malloc(fdsize); |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 450 | if (fds == NULL) |
| 451 | fprintf(stderr, "out of memory\n"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 452 | nfds = args[0]; |
| 453 | tprintf("%d", nfds); |
| 454 | for (i = 0; i < 3; i++) { |
| 455 | arg = args[i+1]; |
| 456 | if (arg == 0) { |
| 457 | tprintf(", NULL"); |
| 458 | continue; |
| 459 | } |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 460 | if (fds == NULL || !verbose(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 461 | tprintf(", %#lx", arg); |
| 462 | continue; |
| 463 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 464 | if (umoven(tcp, arg, fdsize, (char *) fds) < 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 465 | tprintf(", [?]"); |
| 466 | continue; |
| 467 | } |
| 468 | tprintf(", ["); |
| 469 | for (j = 0, sep = ""; j < nfds; j++) { |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 470 | if (FD_ISSET(j, fds)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 471 | tprintf("%s%u", sep, j); |
| 472 | sep = " "; |
| 473 | } |
| 474 | } |
| 475 | tprintf("]"); |
| 476 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 477 | free(fds); |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 478 | tprintf(", "); |
| 479 | printtv_bitness(tcp, args[4], bitness); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 480 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 481 | else |
| 482 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 483 | unsigned int cumlen = 0; |
| 484 | char *sep = ""; |
| 485 | |
| 486 | if (syserror(tcp)) |
| 487 | return 0; |
| 488 | |
| 489 | if ((nfds = tcp->u_rval) == 0) { |
| 490 | tcp->auxstr = "Timeout"; |
| 491 | return RVAL_STR; |
| 492 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 493 | |
| 494 | fds = (fd_set *) malloc(fdsize); |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 495 | if (fds == NULL) |
| 496 | fprintf(stderr, "out of memory\n"); |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 497 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 498 | outstr[0] = '\0'; |
| 499 | for (i = 0; i < 3; i++) { |
| 500 | int first = 1; |
| 501 | char str[20]; |
| 502 | |
| 503 | tcp->auxstr = outstr; |
| 504 | arg = args[i+1]; |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 505 | if (fds == NULL || !arg || |
| 506 | umoven(tcp, arg, fdsize, (char *) fds) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 507 | continue; |
| 508 | for (j = 0; j < args[0]; j++) { |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 509 | if (FD_ISSET(j, fds)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 510 | if (first) { |
| 511 | sprintf(str, "%s%s [%u", sep, |
| 512 | i == 0 ? "in" : |
| 513 | i == 1 ? "out" : |
| 514 | "except", j); |
| 515 | first = 0; |
| 516 | sep = ", "; |
| 517 | } |
| 518 | else |
| 519 | sprintf(str, " %u", j); |
| 520 | cumlen += strlen(str); |
| 521 | if (cumlen < sizeof(outstr)) |
| 522 | strcat(outstr, str); |
| 523 | nfds--; |
| 524 | } |
| 525 | } |
| 526 | if (cumlen) |
| 527 | strcat(outstr, "]"); |
| 528 | if (nfds == 0) |
| 529 | break; |
| 530 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 531 | free(fds); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 532 | #ifdef LINUX |
| 533 | /* This contains no useful information on SunOS. */ |
| 534 | if (args[4]) { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 535 | char str[128]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 536 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 537 | sprintf(str, "%sleft ", sep); |
| 538 | sprinttv(tcp, args[4], bitness, str + strlen(str)); |
| 539 | if ((cumlen += strlen(str)) < sizeof(outstr)) |
| 540 | strcat(outstr, str); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 541 | } |
| 542 | #endif /* LINUX */ |
| 543 | return RVAL_STR; |
| 544 | } |
| 545 | return 0; |
| 546 | } |
| 547 | |
| 548 | #ifdef LINUX |
| 549 | |
| 550 | int |
| 551 | sys_oldselect(tcp) |
| 552 | struct tcb *tcp; |
| 553 | { |
| 554 | long args[5]; |
| 555 | |
| 556 | if (umoven(tcp, tcp->u_arg[0], sizeof args, (char *) args) < 0) { |
| 557 | tprintf("[...]"); |
| 558 | return 0; |
| 559 | } |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 560 | return decode_select(tcp, args, BITNESS_CURRENT); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 561 | } |
| 562 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 563 | #ifdef ALPHA |
Roland McGrath | e948faf | 2002-12-15 23:58:18 +0000 | [diff] [blame] | 564 | int |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 565 | sys_osf_select(tcp) |
| 566 | struct tcb *tcp; |
| 567 | { |
| 568 | long *args = tcp->u_arg; |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 569 | return decode_select(tcp, args, BITNESS_32); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 570 | } |
| 571 | #endif |
| 572 | |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 573 | static struct xlat epollctls[] = { |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 574 | #ifdef EPOLL_CTL_ADD |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 575 | { EPOLL_CTL_ADD, "EPOLL_CTL_ADD" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 576 | #endif |
| 577 | #ifdef EPOLL_CTL_MOD |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 578 | { EPOLL_CTL_MOD, "EPOLL_CTL_MOD" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 579 | #endif |
| 580 | #ifdef EPOLL_CTL_DEL |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 581 | { EPOLL_CTL_DEL, "EPOLL_CTL_DEL" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 582 | #endif |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 583 | { 0, NULL } |
| 584 | }; |
| 585 | |
| 586 | static struct xlat epollevents[] = { |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 587 | #ifdef EPOLLIN |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 588 | { EPOLLIN, "EPOLLIN" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 589 | #endif |
| 590 | #ifdef EPOLLPRI |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 591 | { EPOLLPRI, "EPOLLPRI" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 592 | #endif |
| 593 | #ifdef EPOLLOUT |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 594 | { EPOLLOUT, "EPOLLOUT" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 595 | #endif |
| 596 | #ifdef EPOLLRDNORM |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 597 | { EPOLLRDNORM, "EPOLLRDNORM" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 598 | #endif |
| 599 | #ifdef EPOLLRDBAND |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 600 | { EPOLLRDBAND, "EPOLLRDBAND" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 601 | #endif |
| 602 | #ifdef EPOLLWRNORM |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 603 | { EPOLLWRNORM, "EPOLLWRNORM" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 604 | #endif |
| 605 | #ifdef EPOLLWRBAND |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 606 | { EPOLLWRBAND, "EPOLLWRBAND" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 607 | #endif |
| 608 | #ifdef EPOLLMSG |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 609 | { EPOLLMSG, "EPOLLMSG" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 610 | #endif |
| 611 | #ifdef EPOLLERR |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 612 | { EPOLLERR, "EPOLLERR" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 613 | #endif |
| 614 | #ifdef EPOLLHUP |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 615 | { EPOLLHUP, "EPOLLHUP" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 616 | #endif |
| 617 | #ifdef EPOLLONESHOT |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 618 | { EPOLLONESHOT, "EPOLLONESHOT" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 619 | #endif |
| 620 | #ifdef EPOLLET |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 621 | { EPOLLET, "EPOLLET" }, |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 622 | #endif |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 623 | { 0, NULL } |
| 624 | }; |
| 625 | |
| 626 | int |
| 627 | sys_epoll_create(tcp) |
| 628 | struct tcb *tcp; |
| 629 | { |
| 630 | if (entering(tcp)) |
| 631 | tprintf("%ld", tcp->u_arg[0]); |
| 632 | return 0; |
| 633 | } |
| 634 | |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 635 | #ifdef HAVE_SYS_EPOLL_H |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 636 | static void |
| 637 | print_epoll_event(ev) |
| 638 | struct epoll_event *ev; |
| 639 | { |
| 640 | tprintf("{"); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 641 | printflags(epollevents, ev->events, "EPOLL???"); |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 642 | /* We cannot know what format the program uses, so print u32 and u64 |
| 643 | which will cover every value. */ |
| 644 | tprintf(", {u32=%" PRIu32 ", u64=%" PRIu64 "}}", |
| 645 | ev->data.u32, ev->data.u64); |
| 646 | } |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 647 | #endif |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 648 | |
| 649 | int |
| 650 | sys_epoll_ctl(tcp) |
| 651 | struct tcb *tcp; |
| 652 | { |
| 653 | if (entering(tcp)) { |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 654 | tprintf("%ld, ", tcp->u_arg[0]); |
| 655 | printxval(epollctls, tcp->u_arg[1], "EPOLL_CTL_???"); |
| 656 | tprintf(", %ld, ", tcp->u_arg[2]); |
| 657 | if (tcp->u_arg[3] == 0) |
| 658 | tprintf("NULL"); |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 659 | else { |
| 660 | #ifdef HAVE_SYS_EPOLL_H |
| 661 | struct epoll_event ev; |
Roland McGrath | 6e52d23 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 662 | if (umove(tcp, tcp->u_arg[3], &ev) == 0) |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 663 | print_epoll_event(&ev); |
| 664 | else |
| 665 | #endif |
| 666 | tprintf("{...}"); |
| 667 | } |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 668 | } |
| 669 | return 0; |
| 670 | } |
| 671 | |
| 672 | int |
| 673 | sys_epoll_wait(tcp) |
| 674 | struct tcb *tcp; |
| 675 | { |
| 676 | if (entering(tcp)) |
| 677 | tprintf("%ld, ", tcp->u_arg[0]); |
| 678 | else { |
| 679 | if (syserror(tcp)) |
| 680 | tprintf("%lx", tcp->u_arg[1]); |
| 681 | else if (tcp->u_rval == 0) |
| 682 | tprintf("{}"); |
| 683 | else { |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 684 | #ifdef HAVE_SYS_EPOLL_H |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 685 | struct epoll_event ev, *start, *cur, *end; |
| 686 | int failed = 0; |
| 687 | |
| 688 | tprintf("{"); |
| 689 | start = (struct epoll_event *) tcp->u_arg[1]; |
| 690 | end = start + tcp->u_rval; |
| 691 | for (cur = start; cur < end; ++cur) { |
| 692 | if (cur > start) |
| 693 | tprintf(", "); |
| 694 | if (umove(tcp, (long) cur, &ev) == 0) |
| 695 | print_epoll_event(&ev); |
| 696 | else { |
| 697 | tprintf("?"); |
| 698 | failed = 1; |
| 699 | break; |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 700 | } |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 701 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 702 | tprintf("}"); |
| 703 | if (failed) |
| 704 | tprintf(" %#lx", (long) start); |
| 705 | #else |
| 706 | tprintf("{...}"); |
Roland McGrath | 63d6e54 | 2004-10-20 02:17:41 +0000 | [diff] [blame] | 707 | #endif |
Roland McGrath | 93817bf | 2004-10-06 22:23:31 +0000 | [diff] [blame] | 708 | } |
| 709 | tprintf(", %ld, %ld", tcp->u_arg[2], tcp->u_arg[3]); |
| 710 | } |
| 711 | return 0; |
| 712 | } |
Roland McGrath | 37b9f84 | 2005-05-09 08:02:00 +0000 | [diff] [blame] | 713 | |
| 714 | int |
| 715 | sys_io_setup(tcp) |
| 716 | struct tcb *tcp; |
| 717 | { |
| 718 | if (entering(tcp)) |
| 719 | tprintf("%ld, ", tcp->u_arg[0]); |
| 720 | else { |
| 721 | if (syserror(tcp)) |
| 722 | tprintf("0x%0lx", tcp->u_arg[1]); |
| 723 | else { |
| 724 | unsigned long user_id; |
| 725 | if (umove(tcp, tcp->u_arg[1], &user_id) == 0) |
| 726 | tprintf("{%lu}", user_id); |
| 727 | else |
| 728 | tprintf("{...}"); |
| 729 | } |
| 730 | } |
| 731 | return 0; |
| 732 | } |
| 733 | |
| 734 | int |
| 735 | sys_io_destroy(tcp) |
| 736 | struct tcb *tcp; |
| 737 | { |
| 738 | if (entering(tcp)) |
| 739 | tprintf("%lu", tcp->u_arg[0]); |
| 740 | return 0; |
| 741 | } |
| 742 | |
| 743 | int |
| 744 | sys_io_submit(tcp) |
| 745 | struct tcb *tcp; |
| 746 | { |
| 747 | long nr; |
| 748 | if (entering(tcp)) { |
| 749 | tprintf("%lu, %ld, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 750 | nr = tcp->u_arg[1]; |
| 751 | /* and if nr is negative? */ |
| 752 | if (nr == 0) |
| 753 | tprintf("{}"); |
| 754 | else { |
| 755 | #ifdef HAVE_LIBAIO_H |
| 756 | long i; |
| 757 | struct iocb *iocbp, **iocbs = (void *)tcp->u_arg[2]; |
| 758 | |
| 759 | for (i = 0; i < nr; i++, iocbs++) { |
| 760 | struct iocb iocb; |
| 761 | if (i == 0) |
| 762 | tprintf("{"); |
| 763 | else |
| 764 | tprintf(", "); |
| 765 | |
| 766 | if (umove(tcp, (unsigned long)iocbs, &iocbp) || |
| 767 | umove(tcp, (unsigned long)iocbp, &iocb)) { |
| 768 | tprintf("{...}"); |
| 769 | continue; |
| 770 | } |
| 771 | tprintf("{%p, %u, %hu, %hu, %d}", |
| 772 | iocb.data, iocb.key, |
| 773 | iocb.aio_lio_opcode, |
| 774 | iocb.aio_reqprio, iocb.aio_fildes); |
| 775 | } |
| 776 | if (i) |
| 777 | tprintf("}"); |
| 778 | #else |
| 779 | tprintf("{...}"); |
| 780 | #endif |
| 781 | } |
| 782 | } |
| 783 | return 0; |
| 784 | } |
| 785 | |
| 786 | int |
| 787 | sys_io_cancel(tcp) |
| 788 | struct tcb *tcp; |
| 789 | { |
| 790 | if (entering(tcp)) { |
| 791 | #ifdef HAVE_LIBAIO_H |
| 792 | struct iocb iocb; |
| 793 | #endif |
| 794 | tprintf("%lu, ", tcp->u_arg[0]); |
| 795 | #ifdef HAVE_LIBAIO_H |
| 796 | if (umove(tcp, tcp->u_arg[1], &iocb) == 0) { |
| 797 | tprintf("{%p, %u, %hu, %hu, %d}, ", |
| 798 | iocb.data, iocb.key, |
| 799 | iocb.aio_lio_opcode, |
| 800 | iocb.aio_reqprio, iocb.aio_fildes); |
| 801 | } else |
| 802 | #endif |
| 803 | tprintf("{...}, "); |
| 804 | } else { |
| 805 | if (tcp->u_rval < 0) |
| 806 | tprintf("{...}"); |
| 807 | else { |
| 808 | #ifdef HAVE_LIBAIO_H |
| 809 | struct io_event event; |
| 810 | if (umove(tcp, tcp->u_arg[2], &event) == 0) |
| 811 | tprintf("{%p, %p, %ld, %ld}", |
| 812 | event.data, event.obj, |
| 813 | event.res, event.res2); |
| 814 | else |
| 815 | #endif |
| 816 | tprintf("{...}"); |
| 817 | } |
| 818 | } |
| 819 | return 0; |
| 820 | } |
| 821 | |
| 822 | int |
| 823 | sys_io_getevents(tcp) |
| 824 | struct tcb *tcp; |
| 825 | { |
| 826 | if (entering(tcp)) { |
| 827 | tprintf("%ld, %ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1], |
| 828 | tcp->u_arg[2]); |
| 829 | } else { |
| 830 | if (tcp->u_rval == 0) { |
| 831 | tprintf("{}"); |
| 832 | } else { |
| 833 | #ifdef HAVE_LIBAIO_H |
| 834 | struct io_event *events = (void *)tcp->u_arg[3]; |
| 835 | long i, nr = tcp->u_rval; |
| 836 | |
| 837 | for (i = 0; i < nr; i++, events++) { |
| 838 | struct io_event event; |
| 839 | |
| 840 | if (i == 0) |
| 841 | tprintf("{"); |
| 842 | else |
| 843 | tprintf(", "); |
| 844 | |
| 845 | if (umove(tcp, (unsigned long)events, &event) != 0) { |
| 846 | tprintf("{...}"); |
| 847 | continue; |
| 848 | } |
| 849 | tprintf("{%p, %p, %ld, %ld}", event.data, |
| 850 | event.obj, event.res, event.res2); |
| 851 | } |
| 852 | tprintf("}, "); |
| 853 | #else |
| 854 | tprintf("{...}"); |
| 855 | #endif |
| 856 | } |
| 857 | |
| 858 | if (tcp->u_arg[4] == 0) |
| 859 | tprintf("NULL"); |
| 860 | else { |
| 861 | struct timespec to; |
| 862 | if (umove(tcp, tcp->u_arg[4], &to) == 0) |
| 863 | tprintf("{%lu, %lu}", to.tv_sec, to.tv_nsec); |
| 864 | else |
| 865 | tprintf("{...}"); |
| 866 | } |
| 867 | } |
| 868 | return 0; |
| 869 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 870 | #endif /* LINUX */ |
| 871 | |
| 872 | int |
| 873 | sys_select(tcp) |
| 874 | struct tcb *tcp; |
| 875 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 876 | return decode_select(tcp, tcp->u_arg, BITNESS_CURRENT); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 877 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 878 | |
| 879 | #ifdef LINUX |
| 880 | int |
| 881 | sys_pselect6(struct tcb *tcp) |
| 882 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 883 | int rc = decode_select(tcp, tcp->u_arg, BITNESS_CURRENT); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 884 | if (exiting(tcp)) { |
| 885 | struct { |
| 886 | void *ss; |
| 887 | unsigned long len; |
| 888 | } data; |
| 889 | if (umove(tcp, tcp->u_arg[5], &data) < 0) |
| 890 | tprintf(", %#lx", tcp->u_arg[5]); |
| 891 | else { |
| 892 | tprintf(", {"); |
| 893 | if (data.len < sizeof(sigset_t)) |
| 894 | tprintf("%#lx", (long)data.ss); |
| 895 | else |
| 896 | print_sigset(tcp, (long)data.ss, 0); |
| 897 | tprintf(", %lu}", data.len); |
| 898 | } |
| 899 | } |
| 900 | return rc; |
| 901 | } |
| 902 | #endif |