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>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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.
34 #if defined(SPARC) || defined(SPARC64)
36 unsigned short st_dev;
38 unsigned short st_mode;
40 unsigned short st_uid;
41 unsigned short st_gid;
42 unsigned short st_rdev;
45 unsigned int __unused1;
47 unsigned int __unused2;
49 unsigned int __unused3;
52 unsigned int __unused4[2];
59 unsigned int st_nlink;
69 unsigned long __unused4[2];
72 # define stat kernel_stat
73 # include <asm/stat.h>
77 unsigned long long st_dev;
78 unsigned long long st_ino;
79 unsigned long long st_nlink;
85 unsigned long long st_rdev;
90 unsigned long long st_atime;
91 unsigned long long st_atime_nsec;
92 unsigned long long st_mtime;
93 unsigned long long st_mtime_nsec;
94 unsigned long long st_ctime;
95 unsigned long long st_ctime_nsec;
96 long long __unused[3];
100 unsigned long long st_dev;
101 unsigned char __pad0[4];
102 unsigned long __st_ino;
103 unsigned int st_mode;
104 unsigned int st_nlink;
105 unsigned long st_uid;
106 unsigned long st_gid;
107 unsigned long long st_rdev;
108 unsigned char __pad3[4];
110 unsigned long st_blksize;
111 unsigned long long st_blocks;
112 unsigned long st_atime;
113 unsigned long st_atime_nsec;
114 unsigned long st_mtime;
115 unsigned int st_mtime_nsec;
116 unsigned long st_ctime;
117 unsigned long st_ctime_nsec;
118 unsigned long long st_ino;
119 } __attribute__((packed));
120 # define HAVE_STAT64 1
122 struct __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;
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
153 # include <asm/stat.h>
165 # define mode_t mode_t
166 # define nlink_t nlink_t
170 # define loff_t loff_t
173 #define stat libc_stat
174 #define stat64 libc_stat64
175 #include <sys/stat.h>
178 /* These might be macros. */
184 #ifdef HAVE_SYS_VFS_H
185 # include <sys/vfs.h>
187 #ifdef HAVE_LINUX_XATTR_H
188 # include <linux/xattr.h>
190 # define XATTR_CREATE 1
191 # define XATTR_REPLACE 2
194 #ifdef MAJOR_IN_SYSMACROS
195 # include <sys/sysmacros.h>
198 #ifdef MAJOR_IN_MKDEV
199 # include <sys/mkdev.h>
202 #ifdef HAVE_SYS_ASYNCH_H
203 # include <sys/asynch.h>
207 # if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
210 # define O_LARGEFILE 0x40000
211 # elif defined X86_64 || defined S390X
212 # define O_LARGEFILE 0100000
217 #include "xlat/open_access_modes.h"
218 #include "xlat/open_mode_flags.h"
221 # define AT_FDCWD -100
224 /* The fd is an "int", so when decoding x86 on x86_64, we need to force sign
225 * extension to get the right value. We do this by declaring fd as int here.
228 print_dirfd(struct tcb *tcp, int fd)
231 tprints("AT_FDCWD, ");
239 * low bits of the open(2) flags define access mode,
240 * other bits are real flags.
243 sprint_open_modes(mode_t flags)
245 static char outstr[(1 + ARRAY_SIZE(open_mode_flags)) * sizeof("O_LARGEFILE")];
249 const struct xlat *x;
252 p = stpcpy(outstr, "flags");
253 str = xlookup(open_access_modes, flags & 3);
263 for (x = open_mode_flags; x->str; x++) {
264 if ((flags & x->val) == x->val) {
266 p = stpcpy(p, x->str);
273 /* flags is still nonzero */
275 sprintf(p, "%#x", flags);
280 tprint_open_modes(mode_t flags)
282 tprints(sprint_open_modes(flags) + sizeof("flags"));
286 decode_open(struct tcb *tcp, int offset)
289 printpath(tcp, tcp->u_arg[offset]);
292 tprint_open_modes(tcp->u_arg[offset + 1]);
293 if (tcp->u_arg[offset + 1] & O_CREAT) {
295 tprintf(", %#lo", tcp->u_arg[offset + 2]);
302 sys_open(struct tcb *tcp)
304 return decode_open(tcp, 0);
308 sys_openat(struct tcb *tcp)
311 print_dirfd(tcp, tcp->u_arg[0]);
312 return decode_open(tcp, 1);
315 #if defined(SPARC) || defined(SPARC64)
316 #include "xlat/openmodessol.h"
319 solaris_open(struct tcb *tcp)
322 printpath(tcp, tcp->u_arg[0]);
325 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
326 if (tcp->u_arg[1] & 0x100) {
328 tprintf(", %#lo", tcp->u_arg[2]);
337 sys_creat(struct tcb *tcp)
340 printpath(tcp, tcp->u_arg[0]);
341 tprintf(", %#lo", tcp->u_arg[1]);
346 #include "xlat/access_flags.h"
349 decode_access(struct tcb *tcp, int offset)
352 printpath(tcp, tcp->u_arg[offset]);
354 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK");
360 sys_access(struct tcb *tcp)
362 return decode_access(tcp, 0);
366 sys_faccessat(struct tcb *tcp)
369 print_dirfd(tcp, tcp->u_arg[0]);
370 return decode_access(tcp, 1);
374 sys_umask(struct tcb *tcp)
377 tprintf("%#lo", tcp->u_arg[0]);
382 #include "xlat/whence_codes.h"
384 /* Linux kernel has exactly one version of lseek:
385 * fs/read_write.c::SYSCALL_DEFINE3(lseek, unsigned, fd, off_t, offset, unsigned, origin)
386 * In kernel, off_t is always the same as (kernel's) long
387 * (see include/uapi/asm-generic/posix_types.h),
388 * which means that on x32 we need to use tcp->ext_arg[N] to get offset argument.
389 * Use test/x32_lseek.c to test lseek decoding.
391 #if defined(LINUX_MIPSN32) || defined(X32)
393 sys_lseek(struct tcb *tcp)
399 printfd(tcp, tcp->u_arg[0]);
400 offset = tcp->ext_arg[1];
401 whence = tcp->u_arg[2];
402 if (whence == SEEK_SET)
403 tprintf(", %llu, ", offset);
405 tprintf(", %lld, ", offset);
406 printxval(whence_codes, whence, "SEEK_???");
408 return RVAL_LUDECIMAL;
412 sys_lseek(struct tcb *tcp)
418 printfd(tcp, tcp->u_arg[0]);
419 offset = tcp->u_arg[1];
420 whence = tcp->u_arg[2];
421 if (whence == SEEK_SET)
422 tprintf(", %lu, ", offset);
424 tprintf(", %ld, ", offset);
425 printxval(whence_codes, whence, "SEEK_???");
427 return RVAL_UDECIMAL;
431 /* llseek syscall takes explicitly two ulong arguments hi, lo,
432 * rather than one 64-bit argument for which LONG_LONG works
433 * appropriate for the native byte order.
435 * See kernel's fs/read_write.c::SYSCALL_DEFINE5(llseek, ...)
437 * hi,lo are "unsigned longs" and combined exactly this way in kernel:
438 * ((loff_t) hi << 32) | lo
439 * Note that for architectures with kernel's long wider than userspace long
440 * (such as x32), combining code will use *kernel's*, i.e. *wide* longs
441 * for hi and lo. We would need to use tcp->ext_arg[N] on x32...
442 * ...however, x32 (and x86_64) does not _have_ llseek syscall as such.
445 sys_llseek(struct tcb *tcp)
448 printfd(tcp, tcp->u_arg[0]);
449 if (tcp->u_arg[4] == SEEK_SET)
451 ((long long) tcp->u_arg[1]) << 32 |
452 (unsigned long long) (unsigned) tcp->u_arg[2]);
455 ((long long) tcp->u_arg[1]) << 32 |
456 (unsigned long long) (unsigned) tcp->u_arg[2]);
460 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
461 tprintf("%#lx, ", tcp->u_arg[3]);
463 tprintf("[%llu], ", off);
464 printxval(whence_codes, tcp->u_arg[4], "SEEK_???");
470 sys_readahead(struct tcb *tcp)
474 printfd(tcp, tcp->u_arg[0]);
475 argn = printllval(tcp, ", %lld", 1);
476 tprintf(", %ld", tcp->u_arg[argn]);
482 sys_truncate(struct tcb *tcp)
485 printpath(tcp, tcp->u_arg[0]);
486 tprintf(", %lu", tcp->u_arg[1]);
492 sys_truncate64(struct tcb *tcp)
495 printpath(tcp, tcp->u_arg[0]);
496 printllval(tcp, ", %llu", 1);
502 sys_ftruncate(struct tcb *tcp)
505 printfd(tcp, tcp->u_arg[0]);
506 tprintf(", %lu", tcp->u_arg[1]);
512 sys_ftruncate64(struct tcb *tcp)
515 printfd(tcp, tcp->u_arg[0]);
516 printllval(tcp, ", %llu", 1);
523 #include "xlat/modetypes.h"
528 static char buf[sizeof("S_IFSOCK|S_ISUID|S_ISGID|S_ISVTX|%o")
533 if ((mode & S_IFMT) == 0)
535 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
536 sprintf(buf, "%#o", mode);
539 s = buf + sprintf(buf, "%s%s%s%s", s,
540 (mode & S_ISUID) ? "|S_ISUID" : "",
541 (mode & S_ISGID) ? "|S_ISGID" : "",
542 (mode & S_ISVTX) ? "|S_ISVTX" : "");
543 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
545 sprintf((char*)s, "|%#o", mode);
546 s = (*buf == '|') ? buf + 1 : buf;
554 static char buf[sizeof("yyyy/mm/dd-hh:mm:ss")];
562 snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d",
563 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
564 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
566 snprintf(buf, sizeof buf, "%lu", (unsigned long) t);
571 #if defined(SPARC) || defined(SPARC64)
579 int st_pad1[3]; /* network id */
588 int st_pad3; /* st_size, off_t expansion */
589 timestruct_t st_atime;
590 timestruct_t st_mtime;
591 timestruct_t st_ctime;
595 int st_pad4[8]; /* expansion area */
599 printstatsol(struct tcb *tcp, long addr)
601 struct solstat statbuf;
603 if (umove(tcp, addr, &statbuf) < 0) {
608 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
609 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
610 (unsigned long) (statbuf.st_dev & 0x3ffff),
611 (unsigned long) statbuf.st_ino,
612 sprintmode(statbuf.st_mode));
613 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
614 (unsigned long) statbuf.st_nlink,
615 (unsigned long) statbuf.st_uid,
616 (unsigned long) statbuf.st_gid);
617 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
618 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
621 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
622 switch (statbuf.st_mode & S_IFMT) {
623 case S_IFCHR: case S_IFBLK:
624 tprintf("st_rdev=makedev(%lu, %lu), ",
625 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
626 (unsigned long) (statbuf.st_rdev & 0x3ffff));
629 tprintf("st_size=%u, ", statbuf.st_size);
633 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
634 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
635 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
641 # if defined(SPARC64)
643 printstat_sparc64(struct tcb *tcp, long addr)
645 struct stat_sparc64 statbuf;
647 if (umove(tcp, addr, &statbuf) < 0) {
653 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
654 (unsigned long) major(statbuf.st_dev),
655 (unsigned long) minor(statbuf.st_dev),
656 (unsigned long) statbuf.st_ino,
657 sprintmode(statbuf.st_mode));
658 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
659 (unsigned long) statbuf.st_nlink,
660 (unsigned long) statbuf.st_uid,
661 (unsigned long) statbuf.st_gid);
662 tprintf("st_blksize=%lu, ",
663 (unsigned long) statbuf.st_blksize);
664 tprintf("st_blocks=%lu, ",
665 (unsigned long) statbuf.st_blocks);
668 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
669 switch (statbuf.st_mode & S_IFMT) {
670 case S_IFCHR: case S_IFBLK:
671 tprintf("st_rdev=makedev(%lu, %lu), ",
672 (unsigned long) major(statbuf.st_rdev),
673 (unsigned long) minor(statbuf.st_rdev));
676 tprintf("st_size=%lu, ", statbuf.st_size);
680 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
681 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
682 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
687 # endif /* SPARC64 */
688 #endif /* SPARC[64] */
690 #if defined POWERPC64
691 struct stat_powerpc32 {
694 unsigned int st_mode;
695 unsigned short st_nlink;
698 unsigned int st_rdev;
699 unsigned int st_size;
700 unsigned int st_blksize;
701 unsigned int st_blocks;
702 unsigned int st_atime;
703 unsigned int st_atime_nsec;
704 unsigned int st_mtime;
705 unsigned int st_mtime_nsec;
706 unsigned int st_ctime;
707 unsigned int st_ctime_nsec;
708 unsigned int __unused4;
709 unsigned int __unused5;
713 printstat_powerpc32(struct tcb *tcp, long addr)
715 struct stat_powerpc32 statbuf;
717 if (umove(tcp, addr, &statbuf) < 0) {
723 tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ",
724 major(statbuf.st_dev), minor(statbuf.st_dev),
726 sprintmode(statbuf.st_mode));
727 tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ",
728 statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid);
729 tprintf("st_blksize=%u, ", statbuf.st_blksize);
730 tprintf("st_blocks=%u, ", statbuf.st_blocks);
733 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
734 switch (statbuf.st_mode & S_IFMT) {
735 case S_IFCHR: case S_IFBLK:
736 tprintf("st_rdev=makedev(%lu, %lu), ",
737 (unsigned long) major(statbuf.st_rdev),
738 (unsigned long) minor(statbuf.st_rdev));
741 tprintf("st_size=%u, ", statbuf.st_size);
745 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
746 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
747 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
752 #endif /* POWERPC64 */
754 #include "xlat/fileflags.h"
757 realprintstat(struct tcb *tcp, struct stat *statbuf)
760 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
761 (unsigned long) major(statbuf->st_dev),
762 (unsigned long) minor(statbuf->st_dev),
763 (unsigned long) statbuf->st_ino,
764 sprintmode(statbuf->st_mode));
765 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
766 (unsigned long) statbuf->st_nlink,
767 (unsigned long) statbuf->st_uid,
768 (unsigned long) statbuf->st_gid);
769 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
770 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
772 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
773 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
777 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
778 switch (statbuf->st_mode & S_IFMT) {
779 case S_IFCHR: case S_IFBLK:
780 #ifdef HAVE_STRUCT_STAT_ST_RDEV
781 tprintf("st_rdev=makedev(%lu, %lu), ",
782 (unsigned long) major(statbuf->st_rdev),
783 (unsigned long) minor(statbuf->st_rdev));
784 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
785 tprintf("st_size=makedev(%lu, %lu), ",
786 (unsigned long) major(statbuf->st_size),
787 (unsigned long) minor(statbuf->st_size));
788 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
791 tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size);
795 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
796 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
797 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
798 #if HAVE_STRUCT_STAT_ST_FLAGS
799 tprints(", st_flags=");
800 printflags(fileflags, statbuf->st_flags, "UF_???");
802 #if HAVE_STRUCT_STAT_ST_ACLCNT
803 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
805 #if HAVE_STRUCT_STAT_ST_LEVEL
806 tprintf(", st_level=%ld", statbuf->st_level);
808 #if HAVE_STRUCT_STAT_ST_FSTYPE
809 tprintf(", st_fstype=%.*s",
810 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
812 #if HAVE_STRUCT_STAT_ST_GEN
813 tprintf(", st_gen=%u", statbuf->st_gen);
823 printstat(struct tcb *tcp, long addr)
831 if (syserror(tcp) || !verbose(tcp)) {
832 tprintf("%#lx", addr);
836 #if defined(SPARC) || defined(SPARC64)
837 if (current_personality == 1) {
838 printstatsol(tcp, addr);
842 else if (current_personality == 2) {
843 printstat_sparc64(tcp, addr);
847 #endif /* SPARC[64] */
849 #if defined POWERPC64
850 if (current_personality == 1) {
851 printstat_powerpc32(tcp, addr);
856 if (umove(tcp, addr, &statbuf) < 0) {
861 realprintstat(tcp, &statbuf);
864 # define printstat printstat64
867 #if !defined HAVE_STAT64 && (defined AARCH64 || defined X86_64)
869 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
870 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
871 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
872 * __GNUC__ is needed for the required __attribute__ below.
874 * Similarly, aarch64 has a unified `struct stat' but its arm personality
875 * needs `struct stat64' (which also expects a 32-bit `long' but which
876 * shouldn't be packed).
879 unsigned long long st_dev;
880 unsigned char __pad0[4];
881 unsigned int __st_ino;
882 unsigned int st_mode;
883 unsigned int st_nlink;
886 unsigned long long st_rdev;
887 unsigned char __pad3[4];
889 unsigned int st_blksize;
890 unsigned long long st_blocks;
891 unsigned int st_atime;
892 unsigned int st_atime_nsec;
893 unsigned int st_mtime;
894 unsigned int st_mtime_nsec;
895 unsigned int st_ctime;
896 unsigned int st_ctime_nsec;
897 unsigned long long st_ino;
900 __attribute__((packed))
901 # define STAT64_SIZE 96
903 # define STAT64_SIZE 104
906 # define HAVE_STAT64 1
911 printstat64(struct tcb *tcp, long addr)
916 struct stat64 statbuf;
920 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
927 if (syserror(tcp) || !verbose(tcp)) {
928 tprintf("%#lx", addr);
932 #if defined(SPARC) || defined(SPARC64)
933 if (current_personality == 1) {
934 printstatsol(tcp, addr);
938 else if (current_personality == 2) {
939 printstat_sparc64(tcp, addr);
943 #endif /* SPARC[64] */
946 if (current_personality != 0) {
947 printstat(tcp, addr);
952 if (current_personality != 1) {
953 printstat(tcp, addr);
958 if (umove(tcp, addr, &statbuf) < 0) {
964 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
965 (unsigned long) major(statbuf.st_dev),
966 (unsigned long) minor(statbuf.st_dev),
967 (unsigned long long) statbuf.st_ino,
968 sprintmode(statbuf.st_mode));
969 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
970 (unsigned long) statbuf.st_nlink,
971 (unsigned long) statbuf.st_uid,
972 (unsigned long) statbuf.st_gid);
973 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
974 tprintf("st_blksize=%lu, ",
975 (unsigned long) statbuf.st_blksize);
976 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
977 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
978 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
979 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
982 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
983 switch (statbuf.st_mode & S_IFMT) {
984 case S_IFCHR: case S_IFBLK:
985 #ifdef HAVE_STRUCT_STAT_ST_RDEV
986 tprintf("st_rdev=makedev(%lu, %lu), ",
987 (unsigned long) major(statbuf.st_rdev),
988 (unsigned long) minor(statbuf.st_rdev));
989 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
990 tprintf("st_size=makedev(%lu, %lu), ",
991 (unsigned long) major(statbuf.st_size),
992 (unsigned long) minor(statbuf.st_size));
993 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
996 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1000 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1001 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
1002 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
1003 #if HAVE_STRUCT_STAT_ST_FLAGS
1004 tprints(", st_flags=");
1005 printflags(fileflags, statbuf.st_flags, "UF_???");
1007 #if HAVE_STRUCT_STAT_ST_ACLCNT
1008 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1010 #if HAVE_STRUCT_STAT_ST_LEVEL
1011 tprintf(", st_level=%ld", statbuf.st_level);
1013 #if HAVE_STRUCT_STAT_ST_FSTYPE
1014 tprintf(", st_fstype=%.*s",
1015 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1017 #if HAVE_STRUCT_STAT_ST_GEN
1018 tprintf(", st_gen=%u", statbuf.st_gen);
1025 #endif /* HAVE_STAT64 */
1027 #if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1029 convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
1031 newbuf->st_dev = oldbuf->st_dev;
1032 newbuf->st_ino = oldbuf->st_ino;
1033 newbuf->st_mode = oldbuf->st_mode;
1034 newbuf->st_nlink = oldbuf->st_nlink;
1035 newbuf->st_uid = oldbuf->st_uid;
1036 newbuf->st_gid = oldbuf->st_gid;
1037 newbuf->st_rdev = oldbuf->st_rdev;
1038 newbuf->st_size = oldbuf->st_size;
1039 newbuf->st_atime = oldbuf->st_atime;
1040 newbuf->st_mtime = oldbuf->st_mtime;
1041 newbuf->st_ctime = oldbuf->st_ctime;
1042 newbuf->st_blksize = 0; /* not supported in old_stat */
1043 newbuf->st_blocks = 0; /* not supported in old_stat */
1047 printoldstat(struct tcb *tcp, long addr)
1049 struct __old_kernel_stat statbuf;
1050 struct stat newstatbuf;
1056 if (syserror(tcp) || !verbose(tcp)) {
1057 tprintf("%#lx", addr);
1061 # if defined(SPARC) || defined(SPARC64)
1062 if (current_personality == 1) {
1063 printstatsol(tcp, addr);
1068 if (umove(tcp, addr, &statbuf) < 0) {
1073 convertoldstat(&statbuf, &newstatbuf);
1074 realprintstat(tcp, &newstatbuf);
1079 sys_stat(struct tcb *tcp)
1081 if (entering(tcp)) {
1082 printpath(tcp, tcp->u_arg[0]);
1085 printstat(tcp, tcp->u_arg[1]);
1092 printstat64_x32(struct tcb *tcp, long addr)
1094 struct stat64 statbuf;
1100 if (syserror(tcp) || !verbose(tcp)) {
1101 tprintf("%#lx", addr);
1105 if (umove(tcp, addr, &statbuf) < 0) {
1111 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1112 (unsigned long) major(statbuf.st_dev),
1113 (unsigned long) minor(statbuf.st_dev),
1114 (unsigned long long) statbuf.st_ino,
1115 sprintmode(statbuf.st_mode));
1116 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1117 (unsigned long) statbuf.st_nlink,
1118 (unsigned long) statbuf.st_uid,
1119 (unsigned long) statbuf.st_gid);
1120 tprintf("st_blksize=%lu, ",
1121 (unsigned long) statbuf.st_blksize);
1122 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
1125 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1126 switch (statbuf.st_mode & S_IFMT) {
1127 case S_IFCHR: case S_IFBLK:
1128 tprintf("st_rdev=makedev(%lu, %lu), ",
1129 (unsigned long) major(statbuf.st_rdev),
1130 (unsigned long) minor(statbuf.st_rdev));
1133 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1137 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1138 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
1139 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
1148 sys_stat64(struct tcb *tcp)
1151 if (entering(tcp)) {
1152 printpath(tcp, tcp->u_arg[0]);
1156 printstat64_x32(tcp, tcp->u_arg[1]);
1158 printstat64(tcp, tcp->u_arg[1]);
1163 return printargs(tcp);
1167 #ifndef AT_SYMLINK_NOFOLLOW
1168 # define AT_SYMLINK_NOFOLLOW 0x100
1170 #ifndef AT_REMOVEDIR
1171 # define AT_REMOVEDIR 0x200
1173 #ifndef AT_SYMLINK_FOLLOW
1174 # define AT_SYMLINK_FOLLOW 0x400
1176 #ifndef AT_NO_AUTOMOUNT
1177 # define AT_NO_AUTOMOUNT 0x800
1179 #ifndef AT_EMPTY_PATH
1180 # define AT_EMPTY_PATH 0x1000
1183 #include "xlat/at_flags.h"
1186 sys_newfstatat(struct tcb *tcp)
1188 if (entering(tcp)) {
1189 print_dirfd(tcp, tcp->u_arg[0]);
1190 printpath(tcp, tcp->u_arg[1]);
1194 if (current_personality == 0)
1195 printstat(tcp, tcp->u_arg[2]);
1197 printstat64(tcp, tcp->u_arg[2]);
1198 #elif defined HAVE_STAT64
1199 printstat64(tcp, tcp->u_arg[2]);
1201 printstat(tcp, tcp->u_arg[2]);
1204 printflags(at_flags, tcp->u_arg[3], "AT_???");
1209 #if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1211 sys_oldstat(struct tcb *tcp)
1213 if (entering(tcp)) {
1214 printpath(tcp, tcp->u_arg[0]);
1217 printoldstat(tcp, tcp->u_arg[1]);
1224 sys_fstat(struct tcb *tcp)
1226 if (entering(tcp)) {
1227 printfd(tcp, tcp->u_arg[0]);
1230 printstat(tcp, tcp->u_arg[1]);
1236 sys_fstat64(struct tcb *tcp)
1239 if (entering(tcp)) {
1240 printfd(tcp, tcp->u_arg[0]);
1244 printstat64_x32(tcp, tcp->u_arg[1]);
1246 printstat64(tcp, tcp->u_arg[1]);
1251 return printargs(tcp);
1255 #if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1257 sys_oldfstat(struct tcb *tcp)
1259 if (entering(tcp)) {
1260 printfd(tcp, tcp->u_arg[0]);
1263 printoldstat(tcp, tcp->u_arg[1]);
1269 #if defined(SPARC) || defined(SPARC64)
1272 sys_xstat(struct tcb *tcp)
1274 if (entering(tcp)) {
1275 tprintf("%ld, ", tcp->u_arg[0]);
1276 printpath(tcp, tcp->u_arg[1]);
1280 if (tcp->u_arg[0] == _STAT64_VER)
1281 printstat64(tcp, tcp->u_arg[2]);
1284 printstat(tcp, tcp->u_arg[2]);
1290 sys_fxstat(struct tcb *tcp)
1293 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1296 if (tcp->u_arg[0] == _STAT64_VER)
1297 printstat64(tcp, tcp->u_arg[2]);
1300 printstat(tcp, tcp->u_arg[2]);
1306 sys_lxstat(struct tcb *tcp)
1308 if (entering(tcp)) {
1309 tprintf("%ld, ", tcp->u_arg[0]);
1310 printpath(tcp, tcp->u_arg[1]);
1314 if (tcp->u_arg[0] == _STAT64_VER)
1315 printstat64(tcp, tcp->u_arg[2]);
1318 printstat(tcp, tcp->u_arg[2]);
1324 sys_xmknod(struct tcb *tcp)
1326 int mode = tcp->u_arg[2];
1328 if (entering(tcp)) {
1329 tprintf("%ld, ", tcp->u_arg[0]);
1330 printpath(tcp, tcp->u_arg[1]);
1331 tprintf(", %s", sprintmode(mode));
1332 switch (mode & S_IFMT) {
1333 case S_IFCHR: case S_IFBLK:
1334 tprintf(", makedev(%lu, %lu)",
1335 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1336 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1345 # ifdef HAVE_SYS_ACL_H
1347 # include <sys/acl.h>
1349 #include "xlat/aclcmds.h"
1352 sys_acl(struct tcb *tcp)
1354 if (entering(tcp)) {
1355 printpath(tcp, tcp->u_arg[0]);
1357 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1358 tprintf(", %ld", tcp->u_arg[2]);
1360 * FIXME - dump out the list of aclent_t's pointed to
1361 * by "tcp->u_arg[3]" if it's not NULL.
1364 tprintf(", %#lx", tcp->u_arg[3]);
1372 sys_facl(struct tcb *tcp)
1374 if (entering(tcp)) {
1375 tprintf("%ld, ", tcp->u_arg[0]);
1376 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1377 tprintf(", %ld", tcp->u_arg[2]);
1379 * FIXME - dump out the list of aclent_t's pointed to
1380 * by "tcp->u_arg[3]" if it's not NULL.
1383 tprintf(", %#lx", tcp->u_arg[3]);
1390 #include "xlat/aclipc.h"
1393 sys_aclipc(struct tcb *tcp)
1395 if (entering(tcp)) {
1396 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1397 tprintf(", %#lx, ", tcp->u_arg[1]);
1398 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1399 tprintf(", %ld", tcp->u_arg[3]);
1401 * FIXME - dump out the list of aclent_t's pointed to
1402 * by "tcp->u_arg[4]" if it's not NULL.
1405 tprintf(", %#lx", tcp->u_arg[4]);
1412 # endif /* HAVE_SYS_ACL_H */
1414 #endif /* SPARC[64] */
1416 #include "xlat/fsmagic.h"
1419 sprintfstype(int magic)
1421 static char buf[32];
1424 s = xlookup(fsmagic, magic);
1426 sprintf(buf, "\"%s\"", s);
1429 sprintf(buf, "%#x", magic);
1434 printstatfs(struct tcb *tcp, long addr)
1436 struct statfs statbuf;
1438 if (syserror(tcp) || !verbose(tcp)) {
1439 tprintf("%#lx", addr);
1442 if (umove(tcp, addr, &statbuf) < 0) {
1448 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1449 sprintfstype(statbuf.f_type),
1450 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1451 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1452 statbuf.f_bavail, statbuf.f_files, statbuf.f_ffree,
1453 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1456 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1457 sprintfstype(statbuf.f_type),
1458 (unsigned long)statbuf.f_bsize,
1459 (unsigned long)statbuf.f_blocks,
1460 (unsigned long)statbuf.f_bfree);
1461 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1462 (unsigned long)statbuf.f_bavail,
1463 (unsigned long)statbuf.f_files,
1464 (unsigned long)statbuf.f_ffree,
1465 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1466 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1468 #ifdef _STATFS_F_FRSIZE
1469 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1475 sys_statfs(struct tcb *tcp)
1477 if (entering(tcp)) {
1478 printpath(tcp, tcp->u_arg[0]);
1481 printstatfs(tcp, tcp->u_arg[1]);
1487 sys_fstatfs(struct tcb *tcp)
1489 if (entering(tcp)) {
1490 printfd(tcp, tcp->u_arg[0]);
1493 printstatfs(tcp, tcp->u_arg[1]);
1498 #if defined HAVE_STATFS64
1500 printstatfs64(struct tcb *tcp, long addr)
1502 struct statfs64 statbuf;
1504 if (syserror(tcp) || !verbose(tcp)) {
1505 tprintf("%#lx", addr);
1508 if (umove(tcp, addr, &statbuf) < 0) {
1512 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
1513 sprintfstype(statbuf.f_type),
1514 (unsigned long long)statbuf.f_bsize,
1515 (unsigned long long)statbuf.f_blocks,
1516 (unsigned long long)statbuf.f_bfree);
1517 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1518 (unsigned long long)statbuf.f_bavail,
1519 (unsigned long long)statbuf.f_files,
1520 (unsigned long long)statbuf.f_ffree,
1521 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1522 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1523 #ifdef _STATFS_F_FRSIZE
1524 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
1526 #ifdef _STATFS_F_FLAGS
1527 tprintf(", f_flags=%llu", (unsigned long long)statbuf.f_flags);
1532 struct compat_statfs64 {
1544 uint32_t f_spare[4];
1546 #if defined(X86_64) || defined(IA64)
1547 __attribute__ ((packed, aligned(4)))
1552 printcompat_statfs64(struct tcb *tcp, long addr)
1554 struct compat_statfs64 statbuf;
1556 if (syserror(tcp) || !verbose(tcp)) {
1557 tprintf("%#lx", addr);
1560 if (umove(tcp, addr, &statbuf) < 0) {
1564 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%llu, f_bfree=%llu, ",
1565 sprintfstype(statbuf.f_type),
1566 (unsigned long)statbuf.f_bsize,
1567 (unsigned long long)statbuf.f_blocks,
1568 (unsigned long long)statbuf.f_bfree);
1569 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1570 (unsigned long long)statbuf.f_bavail,
1571 (unsigned long long)statbuf.f_files,
1572 (unsigned long long)statbuf.f_ffree,
1573 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1574 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1575 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1576 tprintf(", f_flags=%lu}", (unsigned long)statbuf.f_frsize);
1580 sys_statfs64(struct tcb *tcp)
1582 if (entering(tcp)) {
1583 printpath(tcp, tcp->u_arg[0]);
1584 tprintf(", %lu, ", tcp->u_arg[1]);
1586 if (tcp->u_arg[1] == sizeof(struct statfs64))
1587 printstatfs64(tcp, tcp->u_arg[2]);
1588 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
1589 printcompat_statfs64(tcp, tcp->u_arg[2]);
1597 sys_fstatfs64(struct tcb *tcp)
1599 if (entering(tcp)) {
1600 printfd(tcp, tcp->u_arg[0]);
1601 tprintf(", %lu, ", tcp->u_arg[1]);
1603 if (tcp->u_arg[1] == sizeof(struct statfs64))
1604 printstatfs64(tcp, tcp->u_arg[2]);
1605 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
1606 printcompat_statfs64(tcp, tcp->u_arg[2]);
1616 osf_statfs(struct tcb *tcp)
1618 if (entering(tcp)) {
1619 printpath(tcp, tcp->u_arg[0]);
1622 printstatfs(tcp, tcp->u_arg[1]);
1623 tprintf(", %lu", tcp->u_arg[2]);
1629 osf_fstatfs(struct tcb *tcp)
1631 if (entering(tcp)) {
1632 tprintf("%lu, ", tcp->u_arg[0]);
1634 printstatfs(tcp, tcp->u_arg[1]);
1635 tprintf(", %lu", tcp->u_arg[2]);
1643 sys_chdir(struct tcb *tcp)
1645 if (entering(tcp)) {
1646 printpath(tcp, tcp->u_arg[0]);
1652 decode_mkdir(struct tcb *tcp, int offset)
1654 if (entering(tcp)) {
1655 printpath(tcp, tcp->u_arg[offset]);
1656 tprintf(", %#lo", tcp->u_arg[offset + 1]);
1662 sys_mkdir(struct tcb *tcp)
1664 return decode_mkdir(tcp, 0);
1668 sys_mkdirat(struct tcb *tcp)
1671 print_dirfd(tcp, tcp->u_arg[0]);
1672 return decode_mkdir(tcp, 1);
1676 sys_link(struct tcb *tcp)
1678 if (entering(tcp)) {
1679 printpath(tcp, tcp->u_arg[0]);
1681 printpath(tcp, tcp->u_arg[1]);
1687 sys_linkat(struct tcb *tcp)
1689 if (entering(tcp)) {
1690 print_dirfd(tcp, tcp->u_arg[0]);
1691 printpath(tcp, tcp->u_arg[1]);
1693 print_dirfd(tcp, tcp->u_arg[2]);
1694 printpath(tcp, tcp->u_arg[3]);
1696 printflags(at_flags, tcp->u_arg[4], "AT_???");
1702 sys_unlinkat(struct tcb *tcp)
1704 if (entering(tcp)) {
1705 print_dirfd(tcp, tcp->u_arg[0]);
1706 printpath(tcp, tcp->u_arg[1]);
1708 printflags(at_flags, tcp->u_arg[2], "AT_???");
1714 sys_symlinkat(struct tcb *tcp)
1716 if (entering(tcp)) {
1717 printpath(tcp, tcp->u_arg[0]);
1719 print_dirfd(tcp, tcp->u_arg[1]);
1720 printpath(tcp, tcp->u_arg[2]);
1726 decode_readlink(struct tcb *tcp, int offset)
1728 if (entering(tcp)) {
1729 printpath(tcp, tcp->u_arg[offset]);
1733 tprintf("%#lx", tcp->u_arg[offset + 1]);
1735 /* Used to use printpathn(), but readlink
1736 * neither includes NUL in the returned count,
1737 * nor actually writes it into memory.
1738 * printpathn() would decide on printing
1739 * "..." continuation based on garbage
1740 * past return buffer's end.
1742 printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
1743 tprintf(", %lu", tcp->u_arg[offset + 2]);
1749 sys_readlink(struct tcb *tcp)
1751 return decode_readlink(tcp, 0);
1755 sys_readlinkat(struct tcb *tcp)
1758 print_dirfd(tcp, tcp->u_arg[0]);
1759 return decode_readlink(tcp, 1);
1763 decode_renameat(struct tcb *tcp)
1765 print_dirfd(tcp, tcp->u_arg[0]);
1766 printpath(tcp, tcp->u_arg[1]);
1768 print_dirfd(tcp, tcp->u_arg[2]);
1769 printpath(tcp, tcp->u_arg[3]);
1773 sys_renameat(struct tcb *tcp)
1775 if (entering(tcp)) {
1776 decode_renameat(tcp);
1781 #include "xlat/rename_flags.h"
1784 sys_renameat2(struct tcb *tcp)
1786 if (entering(tcp)) {
1787 decode_renameat(tcp);
1789 printflags(rename_flags, tcp->u_arg[4], "RENAME_??");
1795 sys_chown(struct tcb *tcp)
1797 if (entering(tcp)) {
1798 printpath(tcp, tcp->u_arg[0]);
1799 printuid(", ", tcp->u_arg[1]);
1800 printuid(", ", tcp->u_arg[2]);
1806 sys_fchownat(struct tcb *tcp)
1808 if (entering(tcp)) {
1809 print_dirfd(tcp, tcp->u_arg[0]);
1810 printpath(tcp, tcp->u_arg[1]);
1811 printuid(", ", tcp->u_arg[2]);
1812 printuid(", ", tcp->u_arg[3]);
1814 printflags(at_flags, tcp->u_arg[4], "AT_???");
1820 sys_fchown(struct tcb *tcp)
1822 if (entering(tcp)) {
1823 printfd(tcp, tcp->u_arg[0]);
1824 printuid(", ", tcp->u_arg[1]);
1825 printuid(", ", tcp->u_arg[2]);
1831 decode_chmod(struct tcb *tcp, int offset)
1833 if (entering(tcp)) {
1834 printpath(tcp, tcp->u_arg[offset]);
1835 tprintf(", %#lo", tcp->u_arg[offset + 1]);
1841 sys_chmod(struct tcb *tcp)
1843 return decode_chmod(tcp, 0);
1847 sys_fchmodat(struct tcb *tcp)
1850 print_dirfd(tcp, tcp->u_arg[0]);
1851 return decode_chmod(tcp, 1);
1855 sys_fchmod(struct tcb *tcp)
1857 if (entering(tcp)) {
1858 printfd(tcp, tcp->u_arg[0]);
1859 tprintf(", %#lo", tcp->u_arg[1]);
1866 sys_osf_utimes(struct tcb *tcp)
1868 if (entering(tcp)) {
1869 printpath(tcp, tcp->u_arg[0]);
1871 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
1878 decode_utimes(struct tcb *tcp, int offset, int special)
1880 if (entering(tcp)) {
1881 printpath(tcp, tcp->u_arg[offset]);
1883 if (tcp->u_arg[offset + 1] == 0)
1887 printtv_bitness(tcp, tcp->u_arg[offset + 1],
1888 BITNESS_CURRENT, special);
1890 printtv_bitness(tcp, tcp->u_arg[offset + 1]
1891 + sizeof(struct timeval),
1892 BITNESS_CURRENT, special);
1900 sys_utimes(struct tcb *tcp)
1902 return decode_utimes(tcp, 0, 0);
1906 sys_futimesat(struct tcb *tcp)
1909 print_dirfd(tcp, tcp->u_arg[0]);
1910 return decode_utimes(tcp, 1, 0);
1914 sys_utimensat(struct tcb *tcp)
1916 if (entering(tcp)) {
1917 print_dirfd(tcp, tcp->u_arg[0]);
1918 decode_utimes(tcp, 1, 1);
1920 printflags(at_flags, tcp->u_arg[3], "AT_???");
1926 sys_utime(struct tcb *tcp)
1931 long paranoia_for_huge_wordsize[4];
1935 if (entering(tcp)) {
1936 printpath(tcp, tcp->u_arg[0]);
1939 wordsize = current_wordsize;
1942 else if (!verbose(tcp))
1943 tprintf("%#lx", tcp->u_arg[1]);
1944 else if (umoven(tcp, tcp->u_arg[1], 2 * wordsize, (char *) &u) < 0)
1946 else if (wordsize == sizeof u.utl[0]) {
1947 tprintf("[%s,", sprinttime(u.utl[0]));
1948 tprintf(" %s]", sprinttime(u.utl[1]));
1950 else if (wordsize == sizeof u.uti[0]) {
1951 tprintf("[%s,", sprinttime(u.uti[0]));
1952 tprintf(" %s]", sprinttime(u.uti[1]));
1955 tprintf("<decode error: unsupported wordsize %d>",
1962 decode_mknod(struct tcb *tcp, int offset)
1964 int mode = tcp->u_arg[offset + 1];
1966 if (entering(tcp)) {
1967 printpath(tcp, tcp->u_arg[offset]);
1968 tprintf(", %s", sprintmode(mode));
1969 switch (mode & S_IFMT) {
1972 #if defined(SPARC) || defined(SPARC64)
1973 if (current_personality == 1)
1974 tprintf(", makedev(%lu, %lu)",
1975 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
1976 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
1979 tprintf(", makedev(%lu, %lu)",
1980 (unsigned long) major(tcp->u_arg[offset + 2]),
1981 (unsigned long) minor(tcp->u_arg[offset + 2]));
1991 sys_mknod(struct tcb *tcp)
1993 return decode_mknod(tcp, 0);
1997 sys_mknodat(struct tcb *tcp)
2000 print_dirfd(tcp, tcp->u_arg[0]);
2001 return decode_mknod(tcp, 1);
2005 sys_getcwd(struct tcb *tcp)
2009 tprintf("%#lx", tcp->u_arg[0]);
2011 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2012 tprintf(", %lu", tcp->u_arg[1]);
2017 #ifdef HAVE_SYS_ASYNCH_H
2020 sys_aioread(struct tcb *tcp)
2022 struct aio_result_t res;
2024 if (entering(tcp)) {
2025 tprintf("%lu, ", tcp->u_arg[0]);
2028 tprintf("%#lx", tcp->u_arg[1]);
2030 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2031 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2032 printxval(whence, tcp->u_arg[4], "L_???");
2033 if (syserror(tcp) || tcp->u_arg[5] == 0
2034 || umove(tcp, tcp->u_arg[5], &res) < 0)
2035 tprintf(", %#lx", tcp->u_arg[5]);
2037 tprintf(", {aio_return %d aio_errno %d}",
2038 res.aio_return, res.aio_errno);
2044 sys_aiowrite(struct tcb *tcp)
2046 struct aio_result_t res;
2048 if (entering(tcp)) {
2049 tprintf("%lu, ", tcp->u_arg[0]);
2050 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2051 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2052 printxval(whence, tcp->u_arg[4], "L_???");
2055 if (tcp->u_arg[5] == 0)
2057 else if (syserror(tcp)
2058 || umove(tcp, tcp->u_arg[5], &res) < 0)
2059 tprintf(", %#lx", tcp->u_arg[5]);
2061 tprintf(", {aio_return %d aio_errno %d}",
2062 res.aio_return, res.aio_errno);
2068 sys_aiowait(struct tcb *tcp)
2071 printtv(tcp, tcp->u_arg[0]);
2076 sys_aiocancel(struct tcb *tcp)
2078 struct aio_result_t res;
2081 if (tcp->u_arg[0] == 0)
2083 else if (syserror(tcp)
2084 || umove(tcp, tcp->u_arg[0], &res) < 0)
2085 tprintf("%#lx", tcp->u_arg[0]);
2087 tprintf("{aio_return %d aio_errno %d}",
2088 res.aio_return, res.aio_errno);
2093 #endif /* HAVE_SYS_ASYNCH_H */
2095 #include "xlat/xattrflags.h"
2098 print_xattr_val(struct tcb *tcp, int failed,
2100 unsigned long insize,
2106 unsigned long capacity = 4 * size + 1;
2107 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
2108 if (buf == NULL || /* probably a bogus size argument */
2109 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2113 unsigned char *out = buf;
2114 unsigned char *in = &buf[3 * size];
2116 for (i = 0; i < size; ++i) {
2117 if (in[i] >= ' ' && in[i] <= 0x7e)
2120 #define tohex(n) "0123456789abcdef"[n]
2123 *out++ = tohex(in[i] / 16);
2124 *out++ = tohex(in[i] % 16);
2127 /* Don't print terminating NUL if there is one. */
2128 if (i > 0 && in[i - 1] == '\0')
2131 tprintf(", \"%s\", %ld", buf, insize);
2136 tprintf(", 0x%lx, %ld", arg, insize);
2140 sys_setxattr(struct tcb *tcp)
2142 if (entering(tcp)) {
2143 printpath(tcp, tcp->u_arg[0]);
2145 printstr(tcp, tcp->u_arg[1], -1);
2146 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2148 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2154 sys_fsetxattr(struct tcb *tcp)
2156 if (entering(tcp)) {
2157 printfd(tcp, tcp->u_arg[0]);
2159 printstr(tcp, tcp->u_arg[1], -1);
2160 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2162 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2168 sys_getxattr(struct tcb *tcp)
2170 if (entering(tcp)) {
2171 printpath(tcp, tcp->u_arg[0]);
2173 printstr(tcp, tcp->u_arg[1], -1);
2175 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2182 sys_fgetxattr(struct tcb *tcp)
2184 if (entering(tcp)) {
2185 printfd(tcp, tcp->u_arg[0]);
2187 printstr(tcp, tcp->u_arg[1], -1);
2189 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2196 print_xattr_list(struct tcb *tcp, unsigned long addr, unsigned long size)
2198 if (syserror(tcp)) {
2199 tprintf("%#lx", addr);
2205 (size < tcp->u_rval) ? size : tcp->u_rval;
2206 printstr(tcp, addr, len);
2209 tprintf(", %lu", size);
2213 sys_listxattr(struct tcb *tcp)
2215 if (entering(tcp)) {
2216 printpath(tcp, tcp->u_arg[0]);
2219 print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2225 sys_flistxattr(struct tcb *tcp)
2227 if (entering(tcp)) {
2228 printfd(tcp, tcp->u_arg[0]);
2231 print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2237 sys_removexattr(struct tcb *tcp)
2239 if (entering(tcp)) {
2240 printpath(tcp, tcp->u_arg[0]);
2242 printstr(tcp, tcp->u_arg[1], -1);
2248 sys_fremovexattr(struct tcb *tcp)
2250 if (entering(tcp)) {
2251 printfd(tcp, tcp->u_arg[0]);
2253 printstr(tcp, tcp->u_arg[1], -1);
2258 #include "xlat/advise.h"
2261 sys_fadvise64(struct tcb *tcp)
2263 if (entering(tcp)) {
2265 printfd(tcp, tcp->u_arg[0]);
2266 argn = printllval(tcp, ", %lld", 1);
2267 tprintf(", %ld, ", tcp->u_arg[argn++]);
2268 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
2274 sys_fadvise64_64(struct tcb *tcp)
2276 if (entering(tcp)) {
2278 printfd(tcp, tcp->u_arg[0]);
2279 argn = printllval(tcp, ", %lld, ", 1);
2280 argn = printllval(tcp, "%lld, ", argn);
2281 #if defined __ARM_EABI__ || defined AARCH64 || defined POWERPC || defined XTENSA
2282 printxval(advise, tcp->u_arg[1], "POSIX_FADV_???");
2284 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
2290 #include "xlat/sync_file_range_flags.h"
2293 sys_sync_file_range(struct tcb *tcp)
2295 if (entering(tcp)) {
2297 printfd(tcp, tcp->u_arg[0]);
2298 argn = printllval(tcp, ", %lld, ", 1);
2299 argn = printllval(tcp, "%lld, ", argn);
2300 printflags(sync_file_range_flags, tcp->u_arg[argn],
2301 "SYNC_FILE_RANGE_???");
2307 sys_sync_file_range2(struct tcb *tcp)
2309 if (entering(tcp)) {
2311 printfd(tcp, tcp->u_arg[0]);
2312 printflags(sync_file_range_flags, 1,
2313 "SYNC_FILE_RANGE_???");
2314 argn = printllval(tcp, ", %lld, ", 2);
2315 argn = printllval(tcp, "%lld, ", argn);
2321 sys_fallocate(struct tcb *tcp)
2323 if (entering(tcp)) {
2325 printfd(tcp, tcp->u_arg[0]); /* fd */
2326 tprintf(", %#lo, ", tcp->u_arg[1]); /* mode */
2327 argn = printllval(tcp, "%llu, ", 2); /* offset */
2328 printllval(tcp, "%llu", argn); /* len */
2333 #ifndef SWAP_FLAG_PREFER
2334 # define SWAP_FLAG_PREFER 0x8000
2336 #ifndef SWAP_FLAG_DISCARD
2337 # define SWAP_FLAG_DISCARD 0x10000
2339 #include "xlat/swap_flags.h"
2342 sys_swapon(struct tcb *tcp)
2344 if (entering(tcp)) {
2345 int flags = tcp->u_arg[1];
2346 printpath(tcp, tcp->u_arg[0]);
2348 printflags(swap_flags, flags & ~SWAP_FLAG_PRIO_MASK,
2350 if (flags & SWAP_FLAG_PREFER)
2351 tprintf("|%d", flags & SWAP_FLAG_PRIO_MASK);