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> |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in the |
| 14 | * documentation and/or other materials provided with the distribution. |
| 15 | * 3. The name of the author may not be used to endorse or promote products |
| 16 | * derived from this software without specific prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | * |
| 29 | * $Id$ |
| 30 | */ |
| 31 | |
| 32 | #include "defs.h" |
| 33 | |
| 34 | #include <dirent.h> |
| 35 | |
| 36 | #include <sys/stat.h> |
| 37 | #include <fcntl.h> |
| 38 | |
| 39 | #ifdef SVR4 |
| 40 | # include <sys/cred.h> |
| 41 | #endif /* SVR4 */ |
| 42 | |
| 43 | #include <sys/vfs.h> |
| 44 | |
| 45 | #ifdef MAJOR_IN_SYSMACROS |
| 46 | #include <sys/sysmacros.h> |
| 47 | #endif |
| 48 | |
| 49 | #ifdef MAJOR_IN_MKDEV |
| 50 | #include <sys/mkdev.h> |
| 51 | #endif |
| 52 | |
| 53 | #ifdef HAVE_SYS_ASYNCH_H |
| 54 | #include <sys/asynch.h> |
| 55 | #endif |
| 56 | |
| 57 | #ifdef SUNOS4 |
| 58 | #include <ustat.h> |
| 59 | #endif |
| 60 | |
| 61 | /* |
| 62 | * This is a really dirty trick but it should always work. Traditional |
| 63 | * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by |
| 64 | * adding 1. Just remember to add 1 to any arg decoded with openmodes. |
| 65 | */ |
| 66 | struct xlat openmodes[] = { |
| 67 | { O_RDWR+1, "O_RDWR" }, |
| 68 | { O_RDONLY+1, "O_RDONLY" }, |
| 69 | { O_WRONLY+1, "O_WRONLY" }, |
| 70 | { O_NONBLOCK, "O_NONBLOCK" }, |
| 71 | { O_APPEND, "O_APPEND" }, |
| 72 | { O_CREAT, "O_CREAT" }, |
| 73 | { O_TRUNC, "O_TRUNC" }, |
| 74 | { O_EXCL, "O_EXCL" }, |
| 75 | { O_NOCTTY, "O_NOCTTY" }, |
| 76 | #ifdef O_SYNC |
| 77 | { O_SYNC, "O_SYNC" }, |
| 78 | #endif |
| 79 | #ifdef O_ASYNC |
| 80 | { O_ASYNC, "O_ASYNC" }, |
| 81 | #endif |
| 82 | #ifdef O_DSYNC |
| 83 | { O_DSYNC, "O_DSYNC" }, |
| 84 | #endif |
| 85 | #ifdef O_RSYNC |
| 86 | { O_RSYNC, "O_RSYNC" }, |
| 87 | #endif |
| 88 | #ifdef O_NDELAY |
| 89 | { O_NDELAY, "O_NDELAY" }, |
| 90 | #endif |
| 91 | #ifdef O_PRIV |
| 92 | { O_PRIV, "O_PRIV" }, |
| 93 | #endif |
| 94 | #ifdef O_DIRECT |
| 95 | { O_DIRECT, "O_DIRECT" }, |
| 96 | #endif |
| 97 | #ifdef O_LARGEFILE |
| 98 | { O_LARGEFILE, "O_LARGEFILE" }, |
| 99 | #endif |
| 100 | #ifdef O_DIRECTORY |
| 101 | { O_DIRECTORY, "O_DIRECTORY" }, |
| 102 | #endif |
| 103 | |
| 104 | #ifdef FNDELAY |
| 105 | { FNDELAY, "FNDELAY" }, |
| 106 | #endif |
| 107 | #ifdef FAPPEND |
| 108 | { FAPPEND, "FAPPEND" }, |
| 109 | #endif |
| 110 | #ifdef FMARK |
| 111 | { FMARK, "FMARK" }, |
| 112 | #endif |
| 113 | #ifdef FDEFER |
| 114 | { FDEFER, "FDEFER" }, |
| 115 | #endif |
| 116 | #ifdef FASYNC |
| 117 | { FASYNC, "FASYNC" }, |
| 118 | #endif |
| 119 | #ifdef FSHLOCK |
| 120 | { FSHLOCK, "FSHLOCK" }, |
| 121 | #endif |
| 122 | #ifdef FEXLOCK |
| 123 | { FEXLOCK, "FEXLOCK" }, |
| 124 | #endif |
| 125 | #ifdef FCREAT |
| 126 | { FCREAT, "FCREAT" }, |
| 127 | #endif |
| 128 | #ifdef FTRUNC |
| 129 | { FTRUNC, "FTRUNC" }, |
| 130 | #endif |
| 131 | #ifdef FEXCL |
| 132 | { FEXCL, "FEXCL" }, |
| 133 | #endif |
| 134 | #ifdef FNBIO |
| 135 | { FNBIO, "FNBIO" }, |
| 136 | #endif |
| 137 | #ifdef FSYNC |
| 138 | { FSYNC, "FSYNC" }, |
| 139 | #endif |
| 140 | #ifdef FNOCTTY |
| 141 | { FNOCTTY, "FNOCTTY" }, |
| 142 | #endif |
| 143 | { 0, NULL }, |
| 144 | }; |
| 145 | |
| 146 | int |
| 147 | sys_open(tcp) |
| 148 | struct tcb *tcp; |
| 149 | { |
| 150 | if (entering(tcp)) { |
| 151 | printpath(tcp, tcp->u_arg[0]); |
| 152 | tprintf(", "); |
| 153 | /* flags */ |
| 154 | printflags(openmodes, tcp->u_arg[1] + 1); |
| 155 | if (tcp->u_arg[1] & O_CREAT) { |
| 156 | /* mode */ |
| 157 | tprintf(", %#lo", tcp->u_arg[2]); |
| 158 | } |
| 159 | } |
| 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | #ifdef LINUXSPARC |
| 164 | struct xlat openmodessol[] = { |
| 165 | { 0, "O_RDWR" }, |
| 166 | { 1, "O_RDONLY" }, |
| 167 | { 2, "O_WRONLY" }, |
| 168 | { 0x80, "O_NONBLOCK" }, |
| 169 | { 8, "O_APPEND" }, |
| 170 | { 0x100, "O_CREAT" }, |
| 171 | { 0x200, "O_TRUNC" }, |
| 172 | { 0x400, "O_EXCL" }, |
| 173 | { 0x800, "O_NOCTTY" }, |
| 174 | { 0x10, "O_SYNC" }, |
| 175 | { 0x40, "O_DSYNC" }, |
| 176 | { 0x8000, "O_RSYNC" }, |
| 177 | { 4, "O_NDELAY" }, |
| 178 | { 0x1000, "O_PRIV" }, |
| 179 | { 0, NULL }, |
| 180 | }; |
| 181 | |
| 182 | int |
| 183 | solaris_open(tcp) |
| 184 | struct tcb *tcp; |
| 185 | { |
| 186 | if (entering(tcp)) { |
| 187 | printpath(tcp, tcp->u_arg[0]); |
| 188 | tprintf(", "); |
| 189 | /* flags */ |
| 190 | printflags(openmodessol, tcp->u_arg[1] + 1); |
| 191 | if (tcp->u_arg[1] & 0x100) { |
| 192 | /* mode */ |
| 193 | tprintf(", %#lo", tcp->u_arg[2]); |
| 194 | } |
| 195 | } |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | #endif |
| 200 | |
| 201 | int |
| 202 | sys_creat(tcp) |
| 203 | struct tcb *tcp; |
| 204 | { |
| 205 | if (entering(tcp)) { |
| 206 | printpath(tcp, tcp->u_arg[0]); |
| 207 | tprintf(", %#lo", tcp->u_arg[1]); |
| 208 | } |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | static struct xlat access_flags[] = { |
| 213 | { F_OK, "F_OK", }, |
| 214 | { R_OK, "R_OK" }, |
| 215 | { W_OK, "W_OK" }, |
| 216 | { X_OK, "X_OK" }, |
| 217 | #ifdef EFF_ONLY_OK |
| 218 | { EFF_ONLY_OK, "EFF_ONLY_OK" }, |
| 219 | #endif |
| 220 | #ifdef EX_OK |
| 221 | { EX_OK, "EX_OK" }, |
| 222 | #endif |
| 223 | { 0, NULL }, |
| 224 | }; |
| 225 | |
| 226 | int |
| 227 | sys_access(tcp) |
| 228 | struct tcb *tcp; |
| 229 | { |
| 230 | if (entering(tcp)) { |
| 231 | printpath(tcp, tcp->u_arg[0]); |
| 232 | tprintf(", "); |
| 233 | printflags(access_flags, tcp->u_arg[1]); |
| 234 | } |
| 235 | return 0; |
| 236 | } |
| 237 | |
| 238 | int |
| 239 | sys_umask(tcp) |
| 240 | struct tcb *tcp; |
| 241 | { |
| 242 | if (entering(tcp)) { |
| 243 | tprintf("%#lo", tcp->u_arg[0]); |
| 244 | } |
| 245 | return RVAL_OCTAL; |
| 246 | } |
| 247 | |
| 248 | static struct xlat whence[] = { |
| 249 | { SEEK_SET, "SEEK_SET" }, |
| 250 | { SEEK_CUR, "SEEK_CUR" }, |
| 251 | { SEEK_END, "SEEK_END" }, |
| 252 | { 0, NULL }, |
| 253 | }; |
| 254 | |
| 255 | int |
| 256 | sys_lseek(tcp) |
| 257 | struct tcb *tcp; |
| 258 | { |
| 259 | if (entering(tcp)) { |
| 260 | tprintf("%ld, ", tcp->u_arg[0]); |
| 261 | if (tcp->u_arg[2] == SEEK_SET) |
| 262 | tprintf("%lu, ", tcp->u_arg[1]); |
| 263 | else |
| 264 | tprintf("%ld, ", tcp->u_arg[1]); |
| 265 | printxval(whence, tcp->u_arg[2], "SEEK_???"); |
| 266 | } |
| 267 | return RVAL_UDECIMAL; |
| 268 | } |
| 269 | |
| 270 | #ifdef LINUX |
| 271 | int |
| 272 | sys_llseek (tcp) |
| 273 | struct tcb *tcp; |
| 274 | { |
| 275 | if (entering(tcp)) { |
| 276 | if (tcp->u_arg[4] == SEEK_SET) |
| 277 | tprintf("%ld, %llu, ", tcp->u_arg[0], |
| 278 | (((unsigned long long int) tcp->u_arg[1]) << 32 |
| 279 | | (unsigned long) tcp->u_arg[2])); |
| 280 | else |
| 281 | tprintf("%ld, %lld, ", tcp->u_arg[0], |
| 282 | (((long long int) tcp->u_arg[1]) << 32 |
| 283 | | (unsigned long) tcp->u_arg[2])); |
| 284 | } |
| 285 | else { |
| 286 | if (syserror(tcp)) |
| 287 | tprintf("%#lx, ", tcp->u_arg[3]); |
| 288 | else { |
| 289 | long long int off; |
| 290 | umove(tcp, tcp->u_arg[3], &off); |
| 291 | tprintf("{%lld}, ", off); |
| 292 | } |
| 293 | printxval(whence, tcp->u_arg[4], "SEEK_???"); |
| 294 | } |
| 295 | return 0; |
| 296 | } |
| 297 | #endif |
| 298 | |
| 299 | int |
| 300 | sys_truncate(tcp) |
| 301 | struct tcb *tcp; |
| 302 | { |
| 303 | if (entering(tcp)) { |
| 304 | printpath(tcp, tcp->u_arg[0]); |
| 305 | tprintf(", %lu", tcp->u_arg[1]); |
| 306 | } |
| 307 | return 0; |
| 308 | } |
| 309 | |
| 310 | int |
| 311 | sys_ftruncate(tcp) |
| 312 | struct tcb *tcp; |
| 313 | { |
| 314 | if (entering(tcp)) { |
| 315 | tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
| 316 | } |
| 317 | return 0; |
| 318 | } |
| 319 | |
| 320 | /* several stats */ |
| 321 | |
| 322 | static struct xlat modetypes[] = { |
| 323 | { S_IFREG, "S_IFREG" }, |
| 324 | { S_IFSOCK, "S_IFSOCK" }, |
| 325 | { S_IFIFO, "S_IFIFO" }, |
| 326 | { S_IFLNK, "S_IFLNK" }, |
| 327 | { S_IFDIR, "S_IFDIR" }, |
| 328 | { S_IFBLK, "S_IFBLK" }, |
| 329 | { S_IFCHR, "S_IFCHR" }, |
| 330 | { 0, NULL }, |
| 331 | }; |
| 332 | |
| 333 | static char * |
| 334 | sprintmode(mode) |
| 335 | int mode; |
| 336 | { |
| 337 | static char buf[64]; |
| 338 | char *s; |
| 339 | |
| 340 | if ((mode & S_IFMT) == 0) |
| 341 | s = ""; |
| 342 | else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) { |
| 343 | sprintf(buf, "%#o", mode); |
| 344 | return buf; |
| 345 | } |
| 346 | sprintf(buf, "%s%s%s%s", s, |
| 347 | (mode & S_ISUID) ? "|S_ISUID" : "", |
| 348 | (mode & S_ISGID) ? "|S_ISGID" : "", |
| 349 | (mode & S_ISVTX) ? "|S_ISVTX" : ""); |
| 350 | mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX); |
| 351 | if (mode) |
| 352 | sprintf(buf + strlen(buf), "|%#o", mode); |
| 353 | s = (*buf == '|') ? buf + 1 : buf; |
| 354 | return *s ? s : "0"; |
| 355 | } |
| 356 | |
| 357 | static char * |
| 358 | sprinttime(t) |
| 359 | time_t t; |
| 360 | { |
| 361 | struct tm *tmp; |
| 362 | static char buf[32]; |
| 363 | |
| 364 | if (t == 0) { |
| 365 | sprintf(buf, "0"); |
| 366 | return buf; |
| 367 | } |
| 368 | tmp = localtime(&t); |
| 369 | sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d", |
| 370 | tmp->tm_year, tmp->tm_mon + 1, tmp->tm_mday, |
| 371 | tmp->tm_hour, tmp->tm_min, tmp->tm_sec); |
| 372 | return buf; |
| 373 | } |
| 374 | |
| 375 | #ifdef LINUXSPARC |
| 376 | typedef struct { |
| 377 | int tv_sec; |
| 378 | int tv_nsec; |
| 379 | } timestruct_t; |
| 380 | |
| 381 | struct solstat { |
| 382 | unsigned st_dev; |
| 383 | int st_pad1[3]; /* network id */ |
| 384 | unsigned st_ino; |
| 385 | unsigned st_mode; |
| 386 | unsigned st_nlink; |
| 387 | unsigned st_uid; |
| 388 | unsigned st_gid; |
| 389 | unsigned st_rdev; |
| 390 | int st_pad2[2]; |
| 391 | int st_size; |
| 392 | int st_pad3; /* st_size, off_t expansion */ |
| 393 | timestruct_t st_atime; |
| 394 | timestruct_t st_mtime; |
| 395 | timestruct_t st_ctime; |
| 396 | int st_blksize; |
| 397 | int st_blocks; |
| 398 | char st_fstype[16]; |
| 399 | int st_pad4[8]; /* expansion area */ |
| 400 | }; |
| 401 | |
| 402 | static void |
| 403 | printstatsol(tcp, addr) |
| 404 | struct tcb *tcp; |
| 405 | int addr; |
| 406 | { |
| 407 | struct solstat statbuf; |
| 408 | |
| 409 | if (!addr) { |
| 410 | tprintf("NULL"); |
| 411 | return; |
| 412 | } |
| 413 | if (syserror(tcp) || !verbose(tcp)) { |
| 414 | tprintf("%#x", addr); |
| 415 | return; |
| 416 | } |
| 417 | if (umove(tcp, addr, &statbuf) < 0) { |
| 418 | tprintf("{...}"); |
| 419 | return; |
| 420 | } |
| 421 | if (!abbrev(tcp)) { |
| 422 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 423 | (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff), |
| 424 | (unsigned long) (statbuf.st_dev & 0x3ffff), |
| 425 | (unsigned long) statbuf.st_ino, |
| 426 | sprintmode(statbuf.st_mode)); |
| 427 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 428 | (unsigned long) statbuf.st_nlink, |
| 429 | (unsigned long) statbuf.st_uid, |
| 430 | (unsigned long) statbuf.st_gid); |
| 431 | tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize); |
| 432 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
| 433 | } |
| 434 | else |
| 435 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 436 | switch (statbuf.st_mode & S_IFMT) { |
| 437 | case S_IFCHR: case S_IFBLK: |
| 438 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 439 | (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff), |
| 440 | (unsigned long) (statbuf.st_rdev & 0x3ffff)); |
| 441 | break; |
| 442 | default: |
| 443 | tprintf("st_size=%u, ", statbuf.st_size); |
| 444 | break; |
| 445 | } |
| 446 | if (!abbrev(tcp)) { |
| 447 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 448 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
| 449 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); |
| 450 | } |
| 451 | else |
| 452 | tprintf("...}"); |
| 453 | } |
| 454 | #endif |
| 455 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 456 | static void |
| 457 | printstat(tcp, addr) |
| 458 | struct tcb *tcp; |
| 459 | int addr; |
| 460 | { |
| 461 | struct stat statbuf; |
| 462 | |
| 463 | #ifdef LINUXSPARC |
| 464 | if (current_personality == 1) { |
| 465 | printstatsol(tcp, addr); |
| 466 | return; |
| 467 | } |
| 468 | #endif /* LINUXSPARC */ |
| 469 | |
| 470 | if (!addr) { |
| 471 | tprintf("NULL"); |
| 472 | return; |
| 473 | } |
| 474 | if (syserror(tcp) || !verbose(tcp)) { |
| 475 | tprintf("%#x", addr); |
| 476 | return; |
| 477 | } |
| 478 | if (umove(tcp, addr, &statbuf) < 0) { |
| 479 | tprintf("{...}"); |
| 480 | return; |
| 481 | } |
| 482 | if (!abbrev(tcp)) { |
| 483 | tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", |
| 484 | (unsigned long) major(statbuf.st_dev), |
| 485 | (unsigned long) minor(statbuf.st_dev), |
| 486 | (unsigned long) statbuf.st_ino, |
| 487 | sprintmode(statbuf.st_mode)); |
| 488 | tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", |
| 489 | (unsigned long) statbuf.st_nlink, |
| 490 | (unsigned long) statbuf.st_uid, |
| 491 | (unsigned long) statbuf.st_gid); |
| 492 | #ifdef HAVE_ST_BLKSIZE |
| 493 | tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize); |
| 494 | #endif /* HAVE_ST_BLKSIZE */ |
| 495 | #ifdef HAVE_ST_BLOCKS |
| 496 | tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); |
| 497 | #endif /* HAVE_ST_BLOCKS */ |
| 498 | } |
| 499 | else |
| 500 | tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); |
| 501 | switch (statbuf.st_mode & S_IFMT) { |
| 502 | case S_IFCHR: case S_IFBLK: |
| 503 | #ifdef HAVE_ST_RDEV |
| 504 | tprintf("st_rdev=makedev(%lu, %lu), ", |
| 505 | (unsigned long) major(statbuf.st_rdev), |
| 506 | (unsigned long) minor(statbuf.st_rdev)); |
| 507 | #else /* !HAVE_ST_RDEV */ |
| 508 | tprintf("st_size=makedev(%lu, %lu), ", |
| 509 | (unsigned long) major(statbuf.st_size), |
| 510 | (unsigned long) minor(statbuf.st_size)); |
| 511 | #endif /* !HAVE_ST_RDEV */ |
| 512 | break; |
| 513 | default: |
| 514 | tprintf("st_size=%lu, ", statbuf.st_size); |
| 515 | break; |
| 516 | } |
| 517 | if (!abbrev(tcp)) { |
| 518 | tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); |
| 519 | tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); |
| 520 | tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); |
| 521 | } |
| 522 | else |
| 523 | tprintf("...}"); |
| 524 | } |
| 525 | |
| 526 | int |
| 527 | sys_stat(tcp) |
| 528 | struct tcb *tcp; |
| 529 | { |
| 530 | if (entering(tcp)) { |
| 531 | printpath(tcp, tcp->u_arg[0]); |
| 532 | tprintf(", "); |
| 533 | } else { |
| 534 | printstat(tcp, tcp->u_arg[1]); |
| 535 | } |
| 536 | return 0; |
| 537 | } |
| 538 | |
| 539 | int |
| 540 | sys_fstat(tcp) |
| 541 | struct tcb *tcp; |
| 542 | { |
| 543 | if (entering(tcp)) |
| 544 | tprintf("%ld, ", tcp->u_arg[0]); |
| 545 | else { |
| 546 | printstat(tcp, tcp->u_arg[1]); |
| 547 | } |
| 548 | return 0; |
| 549 | } |
| 550 | |
| 551 | int |
| 552 | sys_lstat(tcp) |
| 553 | struct tcb *tcp; |
| 554 | { |
| 555 | if (entering(tcp)) { |
| 556 | printpath(tcp, tcp->u_arg[0]); |
| 557 | tprintf(", "); |
| 558 | } else { |
| 559 | printstat(tcp, tcp->u_arg[1]); |
| 560 | } |
| 561 | return 0; |
| 562 | } |
| 563 | |
| 564 | #if defined(SVR4) || defined(LINUXSPARC) |
| 565 | |
| 566 | int |
| 567 | sys_xstat(tcp) |
| 568 | struct tcb *tcp; |
| 569 | { |
| 570 | if (entering(tcp)) { |
| 571 | tprintf("%ld, ", tcp->u_arg[0]); |
| 572 | printpath(tcp, tcp->u_arg[1]); |
| 573 | tprintf(", "); |
| 574 | } else { |
| 575 | printstat(tcp, tcp->u_arg[2]); |
| 576 | } |
| 577 | return 0; |
| 578 | } |
| 579 | |
| 580 | int |
| 581 | sys_fxstat(tcp) |
| 582 | struct tcb *tcp; |
| 583 | { |
| 584 | if (entering(tcp)) |
| 585 | tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 586 | else { |
| 587 | printstat(tcp, tcp->u_arg[2]); |
| 588 | } |
| 589 | return 0; |
| 590 | } |
| 591 | |
| 592 | int |
| 593 | sys_lxstat(tcp) |
| 594 | struct tcb *tcp; |
| 595 | { |
| 596 | if (entering(tcp)) { |
| 597 | tprintf("%ld, ", tcp->u_arg[0]); |
| 598 | printpath(tcp, tcp->u_arg[1]); |
| 599 | tprintf(", "); |
| 600 | } else { |
| 601 | printstat(tcp, tcp->u_arg[2]); |
| 602 | } |
| 603 | return 0; |
| 604 | } |
| 605 | |
| 606 | int |
| 607 | sys_xmknod(tcp) |
| 608 | struct tcb *tcp; |
| 609 | { |
| 610 | int mode = tcp->u_arg[2]; |
| 611 | |
| 612 | if (entering(tcp)) { |
| 613 | tprintf("%ld, ", tcp->u_arg[0]); |
| 614 | printpath(tcp, tcp->u_arg[1]); |
| 615 | tprintf(", %s", sprintmode(mode)); |
| 616 | switch (mode & S_IFMT) { |
| 617 | case S_IFCHR: case S_IFBLK: |
| 618 | #ifdef LINUXSPARC |
| 619 | tprintf(", makedev(%lu, %lu)", |
| 620 | (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff), |
| 621 | (unsigned long) (tcp->u_arg[3] & 0x3ffff)); |
| 622 | #else |
| 623 | tprintf(", makedev(%lu, %lu)", |
| 624 | (unsigned long) major(tcp->u_arg[3]), |
| 625 | (unsigned long) minor(tcp->u_arg[3])); |
| 626 | #endif |
| 627 | break; |
| 628 | default: |
| 629 | break; |
| 630 | } |
| 631 | } |
| 632 | return 0; |
| 633 | } |
| 634 | |
| 635 | #endif /* SVR4 || LINUXSPARC */ |
| 636 | |
| 637 | #ifdef LINUX |
| 638 | |
| 639 | static struct xlat fsmagic[] = { |
| 640 | { 0xef51, "EXT2_OLD_SUPER_MAGIC" }, |
| 641 | { 0xef53, "EXT2_SUPER_MAGIC" }, |
| 642 | { 0x137d, "EXT_SUPER_MAGIC" }, |
| 643 | { 0x9660, "ISOFS_SUPER_MAGIC" }, |
| 644 | { 0x137f, "MINIX_SUPER_MAGIC" }, |
| 645 | { 0x138f, "MINIX_SUPER_MAGIC2" }, |
| 646 | { 0x2468, "NEW_MINIX_SUPER_MAGIC" }, |
| 647 | { 0x4d44, "MSDOS_SUPER_MAGIC" }, |
| 648 | { 0x6969, "NFS_SUPER_MAGIC" }, |
| 649 | { 0x9fa0, "PROC_SUPER_MAGIC" }, |
| 650 | { 0x012fd16d, "XIAFS_SUPER_MAGIC" }, |
| 651 | { 0, NULL }, |
| 652 | }; |
| 653 | |
| 654 | #endif /* LINUX */ |
| 655 | |
| 656 | #ifndef SVR4 |
| 657 | |
| 658 | static char * |
| 659 | sprintfstype(magic) |
| 660 | int magic; |
| 661 | { |
| 662 | static char buf[32]; |
| 663 | #ifdef LINUX |
| 664 | char *s; |
| 665 | |
| 666 | s = xlookup(fsmagic, magic); |
| 667 | if (s) { |
| 668 | sprintf(buf, "\"%s\"", s); |
| 669 | return buf; |
| 670 | } |
| 671 | #endif /* LINUX */ |
| 672 | sprintf(buf, "%#x", magic); |
| 673 | return buf; |
| 674 | } |
| 675 | |
| 676 | static void |
| 677 | printstatfs(tcp, addr) |
| 678 | struct tcb *tcp; |
| 679 | long addr; |
| 680 | { |
| 681 | struct statfs statbuf; |
| 682 | |
| 683 | if (syserror(tcp) || !verbose(tcp)) { |
| 684 | tprintf("%#lx", addr); |
| 685 | return; |
| 686 | } |
| 687 | if (umove(tcp, addr, &statbuf) < 0) { |
| 688 | tprintf("{...}"); |
| 689 | return; |
| 690 | } |
| 691 | #ifdef ALPHA |
| 692 | |
| 693 | tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ", |
| 694 | sprintfstype(statbuf.f_type), |
| 695 | statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree); |
| 696 | tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u}", |
| 697 | statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen); |
| 698 | #else /* !ALPHA */ |
| 699 | tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ", |
| 700 | sprintfstype(statbuf.f_type), |
| 701 | statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree); |
| 702 | tprintf("f_files=%lu, f_ffree=%lu", |
| 703 | statbuf.f_files, statbuf.f_ffree); |
| 704 | #ifdef LINUX |
| 705 | tprintf(", f_namelen=%lu}", statbuf.f_namelen); |
| 706 | #endif /* LINUX */ |
| 707 | #endif /* !ALPHA */ |
| 708 | tprintf("}"); |
| 709 | } |
| 710 | |
| 711 | int |
| 712 | sys_statfs(tcp) |
| 713 | struct tcb *tcp; |
| 714 | { |
| 715 | if (entering(tcp)) { |
| 716 | printpath(tcp, tcp->u_arg[0]); |
| 717 | tprintf(", "); |
| 718 | } else { |
| 719 | printstatfs(tcp, tcp->u_arg[1]); |
| 720 | } |
| 721 | return 0; |
| 722 | } |
| 723 | |
| 724 | int |
| 725 | sys_fstatfs(tcp) |
| 726 | struct tcb *tcp; |
| 727 | { |
| 728 | if (entering(tcp)) { |
| 729 | tprintf("%lu, ", tcp->u_arg[0]); |
| 730 | } else { |
| 731 | printstatfs(tcp, tcp->u_arg[1]); |
| 732 | } |
| 733 | return 0; |
| 734 | } |
| 735 | |
| 736 | #ifdef LINUX |
| 737 | #ifdef ALPHA |
| 738 | |
| 739 | int |
| 740 | osf_statfs(tcp) |
| 741 | struct tcb *tcp; |
| 742 | { |
| 743 | if (entering(tcp)) { |
| 744 | printpath(tcp, tcp->u_arg[0]); |
| 745 | tprintf(", "); |
| 746 | } else { |
| 747 | printstatfs(tcp, tcp->u_arg[1]); |
| 748 | tprintf(", %lu", tcp->u_arg[2]); |
| 749 | } |
| 750 | return 0; |
| 751 | } |
| 752 | |
| 753 | int |
| 754 | osf_fstatfs(tcp) |
| 755 | struct tcb *tcp; |
| 756 | { |
| 757 | if (entering(tcp)) { |
| 758 | tprintf("%lu, ", tcp->u_arg[0]); |
| 759 | } else { |
| 760 | printstatfs(tcp, tcp->u_arg[1]); |
| 761 | tprintf(", %lu", tcp->u_arg[2]); |
| 762 | } |
| 763 | return 0; |
| 764 | } |
| 765 | #endif /* ALPHA */ |
| 766 | #endif /* LINUX */ |
| 767 | |
| 768 | #endif /* !SVR4 */ |
| 769 | |
| 770 | #ifdef SUNOS4 |
| 771 | |
| 772 | int |
| 773 | sys_ustat(tcp) |
| 774 | struct tcb *tcp; |
| 775 | { |
| 776 | struct ustat statbuf; |
| 777 | |
| 778 | if (entering(tcp)) { |
| 779 | tprintf("makedev(%lu, %lu), ", |
| 780 | (long) major(tcp->u_arg[0]), |
| 781 | (long) minor(tcp->u_arg[0])); |
| 782 | } |
| 783 | else { |
| 784 | if (syserror(tcp) || !verbose(tcp)) |
| 785 | tprintf("%#lx", tcp->u_arg[1]); |
| 786 | else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0) |
| 787 | tprintf("{...}"); |
| 788 | else { |
| 789 | tprintf("{f_tfree=%lu, f_tinode=%lu, ", |
| 790 | statbuf.f_tfree, statbuf.f_tinode); |
| 791 | tprintf("f_fname=\"%.*s\", ", |
| 792 | (int) sizeof(statbuf.f_fname), |
| 793 | statbuf.f_fname); |
| 794 | tprintf("f_fpack=\"%.*s\"}", |
| 795 | (int) sizeof(statbuf.f_fpack), |
| 796 | statbuf.f_fpack); |
| 797 | } |
| 798 | } |
| 799 | return 0; |
| 800 | } |
| 801 | |
| 802 | #endif /* SUNOS4 */ |
| 803 | |
| 804 | /* directory */ |
| 805 | int |
| 806 | sys_chdir(tcp) |
| 807 | struct tcb *tcp; |
| 808 | { |
| 809 | if (entering(tcp)) { |
| 810 | printpath(tcp, tcp->u_arg[0]); |
| 811 | } |
| 812 | return 0; |
| 813 | } |
| 814 | |
| 815 | int |
| 816 | sys_mkdir(tcp) |
| 817 | struct tcb *tcp; |
| 818 | { |
| 819 | if (entering(tcp)) { |
| 820 | printpath(tcp, tcp->u_arg[0]); |
| 821 | tprintf(", %#lo", tcp->u_arg[1]); |
| 822 | } |
| 823 | return 0; |
| 824 | } |
| 825 | |
| 826 | int |
| 827 | sys_rmdir(tcp) |
| 828 | struct tcb *tcp; |
| 829 | { |
| 830 | if (entering(tcp)) { |
| 831 | printpath(tcp, tcp->u_arg[0]); |
| 832 | } |
| 833 | return 0; |
| 834 | } |
| 835 | |
| 836 | int |
| 837 | sys_fchdir(tcp) |
| 838 | struct tcb *tcp; |
| 839 | { |
| 840 | if (entering(tcp)) { |
| 841 | tprintf("%ld", tcp->u_arg[0]); |
| 842 | } |
| 843 | return 0; |
| 844 | } |
| 845 | |
| 846 | int |
| 847 | sys_chroot(tcp) |
| 848 | struct tcb *tcp; |
| 849 | { |
| 850 | if (entering(tcp)) { |
| 851 | printpath(tcp, tcp->u_arg[0]); |
| 852 | } |
| 853 | return 0; |
| 854 | } |
| 855 | |
| 856 | int |
| 857 | sys_fchroot(tcp) |
| 858 | struct tcb *tcp; |
| 859 | { |
| 860 | if (entering(tcp)) { |
| 861 | tprintf("%ld", tcp->u_arg[0]); |
| 862 | } |
| 863 | return 0; |
| 864 | } |
| 865 | |
| 866 | int |
| 867 | sys_link(tcp) |
| 868 | struct tcb *tcp; |
| 869 | { |
| 870 | if (entering(tcp)) { |
| 871 | printpath(tcp, tcp->u_arg[0]); |
| 872 | tprintf(", "); |
| 873 | printpath(tcp, tcp->u_arg[1]); |
| 874 | } |
| 875 | return 0; |
| 876 | } |
| 877 | |
| 878 | int |
| 879 | sys_unlink(tcp) |
| 880 | struct tcb *tcp; |
| 881 | { |
| 882 | if (entering(tcp)) { |
| 883 | printpath(tcp, tcp->u_arg[0]); |
| 884 | } |
| 885 | return 0; |
| 886 | } |
| 887 | |
| 888 | int |
| 889 | sys_symlink(tcp) |
| 890 | struct tcb *tcp; |
| 891 | { |
| 892 | if (entering(tcp)) { |
| 893 | printpath(tcp, tcp->u_arg[0]); |
| 894 | tprintf(", "); |
| 895 | printpath(tcp, tcp->u_arg[1]); |
| 896 | } |
| 897 | return 0; |
| 898 | } |
| 899 | |
| 900 | int |
| 901 | sys_readlink(tcp) |
| 902 | struct tcb *tcp; |
| 903 | { |
| 904 | if (entering(tcp)) { |
| 905 | printpath(tcp, tcp->u_arg[0]); |
| 906 | tprintf(", "); |
| 907 | } else { |
| 908 | if (syserror(tcp)) |
| 909 | tprintf("%#lx", tcp->u_arg[1]); |
| 910 | else |
| 911 | printpathn(tcp, tcp->u_arg[1], tcp->u_rval); |
| 912 | tprintf(", %lu", tcp->u_arg[2]); |
| 913 | } |
| 914 | return 0; |
| 915 | } |
| 916 | |
| 917 | int |
| 918 | sys_rename(tcp) |
| 919 | struct tcb *tcp; |
| 920 | { |
| 921 | if (entering(tcp)) { |
| 922 | printpath(tcp, tcp->u_arg[0]); |
| 923 | tprintf(", "); |
| 924 | printpath(tcp, tcp->u_arg[1]); |
| 925 | } |
| 926 | return 0; |
| 927 | } |
| 928 | |
| 929 | int |
| 930 | sys_chown(tcp) |
| 931 | struct tcb *tcp; |
| 932 | { |
| 933 | if (entering(tcp)) { |
| 934 | printpath(tcp, tcp->u_arg[0]); |
| 935 | tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
| 936 | } |
| 937 | return 0; |
| 938 | } |
| 939 | |
| 940 | int |
| 941 | sys_fchown(tcp) |
| 942 | struct tcb *tcp; |
| 943 | { |
| 944 | if (entering(tcp)) { |
| 945 | tprintf("%ld, %lu, %lu", |
| 946 | tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]); |
| 947 | } |
| 948 | return 0; |
| 949 | } |
| 950 | |
| 951 | int |
| 952 | sys_chmod(tcp) |
| 953 | struct tcb *tcp; |
| 954 | { |
| 955 | if (entering(tcp)) { |
| 956 | printpath(tcp, tcp->u_arg[0]); |
| 957 | tprintf(", %#lo", tcp->u_arg[1]); |
| 958 | } |
| 959 | return 0; |
| 960 | } |
| 961 | |
| 962 | int |
| 963 | sys_fchmod(tcp) |
| 964 | struct tcb *tcp; |
| 965 | { |
| 966 | if (entering(tcp)) { |
| 967 | tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]); |
| 968 | } |
| 969 | return 0; |
| 970 | } |
| 971 | |
| 972 | int |
| 973 | sys_utimes(tcp) |
| 974 | struct tcb *tcp; |
| 975 | { |
| 976 | if (entering(tcp)) { |
| 977 | printpath(tcp, tcp->u_arg[0]); |
| 978 | tprintf(", "); |
| 979 | printtv(tcp, tcp->u_arg[1]); |
| 980 | } |
| 981 | return 0; |
| 982 | } |
| 983 | |
| 984 | int |
| 985 | sys_utime(tcp) |
| 986 | struct tcb *tcp; |
| 987 | { |
| 988 | long ut[2]; |
| 989 | |
| 990 | if (entering(tcp)) { |
| 991 | printpath(tcp, tcp->u_arg[0]); |
| 992 | tprintf(", "); |
| 993 | if (!tcp->u_arg[1]) |
| 994 | tprintf("NULL"); |
| 995 | else if (!verbose(tcp)) |
| 996 | tprintf("%#lx", tcp->u_arg[1]); |
| 997 | else if (umoven(tcp, tcp->u_arg[1], sizeof ut, |
| 998 | (char *) ut) < 0) |
| 999 | tprintf("[?, ?]"); |
| 1000 | else { |
| 1001 | tprintf("[%s,", sprinttime(ut[0])); |
| 1002 | tprintf(" %s]", sprinttime(ut[1])); |
| 1003 | } |
| 1004 | } |
| 1005 | return 0; |
| 1006 | } |
| 1007 | |
| 1008 | int |
| 1009 | sys_mknod(tcp) |
| 1010 | struct tcb *tcp; |
| 1011 | { |
| 1012 | int mode = tcp->u_arg[1]; |
| 1013 | |
| 1014 | if (entering(tcp)) { |
| 1015 | printpath(tcp, tcp->u_arg[0]); |
| 1016 | tprintf(", %s", sprintmode(mode)); |
| 1017 | switch (mode & S_IFMT) { |
| 1018 | case S_IFCHR: case S_IFBLK: |
| 1019 | #ifdef LINUXSPARC |
| 1020 | if (current_personality == 1) |
| 1021 | tprintf(", makedev(%lu, %lu)", |
| 1022 | (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff), |
| 1023 | (unsigned long) (tcp->u_arg[2] & 0x3ffff)); |
| 1024 | else |
| 1025 | #endif |
| 1026 | tprintf(", makedev(%lu, %lu)", |
| 1027 | (unsigned long) major(tcp->u_arg[2]), |
| 1028 | (unsigned long) minor(tcp->u_arg[2])); |
| 1029 | break; |
| 1030 | default: |
| 1031 | break; |
| 1032 | } |
| 1033 | } |
| 1034 | return 0; |
| 1035 | } |
| 1036 | |
| 1037 | int |
| 1038 | sys_mkfifo(tcp) |
| 1039 | struct tcb *tcp; |
| 1040 | { |
| 1041 | if (entering(tcp)) { |
| 1042 | printpath(tcp, tcp->u_arg[0]); |
| 1043 | tprintf(", %#lo", tcp->u_arg[1]); |
| 1044 | } |
| 1045 | return 0; |
| 1046 | } |
| 1047 | |
| 1048 | int |
| 1049 | sys_fsync(tcp) |
| 1050 | struct tcb *tcp; |
| 1051 | { |
| 1052 | if (entering(tcp)) { |
| 1053 | tprintf("%ld", tcp->u_arg[0]); |
| 1054 | } |
| 1055 | return 0; |
| 1056 | } |
| 1057 | |
| 1058 | #ifdef LINUX |
| 1059 | |
| 1060 | static void |
| 1061 | printdir(tcp, addr) |
| 1062 | struct tcb *tcp; |
| 1063 | long addr; |
| 1064 | { |
| 1065 | struct dirent d; |
| 1066 | |
| 1067 | if (!verbose(tcp)) { |
| 1068 | tprintf("%#lx", addr); |
| 1069 | return; |
| 1070 | } |
| 1071 | if (umove(tcp, addr, &d) < 0) { |
| 1072 | tprintf("{...}"); |
| 1073 | return; |
| 1074 | } |
| 1075 | tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino); |
| 1076 | #ifndef LINUX |
| 1077 | /* This contains garbage under Linux. */ |
| 1078 | tprintf("d_off=%d, ", d.d_off); |
| 1079 | #endif /* !LINUX */ |
| 1080 | #ifndef LINUX |
| 1081 | /* No point in printing this out since the syscall returns it. */ |
| 1082 | tprintf("d_reclen=%u, ", d.d_reclen); |
| 1083 | #endif /* !LINUX */ |
| 1084 | tprintf("d_name="); |
| 1085 | printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen); |
| 1086 | tprintf("}"); |
| 1087 | } |
| 1088 | |
| 1089 | int |
| 1090 | sys_readdir(tcp) |
| 1091 | struct tcb *tcp; |
| 1092 | { |
| 1093 | if (entering(tcp)) { |
| 1094 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1095 | } else { |
| 1096 | if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp)) |
| 1097 | tprintf("%#lx", tcp->u_arg[1]); |
| 1098 | else |
| 1099 | printdir(tcp, tcp->u_arg[1]); |
| 1100 | /* Not much point in printing this out, it is always 1. */ |
| 1101 | if (tcp->u_arg[2] != 1) |
| 1102 | tprintf(", %lu", tcp->u_arg[2]); |
| 1103 | } |
| 1104 | return 0; |
| 1105 | } |
| 1106 | |
| 1107 | #endif /* LINUX */ |
| 1108 | |
| 1109 | int |
| 1110 | sys_getdents(tcp) |
| 1111 | struct tcb *tcp; |
| 1112 | { |
| 1113 | int i, len, dents = 0; |
| 1114 | char *buf; |
| 1115 | |
| 1116 | if (entering(tcp)) { |
| 1117 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1118 | return 0; |
| 1119 | } |
| 1120 | if (syserror(tcp) || !verbose(tcp)) { |
| 1121 | tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); |
| 1122 | return 0; |
| 1123 | } |
| 1124 | #ifdef linux |
| 1125 | #ifdef __sparc__ |
| 1126 | tprintf (" = Unknown value\n"); |
| 1127 | return 0; |
| 1128 | #endif |
| 1129 | #endif |
| 1130 | len = tcp->u_rval; |
| 1131 | if ((buf = malloc(len)) == NULL) { |
| 1132 | tprintf("out of memory\n"); |
| 1133 | return 0; |
| 1134 | } |
| 1135 | if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { |
| 1136 | tprintf("{...}, %lu", tcp->u_arg[2]); |
| 1137 | free(buf); |
| 1138 | return 0; |
| 1139 | } |
| 1140 | if (!abbrev(tcp)) |
| 1141 | tprintf("{"); |
| 1142 | for (i = 0; i < len;) { |
| 1143 | struct dirent *d = (struct dirent *) &buf[i]; |
| 1144 | #ifdef LINUX |
| 1145 | if (!abbrev(tcp)) { |
| 1146 | tprintf("%s{d_ino=%lu, d_off=%lu, ", |
| 1147 | i ? " " : "", d->d_ino, d->d_off); |
| 1148 | tprintf("d_reclen=%u, d_name=\"%s\"}", |
| 1149 | d->d_reclen, d->d_name); |
| 1150 | } |
| 1151 | #endif /* LINUX */ |
| 1152 | #ifdef SVR4 |
| 1153 | if (!abbrev(tcp)) { |
| 1154 | tprintf("%s{d_ino=%lu, d_off=%lu, ", |
| 1155 | i ? " " : "", d->d_ino, d->d_off); |
| 1156 | tprintf("d_reclen=%u, d_name=\"%s\"}", |
| 1157 | d->d_reclen, d->d_name); |
| 1158 | } |
| 1159 | #endif /* SVR4 */ |
| 1160 | #ifdef SUNOS4 |
| 1161 | if (!abbrev(tcp)) { |
| 1162 | tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ", |
| 1163 | i ? " " : "", d->d_off, d->d_fileno, |
| 1164 | d->d_reclen); |
| 1165 | tprintf("d_namlen=%u, d_name=\"%.*s\"}", |
| 1166 | d->d_namlen, d->d_namlen, d->d_name); |
| 1167 | } |
| 1168 | #endif /* SUNOS4 */ |
| 1169 | i += d->d_reclen; |
| 1170 | dents++; |
| 1171 | } |
| 1172 | if (!abbrev(tcp)) |
| 1173 | tprintf("}"); |
| 1174 | else |
| 1175 | tprintf("/* %u entries */", dents); |
| 1176 | tprintf(", %lu", tcp->u_arg[2]); |
| 1177 | free(buf); |
| 1178 | return 0; |
| 1179 | } |
| 1180 | |
| 1181 | #ifdef LINUX |
| 1182 | |
| 1183 | int |
| 1184 | sys_getcwd(tcp) |
| 1185 | struct tcb *tcp; |
| 1186 | { |
| 1187 | if (exiting(tcp)) { |
| 1188 | if (syserror(tcp)) |
| 1189 | tprintf("%#lx", tcp->u_arg[0]); |
| 1190 | else |
| 1191 | printstr(tcp, tcp->u_arg[0], tcp->u_arg[1]); |
| 1192 | tprintf(", %lu", tcp->u_arg[1]); |
| 1193 | } |
| 1194 | return 0; |
| 1195 | } |
| 1196 | #endif /* LINUX */ |
| 1197 | |
| 1198 | #ifdef HAVE_SYS_ASYNCH_H |
| 1199 | |
| 1200 | int |
| 1201 | sys_aioread(tcp) |
| 1202 | struct tcb *tcp; |
| 1203 | { |
| 1204 | struct aio_result_t res; |
| 1205 | |
| 1206 | if (entering(tcp)) { |
| 1207 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1208 | } else { |
| 1209 | if (syserror(tcp)) |
| 1210 | tprintf("%#lx", tcp->u_arg[1]); |
| 1211 | else |
| 1212 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 1213 | tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 1214 | printxval(whence, tcp->u_arg[4], "L_???"); |
| 1215 | if (syserror(tcp) || tcp->u_arg[5] == 0 |
| 1216 | || umove(tcp, tcp->u_arg[5], &res) < 0) |
| 1217 | tprintf(", %#lx", tcp->u_arg[5]); |
| 1218 | else |
| 1219 | tprintf(", {aio_return %d aio_errno %d}", |
| 1220 | res.aio_return, res.aio_errno); |
| 1221 | } |
| 1222 | return 0; |
| 1223 | } |
| 1224 | |
| 1225 | int |
| 1226 | sys_aiowrite(tcp) |
| 1227 | struct tcb *tcp; |
| 1228 | { |
| 1229 | struct aio_result_t res; |
| 1230 | |
| 1231 | if (entering(tcp)) { |
| 1232 | tprintf("%lu, ", tcp->u_arg[0]); |
| 1233 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 1234 | tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]); |
| 1235 | printxval(whence, tcp->u_arg[4], "L_???"); |
| 1236 | } |
| 1237 | else { |
| 1238 | if (tcp->u_arg[5] == 0) |
| 1239 | tprintf(", NULL"); |
| 1240 | else if (syserror(tcp) |
| 1241 | || umove(tcp, tcp->u_arg[5], &res) < 0) |
| 1242 | tprintf(", %#lx", tcp->u_arg[5]); |
| 1243 | else |
| 1244 | tprintf(", {aio_return %d aio_errno %d}", |
| 1245 | res.aio_return, res.aio_errno); |
| 1246 | } |
| 1247 | return 0; |
| 1248 | } |
| 1249 | |
| 1250 | int |
| 1251 | sys_aiowait(tcp) |
| 1252 | struct tcb *tcp; |
| 1253 | { |
| 1254 | if (entering(tcp)) |
| 1255 | printtv(tcp, tcp->u_arg[0]); |
| 1256 | return 0; |
| 1257 | } |
| 1258 | |
| 1259 | int |
| 1260 | sys_aiocancel(tcp) |
| 1261 | struct tcb *tcp; |
| 1262 | { |
| 1263 | struct aio_result_t res; |
| 1264 | |
| 1265 | if (exiting(tcp)) { |
| 1266 | if (tcp->u_arg[0] == 0) |
| 1267 | tprintf("NULL"); |
| 1268 | else if (syserror(tcp) |
| 1269 | || umove(tcp, tcp->u_arg[0], &res) < 0) |
| 1270 | tprintf("%#lx", tcp->u_arg[0]); |
| 1271 | else |
| 1272 | tprintf("{aio_return %d aio_errno %d}", |
| 1273 | res.aio_return, res.aio_errno); |
| 1274 | } |
| 1275 | return 0; |
| 1276 | } |
| 1277 | |
| 1278 | #endif /* HAVE_SYS_ASYNCH_H */ |