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