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.
35 #if defined(SPARC) || defined(SPARC64)
37 unsigned short st_dev;
39 unsigned short st_mode;
41 unsigned short st_uid;
42 unsigned short st_gid;
43 unsigned short st_rdev;
46 unsigned int __unused1;
48 unsigned int __unused2;
50 unsigned int __unused3;
53 unsigned int __unused4[2];
60 unsigned int st_nlink;
70 unsigned long __unused4[2];
73 # define stat kernel_stat
74 # include <asm/stat.h>
78 unsigned long long st_dev;
79 unsigned long long st_ino;
80 unsigned long long st_nlink;
86 unsigned long long st_rdev;
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];
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];
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 } __attribute__((packed));
121 # define HAVE_STAT64 1
123 struct __old_kernel_stat {
124 unsigned short st_dev;
125 unsigned short st_ino;
126 unsigned short st_mode;
127 unsigned short st_nlink;
128 unsigned short st_uid;
129 unsigned short st_gid;
130 unsigned short st_rdev;
131 unsigned int st_size;
132 unsigned int st_atime;
133 unsigned int st_mtime;
134 unsigned int st_ctime;
145 # define dev_t __kernel_dev_t
146 # define ino_t __kernel_ino_t
147 # define mode_t __kernel_mode_t
148 # define nlink_t __kernel_nlink_t
149 # define uid_t __kernel_uid_t
150 # define gid_t __kernel_gid_t
151 # define off_t __kernel_off_t
152 # define loff_t __kernel_loff_t
154 # include <asm/stat.h>
166 # define mode_t mode_t
167 # define nlink_t nlink_t
171 # define loff_t loff_t
174 #define stat libc_stat
175 #define stat64 libc_stat64
176 #include <sys/stat.h>
179 /* These might be macros. */
185 #ifdef HAVE_SYS_VFS_H
186 # include <sys/vfs.h>
188 #ifdef HAVE_LINUX_XATTR_H
189 # include <linux/xattr.h>
191 # define XATTR_CREATE 1
192 # define XATTR_REPLACE 2
195 #ifdef MAJOR_IN_SYSMACROS
196 # include <sys/sysmacros.h>
199 #ifdef MAJOR_IN_MKDEV
200 # include <sys/mkdev.h>
203 #ifdef HAVE_SYS_ASYNCH_H
204 # include <sys/asynch.h>
207 struct kernel_dirent {
210 unsigned short d_reclen;
215 # if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
218 # define O_LARGEFILE 0x40000
219 # elif defined X86_64 || defined S390X
220 # define O_LARGEFILE 0100000
225 #include "xlat/open_access_modes.h"
226 #include "xlat/open_mode_flags.h"
229 # define AT_FDCWD -100
232 /* The fd is an "int", so when decoding x86 on x86_64, we need to force sign
233 * extension to get the right value. We do this by declaring fd as int here.
236 print_dirfd(struct tcb *tcp, int fd)
239 tprints("AT_FDCWD, ");
247 * low bits of the open(2) flags define access mode,
248 * other bits are real flags.
251 sprint_open_modes(mode_t flags)
253 static char outstr[(1 + ARRAY_SIZE(open_mode_flags)) * sizeof("O_LARGEFILE")];
257 const struct xlat *x;
260 p = stpcpy(outstr, "flags");
261 str = xlookup(open_access_modes, flags & 3);
271 for (x = open_mode_flags; x->str; x++) {
272 if ((flags & x->val) == x->val) {
274 p = stpcpy(p, x->str);
281 /* flags is still nonzero */
283 sprintf(p, "%#x", flags);
288 tprint_open_modes(mode_t flags)
290 tprints(sprint_open_modes(flags) + sizeof("flags"));
294 decode_open(struct tcb *tcp, int offset)
297 printpath(tcp, tcp->u_arg[offset]);
300 tprint_open_modes(tcp->u_arg[offset + 1]);
301 if (tcp->u_arg[offset + 1] & O_CREAT) {
303 tprintf(", %#lo", tcp->u_arg[offset + 2]);
310 sys_open(struct tcb *tcp)
312 return decode_open(tcp, 0);
316 sys_openat(struct tcb *tcp)
319 print_dirfd(tcp, tcp->u_arg[0]);
320 return decode_open(tcp, 1);
323 #if defined(SPARC) || defined(SPARC64)
324 #include "xlat/openmodessol.h"
327 solaris_open(struct tcb *tcp)
330 printpath(tcp, tcp->u_arg[0]);
333 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
334 if (tcp->u_arg[1] & 0x100) {
336 tprintf(", %#lo", tcp->u_arg[2]);
345 sys_creat(struct tcb *tcp)
348 printpath(tcp, tcp->u_arg[0]);
349 tprintf(", %#lo", tcp->u_arg[1]);
354 #include "xlat/access_flags.h"
357 decode_access(struct tcb *tcp, int offset)
360 printpath(tcp, tcp->u_arg[offset]);
362 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK");
368 sys_access(struct tcb *tcp)
370 return decode_access(tcp, 0);
374 sys_faccessat(struct tcb *tcp)
377 print_dirfd(tcp, tcp->u_arg[0]);
378 return decode_access(tcp, 1);
382 sys_umask(struct tcb *tcp)
385 tprintf("%#lo", tcp->u_arg[0]);
390 #include "xlat/whence_codes.h"
392 /* Linux kernel has exactly one version of lseek:
393 * fs/read_write.c::SYSCALL_DEFINE3(lseek, unsigned, fd, off_t, offset, unsigned, origin)
394 * In kernel, off_t is always the same as (kernel's) long
395 * (see include/uapi/asm-generic/posix_types.h),
396 * which means that on x32 we need to use tcp->ext_arg[N] to get offset argument.
397 * Use test/x32_lseek.c to test lseek decoding.
399 #if defined(LINUX_MIPSN32) || defined(X32)
401 sys_lseek(struct tcb *tcp)
407 printfd(tcp, tcp->u_arg[0]);
408 offset = tcp->ext_arg[1];
409 whence = tcp->u_arg[2];
410 if (whence == SEEK_SET)
411 tprintf(", %llu, ", offset);
413 tprintf(", %lld, ", offset);
414 printxval(whence_codes, whence, "SEEK_???");
416 return RVAL_LUDECIMAL;
420 sys_lseek(struct tcb *tcp)
426 printfd(tcp, tcp->u_arg[0]);
427 offset = tcp->u_arg[1];
428 whence = tcp->u_arg[2];
429 if (whence == SEEK_SET)
430 tprintf(", %lu, ", offset);
432 tprintf(", %ld, ", offset);
433 printxval(whence_codes, whence, "SEEK_???");
435 return RVAL_UDECIMAL;
439 /* llseek syscall takes explicitly two ulong arguments hi, lo,
440 * rather than one 64-bit argument for which LONG_LONG works
441 * appropriate for the native byte order.
443 * See kernel's fs/read_write.c::SYSCALL_DEFINE5(llseek, ...)
445 * hi,lo are "unsigned longs" and combined exactly this way in kernel:
446 * ((loff_t) hi << 32) | lo
447 * Note that for architectures with kernel's long wider than userspace long
448 * (such as x32), combining code will use *kernel's*, i.e. *wide* longs
449 * for hi and lo. We would need to use tcp->ext_arg[N] on x32...
450 * ...however, x32 (and x86_64) does not _have_ llseek syscall as such.
453 sys_llseek(struct tcb *tcp)
456 printfd(tcp, tcp->u_arg[0]);
457 if (tcp->u_arg[4] == SEEK_SET)
459 ((long long) tcp->u_arg[1]) << 32 |
460 (unsigned long long) (unsigned) tcp->u_arg[2]);
463 ((long long) tcp->u_arg[1]) << 32 |
464 (unsigned long long) (unsigned) tcp->u_arg[2]);
468 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
469 tprintf("%#lx, ", tcp->u_arg[3]);
471 tprintf("[%llu], ", off);
472 printxval(whence_codes, tcp->u_arg[4], "SEEK_???");
478 sys_readahead(struct tcb *tcp)
482 printfd(tcp, tcp->u_arg[0]);
483 argn = printllval_aligned(tcp, ", %lld", 1);
484 tprintf(", %ld", tcp->u_arg[argn]);
490 sys_truncate(struct tcb *tcp)
493 printpath(tcp, tcp->u_arg[0]);
494 tprintf(", %lu", tcp->u_arg[1]);
500 sys_truncate64(struct tcb *tcp)
503 printpath(tcp, tcp->u_arg[0]);
504 printllval_aligned(tcp, ", %llu", 1);
510 sys_ftruncate(struct tcb *tcp)
513 printfd(tcp, tcp->u_arg[0]);
514 tprintf(", %lu", tcp->u_arg[1]);
520 sys_ftruncate64(struct tcb *tcp)
523 printfd(tcp, tcp->u_arg[0]);
524 printllval_aligned(tcp, ", %llu", 1);
531 #include "xlat/modetypes.h"
536 static char buf[sizeof("S_IFSOCK|S_ISUID|S_ISGID|S_ISVTX|%o")
541 if ((mode & S_IFMT) == 0)
543 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
544 sprintf(buf, "%#o", mode);
547 s = buf + sprintf(buf, "%s%s%s%s", s,
548 (mode & S_ISUID) ? "|S_ISUID" : "",
549 (mode & S_ISGID) ? "|S_ISGID" : "",
550 (mode & S_ISVTX) ? "|S_ISVTX" : "");
551 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
553 sprintf((char*)s, "|%#o", mode);
554 s = (*buf == '|') ? buf + 1 : buf;
562 static char buf[sizeof("yyyy/mm/dd-hh:mm:ss")];
570 snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d",
571 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
572 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
574 snprintf(buf, sizeof buf, "%lu", (unsigned long) t);
579 #if defined(SPARC) || defined(SPARC64)
587 int st_pad1[3]; /* network id */
596 int st_pad3; /* st_size, off_t expansion */
597 timestruct_t st_atime;
598 timestruct_t st_mtime;
599 timestruct_t st_ctime;
603 int st_pad4[8]; /* expansion area */
607 printstatsol(struct tcb *tcp, long addr)
609 struct solstat statbuf;
611 if (umove(tcp, addr, &statbuf) < 0) {
616 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
617 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
618 (unsigned long) (statbuf.st_dev & 0x3ffff),
619 (unsigned long) statbuf.st_ino,
620 sprintmode(statbuf.st_mode));
621 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
622 (unsigned long) statbuf.st_nlink,
623 (unsigned long) statbuf.st_uid,
624 (unsigned long) statbuf.st_gid);
625 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
626 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
629 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
630 switch (statbuf.st_mode & S_IFMT) {
631 case S_IFCHR: case S_IFBLK:
632 tprintf("st_rdev=makedev(%lu, %lu), ",
633 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
634 (unsigned long) (statbuf.st_rdev & 0x3ffff));
637 tprintf("st_size=%u, ", statbuf.st_size);
641 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
642 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
643 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
649 # if defined(SPARC64)
651 printstat_sparc64(struct tcb *tcp, long addr)
653 struct stat_sparc64 statbuf;
655 if (umove(tcp, addr, &statbuf) < 0) {
661 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
662 (unsigned long) major(statbuf.st_dev),
663 (unsigned long) minor(statbuf.st_dev),
664 (unsigned long) statbuf.st_ino,
665 sprintmode(statbuf.st_mode));
666 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
667 (unsigned long) statbuf.st_nlink,
668 (unsigned long) statbuf.st_uid,
669 (unsigned long) statbuf.st_gid);
670 tprintf("st_blksize=%lu, ",
671 (unsigned long) statbuf.st_blksize);
672 tprintf("st_blocks=%lu, ",
673 (unsigned long) statbuf.st_blocks);
676 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
677 switch (statbuf.st_mode & S_IFMT) {
678 case S_IFCHR: case S_IFBLK:
679 tprintf("st_rdev=makedev(%lu, %lu), ",
680 (unsigned long) major(statbuf.st_rdev),
681 (unsigned long) minor(statbuf.st_rdev));
684 tprintf("st_size=%lu, ", statbuf.st_size);
688 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
689 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
690 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
695 # endif /* SPARC64 */
696 #endif /* SPARC[64] */
698 #if defined POWERPC64
699 struct stat_powerpc32 {
702 unsigned int st_mode;
703 unsigned short st_nlink;
706 unsigned int st_rdev;
707 unsigned int st_size;
708 unsigned int st_blksize;
709 unsigned int st_blocks;
710 unsigned int st_atime;
711 unsigned int st_atime_nsec;
712 unsigned int st_mtime;
713 unsigned int st_mtime_nsec;
714 unsigned int st_ctime;
715 unsigned int st_ctime_nsec;
716 unsigned int __unused4;
717 unsigned int __unused5;
721 printstat_powerpc32(struct tcb *tcp, long addr)
723 struct stat_powerpc32 statbuf;
725 if (umove(tcp, addr, &statbuf) < 0) {
731 tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ",
732 major(statbuf.st_dev), minor(statbuf.st_dev),
734 sprintmode(statbuf.st_mode));
735 tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ",
736 statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid);
737 tprintf("st_blksize=%u, ", statbuf.st_blksize);
738 tprintf("st_blocks=%u, ", statbuf.st_blocks);
741 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
742 switch (statbuf.st_mode & S_IFMT) {
743 case S_IFCHR: case S_IFBLK:
744 tprintf("st_rdev=makedev(%lu, %lu), ",
745 (unsigned long) major(statbuf.st_rdev),
746 (unsigned long) minor(statbuf.st_rdev));
749 tprintf("st_size=%u, ", statbuf.st_size);
753 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
754 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
755 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
760 #endif /* POWERPC64 */
762 #include "xlat/fileflags.h"
765 realprintstat(struct tcb *tcp, struct stat *statbuf)
768 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
769 (unsigned long) major(statbuf->st_dev),
770 (unsigned long) minor(statbuf->st_dev),
771 (unsigned long) statbuf->st_ino,
772 sprintmode(statbuf->st_mode));
773 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
774 (unsigned long) statbuf->st_nlink,
775 (unsigned long) statbuf->st_uid,
776 (unsigned long) statbuf->st_gid);
777 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
778 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
780 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
781 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
785 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
786 switch (statbuf->st_mode & S_IFMT) {
787 case S_IFCHR: case S_IFBLK:
788 #ifdef HAVE_STRUCT_STAT_ST_RDEV
789 tprintf("st_rdev=makedev(%lu, %lu), ",
790 (unsigned long) major(statbuf->st_rdev),
791 (unsigned long) minor(statbuf->st_rdev));
792 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
793 tprintf("st_size=makedev(%lu, %lu), ",
794 (unsigned long) major(statbuf->st_size),
795 (unsigned long) minor(statbuf->st_size));
796 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
799 tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size);
803 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
804 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
805 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
806 #if HAVE_STRUCT_STAT_ST_FLAGS
807 tprints(", st_flags=");
808 printflags(fileflags, statbuf->st_flags, "UF_???");
810 #if HAVE_STRUCT_STAT_ST_ACLCNT
811 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
813 #if HAVE_STRUCT_STAT_ST_LEVEL
814 tprintf(", st_level=%ld", statbuf->st_level);
816 #if HAVE_STRUCT_STAT_ST_FSTYPE
817 tprintf(", st_fstype=%.*s",
818 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
820 #if HAVE_STRUCT_STAT_ST_GEN
821 tprintf(", st_gen=%u", statbuf->st_gen);
831 printstat(struct tcb *tcp, long addr)
839 if (syserror(tcp) || !verbose(tcp)) {
840 tprintf("%#lx", addr);
844 #if defined(SPARC) || defined(SPARC64)
845 if (current_personality == 1) {
846 printstatsol(tcp, addr);
850 else if (current_personality == 2) {
851 printstat_sparc64(tcp, addr);
855 #endif /* SPARC[64] */
857 #if defined POWERPC64
858 if (current_personality == 1) {
859 printstat_powerpc32(tcp, addr);
864 if (umove(tcp, addr, &statbuf) < 0) {
869 realprintstat(tcp, &statbuf);
872 # define printstat printstat64
875 #if !defined HAVE_STAT64 && (defined AARCH64 || defined X86_64)
877 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
878 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
879 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
880 * __GNUC__ is needed for the required __attribute__ below.
882 * Similarly, aarch64 has a unified `struct stat' but its arm personality
883 * needs `struct stat64' (which also expects a 32-bit `long' but which
884 * shouldn't be packed).
887 unsigned long long st_dev;
888 unsigned char __pad0[4];
889 unsigned int __st_ino;
890 unsigned int st_mode;
891 unsigned int st_nlink;
894 unsigned long long st_rdev;
895 unsigned char __pad3[4];
897 unsigned int st_blksize;
898 unsigned long long st_blocks;
899 unsigned int st_atime;
900 unsigned int st_atime_nsec;
901 unsigned int st_mtime;
902 unsigned int st_mtime_nsec;
903 unsigned int st_ctime;
904 unsigned int st_ctime_nsec;
905 unsigned long long st_ino;
908 __attribute__((packed))
909 # define STAT64_SIZE 96
911 # define STAT64_SIZE 104
914 # define HAVE_STAT64 1
919 printstat64(struct tcb *tcp, long addr)
924 struct stat64 statbuf;
928 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
935 if (syserror(tcp) || !verbose(tcp)) {
936 tprintf("%#lx", addr);
940 #if defined(SPARC) || defined(SPARC64)
941 if (current_personality == 1) {
942 printstatsol(tcp, addr);
946 else if (current_personality == 2) {
947 printstat_sparc64(tcp, addr);
951 #endif /* SPARC[64] */
954 if (current_personality != 0) {
955 printstat(tcp, addr);
960 if (current_personality != 1) {
961 printstat(tcp, addr);
966 if (umove(tcp, addr, &statbuf) < 0) {
972 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
973 (unsigned long) major(statbuf.st_dev),
974 (unsigned long) minor(statbuf.st_dev),
975 (unsigned long long) statbuf.st_ino,
976 sprintmode(statbuf.st_mode));
977 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
978 (unsigned long) statbuf.st_nlink,
979 (unsigned long) statbuf.st_uid,
980 (unsigned long) statbuf.st_gid);
981 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
982 tprintf("st_blksize=%lu, ",
983 (unsigned long) statbuf.st_blksize);
984 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
985 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
986 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
987 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
990 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
991 switch (statbuf.st_mode & S_IFMT) {
992 case S_IFCHR: case S_IFBLK:
993 #ifdef HAVE_STRUCT_STAT_ST_RDEV
994 tprintf("st_rdev=makedev(%lu, %lu), ",
995 (unsigned long) major(statbuf.st_rdev),
996 (unsigned long) minor(statbuf.st_rdev));
997 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
998 tprintf("st_size=makedev(%lu, %lu), ",
999 (unsigned long) major(statbuf.st_size),
1000 (unsigned long) minor(statbuf.st_size));
1001 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
1004 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1008 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1009 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
1010 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
1011 #if HAVE_STRUCT_STAT_ST_FLAGS
1012 tprints(", st_flags=");
1013 printflags(fileflags, statbuf.st_flags, "UF_???");
1015 #if HAVE_STRUCT_STAT_ST_ACLCNT
1016 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1018 #if HAVE_STRUCT_STAT_ST_LEVEL
1019 tprintf(", st_level=%ld", statbuf.st_level);
1021 #if HAVE_STRUCT_STAT_ST_FSTYPE
1022 tprintf(", st_fstype=%.*s",
1023 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1025 #if HAVE_STRUCT_STAT_ST_GEN
1026 tprintf(", st_gen=%u", statbuf.st_gen);
1033 #endif /* HAVE_STAT64 */
1035 #if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1037 convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
1039 newbuf->st_dev = oldbuf->st_dev;
1040 newbuf->st_ino = oldbuf->st_ino;
1041 newbuf->st_mode = oldbuf->st_mode;
1042 newbuf->st_nlink = oldbuf->st_nlink;
1043 newbuf->st_uid = oldbuf->st_uid;
1044 newbuf->st_gid = oldbuf->st_gid;
1045 newbuf->st_rdev = oldbuf->st_rdev;
1046 newbuf->st_size = oldbuf->st_size;
1047 newbuf->st_atime = oldbuf->st_atime;
1048 newbuf->st_mtime = oldbuf->st_mtime;
1049 newbuf->st_ctime = oldbuf->st_ctime;
1050 newbuf->st_blksize = 0; /* not supported in old_stat */
1051 newbuf->st_blocks = 0; /* not supported in old_stat */
1055 printoldstat(struct tcb *tcp, long addr)
1057 struct __old_kernel_stat statbuf;
1058 struct stat newstatbuf;
1064 if (syserror(tcp) || !verbose(tcp)) {
1065 tprintf("%#lx", addr);
1069 # if defined(SPARC) || defined(SPARC64)
1070 if (current_personality == 1) {
1071 printstatsol(tcp, addr);
1076 if (umove(tcp, addr, &statbuf) < 0) {
1081 convertoldstat(&statbuf, &newstatbuf);
1082 realprintstat(tcp, &newstatbuf);
1087 sys_stat(struct tcb *tcp)
1089 if (entering(tcp)) {
1090 printpath(tcp, tcp->u_arg[0]);
1093 printstat(tcp, tcp->u_arg[1]);
1100 printstat64_x32(struct tcb *tcp, long addr)
1102 struct stat64 statbuf;
1108 if (syserror(tcp) || !verbose(tcp)) {
1109 tprintf("%#lx", addr);
1113 if (umove(tcp, addr, &statbuf) < 0) {
1119 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1120 (unsigned long) major(statbuf.st_dev),
1121 (unsigned long) minor(statbuf.st_dev),
1122 (unsigned long long) statbuf.st_ino,
1123 sprintmode(statbuf.st_mode));
1124 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1125 (unsigned long) statbuf.st_nlink,
1126 (unsigned long) statbuf.st_uid,
1127 (unsigned long) statbuf.st_gid);
1128 tprintf("st_blksize=%lu, ",
1129 (unsigned long) statbuf.st_blksize);
1130 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
1133 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1134 switch (statbuf.st_mode & S_IFMT) {
1135 case S_IFCHR: case S_IFBLK:
1136 tprintf("st_rdev=makedev(%lu, %lu), ",
1137 (unsigned long) major(statbuf.st_rdev),
1138 (unsigned long) minor(statbuf.st_rdev));
1141 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1145 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1146 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
1147 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
1156 sys_stat64(struct tcb *tcp)
1159 if (entering(tcp)) {
1160 printpath(tcp, tcp->u_arg[0]);
1164 printstat64_x32(tcp, tcp->u_arg[1]);
1166 printstat64(tcp, tcp->u_arg[1]);
1171 return printargs(tcp);
1175 #ifndef AT_SYMLINK_NOFOLLOW
1176 # define AT_SYMLINK_NOFOLLOW 0x100
1178 #ifndef AT_REMOVEDIR
1179 # define AT_REMOVEDIR 0x200
1181 #ifndef AT_SYMLINK_FOLLOW
1182 # define AT_SYMLINK_FOLLOW 0x400
1184 #ifndef AT_NO_AUTOMOUNT
1185 # define AT_NO_AUTOMOUNT 0x800
1187 #ifndef AT_EMPTY_PATH
1188 # define AT_EMPTY_PATH 0x1000
1191 #include "xlat/at_flags.h"
1194 sys_newfstatat(struct tcb *tcp)
1196 if (entering(tcp)) {
1197 print_dirfd(tcp, tcp->u_arg[0]);
1198 printpath(tcp, tcp->u_arg[1]);
1202 if (current_personality == 0)
1203 printstat(tcp, tcp->u_arg[2]);
1205 printstat64(tcp, tcp->u_arg[2]);
1206 #elif defined HAVE_STAT64
1207 printstat64(tcp, tcp->u_arg[2]);
1209 printstat(tcp, tcp->u_arg[2]);
1212 printflags(at_flags, tcp->u_arg[3], "AT_???");
1217 #if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1219 sys_oldstat(struct tcb *tcp)
1221 if (entering(tcp)) {
1222 printpath(tcp, tcp->u_arg[0]);
1225 printoldstat(tcp, tcp->u_arg[1]);
1232 sys_fstat(struct tcb *tcp)
1234 if (entering(tcp)) {
1235 printfd(tcp, tcp->u_arg[0]);
1238 printstat(tcp, tcp->u_arg[1]);
1244 sys_fstat64(struct tcb *tcp)
1247 if (entering(tcp)) {
1248 printfd(tcp, tcp->u_arg[0]);
1252 printstat64_x32(tcp, tcp->u_arg[1]);
1254 printstat64(tcp, tcp->u_arg[1]);
1259 return printargs(tcp);
1263 #if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1265 sys_oldfstat(struct tcb *tcp)
1267 if (entering(tcp)) {
1268 printfd(tcp, tcp->u_arg[0]);
1271 printoldstat(tcp, tcp->u_arg[1]);
1277 #if defined(SPARC) || defined(SPARC64)
1280 sys_xstat(struct tcb *tcp)
1282 if (entering(tcp)) {
1283 tprintf("%ld, ", tcp->u_arg[0]);
1284 printpath(tcp, tcp->u_arg[1]);
1288 if (tcp->u_arg[0] == _STAT64_VER)
1289 printstat64(tcp, tcp->u_arg[2]);
1292 printstat(tcp, tcp->u_arg[2]);
1298 sys_fxstat(struct tcb *tcp)
1301 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1304 if (tcp->u_arg[0] == _STAT64_VER)
1305 printstat64(tcp, tcp->u_arg[2]);
1308 printstat(tcp, tcp->u_arg[2]);
1314 sys_lxstat(struct tcb *tcp)
1316 if (entering(tcp)) {
1317 tprintf("%ld, ", tcp->u_arg[0]);
1318 printpath(tcp, tcp->u_arg[1]);
1322 if (tcp->u_arg[0] == _STAT64_VER)
1323 printstat64(tcp, tcp->u_arg[2]);
1326 printstat(tcp, tcp->u_arg[2]);
1332 sys_xmknod(struct tcb *tcp)
1334 int mode = tcp->u_arg[2];
1336 if (entering(tcp)) {
1337 tprintf("%ld, ", tcp->u_arg[0]);
1338 printpath(tcp, tcp->u_arg[1]);
1339 tprintf(", %s", sprintmode(mode));
1340 switch (mode & S_IFMT) {
1341 case S_IFCHR: case S_IFBLK:
1342 tprintf(", makedev(%lu, %lu)",
1343 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1344 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1353 # ifdef HAVE_SYS_ACL_H
1355 # include <sys/acl.h>
1357 #include "xlat/aclcmds.h"
1360 sys_acl(struct tcb *tcp)
1362 if (entering(tcp)) {
1363 printpath(tcp, tcp->u_arg[0]);
1365 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1366 tprintf(", %ld", tcp->u_arg[2]);
1368 * FIXME - dump out the list of aclent_t's pointed to
1369 * by "tcp->u_arg[3]" if it's not NULL.
1372 tprintf(", %#lx", tcp->u_arg[3]);
1380 sys_facl(struct tcb *tcp)
1382 if (entering(tcp)) {
1383 tprintf("%ld, ", tcp->u_arg[0]);
1384 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1385 tprintf(", %ld", tcp->u_arg[2]);
1387 * FIXME - dump out the list of aclent_t's pointed to
1388 * by "tcp->u_arg[3]" if it's not NULL.
1391 tprintf(", %#lx", tcp->u_arg[3]);
1398 #include "xlat/aclipc.h"
1401 sys_aclipc(struct tcb *tcp)
1403 if (entering(tcp)) {
1404 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1405 tprintf(", %#lx, ", tcp->u_arg[1]);
1406 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1407 tprintf(", %ld", tcp->u_arg[3]);
1409 * FIXME - dump out the list of aclent_t's pointed to
1410 * by "tcp->u_arg[4]" if it's not NULL.
1413 tprintf(", %#lx", tcp->u_arg[4]);
1420 # endif /* HAVE_SYS_ACL_H */
1422 #endif /* SPARC[64] */
1424 #include "xlat/fsmagic.h"
1427 sprintfstype(int magic)
1429 static char buf[32];
1432 s = xlookup(fsmagic, magic);
1434 sprintf(buf, "\"%s\"", s);
1437 sprintf(buf, "%#x", magic);
1442 printstatfs(struct tcb *tcp, long addr)
1444 struct statfs statbuf;
1446 if (syserror(tcp) || !verbose(tcp)) {
1447 tprintf("%#lx", addr);
1450 if (umove(tcp, addr, &statbuf) < 0) {
1456 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1457 sprintfstype(statbuf.f_type),
1458 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1459 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1460 statbuf.f_bavail, statbuf.f_files, statbuf.f_ffree,
1461 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1464 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1465 sprintfstype(statbuf.f_type),
1466 (unsigned long)statbuf.f_bsize,
1467 (unsigned long)statbuf.f_blocks,
1468 (unsigned long)statbuf.f_bfree);
1469 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1470 (unsigned long)statbuf.f_bavail,
1471 (unsigned long)statbuf.f_files,
1472 (unsigned long)statbuf.f_ffree,
1473 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1474 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1476 #ifdef _STATFS_F_FRSIZE
1477 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1483 sys_statfs(struct tcb *tcp)
1485 if (entering(tcp)) {
1486 printpath(tcp, tcp->u_arg[0]);
1489 printstatfs(tcp, tcp->u_arg[1]);
1495 sys_fstatfs(struct tcb *tcp)
1497 if (entering(tcp)) {
1498 printfd(tcp, tcp->u_arg[0]);
1501 printstatfs(tcp, tcp->u_arg[1]);
1506 #if defined HAVE_STATFS64
1508 printstatfs64(struct tcb *tcp, long addr)
1510 struct statfs64 statbuf;
1512 if (syserror(tcp) || !verbose(tcp)) {
1513 tprintf("%#lx", addr);
1516 if (umove(tcp, addr, &statbuf) < 0) {
1520 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
1521 sprintfstype(statbuf.f_type),
1522 (unsigned long long)statbuf.f_bsize,
1523 (unsigned long long)statbuf.f_blocks,
1524 (unsigned long long)statbuf.f_bfree);
1525 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1526 (unsigned long long)statbuf.f_bavail,
1527 (unsigned long long)statbuf.f_files,
1528 (unsigned long long)statbuf.f_ffree,
1529 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1530 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1531 #ifdef _STATFS_F_FRSIZE
1532 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
1534 #ifdef _STATFS_F_FLAGS
1535 tprintf(", f_flags=%llu", (unsigned long long)statbuf.f_flags);
1540 struct compat_statfs64 {
1552 uint32_t f_spare[4];
1554 #if defined(X86_64) || defined(IA64)
1555 __attribute__ ((packed, aligned(4)))
1560 printcompat_statfs64(struct tcb *tcp, long addr)
1562 struct compat_statfs64 statbuf;
1564 if (syserror(tcp) || !verbose(tcp)) {
1565 tprintf("%#lx", addr);
1568 if (umove(tcp, addr, &statbuf) < 0) {
1572 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%llu, f_bfree=%llu, ",
1573 sprintfstype(statbuf.f_type),
1574 (unsigned long)statbuf.f_bsize,
1575 (unsigned long long)statbuf.f_blocks,
1576 (unsigned long long)statbuf.f_bfree);
1577 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1578 (unsigned long long)statbuf.f_bavail,
1579 (unsigned long long)statbuf.f_files,
1580 (unsigned long long)statbuf.f_ffree,
1581 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1582 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1583 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1584 tprintf(", f_flags=%lu}", (unsigned long)statbuf.f_frsize);
1588 sys_statfs64(struct tcb *tcp)
1590 if (entering(tcp)) {
1591 printpath(tcp, tcp->u_arg[0]);
1592 tprintf(", %lu, ", tcp->u_arg[1]);
1594 if (tcp->u_arg[1] == sizeof(struct statfs64))
1595 printstatfs64(tcp, tcp->u_arg[2]);
1596 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
1597 printcompat_statfs64(tcp, tcp->u_arg[2]);
1605 sys_fstatfs64(struct tcb *tcp)
1607 if (entering(tcp)) {
1608 printfd(tcp, tcp->u_arg[0]);
1609 tprintf(", %lu, ", tcp->u_arg[1]);
1611 if (tcp->u_arg[1] == sizeof(struct statfs64))
1612 printstatfs64(tcp, tcp->u_arg[2]);
1613 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
1614 printcompat_statfs64(tcp, tcp->u_arg[2]);
1624 osf_statfs(struct tcb *tcp)
1626 if (entering(tcp)) {
1627 printpath(tcp, tcp->u_arg[0]);
1630 printstatfs(tcp, tcp->u_arg[1]);
1631 tprintf(", %lu", tcp->u_arg[2]);
1637 osf_fstatfs(struct tcb *tcp)
1639 if (entering(tcp)) {
1640 tprintf("%lu, ", tcp->u_arg[0]);
1642 printstatfs(tcp, tcp->u_arg[1]);
1643 tprintf(", %lu", tcp->u_arg[2]);
1651 sys_chdir(struct tcb *tcp)
1653 if (entering(tcp)) {
1654 printpath(tcp, tcp->u_arg[0]);
1660 decode_mkdir(struct tcb *tcp, int offset)
1662 if (entering(tcp)) {
1663 printpath(tcp, tcp->u_arg[offset]);
1664 tprintf(", %#lo", tcp->u_arg[offset + 1]);
1670 sys_mkdir(struct tcb *tcp)
1672 return decode_mkdir(tcp, 0);
1676 sys_mkdirat(struct tcb *tcp)
1679 print_dirfd(tcp, tcp->u_arg[0]);
1680 return decode_mkdir(tcp, 1);
1684 sys_link(struct tcb *tcp)
1686 if (entering(tcp)) {
1687 printpath(tcp, tcp->u_arg[0]);
1689 printpath(tcp, tcp->u_arg[1]);
1695 sys_linkat(struct tcb *tcp)
1697 if (entering(tcp)) {
1698 print_dirfd(tcp, tcp->u_arg[0]);
1699 printpath(tcp, tcp->u_arg[1]);
1701 print_dirfd(tcp, tcp->u_arg[2]);
1702 printpath(tcp, tcp->u_arg[3]);
1704 printflags(at_flags, tcp->u_arg[4], "AT_???");
1710 sys_unlinkat(struct tcb *tcp)
1712 if (entering(tcp)) {
1713 print_dirfd(tcp, tcp->u_arg[0]);
1714 printpath(tcp, tcp->u_arg[1]);
1716 printflags(at_flags, tcp->u_arg[2], "AT_???");
1722 sys_symlinkat(struct tcb *tcp)
1724 if (entering(tcp)) {
1725 printpath(tcp, tcp->u_arg[0]);
1727 print_dirfd(tcp, tcp->u_arg[1]);
1728 printpath(tcp, tcp->u_arg[2]);
1734 decode_readlink(struct tcb *tcp, int offset)
1736 if (entering(tcp)) {
1737 printpath(tcp, tcp->u_arg[offset]);
1741 tprintf("%#lx", tcp->u_arg[offset + 1]);
1743 /* Used to use printpathn(), but readlink
1744 * neither includes NUL in the returned count,
1745 * nor actually writes it into memory.
1746 * printpathn() would decide on printing
1747 * "..." continuation based on garbage
1748 * past return buffer's end.
1750 printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
1751 tprintf(", %lu", tcp->u_arg[offset + 2]);
1757 sys_readlink(struct tcb *tcp)
1759 return decode_readlink(tcp, 0);
1763 sys_readlinkat(struct tcb *tcp)
1766 print_dirfd(tcp, tcp->u_arg[0]);
1767 return decode_readlink(tcp, 1);
1771 sys_renameat(struct tcb *tcp)
1773 if (entering(tcp)) {
1774 print_dirfd(tcp, tcp->u_arg[0]);
1775 printpath(tcp, tcp->u_arg[1]);
1777 print_dirfd(tcp, tcp->u_arg[2]);
1778 printpath(tcp, tcp->u_arg[3]);
1784 sys_chown(struct tcb *tcp)
1786 if (entering(tcp)) {
1787 printpath(tcp, tcp->u_arg[0]);
1788 printuid(", ", tcp->u_arg[1]);
1789 printuid(", ", tcp->u_arg[2]);
1795 sys_fchownat(struct tcb *tcp)
1797 if (entering(tcp)) {
1798 print_dirfd(tcp, tcp->u_arg[0]);
1799 printpath(tcp, tcp->u_arg[1]);
1800 printuid(", ", tcp->u_arg[2]);
1801 printuid(", ", tcp->u_arg[3]);
1803 printflags(at_flags, tcp->u_arg[4], "AT_???");
1809 sys_fchown(struct tcb *tcp)
1811 if (entering(tcp)) {
1812 printfd(tcp, tcp->u_arg[0]);
1813 printuid(", ", tcp->u_arg[1]);
1814 printuid(", ", tcp->u_arg[2]);
1820 decode_chmod(struct tcb *tcp, int offset)
1822 if (entering(tcp)) {
1823 printpath(tcp, tcp->u_arg[offset]);
1824 tprintf(", %#lo", tcp->u_arg[offset + 1]);
1830 sys_chmod(struct tcb *tcp)
1832 return decode_chmod(tcp, 0);
1836 sys_fchmodat(struct tcb *tcp)
1839 print_dirfd(tcp, tcp->u_arg[0]);
1840 return decode_chmod(tcp, 1);
1844 sys_fchmod(struct tcb *tcp)
1846 if (entering(tcp)) {
1847 printfd(tcp, tcp->u_arg[0]);
1848 tprintf(", %#lo", tcp->u_arg[1]);
1855 sys_osf_utimes(struct tcb *tcp)
1857 if (entering(tcp)) {
1858 printpath(tcp, tcp->u_arg[0]);
1860 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
1867 decode_utimes(struct tcb *tcp, int offset, int special)
1869 if (entering(tcp)) {
1870 printpath(tcp, tcp->u_arg[offset]);
1872 if (tcp->u_arg[offset + 1] == 0)
1876 printtv_bitness(tcp, tcp->u_arg[offset + 1],
1877 BITNESS_CURRENT, special);
1879 printtv_bitness(tcp, tcp->u_arg[offset + 1]
1880 + sizeof(struct timeval),
1881 BITNESS_CURRENT, special);
1889 sys_utimes(struct tcb *tcp)
1891 return decode_utimes(tcp, 0, 0);
1895 sys_futimesat(struct tcb *tcp)
1898 print_dirfd(tcp, tcp->u_arg[0]);
1899 return decode_utimes(tcp, 1, 0);
1903 sys_utimensat(struct tcb *tcp)
1905 if (entering(tcp)) {
1906 print_dirfd(tcp, tcp->u_arg[0]);
1907 decode_utimes(tcp, 1, 1);
1909 printflags(at_flags, tcp->u_arg[3], "AT_???");
1915 sys_utime(struct tcb *tcp)
1920 long paranoia_for_huge_wordsize[4];
1924 if (entering(tcp)) {
1925 printpath(tcp, tcp->u_arg[0]);
1928 wordsize = current_wordsize;
1931 else if (!verbose(tcp))
1932 tprintf("%#lx", tcp->u_arg[1]);
1933 else if (umoven(tcp, tcp->u_arg[1], 2 * wordsize, (char *) &u) < 0)
1935 else if (wordsize == sizeof u.utl[0]) {
1936 tprintf("[%s,", sprinttime(u.utl[0]));
1937 tprintf(" %s]", sprinttime(u.utl[1]));
1939 else if (wordsize == sizeof u.uti[0]) {
1940 tprintf("[%s,", sprinttime(u.uti[0]));
1941 tprintf(" %s]", sprinttime(u.uti[1]));
1944 tprintf("<decode error: unsupported wordsize %d>",
1951 decode_mknod(struct tcb *tcp, int offset)
1953 int mode = tcp->u_arg[offset + 1];
1955 if (entering(tcp)) {
1956 printpath(tcp, tcp->u_arg[offset]);
1957 tprintf(", %s", sprintmode(mode));
1958 switch (mode & S_IFMT) {
1961 #if defined(SPARC) || defined(SPARC64)
1962 if (current_personality == 1)
1963 tprintf(", makedev(%lu, %lu)",
1964 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
1965 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
1968 tprintf(", makedev(%lu, %lu)",
1969 (unsigned long) major(tcp->u_arg[offset + 2]),
1970 (unsigned long) minor(tcp->u_arg[offset + 2]));
1980 sys_mknod(struct tcb *tcp)
1982 return decode_mknod(tcp, 0);
1986 sys_mknodat(struct tcb *tcp)
1989 print_dirfd(tcp, tcp->u_arg[0]);
1990 return decode_mknod(tcp, 1);
1994 print_old_dirent(struct tcb *tcp, long addr)
1997 typedef struct kernel_dirent old_dirent_t;
2002 unsigned short d_reclen;
2008 if (!verbose(tcp) || umove(tcp, addr, &d) < 0) {
2009 tprintf("%#lx", addr);
2013 tprintf("{d_ino=%lu, d_off=%lu, d_reclen=%u, d_name=\"",
2014 (unsigned long) d.d_ino, (unsigned long) d.d_off, d.d_reclen);
2015 if (d.d_reclen > 256)
2017 printpathn(tcp, addr + offsetof(old_dirent_t, d_name), d.d_reclen);
2022 sys_readdir(struct tcb *tcp)
2024 if (entering(tcp)) {
2025 printfd(tcp, tcp->u_arg[0]);
2028 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
2029 tprintf("%#lx", tcp->u_arg[1]);
2031 print_old_dirent(tcp, tcp->u_arg[1]);
2032 /* Not much point in printing this out, it is always 1. */
2033 if (tcp->u_arg[2] != 1)
2034 tprintf(", %lu", tcp->u_arg[2]);
2039 #include "xlat/direnttypes.h"
2042 sys_getdents(struct tcb *tcp)
2044 int i, len, dents = 0;
2047 if (entering(tcp)) {
2048 printfd(tcp, tcp->u_arg[0]);
2052 if (syserror(tcp) || !verbose(tcp)) {
2053 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2057 /* Beware of insanely large or negative values in tcp->u_rval */
2058 if (tcp->u_rval > 1024*1024)
2060 if (tcp->u_rval < 0)
2062 buf = len ? malloc(len) : NULL;
2064 die_out_of_memory();
2065 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2066 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2072 for (i = 0; i < len;) {
2073 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2075 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2076 i ? " " : "", d->d_ino, d->d_off);
2077 tprintf("d_reclen=%u, d_name=\"%s\", d_type=",
2078 d->d_reclen, d->d_name);
2079 printxval(direnttypes, buf[i + d->d_reclen - 1], "DT_???");
2083 tprints("/* d_reclen == 0, problem here */");
2092 tprintf("/* %u entries */", dents);
2093 tprintf(", %lu", tcp->u_arg[2]);
2099 sys_getdents64(struct tcb *tcp)
2101 int i, len, dents = 0;
2104 if (entering(tcp)) {
2105 printfd(tcp, tcp->u_arg[0]);
2109 if (syserror(tcp) || !verbose(tcp)) {
2110 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2115 /* Beware of insanely large or negative tcp->u_rval */
2116 if (tcp->u_rval > 1024*1024)
2118 if (tcp->u_rval < 0)
2120 buf = len ? malloc(len) : NULL;
2122 die_out_of_memory();
2124 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2125 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2131 for (i = 0; i < len;) {
2132 struct dirent64 *d = (struct dirent64 *) &buf[i];
2134 tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ",
2139 printxval(direnttypes, d->d_type, "DT_???");
2141 tprintf("d_reclen=%u, d_name=\"%s\"}",
2142 d->d_reclen, d->d_name);
2145 tprints("/* d_reclen == 0, problem here */");
2154 tprintf("/* %u entries */", dents);
2155 tprintf(", %lu", tcp->u_arg[2]);
2161 sys_getcwd(struct tcb *tcp)
2165 tprintf("%#lx", tcp->u_arg[0]);
2167 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2168 tprintf(", %lu", tcp->u_arg[1]);
2173 #ifdef HAVE_SYS_ASYNCH_H
2176 sys_aioread(struct tcb *tcp)
2178 struct aio_result_t res;
2180 if (entering(tcp)) {
2181 tprintf("%lu, ", tcp->u_arg[0]);
2184 tprintf("%#lx", tcp->u_arg[1]);
2186 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2187 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2188 printxval(whence, tcp->u_arg[4], "L_???");
2189 if (syserror(tcp) || tcp->u_arg[5] == 0
2190 || umove(tcp, tcp->u_arg[5], &res) < 0)
2191 tprintf(", %#lx", tcp->u_arg[5]);
2193 tprintf(", {aio_return %d aio_errno %d}",
2194 res.aio_return, res.aio_errno);
2200 sys_aiowrite(struct tcb *tcp)
2202 struct aio_result_t res;
2204 if (entering(tcp)) {
2205 tprintf("%lu, ", tcp->u_arg[0]);
2206 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2207 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2208 printxval(whence, tcp->u_arg[4], "L_???");
2211 if (tcp->u_arg[5] == 0)
2213 else if (syserror(tcp)
2214 || umove(tcp, tcp->u_arg[5], &res) < 0)
2215 tprintf(", %#lx", tcp->u_arg[5]);
2217 tprintf(", {aio_return %d aio_errno %d}",
2218 res.aio_return, res.aio_errno);
2224 sys_aiowait(struct tcb *tcp)
2227 printtv(tcp, tcp->u_arg[0]);
2232 sys_aiocancel(struct tcb *tcp)
2234 struct aio_result_t res;
2237 if (tcp->u_arg[0] == 0)
2239 else if (syserror(tcp)
2240 || umove(tcp, tcp->u_arg[0], &res) < 0)
2241 tprintf("%#lx", tcp->u_arg[0]);
2243 tprintf("{aio_return %d aio_errno %d}",
2244 res.aio_return, res.aio_errno);
2249 #endif /* HAVE_SYS_ASYNCH_H */
2251 #include "xlat/xattrflags.h"
2254 print_xattr_val(struct tcb *tcp, int failed,
2256 unsigned long insize,
2262 unsigned long capacity = 4 * size + 1;
2263 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
2264 if (buf == NULL || /* probably a bogus size argument */
2265 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2269 unsigned char *out = buf;
2270 unsigned char *in = &buf[3 * size];
2272 for (i = 0; i < size; ++i) {
2273 if (in[i] >= ' ' && in[i] <= 0x7e)
2276 #define tohex(n) "0123456789abcdef"[n]
2279 *out++ = tohex(in[i] / 16);
2280 *out++ = tohex(in[i] % 16);
2283 /* Don't print terminating NUL if there is one. */
2284 if (i > 0 && in[i - 1] == '\0')
2287 tprintf(", \"%s\", %ld", buf, insize);
2292 tprintf(", 0x%lx, %ld", arg, insize);
2296 sys_setxattr(struct tcb *tcp)
2298 if (entering(tcp)) {
2299 printpath(tcp, tcp->u_arg[0]);
2301 printstr(tcp, tcp->u_arg[1], -1);
2302 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2304 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2310 sys_fsetxattr(struct tcb *tcp)
2312 if (entering(tcp)) {
2313 printfd(tcp, tcp->u_arg[0]);
2315 printstr(tcp, tcp->u_arg[1], -1);
2316 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2318 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2324 sys_getxattr(struct tcb *tcp)
2326 if (entering(tcp)) {
2327 printpath(tcp, tcp->u_arg[0]);
2329 printstr(tcp, tcp->u_arg[1], -1);
2331 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2338 sys_fgetxattr(struct tcb *tcp)
2340 if (entering(tcp)) {
2341 printfd(tcp, tcp->u_arg[0]);
2343 printstr(tcp, tcp->u_arg[1], -1);
2345 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2352 print_xattr_list(struct tcb *tcp, unsigned long addr, unsigned long size)
2354 if (syserror(tcp)) {
2355 tprintf("%#lx", addr);
2361 (size < tcp->u_rval) ? size : tcp->u_rval;
2362 printstr(tcp, addr, len);
2365 tprintf(", %lu", size);
2369 sys_listxattr(struct tcb *tcp)
2371 if (entering(tcp)) {
2372 printpath(tcp, tcp->u_arg[0]);
2375 print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2381 sys_flistxattr(struct tcb *tcp)
2383 if (entering(tcp)) {
2384 printfd(tcp, tcp->u_arg[0]);
2387 print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2393 sys_removexattr(struct tcb *tcp)
2395 if (entering(tcp)) {
2396 printpath(tcp, tcp->u_arg[0]);
2398 printstr(tcp, tcp->u_arg[1], -1);
2404 sys_fremovexattr(struct tcb *tcp)
2406 if (entering(tcp)) {
2407 printfd(tcp, tcp->u_arg[0]);
2409 printstr(tcp, tcp->u_arg[1], -1);
2414 #include "xlat/advise.h"
2417 sys_fadvise64(struct tcb *tcp)
2419 if (entering(tcp)) {
2421 printfd(tcp, tcp->u_arg[0]);
2422 argn = printllval_aligned(tcp, ", %lld", 1);
2423 tprintf(", %ld, ", tcp->u_arg[argn++]);
2424 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
2430 sys_fadvise64_64(struct tcb *tcp)
2432 if (entering(tcp)) {
2434 printfd(tcp, tcp->u_arg[0]);
2435 argn = printllval_aligned(tcp, ", %lld, ", 1);
2436 argn = printllval_aligned(tcp, "%lld, ", argn);
2437 #if defined __ARM_EABI__ || defined AARCH64 || defined POWERPC || defined XTENSA
2438 printxval(advise, tcp->u_arg[1], "POSIX_FADV_???");
2440 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
2446 #include "xlat/sync_file_range_flags.h"
2449 sys_sync_file_range(struct tcb *tcp)
2451 if (entering(tcp)) {
2453 printfd(tcp, tcp->u_arg[0]);
2454 argn = printllval_aligned(tcp, ", %lld, ", 1);
2455 argn = printllval_aligned(tcp, "%lld, ", argn);
2456 printflags(sync_file_range_flags, tcp->u_arg[argn],
2457 "SYNC_FILE_RANGE_???");
2463 sys_sync_file_range2(struct tcb *tcp)
2465 if (entering(tcp)) {
2467 printfd(tcp, tcp->u_arg[0]);
2468 printflags(sync_file_range_flags, 1,
2469 "SYNC_FILE_RANGE_???");
2470 argn = printllval_aligned(tcp, ", %lld, ", 2);
2471 argn = printllval_aligned(tcp, "%lld, ", argn);
2477 sys_fallocate(struct tcb *tcp)
2479 if (entering(tcp)) {
2481 printfd(tcp, tcp->u_arg[0]); /* fd */
2482 tprintf(", %#lo, ", tcp->u_arg[1]); /* mode */
2483 argn = printllval_aligned(tcp, "%llu, ", 2); /* offset */
2484 printllval_aligned(tcp, "%llu", argn); /* len */
2489 #ifndef SWAP_FLAG_PREFER
2490 # define SWAP_FLAG_PREFER 0x8000
2492 #ifndef SWAP_FLAG_DISCARD
2493 # define SWAP_FLAG_DISCARD 0x10000
2495 #include "xlat/swap_flags.h"
2498 sys_swapon(struct tcb *tcp)
2500 if (entering(tcp)) {
2501 int flags = tcp->u_arg[1];
2502 printpath(tcp, tcp->u_arg[0]);
2504 printflags(swap_flags, flags & ~SWAP_FLAG_PRIO_MASK,
2506 if (flags & SWAP_FLAG_PREFER)
2507 tprintf("|%d", flags & SWAP_FLAG_PRIO_MASK);