file.c revision 44f0ed1ca560cad60194ae0542b9e223bdeff92b
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 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> 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 31#include "defs.h" 32#include <dirent.h> 33#include <sys/swap.h> 34 35#if defined(SPARC) || defined(SPARC64) 36struct stat { 37 unsigned short st_dev; 38 unsigned int st_ino; 39 unsigned short st_mode; 40 short st_nlink; 41 unsigned short st_uid; 42 unsigned short st_gid; 43 unsigned short st_rdev; 44 unsigned int st_size; 45 int st_atime; 46 unsigned int __unused1; 47 int st_mtime; 48 unsigned int __unused2; 49 int st_ctime; 50 unsigned int __unused3; 51 int st_blksize; 52 int st_blocks; 53 unsigned int __unused4[2]; 54}; 55# if defined(SPARC64) 56struct stat_sparc64 { 57 unsigned int st_dev; 58 unsigned long st_ino; 59 unsigned int st_mode; 60 unsigned int st_nlink; 61 unsigned int st_uid; 62 unsigned int st_gid; 63 unsigned int st_rdev; 64 long st_size; 65 long st_atime; 66 long st_mtime; 67 long st_ctime; 68 long st_blksize; 69 long st_blocks; 70 unsigned long __unused4[2]; 71}; 72# endif /* SPARC64 */ 73# define stat kernel_stat 74# include <asm/stat.h> 75# undef stat 76#elif defined(X32) 77struct stat { 78 unsigned long long st_dev; 79 unsigned long long st_ino; 80 unsigned long long st_nlink; 81 82 unsigned int st_mode; 83 unsigned int st_uid; 84 unsigned int st_gid; 85 unsigned int __pad0; 86 unsigned long long st_rdev; 87 long long st_size; 88 long long st_blksize; 89 long long st_blocks; 90 91 unsigned long long st_atime; 92 unsigned long long st_atime_nsec; 93 unsigned long long st_mtime; 94 unsigned long long st_mtime_nsec; 95 unsigned long long st_ctime; 96 unsigned long long st_ctime_nsec; 97 long long __unused[3]; 98}; 99 100struct stat64 { 101 unsigned long long st_dev; 102 unsigned char __pad0[4]; 103 unsigned long __st_ino; 104 unsigned int st_mode; 105 unsigned int st_nlink; 106 unsigned long st_uid; 107 unsigned long st_gid; 108 unsigned long long st_rdev; 109 unsigned char __pad3[4]; 110 long long st_size; 111 unsigned long st_blksize; 112 unsigned long long st_blocks; 113 unsigned long st_atime; 114 unsigned long st_atime_nsec; 115 unsigned long st_mtime; 116 unsigned int st_mtime_nsec; 117 unsigned long st_ctime; 118 unsigned long st_ctime_nsec; 119 unsigned long long st_ino; 120}; 121 122struct __old_kernel_stat { 123 unsigned short st_dev; 124 unsigned short st_ino; 125 unsigned short st_mode; 126 unsigned short st_nlink; 127 unsigned short st_uid; 128 unsigned short st_gid; 129 unsigned short st_rdev; 130 unsigned int st_size; 131 unsigned int st_atime; 132 unsigned int st_mtime; 133 unsigned int st_ctime; 134}; 135#else 136# undef dev_t 137# undef ino_t 138# undef mode_t 139# undef nlink_t 140# undef uid_t 141# undef gid_t 142# undef off_t 143# undef loff_t 144# define dev_t __kernel_dev_t 145# define ino_t __kernel_ino_t 146# define mode_t __kernel_mode_t 147# define nlink_t __kernel_nlink_t 148# define uid_t __kernel_uid_t 149# define gid_t __kernel_gid_t 150# define off_t __kernel_off_t 151# define loff_t __kernel_loff_t 152 153# include <asm/stat.h> 154 155# undef dev_t 156# undef ino_t 157# undef mode_t 158# undef nlink_t 159# undef uid_t 160# undef gid_t 161# undef off_t 162# undef loff_t 163# define dev_t dev_t 164# define ino_t ino_t 165# define mode_t mode_t 166# define nlink_t nlink_t 167# define uid_t uid_t 168# define gid_t gid_t 169# define off_t off_t 170# define loff_t loff_t 171#endif 172 173#ifdef HPPA /* asm-parisc/stat.h defines stat64 */ 174# undef stat64 175#endif 176#define stat libc_stat 177#define stat64 libc_stat64 178#include <sys/stat.h> 179#undef stat 180#undef stat64 181/* These might be macros. */ 182#undef st_atime 183#undef st_mtime 184#undef st_ctime 185#ifdef HPPA 186# define stat64 hpux_stat64 187#endif 188 189#include <fcntl.h> 190#ifdef HAVE_SYS_VFS_H 191# include <sys/vfs.h> 192#endif 193#ifdef HAVE_LINUX_XATTR_H 194# include <linux/xattr.h> 195#else 196# define XATTR_CREATE 1 197# define XATTR_REPLACE 2 198#endif 199 200#ifdef MAJOR_IN_SYSMACROS 201# include <sys/sysmacros.h> 202#endif 203 204#ifdef MAJOR_IN_MKDEV 205# include <sys/mkdev.h> 206#endif 207 208#ifdef HAVE_SYS_ASYNCH_H 209# include <sys/asynch.h> 210#endif 211 212struct kernel_dirent { 213 unsigned long d_ino; 214 unsigned long d_off; 215 unsigned short d_reclen; 216 char d_name[1]; 217}; 218 219const struct xlat open_access_modes[] = { 220 { O_RDONLY, "O_RDONLY" }, 221 { O_WRONLY, "O_WRONLY" }, 222 { O_RDWR, "O_RDWR" }, 223#ifdef O_ACCMODE 224 { O_ACCMODE, "O_ACCMODE" }, 225#endif 226 { 0, NULL }, 227}; 228 229const struct xlat open_mode_flags[] = { 230 { O_CREAT, "O_CREAT" }, 231 { O_EXCL, "O_EXCL" }, 232 { O_NOCTTY, "O_NOCTTY" }, 233 { O_TRUNC, "O_TRUNC" }, 234 { O_APPEND, "O_APPEND" }, 235 { O_NONBLOCK, "O_NONBLOCK" }, 236#ifdef O_SYNC 237 { O_SYNC, "O_SYNC" }, 238#endif 239#ifdef O_ASYNC 240 { O_ASYNC, "O_ASYNC" }, 241#endif 242#ifdef O_DSYNC 243 { O_DSYNC, "O_DSYNC" }, 244#endif 245#ifdef O_RSYNC 246 { O_RSYNC, "O_RSYNC" }, 247#endif 248#if defined(O_NDELAY) && (O_NDELAY != O_NONBLOCK) 249 { O_NDELAY, "O_NDELAY" }, 250#endif 251#ifdef O_PRIV 252 { O_PRIV, "O_PRIV" }, 253#endif 254#ifdef O_DIRECT 255 { O_DIRECT, "O_DIRECT" }, 256#endif 257#ifdef O_LARGEFILE 258# if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */ 259# undef O_LARGEFILE 260# ifdef SPARC64 261# define O_LARGEFILE 0x40000 262# elif defined X86_64 || defined S390X 263# define O_LARGEFILE 0100000 264# endif 265# endif 266# ifdef O_LARGEFILE 267 { O_LARGEFILE, "O_LARGEFILE" }, 268# endif 269#endif 270#ifdef O_DIRECTORY 271 { O_DIRECTORY, "O_DIRECTORY" }, 272#endif 273#ifdef O_NOFOLLOW 274 { O_NOFOLLOW, "O_NOFOLLOW" }, 275#endif 276#ifdef O_NOATIME 277 { O_NOATIME, "O_NOATIME" }, 278#endif 279#ifdef O_CLOEXEC 280 { O_CLOEXEC, "O_CLOEXEC" }, 281#endif 282#ifdef FNDELAY 283 { FNDELAY, "FNDELAY" }, 284#endif 285#ifdef FAPPEND 286 { FAPPEND, "FAPPEND" }, 287#endif 288#ifdef FMARK 289 { FMARK, "FMARK" }, 290#endif 291#ifdef FDEFER 292 { FDEFER, "FDEFER" }, 293#endif 294#ifdef FASYNC 295 { FASYNC, "FASYNC" }, 296#endif 297#ifdef FSHLOCK 298 { FSHLOCK, "FSHLOCK" }, 299#endif 300#ifdef FEXLOCK 301 { FEXLOCK, "FEXLOCK" }, 302#endif 303#ifdef FCREAT 304 { FCREAT, "FCREAT" }, 305#endif 306#ifdef FTRUNC 307 { FTRUNC, "FTRUNC" }, 308#endif 309#ifdef FEXCL 310 { FEXCL, "FEXCL" }, 311#endif 312#ifdef FNBIO 313 { FNBIO, "FNBIO" }, 314#endif 315#ifdef FSYNC 316 { FSYNC, "FSYNC" }, 317#endif 318#ifdef FNOCTTY 319 { FNOCTTY, "FNOCTTY" }, 320#endif 321#ifdef O_SHLOCK 322 { O_SHLOCK, "O_SHLOCK" }, 323#endif 324#ifdef O_EXLOCK 325 { O_EXLOCK, "O_EXLOCK" }, 326#endif 327 { 0, NULL }, 328}; 329 330#ifndef AT_FDCWD 331# define AT_FDCWD -100 332#endif 333 334/* The fd is an "int", so when decoding x86 on x86_64, we need to force sign 335 * extension to get the right value. We do this by declaring fd as int here. 336 */ 337static void 338print_dirfd(struct tcb *tcp, int fd) 339{ 340 if (fd == AT_FDCWD) 341 tprints("AT_FDCWD, "); 342 else { 343 printfd(tcp, fd); 344 tprints(", "); 345 } 346} 347 348/* 349 * low bits of the open(2) flags define access mode, 350 * other bits are real flags. 351 */ 352const char * 353sprint_open_modes(mode_t flags) 354{ 355 static char outstr[(1 + ARRAY_SIZE(open_mode_flags)) * sizeof("O_LARGEFILE")]; 356 char *p; 357 char sep; 358 const char *str; 359 const struct xlat *x; 360 361 sep = ' '; 362 p = stpcpy(outstr, "flags"); 363 str = xlookup(open_access_modes, flags & 3); 364 if (str) { 365 *p++ = sep; 366 p = stpcpy(p, str); 367 flags &= ~3; 368 if (!flags) 369 return outstr; 370 sep = '|'; 371 } 372 373 for (x = open_mode_flags; x->str; x++) { 374 if ((flags & x->val) == x->val) { 375 *p++ = sep; 376 p = stpcpy(p, x->str); 377 flags &= ~x->val; 378 if (!flags) 379 return outstr; 380 sep = '|'; 381 } 382 } 383 /* flags is still nonzero */ 384 *p++ = sep; 385 sprintf(p, "%#x", flags); 386 return outstr; 387} 388 389void 390tprint_open_modes(mode_t flags) 391{ 392 tprints(sprint_open_modes(flags) + sizeof("flags")); 393} 394 395static int 396decode_open(struct tcb *tcp, int offset) 397{ 398 if (entering(tcp)) { 399 printpath(tcp, tcp->u_arg[offset]); 400 tprints(", "); 401 /* flags */ 402 tprint_open_modes(tcp->u_arg[offset + 1]); 403 if (tcp->u_arg[offset + 1] & O_CREAT) { 404 /* mode */ 405 tprintf(", %#lo", tcp->u_arg[offset + 2]); 406 } 407 } 408 return 0; 409} 410 411int 412sys_open(struct tcb *tcp) 413{ 414 return decode_open(tcp, 0); 415} 416 417int 418sys_openat(struct tcb *tcp) 419{ 420 if (entering(tcp)) 421 print_dirfd(tcp, tcp->u_arg[0]); 422 return decode_open(tcp, 1); 423} 424 425#if defined(SPARC) || defined(SPARC64) 426static const struct xlat openmodessol[] = { 427 { 0, "O_RDWR" }, 428 { 1, "O_RDONLY" }, 429 { 2, "O_WRONLY" }, 430 { 0x80, "O_NONBLOCK" }, 431 { 8, "O_APPEND" }, 432 { 0x100, "O_CREAT" }, 433 { 0x200, "O_TRUNC" }, 434 { 0x400, "O_EXCL" }, 435 { 0x800, "O_NOCTTY" }, 436 { 0x10, "O_SYNC" }, 437 { 0x40, "O_DSYNC" }, 438 { 0x8000, "O_RSYNC" }, 439 { 4, "O_NDELAY" }, 440 { 0x1000, "O_PRIV" }, 441 { 0, NULL }, 442}; 443 444int 445solaris_open(struct tcb *tcp) 446{ 447 if (entering(tcp)) { 448 printpath(tcp, tcp->u_arg[0]); 449 tprints(", "); 450 /* flags */ 451 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???"); 452 if (tcp->u_arg[1] & 0x100) { 453 /* mode */ 454 tprintf(", %#lo", tcp->u_arg[2]); 455 } 456 } 457 return 0; 458} 459 460#endif 461 462int 463sys_creat(struct tcb *tcp) 464{ 465 if (entering(tcp)) { 466 printpath(tcp, tcp->u_arg[0]); 467 tprintf(", %#lo", tcp->u_arg[1]); 468 } 469 return 0; 470} 471 472static const struct xlat access_flags[] = { 473 { F_OK, "F_OK", }, 474 { R_OK, "R_OK" }, 475 { W_OK, "W_OK" }, 476 { X_OK, "X_OK" }, 477#ifdef EFF_ONLY_OK 478 { EFF_ONLY_OK, "EFF_ONLY_OK" }, 479#endif 480#ifdef EX_OK 481 { EX_OK, "EX_OK" }, 482#endif 483 { 0, NULL }, 484}; 485 486static int 487decode_access(struct tcb *tcp, int offset) 488{ 489 if (entering(tcp)) { 490 printpath(tcp, tcp->u_arg[offset]); 491 tprints(", "); 492 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK"); 493 } 494 return 0; 495} 496 497int 498sys_access(struct tcb *tcp) 499{ 500 return decode_access(tcp, 0); 501} 502 503int 504sys_faccessat(struct tcb *tcp) 505{ 506 if (entering(tcp)) 507 print_dirfd(tcp, tcp->u_arg[0]); 508 return decode_access(tcp, 1); 509} 510 511int 512sys_umask(struct tcb *tcp) 513{ 514 if (entering(tcp)) { 515 tprintf("%#lo", tcp->u_arg[0]); 516 } 517 return RVAL_OCTAL; 518} 519 520const struct xlat whence_codes[] = { 521 { SEEK_SET, "SEEK_SET" }, 522 { SEEK_CUR, "SEEK_CUR" }, 523 { SEEK_END, "SEEK_END" }, 524#ifdef SEEK_DATA 525 { SEEK_DATA, "SEEK_DATA" }, 526#endif 527#ifdef SEEK_HOLE 528 { SEEK_HOLE, "SEEK_HOLE" }, 529#endif 530 { 0, NULL }, 531}; 532 533/* Linux kernel has exactly one version of lseek: 534 * fs/read_write.c::SYSCALL_DEFINE3(lseek, unsigned, fd, off_t, offset, unsigned, origin) 535 * In kernel, off_t is always the same as (kernel's) long 536 * (see include/uapi/asm-generic/posix_types.h), 537 * which means that on x32 we need to use tcp->ext_arg[N] to get offset argument. 538 * Use test/x32_lseek.c to test lseek decoding. 539 */ 540#if defined(LINUX_MIPSN32) || defined(X32) 541int 542sys_lseek(struct tcb *tcp) 543{ 544 long long offset; 545 int whence; 546 547 if (entering(tcp)) { 548 printfd(tcp, tcp->u_arg[0]); 549 offset = tcp->ext_arg[1]; 550 whence = tcp->u_arg[2]; 551 if (whence == SEEK_SET) 552 tprintf(", %llu, ", offset); 553 else 554 tprintf(", %lld, ", offset); 555 printxval(whence_codes, whence, "SEEK_???"); 556 } 557 return RVAL_LUDECIMAL; 558} 559#else 560int 561sys_lseek(struct tcb *tcp) 562{ 563 long offset; 564 int whence; 565 566 if (entering(tcp)) { 567 printfd(tcp, tcp->u_arg[0]); 568 offset = tcp->u_arg[1]; 569 whence = tcp->u_arg[2]; 570 if (whence == SEEK_SET) 571 tprintf(", %lu, ", offset); 572 else 573 tprintf(", %ld, ", offset); 574 printxval(whence_codes, whence, "SEEK_???"); 575 } 576 return RVAL_UDECIMAL; 577} 578#endif 579 580/* llseek syscall takes explicitly two ulong arguments hi, lo, 581 * rather than one 64-bit argument for which LONG_LONG works 582 * appropriate for the native byte order. 583 * 584 * See kernel's fs/read_write.c::SYSCALL_DEFINE5(llseek, ...) 585 * 586 * hi,lo are "unsigned longs" and combined exactly this way in kernel: 587 * ((loff_t) hi << 32) | lo 588 * Note that for architectures with kernel's long wider than userspace long 589 * (such as x32), combining code will use *kernel's*, i.e. *wide* longs 590 * for hi and lo. We would need to use tcp->ext_arg[N] on x32... 591 * ...however, x32 (and x86_64) does not _have_ llseek syscall as such. 592 */ 593int 594sys_llseek(struct tcb *tcp) 595{ 596 if (entering(tcp)) { 597 printfd(tcp, tcp->u_arg[0]); 598 if (tcp->u_arg[4] == SEEK_SET) 599 tprintf(", %llu, ", 600 ((long long) tcp->u_arg[1]) << 32 | 601 (unsigned long long) (unsigned) tcp->u_arg[2]); 602 else 603 tprintf(", %lld, ", 604 ((long long) tcp->u_arg[1]) << 32 | 605 (unsigned long long) (unsigned) tcp->u_arg[2]); 606 } 607 else { 608 long long off; 609 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0) 610 tprintf("%#lx, ", tcp->u_arg[3]); 611 else 612 tprintf("[%llu], ", off); 613 printxval(whence_codes, tcp->u_arg[4], "SEEK_???"); 614 } 615 return 0; 616} 617 618int 619sys_readahead(struct tcb *tcp) 620{ 621 if (entering(tcp)) { 622 int argn; 623 printfd(tcp, tcp->u_arg[0]); 624 argn = printllval(tcp, ", %lld", 1); 625 tprintf(", %ld", tcp->u_arg[argn]); 626 } 627 return 0; 628} 629 630int 631sys_truncate(struct tcb *tcp) 632{ 633 if (entering(tcp)) { 634 printpath(tcp, tcp->u_arg[0]); 635 tprintf(", %lu", tcp->u_arg[1]); 636 } 637 return 0; 638} 639 640#if _LFS64_LARGEFILE 641int 642sys_truncate64(struct tcb *tcp) 643{ 644 if (entering(tcp)) { 645 printpath(tcp, tcp->u_arg[0]); 646 printllval(tcp, ", %llu", 1); 647 } 648 return 0; 649} 650#endif 651 652int 653sys_ftruncate(struct tcb *tcp) 654{ 655 if (entering(tcp)) { 656 printfd(tcp, tcp->u_arg[0]); 657 tprintf(", %lu", tcp->u_arg[1]); 658 } 659 return 0; 660} 661 662#if _LFS64_LARGEFILE 663int 664sys_ftruncate64(struct tcb *tcp) 665{ 666 if (entering(tcp)) { 667 printfd(tcp, tcp->u_arg[0]); 668 printllval(tcp, ", %llu", 1); 669 } 670 return 0; 671} 672#endif 673 674/* several stats */ 675 676static const struct xlat modetypes[] = { 677 { S_IFREG, "S_IFREG" }, 678 { S_IFSOCK, "S_IFSOCK" }, 679 { S_IFIFO, "S_IFIFO" }, 680 { S_IFLNK, "S_IFLNK" }, 681 { S_IFDIR, "S_IFDIR" }, 682 { S_IFBLK, "S_IFBLK" }, 683 { S_IFCHR, "S_IFCHR" }, 684 { 0, NULL }, 685}; 686 687static const char * 688sprintmode(int mode) 689{ 690 static char buf[sizeof("S_IFSOCK|S_ISUID|S_ISGID|S_ISVTX|%o") 691 + sizeof(int)*3 692 + /*paranoia:*/ 8]; 693 const char *s; 694 695 if ((mode & S_IFMT) == 0) 696 s = ""; 697 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) { 698 sprintf(buf, "%#o", mode); 699 return buf; 700 } 701 s = buf + sprintf(buf, "%s%s%s%s", s, 702 (mode & S_ISUID) ? "|S_ISUID" : "", 703 (mode & S_ISGID) ? "|S_ISGID" : "", 704 (mode & S_ISVTX) ? "|S_ISVTX" : ""); 705 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX); 706 if (mode) 707 sprintf((char*)s, "|%#o", mode); 708 s = (*buf == '|') ? buf + 1 : buf; 709 return *s ? s : "0"; 710} 711 712static char * 713sprinttime(time_t t) 714{ 715 struct tm *tmp; 716 static char buf[sizeof("yyyy/mm/dd-hh:mm:ss")]; 717 718 if (t == 0) { 719 strcpy(buf, "0"); 720 return buf; 721 } 722 tmp = localtime(&t); 723 if (tmp) 724 snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d", 725 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, 726 tmp->tm_hour, tmp->tm_min, tmp->tm_sec); 727 else 728 snprintf(buf, sizeof buf, "%lu", (unsigned long) t); 729 730 return buf; 731} 732 733#if defined(SPARC) || defined(SPARC64) 734typedef struct { 735 int tv_sec; 736 int tv_nsec; 737} timestruct_t; 738 739struct solstat { 740 unsigned st_dev; 741 int st_pad1[3]; /* network id */ 742 unsigned st_ino; 743 unsigned st_mode; 744 unsigned st_nlink; 745 unsigned st_uid; 746 unsigned st_gid; 747 unsigned st_rdev; 748 int st_pad2[2]; 749 int st_size; 750 int st_pad3; /* st_size, off_t expansion */ 751 timestruct_t st_atime; 752 timestruct_t st_mtime; 753 timestruct_t st_ctime; 754 int st_blksize; 755 int st_blocks; 756 char st_fstype[16]; 757 int st_pad4[8]; /* expansion area */ 758}; 759 760static void 761printstatsol(struct tcb *tcp, long addr) 762{ 763 struct solstat statbuf; 764 765 if (umove(tcp, addr, &statbuf) < 0) { 766 tprints("{...}"); 767 return; 768 } 769 if (!abbrev(tcp)) { 770 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", 771 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff), 772 (unsigned long) (statbuf.st_dev & 0x3ffff), 773 (unsigned long) statbuf.st_ino, 774 sprintmode(statbuf.st_mode)); 775 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", 776 (unsigned long) statbuf.st_nlink, 777 (unsigned long) statbuf.st_uid, 778 (unsigned long) statbuf.st_gid); 779 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize); 780 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); 781 } 782 else 783 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); 784 switch (statbuf.st_mode & S_IFMT) { 785 case S_IFCHR: case S_IFBLK: 786 tprintf("st_rdev=makedev(%lu, %lu), ", 787 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff), 788 (unsigned long) (statbuf.st_rdev & 0x3ffff)); 789 break; 790 default: 791 tprintf("st_size=%u, ", statbuf.st_size); 792 break; 793 } 794 if (!abbrev(tcp)) { 795 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec)); 796 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec)); 797 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec)); 798 } 799 else 800 tprints("...}"); 801} 802 803# if defined(SPARC64) 804static void 805printstat_sparc64(struct tcb *tcp, long addr) 806{ 807 struct stat_sparc64 statbuf; 808 809 if (umove(tcp, addr, &statbuf) < 0) { 810 tprints("{...}"); 811 return; 812 } 813 814 if (!abbrev(tcp)) { 815 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", 816 (unsigned long) major(statbuf.st_dev), 817 (unsigned long) minor(statbuf.st_dev), 818 (unsigned long) statbuf.st_ino, 819 sprintmode(statbuf.st_mode)); 820 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", 821 (unsigned long) statbuf.st_nlink, 822 (unsigned long) statbuf.st_uid, 823 (unsigned long) statbuf.st_gid); 824 tprintf("st_blksize=%lu, ", 825 (unsigned long) statbuf.st_blksize); 826 tprintf("st_blocks=%lu, ", 827 (unsigned long) statbuf.st_blocks); 828 } 829 else 830 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); 831 switch (statbuf.st_mode & S_IFMT) { 832 case S_IFCHR: case S_IFBLK: 833 tprintf("st_rdev=makedev(%lu, %lu), ", 834 (unsigned long) major(statbuf.st_rdev), 835 (unsigned long) minor(statbuf.st_rdev)); 836 break; 837 default: 838 tprintf("st_size=%lu, ", statbuf.st_size); 839 break; 840 } 841 if (!abbrev(tcp)) { 842 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); 843 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); 844 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); 845 } 846 else 847 tprints("...}"); 848} 849# endif /* SPARC64 */ 850#endif /* SPARC[64] */ 851 852#if defined POWERPC64 853struct stat_powerpc32 { 854 unsigned int st_dev; 855 unsigned int st_ino; 856 unsigned int st_mode; 857 unsigned short st_nlink; 858 unsigned int st_uid; 859 unsigned int st_gid; 860 unsigned int st_rdev; 861 unsigned int st_size; 862 unsigned int st_blksize; 863 unsigned int st_blocks; 864 unsigned int st_atime; 865 unsigned int st_atime_nsec; 866 unsigned int st_mtime; 867 unsigned int st_mtime_nsec; 868 unsigned int st_ctime; 869 unsigned int st_ctime_nsec; 870 unsigned int __unused4; 871 unsigned int __unused5; 872}; 873 874static void 875printstat_powerpc32(struct tcb *tcp, long addr) 876{ 877 struct stat_powerpc32 statbuf; 878 879 if (umove(tcp, addr, &statbuf) < 0) { 880 tprints("{...}"); 881 return; 882 } 883 884 if (!abbrev(tcp)) { 885 tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ", 886 major(statbuf.st_dev), minor(statbuf.st_dev), 887 statbuf.st_ino, 888 sprintmode(statbuf.st_mode)); 889 tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ", 890 statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid); 891 tprintf("st_blksize=%u, ", statbuf.st_blksize); 892 tprintf("st_blocks=%u, ", statbuf.st_blocks); 893 } 894 else 895 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); 896 switch (statbuf.st_mode & S_IFMT) { 897 case S_IFCHR: case S_IFBLK: 898 tprintf("st_rdev=makedev(%lu, %lu), ", 899 (unsigned long) major(statbuf.st_rdev), 900 (unsigned long) minor(statbuf.st_rdev)); 901 break; 902 default: 903 tprintf("st_size=%u, ", statbuf.st_size); 904 break; 905 } 906 if (!abbrev(tcp)) { 907 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); 908 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); 909 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime)); 910 } 911 else 912 tprints("...}"); 913} 914#endif /* POWERPC64 */ 915 916static const struct xlat fileflags[] = { 917 { 0, NULL }, 918}; 919 920static void 921realprintstat(struct tcb *tcp, struct stat *statbuf) 922{ 923 if (!abbrev(tcp)) { 924 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", 925 (unsigned long) major(statbuf->st_dev), 926 (unsigned long) minor(statbuf->st_dev), 927 (unsigned long) statbuf->st_ino, 928 sprintmode(statbuf->st_mode)); 929 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", 930 (unsigned long) statbuf->st_nlink, 931 (unsigned long) statbuf->st_uid, 932 (unsigned long) statbuf->st_gid); 933#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE 934 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize); 935#endif 936#ifdef HAVE_STRUCT_STAT_ST_BLOCKS 937 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks); 938#endif 939 } 940 else 941 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode)); 942 switch (statbuf->st_mode & S_IFMT) { 943 case S_IFCHR: case S_IFBLK: 944#ifdef HAVE_STRUCT_STAT_ST_RDEV 945 tprintf("st_rdev=makedev(%lu, %lu), ", 946 (unsigned long) major(statbuf->st_rdev), 947 (unsigned long) minor(statbuf->st_rdev)); 948#else /* !HAVE_STRUCT_STAT_ST_RDEV */ 949 tprintf("st_size=makedev(%lu, %lu), ", 950 (unsigned long) major(statbuf->st_size), 951 (unsigned long) minor(statbuf->st_size)); 952#endif /* !HAVE_STRUCT_STAT_ST_RDEV */ 953 break; 954 default: 955 tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size); 956 break; 957 } 958 if (!abbrev(tcp)) { 959 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime)); 960 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime)); 961 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime)); 962#if HAVE_STRUCT_STAT_ST_FLAGS 963 tprints(", st_flags="); 964 printflags(fileflags, statbuf->st_flags, "UF_???"); 965#endif 966#if HAVE_STRUCT_STAT_ST_ACLCNT 967 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt); 968#endif 969#if HAVE_STRUCT_STAT_ST_LEVEL 970 tprintf(", st_level=%ld", statbuf->st_level); 971#endif 972#if HAVE_STRUCT_STAT_ST_FSTYPE 973 tprintf(", st_fstype=%.*s", 974 (int) sizeof statbuf->st_fstype, statbuf->st_fstype); 975#endif 976#if HAVE_STRUCT_STAT_ST_GEN 977 tprintf(", st_gen=%u", statbuf->st_gen); 978#endif 979 tprints("}"); 980 } 981 else 982 tprints("...}"); 983} 984 985static void 986printstat(struct tcb *tcp, long addr) 987{ 988 struct stat statbuf; 989 990 if (!addr) { 991 tprints("NULL"); 992 return; 993 } 994 if (syserror(tcp) || !verbose(tcp)) { 995 tprintf("%#lx", addr); 996 return; 997 } 998 999#if defined(SPARC) || defined(SPARC64) 1000 if (current_personality == 1) { 1001 printstatsol(tcp, addr); 1002 return; 1003 } 1004#ifdef SPARC64 1005 else if (current_personality == 2) { 1006 printstat_sparc64(tcp, addr); 1007 return; 1008 } 1009#endif 1010#endif /* SPARC[64] */ 1011 1012#if defined POWERPC64 1013 if (current_personality == 1) { 1014 printstat_powerpc32(tcp, addr); 1015 return; 1016 } 1017#endif 1018 1019 if (umove(tcp, addr, &statbuf) < 0) { 1020 tprints("{...}"); 1021 return; 1022 } 1023 1024 realprintstat(tcp, &statbuf); 1025} 1026 1027#if !defined HAVE_STAT64 && defined X86_64 1028/* 1029 * Linux x86_64 has unified `struct stat' but its i386 biarch needs 1030 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'. 1031 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set. 1032 * __GNUC__ is needed for the required __attribute__ below. 1033 */ 1034struct stat64 { 1035 unsigned long long st_dev; 1036 unsigned char __pad0[4]; 1037 unsigned int __st_ino; 1038 unsigned int st_mode; 1039 unsigned int st_nlink; 1040 unsigned int st_uid; 1041 unsigned int st_gid; 1042 unsigned long long st_rdev; 1043 unsigned char __pad3[4]; 1044 long long st_size; 1045 unsigned int st_blksize; 1046 unsigned long long st_blocks; 1047 unsigned int st_atime; 1048 unsigned int st_atime_nsec; 1049 unsigned int st_mtime; 1050 unsigned int st_mtime_nsec; 1051 unsigned int st_ctime; 1052 unsigned int st_ctime_nsec; 1053 unsigned long long st_ino; 1054} __attribute__((packed)); 1055# define HAVE_STAT64 1 1056# define STAT64_SIZE 96 1057#endif 1058 1059#ifdef HAVE_STAT64 1060static void 1061printstat64(struct tcb *tcp, long addr) 1062{ 1063 struct stat64 statbuf; 1064 1065#ifdef STAT64_SIZE 1066 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]); 1067#endif 1068 1069 if (!addr) { 1070 tprints("NULL"); 1071 return; 1072 } 1073 if (syserror(tcp) || !verbose(tcp)) { 1074 tprintf("%#lx", addr); 1075 return; 1076 } 1077 1078#if defined(SPARC) || defined(SPARC64) 1079 if (current_personality == 1) { 1080 printstatsol(tcp, addr); 1081 return; 1082 } 1083# ifdef SPARC64 1084 else if (current_personality == 2) { 1085 printstat_sparc64(tcp, addr); 1086 return; 1087 } 1088# endif 1089#endif /* SPARC[64] */ 1090 1091#if defined X86_64 1092 if (current_personality != 1) { 1093 printstat(tcp, addr); 1094 return; 1095 } 1096#endif 1097 1098 if (umove(tcp, addr, &statbuf) < 0) { 1099 tprints("{...}"); 1100 return; 1101 } 1102 1103 if (!abbrev(tcp)) { 1104#ifdef HAVE_LONG_LONG 1105 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ", 1106#else 1107 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ", 1108#endif 1109 (unsigned long) major(statbuf.st_dev), 1110 (unsigned long) minor(statbuf.st_dev), 1111#ifdef HAVE_LONG_LONG 1112 (unsigned long long) statbuf.st_ino, 1113#else 1114 (unsigned long) statbuf.st_ino, 1115#endif 1116 sprintmode(statbuf.st_mode)); 1117 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", 1118 (unsigned long) statbuf.st_nlink, 1119 (unsigned long) statbuf.st_uid, 1120 (unsigned long) statbuf.st_gid); 1121#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE 1122 tprintf("st_blksize=%lu, ", 1123 (unsigned long) statbuf.st_blksize); 1124#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ 1125#ifdef HAVE_STRUCT_STAT_ST_BLOCKS 1126 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); 1127#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */ 1128 } 1129 else 1130 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); 1131 switch (statbuf.st_mode & S_IFMT) { 1132 case S_IFCHR: case S_IFBLK: 1133#ifdef HAVE_STRUCT_STAT_ST_RDEV 1134 tprintf("st_rdev=makedev(%lu, %lu), ", 1135 (unsigned long) major(statbuf.st_rdev), 1136 (unsigned long) minor(statbuf.st_rdev)); 1137#else /* !HAVE_STRUCT_STAT_ST_RDEV */ 1138 tprintf("st_size=makedev(%lu, %lu), ", 1139 (unsigned long) major(statbuf.st_size), 1140 (unsigned long) minor(statbuf.st_size)); 1141#endif /* !HAVE_STRUCT_STAT_ST_RDEV */ 1142 break; 1143 default: 1144#ifdef HAVE_LONG_LONG 1145 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size); 1146#else 1147 tprintf("st_size=%lu, ", (unsigned long) statbuf.st_size); 1148#endif 1149 break; 1150 } 1151 if (!abbrev(tcp)) { 1152 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); 1153 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); 1154 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime)); 1155#if HAVE_STRUCT_STAT_ST_FLAGS 1156 tprints(", st_flags="); 1157 printflags(fileflags, statbuf.st_flags, "UF_???"); 1158#endif 1159#if HAVE_STRUCT_STAT_ST_ACLCNT 1160 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt); 1161#endif 1162#if HAVE_STRUCT_STAT_ST_LEVEL 1163 tprintf(", st_level=%ld", statbuf.st_level); 1164#endif 1165#if HAVE_STRUCT_STAT_ST_FSTYPE 1166 tprintf(", st_fstype=%.*s", 1167 (int) sizeof statbuf.st_fstype, statbuf.st_fstype); 1168#endif 1169#if HAVE_STRUCT_STAT_ST_GEN 1170 tprintf(", st_gen=%u", statbuf.st_gen); 1171#endif 1172 tprints("}"); 1173 } 1174 else 1175 tprints("...}"); 1176} 1177#endif /* HAVE_STAT64 */ 1178 1179#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) 1180static void 1181convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf) 1182{ 1183 newbuf->st_dev = oldbuf->st_dev; 1184 newbuf->st_ino = oldbuf->st_ino; 1185 newbuf->st_mode = oldbuf->st_mode; 1186 newbuf->st_nlink = oldbuf->st_nlink; 1187 newbuf->st_uid = oldbuf->st_uid; 1188 newbuf->st_gid = oldbuf->st_gid; 1189 newbuf->st_rdev = oldbuf->st_rdev; 1190 newbuf->st_size = oldbuf->st_size; 1191 newbuf->st_atime = oldbuf->st_atime; 1192 newbuf->st_mtime = oldbuf->st_mtime; 1193 newbuf->st_ctime = oldbuf->st_ctime; 1194 newbuf->st_blksize = 0; /* not supported in old_stat */ 1195 newbuf->st_blocks = 0; /* not supported in old_stat */ 1196} 1197 1198static void 1199printoldstat(struct tcb *tcp, long addr) 1200{ 1201 struct __old_kernel_stat statbuf; 1202 struct stat newstatbuf; 1203 1204 if (!addr) { 1205 tprints("NULL"); 1206 return; 1207 } 1208 if (syserror(tcp) || !verbose(tcp)) { 1209 tprintf("%#lx", addr); 1210 return; 1211 } 1212 1213# if defined(SPARC) || defined(SPARC64) 1214 if (current_personality == 1) { 1215 printstatsol(tcp, addr); 1216 return; 1217 } 1218# endif 1219 1220 if (umove(tcp, addr, &statbuf) < 0) { 1221 tprints("{...}"); 1222 return; 1223 } 1224 1225 convertoldstat(&statbuf, &newstatbuf); 1226 realprintstat(tcp, &newstatbuf); 1227} 1228#endif 1229 1230int 1231sys_stat(struct tcb *tcp) 1232{ 1233 if (entering(tcp)) { 1234 printpath(tcp, tcp->u_arg[0]); 1235 tprints(", "); 1236 } else { 1237 printstat(tcp, tcp->u_arg[1]); 1238 } 1239 return 0; 1240} 1241 1242int 1243sys_stat64(struct tcb *tcp) 1244{ 1245#ifdef HAVE_STAT64 1246 if (entering(tcp)) { 1247 printpath(tcp, tcp->u_arg[0]); 1248 tprints(", "); 1249 } else { 1250 printstat64(tcp, tcp->u_arg[1]); 1251 } 1252 return 0; 1253#else 1254 return printargs(tcp); 1255#endif 1256} 1257 1258#ifndef AT_SYMLINK_NOFOLLOW 1259# define AT_SYMLINK_NOFOLLOW 0x100 1260#endif 1261#ifndef AT_REMOVEDIR 1262# define AT_REMOVEDIR 0x200 1263#endif 1264#ifndef AT_SYMLINK_FOLLOW 1265# define AT_SYMLINK_FOLLOW 0x400 1266#endif 1267#ifndef AT_NO_AUTOMOUNT 1268# define AT_NO_AUTOMOUNT 0x800 1269#endif 1270#ifndef AT_EMPTY_PATH 1271# define AT_EMPTY_PATH 0x1000 1272#endif 1273 1274static const struct xlat at_flags[] = { 1275 { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" }, 1276 { AT_REMOVEDIR, "AT_REMOVEDIR" }, 1277 { AT_SYMLINK_FOLLOW, "AT_SYMLINK_FOLLOW" }, 1278 { AT_NO_AUTOMOUNT, "AT_NO_AUTOMOUNT" }, 1279 { AT_EMPTY_PATH, "AT_EMPTY_PATH" }, 1280 { 0, NULL } 1281}; 1282 1283int 1284sys_newfstatat(struct tcb *tcp) 1285{ 1286 if (entering(tcp)) { 1287 print_dirfd(tcp, tcp->u_arg[0]); 1288 printpath(tcp, tcp->u_arg[1]); 1289 tprints(", "); 1290 } else { 1291#ifdef POWERPC64 1292 if (current_personality == 0) 1293 printstat(tcp, tcp->u_arg[2]); 1294 else 1295 printstat64(tcp, tcp->u_arg[2]); 1296#elif defined HAVE_STAT64 1297 printstat64(tcp, tcp->u_arg[2]); 1298#else 1299 printstat(tcp, tcp->u_arg[2]); 1300#endif 1301 tprints(", "); 1302 printflags(at_flags, tcp->u_arg[3], "AT_???"); 1303 } 1304 return 0; 1305} 1306 1307#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) 1308int 1309sys_oldstat(struct tcb *tcp) 1310{ 1311 if (entering(tcp)) { 1312 printpath(tcp, tcp->u_arg[0]); 1313 tprints(", "); 1314 } else { 1315 printoldstat(tcp, tcp->u_arg[1]); 1316 } 1317 return 0; 1318} 1319#endif 1320 1321int 1322sys_fstat(struct tcb *tcp) 1323{ 1324 if (entering(tcp)) { 1325 printfd(tcp, tcp->u_arg[0]); 1326 tprints(", "); 1327 } else { 1328 printstat(tcp, tcp->u_arg[1]); 1329 } 1330 return 0; 1331} 1332 1333int 1334sys_fstat64(struct tcb *tcp) 1335{ 1336#ifdef HAVE_STAT64 1337 if (entering(tcp)) { 1338 printfd(tcp, tcp->u_arg[0]); 1339 tprints(", "); 1340 } else { 1341 printstat64(tcp, tcp->u_arg[1]); 1342 } 1343 return 0; 1344#else 1345 return printargs(tcp); 1346#endif 1347} 1348 1349#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) 1350int 1351sys_oldfstat(struct tcb *tcp) 1352{ 1353 if (entering(tcp)) { 1354 printfd(tcp, tcp->u_arg[0]); 1355 tprints(", "); 1356 } else { 1357 printoldstat(tcp, tcp->u_arg[1]); 1358 } 1359 return 0; 1360} 1361#endif 1362 1363#if defined(SPARC) || defined(SPARC64) 1364 1365int 1366sys_xstat(struct tcb *tcp) 1367{ 1368 if (entering(tcp)) { 1369 tprintf("%ld, ", tcp->u_arg[0]); 1370 printpath(tcp, tcp->u_arg[1]); 1371 tprints(", "); 1372 } else { 1373# ifdef _STAT64_VER 1374 if (tcp->u_arg[0] == _STAT64_VER) 1375 printstat64(tcp, tcp->u_arg[2]); 1376 else 1377# endif 1378 printstat(tcp, tcp->u_arg[2]); 1379 } 1380 return 0; 1381} 1382 1383int 1384sys_fxstat(struct tcb *tcp) 1385{ 1386 if (entering(tcp)) 1387 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]); 1388 else { 1389# ifdef _STAT64_VER 1390 if (tcp->u_arg[0] == _STAT64_VER) 1391 printstat64(tcp, tcp->u_arg[2]); 1392 else 1393# endif 1394 printstat(tcp, tcp->u_arg[2]); 1395 } 1396 return 0; 1397} 1398 1399int 1400sys_lxstat(struct tcb *tcp) 1401{ 1402 if (entering(tcp)) { 1403 tprintf("%ld, ", tcp->u_arg[0]); 1404 printpath(tcp, tcp->u_arg[1]); 1405 tprints(", "); 1406 } else { 1407# ifdef _STAT64_VER 1408 if (tcp->u_arg[0] == _STAT64_VER) 1409 printstat64(tcp, tcp->u_arg[2]); 1410 else 1411# endif 1412 printstat(tcp, tcp->u_arg[2]); 1413 } 1414 return 0; 1415} 1416 1417int 1418sys_xmknod(struct tcb *tcp) 1419{ 1420 int mode = tcp->u_arg[2]; 1421 1422 if (entering(tcp)) { 1423 tprintf("%ld, ", tcp->u_arg[0]); 1424 printpath(tcp, tcp->u_arg[1]); 1425 tprintf(", %s", sprintmode(mode)); 1426 switch (mode & S_IFMT) { 1427 case S_IFCHR: case S_IFBLK: 1428 tprintf(", makedev(%lu, %lu)", 1429 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff), 1430 (unsigned long) (tcp->u_arg[3] & 0x3ffff)); 1431 break; 1432 default: 1433 break; 1434 } 1435 } 1436 return 0; 1437} 1438 1439# ifdef HAVE_SYS_ACL_H 1440 1441# include <sys/acl.h> 1442 1443static const struct xlat aclcmds[] = { 1444# ifdef SETACL 1445 { SETACL, "SETACL" }, 1446# endif 1447# ifdef GETACL 1448 { GETACL, "GETACL" }, 1449# endif 1450# ifdef GETACLCNT 1451 { GETACLCNT, "GETACLCNT" }, 1452# endif 1453# ifdef ACL_GET 1454 { ACL_GET, "ACL_GET" }, 1455# endif 1456# ifdef ACL_SET 1457 { ACL_SET, "ACL_SET" }, 1458# endif 1459# ifdef ACL_CNT 1460 { ACL_CNT, "ACL_CNT" }, 1461# endif 1462 { 0, NULL }, 1463}; 1464 1465int 1466sys_acl(struct tcb *tcp) 1467{ 1468 if (entering(tcp)) { 1469 printpath(tcp, tcp->u_arg[0]); 1470 tprints(", "); 1471 printxval(aclcmds, tcp->u_arg[1], "???ACL???"); 1472 tprintf(", %ld", tcp->u_arg[2]); 1473 /* 1474 * FIXME - dump out the list of aclent_t's pointed to 1475 * by "tcp->u_arg[3]" if it's not NULL. 1476 */ 1477 if (tcp->u_arg[3]) 1478 tprintf(", %#lx", tcp->u_arg[3]); 1479 else 1480 tprints(", NULL"); 1481 } 1482 return 0; 1483} 1484 1485int 1486sys_facl(struct tcb *tcp) 1487{ 1488 if (entering(tcp)) { 1489 tprintf("%ld, ", tcp->u_arg[0]); 1490 printxval(aclcmds, tcp->u_arg[1], "???ACL???"); 1491 tprintf(", %ld", tcp->u_arg[2]); 1492 /* 1493 * FIXME - dump out the list of aclent_t's pointed to 1494 * by "tcp->u_arg[3]" if it's not NULL. 1495 */ 1496 if (tcp->u_arg[3]) 1497 tprintf(", %#lx", tcp->u_arg[3]); 1498 else 1499 tprints(", NULL"); 1500 } 1501 return 0; 1502} 1503 1504static const struct xlat aclipc[] = { 1505# ifdef IPC_SHM 1506 { IPC_SHM, "IPC_SHM" }, 1507# endif 1508# ifdef IPC_SEM 1509 { IPC_SEM, "IPC_SEM" }, 1510# endif 1511# ifdef IPC_MSG 1512 { IPC_MSG, "IPC_MSG" }, 1513# endif 1514 { 0, NULL }, 1515}; 1516 1517int 1518sys_aclipc(struct tcb *tcp) 1519{ 1520 if (entering(tcp)) { 1521 printxval(aclipc, tcp->u_arg[0], "???IPC???"); 1522 tprintf(", %#lx, ", tcp->u_arg[1]); 1523 printxval(aclcmds, tcp->u_arg[2], "???ACL???"); 1524 tprintf(", %ld", tcp->u_arg[3]); 1525 /* 1526 * FIXME - dump out the list of aclent_t's pointed to 1527 * by "tcp->u_arg[4]" if it's not NULL. 1528 */ 1529 if (tcp->u_arg[4]) 1530 tprintf(", %#lx", tcp->u_arg[4]); 1531 else 1532 tprints(", NULL"); 1533 } 1534 return 0; 1535} 1536 1537# endif /* HAVE_SYS_ACL_H */ 1538 1539#endif /* SPARC[64] */ 1540 1541static const struct xlat fsmagic[] = { 1542 { 0x73757245, "CODA_SUPER_MAGIC" }, 1543 { 0x012ff7b7, "COH_SUPER_MAGIC" }, 1544 { 0x1373, "DEVFS_SUPER_MAGIC" }, 1545 { 0x1cd1, "DEVPTS_SUPER_MAGIC" }, 1546 { 0x414A53, "EFS_SUPER_MAGIC" }, 1547 { 0xef51, "EXT2_OLD_SUPER_MAGIC" }, 1548 { 0xef53, "EXT2_SUPER_MAGIC" }, 1549 { 0x137d, "EXT_SUPER_MAGIC" }, 1550 { 0xf995e849, "HPFS_SUPER_MAGIC" }, 1551 { 0x9660, "ISOFS_SUPER_MAGIC" }, 1552 { 0x137f, "MINIX_SUPER_MAGIC" }, 1553 { 0x138f, "MINIX_SUPER_MAGIC2" }, 1554 { 0x2468, "MINIX2_SUPER_MAGIC" }, 1555 { 0x2478, "MINIX2_SUPER_MAGIC2" }, 1556 { 0x4d44, "MSDOS_SUPER_MAGIC" }, 1557 { 0x564c, "NCP_SUPER_MAGIC" }, 1558 { 0x6969, "NFS_SUPER_MAGIC" }, 1559 { 0x9fa0, "PROC_SUPER_MAGIC" }, 1560 { 0x002f, "QNX4_SUPER_MAGIC" }, 1561 { 0x52654973, "REISERFS_SUPER_MAGIC" }, 1562 { 0x02011994, "SHMFS_SUPER_MAGIC" }, 1563 { 0x517b, "SMB_SUPER_MAGIC" }, 1564 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" }, 1565 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" }, 1566 { 0x00011954, "UFS_MAGIC" }, 1567 { 0x54190100, "UFS_CIGAM" }, 1568 { 0x012ff7b4, "XENIX_SUPER_MAGIC" }, 1569 { 0x012fd16d, "XIAFS_SUPER_MAGIC" }, 1570 { 0x62656572, "SYSFS_MAGIC" }, 1571 { 0, NULL }, 1572}; 1573 1574static const char * 1575sprintfstype(int magic) 1576{ 1577 static char buf[32]; 1578 const char *s; 1579 1580 s = xlookup(fsmagic, magic); 1581 if (s) { 1582 sprintf(buf, "\"%s\"", s); 1583 return buf; 1584 } 1585 sprintf(buf, "%#x", magic); 1586 return buf; 1587} 1588 1589static void 1590printstatfs(struct tcb *tcp, long addr) 1591{ 1592 struct statfs statbuf; 1593 1594 if (syserror(tcp) || !verbose(tcp)) { 1595 tprintf("%#lx", addr); 1596 return; 1597 } 1598 if (umove(tcp, addr, &statbuf) < 0) { 1599 tprints("{...}"); 1600 return; 1601 } 1602#ifdef ALPHA 1603 1604 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ", 1605 sprintfstype(statbuf.f_type), 1606 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree); 1607 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u", 1608 statbuf.f_bavail, statbuf.f_files, statbuf.f_ffree, 1609 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1], 1610 statbuf.f_namelen); 1611#else /* !ALPHA */ 1612 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ", 1613 sprintfstype(statbuf.f_type), 1614 (unsigned long)statbuf.f_bsize, 1615 (unsigned long)statbuf.f_blocks, 1616 (unsigned long)statbuf.f_bfree); 1617 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}", 1618 (unsigned long)statbuf.f_bavail, 1619 (unsigned long)statbuf.f_files, 1620 (unsigned long)statbuf.f_ffree, 1621 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]); 1622 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); 1623#endif /* !ALPHA */ 1624#ifdef _STATFS_F_FRSIZE 1625 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize); 1626#endif 1627 tprints("}"); 1628} 1629 1630int 1631sys_statfs(struct tcb *tcp) 1632{ 1633 if (entering(tcp)) { 1634 printpath(tcp, tcp->u_arg[0]); 1635 tprints(", "); 1636 } else { 1637 printstatfs(tcp, tcp->u_arg[1]); 1638 } 1639 return 0; 1640} 1641 1642int 1643sys_fstatfs(struct tcb *tcp) 1644{ 1645 if (entering(tcp)) { 1646 printfd(tcp, tcp->u_arg[0]); 1647 tprints(", "); 1648 } else { 1649 printstatfs(tcp, tcp->u_arg[1]); 1650 } 1651 return 0; 1652} 1653 1654#if defined HAVE_STATFS64 1655static void 1656printstatfs64(struct tcb *tcp, long addr) 1657{ 1658 struct statfs64 statbuf; 1659 1660 if (syserror(tcp) || !verbose(tcp)) { 1661 tprintf("%#lx", addr); 1662 return; 1663 } 1664 if (umove(tcp, addr, &statbuf) < 0) { 1665 tprints("{...}"); 1666 return; 1667 } 1668 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ", 1669 sprintfstype(statbuf.f_type), 1670 (unsigned long long)statbuf.f_bsize, 1671 (unsigned long long)statbuf.f_blocks, 1672 (unsigned long long)statbuf.f_bfree); 1673 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}", 1674 (unsigned long long)statbuf.f_bavail, 1675 (unsigned long long)statbuf.f_files, 1676 (unsigned long long)statbuf.f_ffree, 1677 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]); 1678 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); 1679#ifdef _STATFS_F_FRSIZE 1680 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize); 1681#endif 1682#ifdef _STATFS_F_FLAGS 1683 tprintf(", f_flags=%llu", (unsigned long long)statbuf.f_flags); 1684#endif 1685 tprints("}"); 1686} 1687 1688struct compat_statfs64 { 1689 uint32_t f_type; 1690 uint32_t f_bsize; 1691 uint64_t f_blocks; 1692 uint64_t f_bfree; 1693 uint64_t f_bavail; 1694 uint64_t f_files; 1695 uint64_t f_ffree; 1696 fsid_t f_fsid; 1697 uint32_t f_namelen; 1698 uint32_t f_frsize; 1699 uint32_t f_flags; 1700 uint32_t f_spare[4]; 1701} 1702#if defined(X86_64) || defined(IA64) 1703 __attribute__ ((packed, aligned(4))) 1704#endif 1705; 1706 1707static void 1708printcompat_statfs64(struct tcb *tcp, long addr) 1709{ 1710 struct compat_statfs64 statbuf; 1711 1712 if (syserror(tcp) || !verbose(tcp)) { 1713 tprintf("%#lx", addr); 1714 return; 1715 } 1716 if (umove(tcp, addr, &statbuf) < 0) { 1717 tprints("{...}"); 1718 return; 1719 } 1720 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%llu, f_bfree=%llu, ", 1721 sprintfstype(statbuf.f_type), 1722 (unsigned long)statbuf.f_bsize, 1723 (unsigned long long)statbuf.f_blocks, 1724 (unsigned long long)statbuf.f_bfree); 1725 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}", 1726 (unsigned long long)statbuf.f_bavail, 1727 (unsigned long long)statbuf.f_files, 1728 (unsigned long long)statbuf.f_ffree, 1729 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]); 1730 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); 1731 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize); 1732 tprintf(", f_flags=%lu}", (unsigned long)statbuf.f_frsize); 1733} 1734 1735int 1736sys_statfs64(struct tcb *tcp) 1737{ 1738 if (entering(tcp)) { 1739 printpath(tcp, tcp->u_arg[0]); 1740 tprintf(", %lu, ", tcp->u_arg[1]); 1741 } else { 1742 if (tcp->u_arg[1] == sizeof(struct statfs64)) 1743 printstatfs64(tcp, tcp->u_arg[2]); 1744 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64)) 1745 printcompat_statfs64(tcp, tcp->u_arg[2]); 1746 else 1747 tprints("{???}"); 1748 } 1749 return 0; 1750} 1751 1752int 1753sys_fstatfs64(struct tcb *tcp) 1754{ 1755 if (entering(tcp)) { 1756 printfd(tcp, tcp->u_arg[0]); 1757 tprintf(", %lu, ", tcp->u_arg[1]); 1758 } else { 1759 if (tcp->u_arg[1] == sizeof(struct statfs64)) 1760 printstatfs64(tcp, tcp->u_arg[2]); 1761 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64)) 1762 printcompat_statfs64(tcp, tcp->u_arg[2]); 1763 else 1764 tprints("{???}"); 1765 } 1766 return 0; 1767} 1768#endif 1769 1770#if defined(ALPHA) 1771int 1772osf_statfs(struct tcb *tcp) 1773{ 1774 if (entering(tcp)) { 1775 printpath(tcp, tcp->u_arg[0]); 1776 tprints(", "); 1777 } else { 1778 printstatfs(tcp, tcp->u_arg[1]); 1779 tprintf(", %lu", tcp->u_arg[2]); 1780 } 1781 return 0; 1782} 1783 1784int 1785osf_fstatfs(struct tcb *tcp) 1786{ 1787 if (entering(tcp)) { 1788 tprintf("%lu, ", tcp->u_arg[0]); 1789 } else { 1790 printstatfs(tcp, tcp->u_arg[1]); 1791 tprintf(", %lu", tcp->u_arg[2]); 1792 } 1793 return 0; 1794} 1795#endif 1796 1797/* directory */ 1798int 1799sys_chdir(struct tcb *tcp) 1800{ 1801 if (entering(tcp)) { 1802 printpath(tcp, tcp->u_arg[0]); 1803 } 1804 return 0; 1805} 1806 1807static int 1808decode_mkdir(struct tcb *tcp, int offset) 1809{ 1810 if (entering(tcp)) { 1811 printpath(tcp, tcp->u_arg[offset]); 1812 tprintf(", %#lo", tcp->u_arg[offset + 1]); 1813 } 1814 return 0; 1815} 1816 1817int 1818sys_mkdir(struct tcb *tcp) 1819{ 1820 return decode_mkdir(tcp, 0); 1821} 1822 1823int 1824sys_mkdirat(struct tcb *tcp) 1825{ 1826 if (entering(tcp)) 1827 print_dirfd(tcp, tcp->u_arg[0]); 1828 return decode_mkdir(tcp, 1); 1829} 1830 1831int 1832sys_link(struct tcb *tcp) 1833{ 1834 if (entering(tcp)) { 1835 printpath(tcp, tcp->u_arg[0]); 1836 tprints(", "); 1837 printpath(tcp, tcp->u_arg[1]); 1838 } 1839 return 0; 1840} 1841 1842int 1843sys_linkat(struct tcb *tcp) 1844{ 1845 if (entering(tcp)) { 1846 print_dirfd(tcp, tcp->u_arg[0]); 1847 printpath(tcp, tcp->u_arg[1]); 1848 tprints(", "); 1849 print_dirfd(tcp, tcp->u_arg[2]); 1850 printpath(tcp, tcp->u_arg[3]); 1851 tprints(", "); 1852 printflags(at_flags, tcp->u_arg[4], "AT_???"); 1853 } 1854 return 0; 1855} 1856 1857int 1858sys_unlinkat(struct tcb *tcp) 1859{ 1860 if (entering(tcp)) { 1861 print_dirfd(tcp, tcp->u_arg[0]); 1862 printpath(tcp, tcp->u_arg[1]); 1863 tprints(", "); 1864 printflags(at_flags, tcp->u_arg[2], "AT_???"); 1865 } 1866 return 0; 1867} 1868 1869int 1870sys_symlinkat(struct tcb *tcp) 1871{ 1872 if (entering(tcp)) { 1873 printpath(tcp, tcp->u_arg[0]); 1874 tprints(", "); 1875 print_dirfd(tcp, tcp->u_arg[1]); 1876 printpath(tcp, tcp->u_arg[2]); 1877 } 1878 return 0; 1879} 1880 1881static int 1882decode_readlink(struct tcb *tcp, int offset) 1883{ 1884 if (entering(tcp)) { 1885 printpath(tcp, tcp->u_arg[offset]); 1886 tprints(", "); 1887 } else { 1888 if (syserror(tcp)) 1889 tprintf("%#lx", tcp->u_arg[offset + 1]); 1890 else 1891 /* Used to use printpathn(), but readlink 1892 * neither includes NUL in the returned count, 1893 * nor actually writes it into memory. 1894 * printpathn() would decide on printing 1895 * "..." continuation based on garbage 1896 * past return buffer's end. 1897 */ 1898 printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval); 1899 tprintf(", %lu", tcp->u_arg[offset + 2]); 1900 } 1901 return 0; 1902} 1903 1904int 1905sys_readlink(struct tcb *tcp) 1906{ 1907 return decode_readlink(tcp, 0); 1908} 1909 1910int 1911sys_readlinkat(struct tcb *tcp) 1912{ 1913 if (entering(tcp)) 1914 print_dirfd(tcp, tcp->u_arg[0]); 1915 return decode_readlink(tcp, 1); 1916} 1917 1918int 1919sys_renameat(struct tcb *tcp) 1920{ 1921 if (entering(tcp)) { 1922 print_dirfd(tcp, tcp->u_arg[0]); 1923 printpath(tcp, tcp->u_arg[1]); 1924 tprints(", "); 1925 print_dirfd(tcp, tcp->u_arg[2]); 1926 printpath(tcp, tcp->u_arg[3]); 1927 } 1928 return 0; 1929} 1930 1931int 1932sys_chown(struct tcb *tcp) 1933{ 1934 if (entering(tcp)) { 1935 printpath(tcp, tcp->u_arg[0]); 1936 printuid(", ", tcp->u_arg[1]); 1937 printuid(", ", tcp->u_arg[2]); 1938 } 1939 return 0; 1940} 1941 1942int 1943sys_fchownat(struct tcb *tcp) 1944{ 1945 if (entering(tcp)) { 1946 print_dirfd(tcp, tcp->u_arg[0]); 1947 printpath(tcp, tcp->u_arg[1]); 1948 printuid(", ", tcp->u_arg[2]); 1949 printuid(", ", tcp->u_arg[3]); 1950 tprints(", "); 1951 printflags(at_flags, tcp->u_arg[4], "AT_???"); 1952 } 1953 return 0; 1954} 1955 1956int 1957sys_fchown(struct tcb *tcp) 1958{ 1959 if (entering(tcp)) { 1960 printfd(tcp, tcp->u_arg[0]); 1961 printuid(", ", tcp->u_arg[1]); 1962 printuid(", ", tcp->u_arg[2]); 1963 } 1964 return 0; 1965} 1966 1967static int 1968decode_chmod(struct tcb *tcp, int offset) 1969{ 1970 if (entering(tcp)) { 1971 printpath(tcp, tcp->u_arg[offset]); 1972 tprintf(", %#lo", tcp->u_arg[offset + 1]); 1973 } 1974 return 0; 1975} 1976 1977int 1978sys_chmod(struct tcb *tcp) 1979{ 1980 return decode_chmod(tcp, 0); 1981} 1982 1983int 1984sys_fchmodat(struct tcb *tcp) 1985{ 1986 if (entering(tcp)) 1987 print_dirfd(tcp, tcp->u_arg[0]); 1988 return decode_chmod(tcp, 1); 1989} 1990 1991int 1992sys_fchmod(struct tcb *tcp) 1993{ 1994 if (entering(tcp)) { 1995 printfd(tcp, tcp->u_arg[0]); 1996 tprintf(", %#lo", tcp->u_arg[1]); 1997 } 1998 return 0; 1999} 2000 2001#ifdef ALPHA 2002int 2003sys_osf_utimes(struct tcb *tcp) 2004{ 2005 if (entering(tcp)) { 2006 printpath(tcp, tcp->u_arg[0]); 2007 tprints(", "); 2008 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); 2009 } 2010 return 0; 2011} 2012#endif 2013 2014static int 2015decode_utimes(struct tcb *tcp, int offset, int special) 2016{ 2017 if (entering(tcp)) { 2018 printpath(tcp, tcp->u_arg[offset]); 2019 tprints(", "); 2020 if (tcp->u_arg[offset + 1] == 0) 2021 tprints("NULL"); 2022 else { 2023 tprints("{"); 2024 printtv_bitness(tcp, tcp->u_arg[offset + 1], 2025 BITNESS_CURRENT, special); 2026 tprints(", "); 2027 printtv_bitness(tcp, tcp->u_arg[offset + 1] 2028 + sizeof(struct timeval), 2029 BITNESS_CURRENT, special); 2030 tprints("}"); 2031 } 2032 } 2033 return 0; 2034} 2035 2036int 2037sys_utimes(struct tcb *tcp) 2038{ 2039 return decode_utimes(tcp, 0, 0); 2040} 2041 2042int 2043sys_futimesat(struct tcb *tcp) 2044{ 2045 if (entering(tcp)) 2046 print_dirfd(tcp, tcp->u_arg[0]); 2047 return decode_utimes(tcp, 1, 0); 2048} 2049 2050int 2051sys_utimensat(struct tcb *tcp) 2052{ 2053 if (entering(tcp)) { 2054 print_dirfd(tcp, tcp->u_arg[0]); 2055 decode_utimes(tcp, 1, 1); 2056 tprints(", "); 2057 printflags(at_flags, tcp->u_arg[3], "AT_???"); 2058 } 2059 return 0; 2060} 2061 2062int 2063sys_utime(struct tcb *tcp) 2064{ 2065 union { 2066 long utl[2]; 2067 int uti[2]; 2068 long paranoia_for_huge_wordsize[4]; 2069 } u; 2070 unsigned wordsize; 2071 2072 if (entering(tcp)) { 2073 printpath(tcp, tcp->u_arg[0]); 2074 tprints(", "); 2075 2076 wordsize = current_wordsize; 2077 if (!tcp->u_arg[1]) 2078 tprints("NULL"); 2079 else if (!verbose(tcp)) 2080 tprintf("%#lx", tcp->u_arg[1]); 2081 else if (umoven(tcp, tcp->u_arg[1], 2 * wordsize, (char *) &u) < 0) 2082 tprints("[?, ?]"); 2083 else if (wordsize == sizeof u.utl[0]) { 2084 tprintf("[%s,", sprinttime(u.utl[0])); 2085 tprintf(" %s]", sprinttime(u.utl[1])); 2086 } 2087 else if (wordsize == sizeof u.uti[0]) { 2088 tprintf("[%s,", sprinttime(u.uti[0])); 2089 tprintf(" %s]", sprinttime(u.uti[1])); 2090 } 2091 else 2092 tprintf("<decode error: unsupported wordsize %d>", 2093 wordsize); 2094 } 2095 return 0; 2096} 2097 2098static int 2099decode_mknod(struct tcb *tcp, int offset) 2100{ 2101 int mode = tcp->u_arg[offset + 1]; 2102 2103 if (entering(tcp)) { 2104 printpath(tcp, tcp->u_arg[offset]); 2105 tprintf(", %s", sprintmode(mode)); 2106 switch (mode & S_IFMT) { 2107 case S_IFCHR: 2108 case S_IFBLK: 2109#if defined(SPARC) || defined(SPARC64) 2110 if (current_personality == 1) 2111 tprintf(", makedev(%lu, %lu)", 2112 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff), 2113 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff)); 2114 else 2115#endif 2116 tprintf(", makedev(%lu, %lu)", 2117 (unsigned long) major(tcp->u_arg[offset + 2]), 2118 (unsigned long) minor(tcp->u_arg[offset + 2])); 2119 break; 2120 default: 2121 break; 2122 } 2123 } 2124 return 0; 2125} 2126 2127int 2128sys_mknod(struct tcb *tcp) 2129{ 2130 return decode_mknod(tcp, 0); 2131} 2132 2133int 2134sys_mknodat(struct tcb *tcp) 2135{ 2136 if (entering(tcp)) 2137 print_dirfd(tcp, tcp->u_arg[0]); 2138 return decode_mknod(tcp, 1); 2139} 2140 2141static void 2142print_old_dirent(struct tcb *tcp, long addr) 2143{ 2144#ifdef SH64 2145 typedef struct kernel_dirent old_dirent_t; 2146#else 2147 typedef struct { 2148 uint32_t d_ino; 2149 uint32_t d_off; 2150 unsigned short d_reclen; 2151 char d_name[1]; 2152 } old_dirent_t; 2153#endif 2154 old_dirent_t d; 2155 2156 if (!verbose(tcp) || umove(tcp, addr, &d) < 0) { 2157 tprintf("%#lx", addr); 2158 return; 2159 } 2160 2161 tprintf("{d_ino=%lu, d_off=%lu, d_reclen=%u, d_name=\"", 2162 (unsigned long) d.d_ino, (unsigned long) d.d_off, d.d_reclen); 2163 if (d.d_reclen > 256) 2164 d.d_reclen = 256; 2165 printpathn(tcp, addr + offsetof(old_dirent_t, d_name), d.d_reclen); 2166 tprints("\"}"); 2167} 2168 2169int 2170sys_readdir(struct tcb *tcp) 2171{ 2172 if (entering(tcp)) { 2173 printfd(tcp, tcp->u_arg[0]); 2174 tprints(", "); 2175 } else { 2176 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp)) 2177 tprintf("%#lx", tcp->u_arg[1]); 2178 else 2179 print_old_dirent(tcp, tcp->u_arg[1]); 2180 /* Not much point in printing this out, it is always 1. */ 2181 if (tcp->u_arg[2] != 1) 2182 tprintf(", %lu", tcp->u_arg[2]); 2183 } 2184 return 0; 2185} 2186 2187static const struct xlat direnttypes[] = { 2188 { DT_UNKNOWN, "DT_UNKNOWN" }, 2189 { DT_FIFO, "DT_FIFO" }, 2190 { DT_CHR, "DT_CHR" }, 2191 { DT_DIR, "DT_DIR" }, 2192 { DT_BLK, "DT_BLK" }, 2193 { DT_REG, "DT_REG" }, 2194 { DT_LNK, "DT_LNK" }, 2195 { DT_SOCK, "DT_SOCK" }, 2196 { DT_WHT, "DT_WHT" }, 2197 { 0, NULL }, 2198}; 2199 2200int 2201sys_getdents(struct tcb *tcp) 2202{ 2203 int i, len, dents = 0; 2204 char *buf; 2205 2206 if (entering(tcp)) { 2207 printfd(tcp, tcp->u_arg[0]); 2208 tprints(", "); 2209 return 0; 2210 } 2211 if (syserror(tcp) || !verbose(tcp)) { 2212 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); 2213 return 0; 2214 } 2215 len = tcp->u_rval; 2216 /* Beware of insanely large or negative values in tcp->u_rval */ 2217 if (tcp->u_rval > 1024*1024) 2218 len = 1024*1024; 2219 if (tcp->u_rval < 0) 2220 len = 0; 2221 buf = len ? malloc(len) : NULL; 2222 if (len && !buf) 2223 die_out_of_memory(); 2224 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { 2225 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); 2226 free(buf); 2227 return 0; 2228 } 2229 if (!abbrev(tcp)) 2230 tprints("{"); 2231 for (i = 0; i < len;) { 2232 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i]; 2233 if (!abbrev(tcp)) { 2234 tprintf("%s{d_ino=%lu, d_off=%lu, ", 2235 i ? " " : "", d->d_ino, d->d_off); 2236 tprintf("d_reclen=%u, d_name=\"%s\", d_type=", 2237 d->d_reclen, d->d_name); 2238 printxval(direnttypes, buf[i + d->d_reclen - 1], "DT_???"); 2239 tprints("}"); 2240 } 2241 if (!d->d_reclen) { 2242 tprints("/* d_reclen == 0, problem here */"); 2243 break; 2244 } 2245 i += d->d_reclen; 2246 dents++; 2247 } 2248 if (!abbrev(tcp)) 2249 tprints("}"); 2250 else 2251 tprintf("/* %u entries */", dents); 2252 tprintf(", %lu", tcp->u_arg[2]); 2253 free(buf); 2254 return 0; 2255} 2256 2257#if _LFS64_LARGEFILE 2258int 2259sys_getdents64(struct tcb *tcp) 2260{ 2261 int i, len, dents = 0; 2262 char *buf; 2263 2264 if (entering(tcp)) { 2265 printfd(tcp, tcp->u_arg[0]); 2266 tprints(", "); 2267 return 0; 2268 } 2269 if (syserror(tcp) || !verbose(tcp)) { 2270 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); 2271 return 0; 2272 } 2273 2274 len = tcp->u_rval; 2275 /* Beware of insanely large or negative tcp->u_rval */ 2276 if (tcp->u_rval > 1024*1024) 2277 len = 1024*1024; 2278 if (tcp->u_rval < 0) 2279 len = 0; 2280 buf = len ? malloc(len) : NULL; 2281 if (len && !buf) 2282 die_out_of_memory(); 2283 2284 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { 2285 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); 2286 free(buf); 2287 return 0; 2288 } 2289 if (!abbrev(tcp)) 2290 tprints("{"); 2291 for (i = 0; i < len;) { 2292 struct dirent64 *d = (struct dirent64 *) &buf[i]; 2293 if (!abbrev(tcp)) { 2294 tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ", 2295 i ? " " : "", 2296 d->d_ino, 2297 d->d_off); 2298 tprints("d_type="); 2299 printxval(direnttypes, d->d_type, "DT_???"); 2300 tprints(", "); 2301 tprintf("d_reclen=%u, d_name=\"%s\"}", 2302 d->d_reclen, d->d_name); 2303 } 2304 if (!d->d_reclen) { 2305 tprints("/* d_reclen == 0, problem here */"); 2306 break; 2307 } 2308 i += d->d_reclen; 2309 dents++; 2310 } 2311 if (!abbrev(tcp)) 2312 tprints("}"); 2313 else 2314 tprintf("/* %u entries */", dents); 2315 tprintf(", %lu", tcp->u_arg[2]); 2316 free(buf); 2317 return 0; 2318} 2319#endif 2320 2321int 2322sys_getcwd(struct tcb *tcp) 2323{ 2324 if (exiting(tcp)) { 2325 if (syserror(tcp)) 2326 tprintf("%#lx", tcp->u_arg[0]); 2327 else 2328 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1); 2329 tprintf(", %lu", tcp->u_arg[1]); 2330 } 2331 return 0; 2332} 2333 2334#ifdef HAVE_SYS_ASYNCH_H 2335 2336int 2337sys_aioread(struct tcb *tcp) 2338{ 2339 struct aio_result_t res; 2340 2341 if (entering(tcp)) { 2342 tprintf("%lu, ", tcp->u_arg[0]); 2343 } else { 2344 if (syserror(tcp)) 2345 tprintf("%#lx", tcp->u_arg[1]); 2346 else 2347 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); 2348 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]); 2349 printxval(whence, tcp->u_arg[4], "L_???"); 2350 if (syserror(tcp) || tcp->u_arg[5] == 0 2351 || umove(tcp, tcp->u_arg[5], &res) < 0) 2352 tprintf(", %#lx", tcp->u_arg[5]); 2353 else 2354 tprintf(", {aio_return %d aio_errno %d}", 2355 res.aio_return, res.aio_errno); 2356 } 2357 return 0; 2358} 2359 2360int 2361sys_aiowrite(struct tcb *tcp) 2362{ 2363 struct aio_result_t res; 2364 2365 if (entering(tcp)) { 2366 tprintf("%lu, ", tcp->u_arg[0]); 2367 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); 2368 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]); 2369 printxval(whence, tcp->u_arg[4], "L_???"); 2370 } 2371 else { 2372 if (tcp->u_arg[5] == 0) 2373 tprints(", NULL"); 2374 else if (syserror(tcp) 2375 || umove(tcp, tcp->u_arg[5], &res) < 0) 2376 tprintf(", %#lx", tcp->u_arg[5]); 2377 else 2378 tprintf(", {aio_return %d aio_errno %d}", 2379 res.aio_return, res.aio_errno); 2380 } 2381 return 0; 2382} 2383 2384int 2385sys_aiowait(struct tcb *tcp) 2386{ 2387 if (entering(tcp)) 2388 printtv(tcp, tcp->u_arg[0]); 2389 return 0; 2390} 2391 2392int 2393sys_aiocancel(struct tcb *tcp) 2394{ 2395 struct aio_result_t res; 2396 2397 if (exiting(tcp)) { 2398 if (tcp->u_arg[0] == 0) 2399 tprints("NULL"); 2400 else if (syserror(tcp) 2401 || umove(tcp, tcp->u_arg[0], &res) < 0) 2402 tprintf("%#lx", tcp->u_arg[0]); 2403 else 2404 tprintf("{aio_return %d aio_errno %d}", 2405 res.aio_return, res.aio_errno); 2406 } 2407 return 0; 2408} 2409 2410#endif /* HAVE_SYS_ASYNCH_H */ 2411 2412static const struct xlat xattrflags[] = { 2413#ifdef XATTR_CREATE 2414 { XATTR_CREATE, "XATTR_CREATE" }, 2415 { XATTR_REPLACE, "XATTR_REPLACE" }, 2416#endif 2417 { 0, NULL } 2418}; 2419 2420static void 2421print_xattr_val(struct tcb *tcp, int failed, 2422 unsigned long arg, 2423 unsigned long insize, 2424 unsigned long size) 2425{ 2426 if (insize == 0) 2427 failed = 1; 2428 if (!failed) { 2429 unsigned long capacity = 4 * size + 1; 2430 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity); 2431 if (buf == NULL || /* probably a bogus size argument */ 2432 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) { 2433 failed = 1; 2434 } 2435 else { 2436 unsigned char *out = buf; 2437 unsigned char *in = &buf[3 * size]; 2438 size_t i; 2439 for (i = 0; i < size; ++i) { 2440 if (in[i] >= ' ' && in[i] <= 0x7e) 2441 *out++ = in[i]; 2442 else { 2443#define tohex(n) "0123456789abcdef"[n] 2444 *out++ = '\\'; 2445 *out++ = 'x'; 2446 *out++ = tohex(in[i] / 16); 2447 *out++ = tohex(in[i] % 16); 2448 } 2449 } 2450 /* Don't print terminating NUL if there is one. */ 2451 if (i > 0 && in[i - 1] == '\0') 2452 out -= 4; 2453 *out = '\0'; 2454 tprintf(", \"%s\", %ld", buf, insize); 2455 } 2456 free(buf); 2457 } 2458 if (failed) 2459 tprintf(", 0x%lx, %ld", arg, insize); 2460} 2461 2462int 2463sys_setxattr(struct tcb *tcp) 2464{ 2465 if (entering(tcp)) { 2466 printpath(tcp, tcp->u_arg[0]); 2467 tprints(", "); 2468 printstr(tcp, tcp->u_arg[1], -1); 2469 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]); 2470 tprints(", "); 2471 printflags(xattrflags, tcp->u_arg[4], "XATTR_???"); 2472 } 2473 return 0; 2474} 2475 2476int 2477sys_fsetxattr(struct tcb *tcp) 2478{ 2479 if (entering(tcp)) { 2480 printfd(tcp, tcp->u_arg[0]); 2481 tprints(", "); 2482 printstr(tcp, tcp->u_arg[1], -1); 2483 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]); 2484 tprints(", "); 2485 printflags(xattrflags, tcp->u_arg[4], "XATTR_???"); 2486 } 2487 return 0; 2488} 2489 2490int 2491sys_getxattr(struct tcb *tcp) 2492{ 2493 if (entering(tcp)) { 2494 printpath(tcp, tcp->u_arg[0]); 2495 tprints(", "); 2496 printstr(tcp, tcp->u_arg[1], -1); 2497 } else { 2498 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3], 2499 tcp->u_rval); 2500 } 2501 return 0; 2502} 2503 2504int 2505sys_fgetxattr(struct tcb *tcp) 2506{ 2507 if (entering(tcp)) { 2508 printfd(tcp, tcp->u_arg[0]); 2509 tprints(", "); 2510 printstr(tcp, tcp->u_arg[1], -1); 2511 } else { 2512 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3], 2513 tcp->u_rval); 2514 } 2515 return 0; 2516} 2517 2518static void 2519print_xattr_list(struct tcb *tcp, unsigned long addr, unsigned long size) 2520{ 2521 if (syserror(tcp)) { 2522 tprintf("%#lx", addr); 2523 } else { 2524 if (!addr) { 2525 tprints("NULL"); 2526 } else { 2527 unsigned long len = 2528 (size < tcp->u_rval) ? size : tcp->u_rval; 2529 printstr(tcp, addr, len); 2530 } 2531 } 2532 tprintf(", %lu", size); 2533} 2534 2535int 2536sys_listxattr(struct tcb *tcp) 2537{ 2538 if (entering(tcp)) { 2539 printpath(tcp, tcp->u_arg[0]); 2540 tprints(", "); 2541 } else { 2542 print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]); 2543 } 2544 return 0; 2545} 2546 2547int 2548sys_flistxattr(struct tcb *tcp) 2549{ 2550 if (entering(tcp)) { 2551 printfd(tcp, tcp->u_arg[0]); 2552 tprints(", "); 2553 } else { 2554 print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]); 2555 } 2556 return 0; 2557} 2558 2559int 2560sys_removexattr(struct tcb *tcp) 2561{ 2562 if (entering(tcp)) { 2563 printpath(tcp, tcp->u_arg[0]); 2564 tprints(", "); 2565 printstr(tcp, tcp->u_arg[1], -1); 2566 } 2567 return 0; 2568} 2569 2570int 2571sys_fremovexattr(struct tcb *tcp) 2572{ 2573 if (entering(tcp)) { 2574 printfd(tcp, tcp->u_arg[0]); 2575 tprints(", "); 2576 printstr(tcp, tcp->u_arg[1], -1); 2577 } 2578 return 0; 2579} 2580 2581static const struct xlat advise[] = { 2582 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" }, 2583 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" }, 2584 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" }, 2585 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" }, 2586 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" }, 2587 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" }, 2588 { 0, NULL } 2589}; 2590 2591int 2592sys_fadvise64(struct tcb *tcp) 2593{ 2594 if (entering(tcp)) { 2595 int argn; 2596 printfd(tcp, tcp->u_arg[0]); 2597 argn = printllval(tcp, ", %lld", 1); 2598 tprintf(", %ld, ", tcp->u_arg[argn++]); 2599 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???"); 2600 } 2601 return 0; 2602} 2603 2604int 2605sys_fadvise64_64(struct tcb *tcp) 2606{ 2607 if (entering(tcp)) { 2608 int argn; 2609 printfd(tcp, tcp->u_arg[0]); 2610#if defined ARM || defined POWERPC 2611 argn = printllval(tcp, ", %lld, ", 2); 2612#else 2613 argn = printllval(tcp, ", %lld, ", 1); 2614#endif 2615 argn = printllval(tcp, "%lld, ", argn); 2616#if defined ARM || defined POWERPC 2617 printxval(advise, tcp->u_arg[1], "POSIX_FADV_???"); 2618#else 2619 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???"); 2620#endif 2621 } 2622 return 0; 2623} 2624 2625static const struct xlat inotify_modes[] = { 2626 { 0x00000001, "IN_ACCESS" }, 2627 { 0x00000002, "IN_MODIFY" }, 2628 { 0x00000004, "IN_ATTRIB" }, 2629 { 0x00000008, "IN_CLOSE_WRITE"}, 2630 { 0x00000010, "IN_CLOSE_NOWRITE"}, 2631 { 0x00000020, "IN_OPEN" }, 2632 { 0x00000040, "IN_MOVED_FROM" }, 2633 { 0x00000080, "IN_MOVED_TO" }, 2634 { 0x00000100, "IN_CREATE" }, 2635 { 0x00000200, "IN_DELETE" }, 2636 { 0x00000400, "IN_DELETE_SELF"}, 2637 { 0x00000800, "IN_MOVE_SELF" }, 2638 { 0x00002000, "IN_UNMOUNT" }, 2639 { 0x00004000, "IN_Q_OVERFLOW" }, 2640 { 0x00008000, "IN_IGNORED" }, 2641 { 0x01000000, "IN_ONLYDIR" }, 2642 { 0x02000000, "IN_DONT_FOLLOW"}, 2643 { 0x20000000, "IN_MASK_ADD" }, 2644 { 0x40000000, "IN_ISDIR" }, 2645 { 0x80000000, "IN_ONESHOT" }, 2646 { 0, NULL } 2647}; 2648 2649static const struct xlat inotify_init_flags[] = { 2650 { 0x00000800, "IN_NONBLOCK" }, 2651 { 0x00080000, "IN_CLOEXEC" }, 2652 { 0, NULL } 2653}; 2654 2655int 2656sys_inotify_add_watch(struct tcb *tcp) 2657{ 2658 if (entering(tcp)) { 2659 printfd(tcp, tcp->u_arg[0]); 2660 tprints(", "); 2661 printpath(tcp, tcp->u_arg[1]); 2662 tprints(", "); 2663 printflags(inotify_modes, tcp->u_arg[2], "IN_???"); 2664 } 2665 return 0; 2666} 2667 2668int 2669sys_inotify_rm_watch(struct tcb *tcp) 2670{ 2671 if (entering(tcp)) { 2672 printfd(tcp, tcp->u_arg[0]); 2673 tprintf(", %d", (int) tcp->u_arg[1]); 2674 } 2675 return 0; 2676} 2677 2678int 2679sys_inotify_init1(struct tcb *tcp) 2680{ 2681 if (entering(tcp)) 2682 printflags(inotify_init_flags, tcp->u_arg[0], "IN_???"); 2683 return 0; 2684} 2685 2686int 2687sys_fallocate(struct tcb *tcp) 2688{ 2689 if (entering(tcp)) { 2690 int argn; 2691 printfd(tcp, tcp->u_arg[0]); /* fd */ 2692 tprintf(", %#lo, ", tcp->u_arg[1]); /* mode */ 2693 argn = printllval(tcp, "%llu, ", 2); /* offset */ 2694 printllval(tcp, "%llu", argn); /* len */ 2695 } 2696 return 0; 2697} 2698 2699#ifndef SWAP_FLAG_PREFER 2700# define SWAP_FLAG_PREFER 0x8000 2701#endif 2702#ifndef SWAP_FLAG_DISCARD 2703# define SWAP_FLAG_DISCARD 0x10000 2704#endif 2705static const struct xlat swap_flags[] = { 2706 { SWAP_FLAG_PREFER, "SWAP_FLAG_PREFER" }, 2707 { SWAP_FLAG_DISCARD, "SWAP_FLAG_DISCARD" }, 2708 { 0, NULL } 2709}; 2710 2711int 2712sys_swapon(struct tcb *tcp) 2713{ 2714 if (entering(tcp)) { 2715 int flags = tcp->u_arg[1]; 2716 printpath(tcp, tcp->u_arg[0]); 2717 tprints(", "); 2718 printflags(swap_flags, flags & ~SWAP_FLAG_PRIO_MASK, 2719 "SWAP_FLAG_???"); 2720 if (flags & SWAP_FLAG_PREFER) 2721 tprintf("|%d", flags & SWAP_FLAG_PRIO_MASK); 2722 } 2723 return 0; 2724} 2725 2726#ifdef X32 2727# undef stat64 2728# undef sys_fstat64 2729# undef sys_stat64 2730 2731static void 2732realprintstat64(struct tcb *tcp, long addr) 2733{ 2734 struct stat64 statbuf; 2735 2736 if (!addr) { 2737 tprints("NULL"); 2738 return; 2739 } 2740 if (syserror(tcp) || !verbose(tcp)) { 2741 tprintf("%#lx", addr); 2742 return; 2743 } 2744 2745 if (umove(tcp, addr, &statbuf) < 0) { 2746 tprints("{...}"); 2747 return; 2748 } 2749 2750 if (!abbrev(tcp)) { 2751 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ", 2752 (unsigned long) major(statbuf.st_dev), 2753 (unsigned long) minor(statbuf.st_dev), 2754 (unsigned long long) statbuf.st_ino, 2755 sprintmode(statbuf.st_mode)); 2756 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ", 2757 (unsigned long) statbuf.st_nlink, 2758 (unsigned long) statbuf.st_uid, 2759 (unsigned long) statbuf.st_gid); 2760 tprintf("st_blksize=%lu, ", 2761 (unsigned long) statbuf.st_blksize); 2762 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks); 2763 } 2764 else 2765 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode)); 2766 switch (statbuf.st_mode & S_IFMT) { 2767 case S_IFCHR: case S_IFBLK: 2768 tprintf("st_rdev=makedev(%lu, %lu), ", 2769 (unsigned long) major(statbuf.st_rdev), 2770 (unsigned long) minor(statbuf.st_rdev)); 2771 break; 2772 default: 2773 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size); 2774 break; 2775 } 2776 if (!abbrev(tcp)) { 2777 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime)); 2778 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime)); 2779 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime)); 2780 tprints("}"); 2781 } 2782 else 2783 tprints("...}"); 2784} 2785 2786int 2787sys_fstat64(struct tcb *tcp) 2788{ 2789 if (entering(tcp)) { 2790 printfd(tcp, tcp->u_arg[0]); 2791 tprints(", "); 2792 } else { 2793 realprintstat64(tcp, tcp->u_arg[1]); 2794 } 2795 return 0; 2796} 2797 2798int 2799sys_stat64(struct tcb *tcp) 2800{ 2801 if (entering(tcp)) { 2802 printpath(tcp, tcp->u_arg[0]); 2803 tprints(", "); 2804 } else { 2805 realprintstat64(tcp, tcp->u_arg[1]); 2806 } 2807 return 0; 2808} 2809#endif 2810