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.
33 #if defined(SPARC) || defined(SPARC64)
35 unsigned short st_dev;
37 unsigned short st_mode;
39 unsigned short st_uid;
40 unsigned short st_gid;
41 unsigned short st_rdev;
44 unsigned int __unused1;
46 unsigned int __unused2;
48 unsigned int __unused3;
51 unsigned int __unused4[2];
58 unsigned int st_nlink;
68 unsigned long __unused4[2];
71 # define stat kernel_stat
72 # include <asm/stat.h>
76 unsigned long long st_dev;
77 unsigned long long st_ino;
78 unsigned long long st_nlink;
84 unsigned long long st_rdev;
89 unsigned long long st_atime;
90 unsigned long long st_atime_nsec;
91 unsigned long long st_mtime;
92 unsigned long long st_mtime_nsec;
93 unsigned long long st_ctime;
94 unsigned long long st_ctime_nsec;
95 long long __unused[3];
99 unsigned long long st_dev;
100 unsigned char __pad0[4];
101 unsigned long __st_ino;
102 unsigned int st_mode;
103 unsigned int st_nlink;
104 unsigned long st_uid;
105 unsigned long st_gid;
106 unsigned long long st_rdev;
107 unsigned char __pad3[4];
109 unsigned long st_blksize;
110 unsigned long long st_blocks;
111 unsigned long st_atime;
112 unsigned long st_atime_nsec;
113 unsigned long st_mtime;
114 unsigned int st_mtime_nsec;
115 unsigned long st_ctime;
116 unsigned long st_ctime_nsec;
117 unsigned long long st_ino;
118 } __attribute__((packed));
119 # define HAVE_STAT64 1
121 struct __old_kernel_stat {
122 unsigned short st_dev;
123 unsigned short st_ino;
124 unsigned short st_mode;
125 unsigned short st_nlink;
126 unsigned short st_uid;
127 unsigned short st_gid;
128 unsigned short st_rdev;
129 unsigned int st_size;
130 unsigned int st_atime;
131 unsigned int st_mtime;
132 unsigned int st_ctime;
143 # define dev_t __kernel_dev_t
144 # define ino_t __kernel_ino_t
145 # define mode_t __kernel_mode_t
146 # define nlink_t __kernel_nlink_t
147 # define uid_t __kernel_uid_t
148 # define gid_t __kernel_gid_t
149 # define off_t __kernel_off_t
150 # define loff_t __kernel_loff_t
152 # include <asm/stat.h>
164 # define mode_t mode_t
165 # define nlink_t nlink_t
169 # define loff_t loff_t
172 #define stat libc_stat
173 #define stat64 libc_stat64
174 #include <sys/stat.h>
177 /* These might be macros. */
184 #ifdef MAJOR_IN_SYSMACROS
185 # include <sys/sysmacros.h>
188 #ifdef MAJOR_IN_MKDEV
189 # include <sys/mkdev.h>
193 # if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
196 # define O_LARGEFILE 0x40000
197 # elif defined X86_64 || defined S390X
198 # define O_LARGEFILE 0100000
203 #include "xlat/open_access_modes.h"
204 #include "xlat/open_mode_flags.h"
207 # define AT_FDCWD -100
210 /* The fd is an "int", so when decoding x86 on x86_64, we need to force sign
211 * extension to get the right value. We do this by declaring fd as int here.
214 print_dirfd(struct tcb *tcp, int fd)
217 tprints("AT_FDCWD, ");
225 * low bits of the open(2) flags define access mode,
226 * other bits are real flags.
229 sprint_open_modes(int flags)
231 static char outstr[(1 + ARRAY_SIZE(open_mode_flags)) * sizeof("O_LARGEFILE")];
235 const struct xlat *x;
238 p = stpcpy(outstr, "flags");
239 str = xlookup(open_access_modes, flags & 3);
249 for (x = open_mode_flags; x->str; x++) {
250 if ((flags & x->val) == x->val) {
252 p = stpcpy(p, x->str);
259 /* flags is still nonzero */
261 sprintf(p, "%#x", flags);
266 tprint_open_modes(int flags)
268 tprints(sprint_open_modes(flags) + sizeof("flags"));
272 decode_open(struct tcb *tcp, int offset)
275 printpath(tcp, tcp->u_arg[offset]);
278 tprint_open_modes(tcp->u_arg[offset + 1]);
279 if (tcp->u_arg[offset + 1] & O_CREAT) {
281 tprintf(", %#lo", tcp->u_arg[offset + 2]);
288 sys_open(struct tcb *tcp)
290 return decode_open(tcp, 0);
294 sys_openat(struct tcb *tcp)
297 print_dirfd(tcp, tcp->u_arg[0]);
298 return decode_open(tcp, 1);
301 #if defined(SPARC) || defined(SPARC64)
302 #include "xlat/openmodessol.h"
305 solaris_open(struct tcb *tcp)
308 printpath(tcp, tcp->u_arg[0]);
311 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
312 if (tcp->u_arg[1] & 0x100) {
314 tprintf(", %#lo", tcp->u_arg[2]);
323 sys_creat(struct tcb *tcp)
326 printpath(tcp, tcp->u_arg[0]);
327 tprintf(", %#lo", tcp->u_arg[1]);
332 #include "xlat/access_flags.h"
335 decode_access(struct tcb *tcp, int offset)
338 printpath(tcp, tcp->u_arg[offset]);
340 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK");
346 sys_access(struct tcb *tcp)
348 return decode_access(tcp, 0);
352 sys_faccessat(struct tcb *tcp)
355 print_dirfd(tcp, tcp->u_arg[0]);
356 return decode_access(tcp, 1);
360 sys_umask(struct tcb *tcp)
363 tprintf("%#lo", tcp->u_arg[0]);
368 #include "xlat/whence_codes.h"
370 /* Linux kernel has exactly one version of lseek:
371 * fs/read_write.c::SYSCALL_DEFINE3(lseek, unsigned, fd, off_t, offset, unsigned, origin)
372 * In kernel, off_t is always the same as (kernel's) long
373 * (see include/uapi/asm-generic/posix_types.h),
374 * which means that on x32 we need to use tcp->ext_arg[N] to get offset argument.
375 * Use test/x32_lseek.c to test lseek decoding.
377 #if defined(LINUX_MIPSN32) || defined(X32)
379 sys_lseek(struct tcb *tcp)
385 printfd(tcp, tcp->u_arg[0]);
386 offset = tcp->ext_arg[1];
387 whence = tcp->u_arg[2];
388 if (whence == SEEK_SET)
389 tprintf(", %llu, ", offset);
391 tprintf(", %lld, ", offset);
392 printxval(whence_codes, whence, "SEEK_???");
394 return RVAL_LUDECIMAL;
398 sys_lseek(struct tcb *tcp)
404 printfd(tcp, tcp->u_arg[0]);
405 offset = tcp->u_arg[1];
406 whence = tcp->u_arg[2];
407 if (whence == SEEK_SET)
408 tprintf(", %lu, ", offset);
410 tprintf(", %ld, ", offset);
411 printxval(whence_codes, whence, "SEEK_???");
413 return RVAL_UDECIMAL;
417 /* llseek syscall takes explicitly two ulong arguments hi, lo,
418 * rather than one 64-bit argument for which LONG_LONG works
419 * appropriate for the native byte order.
421 * See kernel's fs/read_write.c::SYSCALL_DEFINE5(llseek, ...)
423 * hi,lo are "unsigned longs" and combined exactly this way in kernel:
424 * ((loff_t) hi << 32) | lo
425 * Note that for architectures with kernel's long wider than userspace long
426 * (such as x32), combining code will use *kernel's*, i.e. *wide* longs
427 * for hi and lo. We would need to use tcp->ext_arg[N] on x32...
428 * ...however, x32 (and x86_64) does not _have_ llseek syscall as such.
431 sys_llseek(struct tcb *tcp)
434 printfd(tcp, tcp->u_arg[0]);
435 if (tcp->u_arg[4] == SEEK_SET)
437 ((long long) tcp->u_arg[1]) << 32 |
438 (unsigned long long) (unsigned) tcp->u_arg[2]);
441 ((long long) tcp->u_arg[1]) << 32 |
442 (unsigned long long) (unsigned) tcp->u_arg[2]);
446 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
447 tprintf("%#lx, ", tcp->u_arg[3]);
449 tprintf("[%llu], ", off);
450 printxval(whence_codes, tcp->u_arg[4], "SEEK_???");
456 sys_readahead(struct tcb *tcp)
460 printfd(tcp, tcp->u_arg[0]);
461 argn = printllval(tcp, ", %lld", 1);
462 tprintf(", %ld", tcp->u_arg[argn]);
468 sys_truncate(struct tcb *tcp)
471 printpath(tcp, tcp->u_arg[0]);
472 tprintf(", %lu", tcp->u_arg[1]);
478 sys_truncate64(struct tcb *tcp)
481 printpath(tcp, tcp->u_arg[0]);
482 printllval(tcp, ", %llu", 1);
488 sys_ftruncate(struct tcb *tcp)
491 printfd(tcp, tcp->u_arg[0]);
492 tprintf(", %lu", tcp->u_arg[1]);
498 sys_ftruncate64(struct tcb *tcp)
501 printfd(tcp, tcp->u_arg[0]);
502 printllval(tcp, ", %llu", 1);
509 #if defined(SPARC) || defined(SPARC64)
517 int st_pad1[3]; /* network id */
526 int st_pad3; /* st_size, off_t expansion */
527 timestruct_t st_atime;
528 timestruct_t st_mtime;
529 timestruct_t st_ctime;
533 int st_pad4[8]; /* expansion area */
537 printstatsol(struct tcb *tcp, long addr)
539 struct solstat statbuf;
541 if (umove(tcp, addr, &statbuf) < 0) {
546 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
547 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
548 (unsigned long) (statbuf.st_dev & 0x3ffff),
549 (unsigned long) statbuf.st_ino,
550 sprintmode(statbuf.st_mode));
551 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
552 (unsigned long) statbuf.st_nlink,
553 (unsigned long) statbuf.st_uid,
554 (unsigned long) statbuf.st_gid);
555 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
556 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
559 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
560 switch (statbuf.st_mode & S_IFMT) {
561 case S_IFCHR: case S_IFBLK:
562 tprintf("st_rdev=makedev(%lu, %lu), ",
563 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
564 (unsigned long) (statbuf.st_rdev & 0x3ffff));
567 tprintf("st_size=%u, ", statbuf.st_size);
571 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
572 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
573 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
579 # if defined(SPARC64)
581 printstat_sparc64(struct tcb *tcp, long addr)
583 struct stat_sparc64 statbuf;
585 if (umove(tcp, addr, &statbuf) < 0) {
591 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
592 (unsigned long) major(statbuf.st_dev),
593 (unsigned long) minor(statbuf.st_dev),
594 (unsigned long) statbuf.st_ino,
595 sprintmode(statbuf.st_mode));
596 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
597 (unsigned long) statbuf.st_nlink,
598 (unsigned long) statbuf.st_uid,
599 (unsigned long) statbuf.st_gid);
600 tprintf("st_blksize=%lu, ",
601 (unsigned long) statbuf.st_blksize);
602 tprintf("st_blocks=%lu, ",
603 (unsigned long) statbuf.st_blocks);
606 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
607 switch (statbuf.st_mode & S_IFMT) {
608 case S_IFCHR: case S_IFBLK:
609 tprintf("st_rdev=makedev(%lu, %lu), ",
610 (unsigned long) major(statbuf.st_rdev),
611 (unsigned long) minor(statbuf.st_rdev));
614 tprintf("st_size=%lu, ", statbuf.st_size);
618 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
619 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
620 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
625 # endif /* SPARC64 */
626 #endif /* SPARC[64] */
628 #if defined POWERPC64
629 struct stat_powerpc32 {
632 unsigned int st_mode;
633 unsigned short st_nlink;
636 unsigned int st_rdev;
637 unsigned int st_size;
638 unsigned int st_blksize;
639 unsigned int st_blocks;
640 unsigned int st_atime;
641 unsigned int st_atime_nsec;
642 unsigned int st_mtime;
643 unsigned int st_mtime_nsec;
644 unsigned int st_ctime;
645 unsigned int st_ctime_nsec;
646 unsigned int __unused4;
647 unsigned int __unused5;
651 printstat_powerpc32(struct tcb *tcp, long addr)
653 struct stat_powerpc32 statbuf;
655 if (umove(tcp, addr, &statbuf) < 0) {
661 tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ",
662 major(statbuf.st_dev), minor(statbuf.st_dev),
664 sprintmode(statbuf.st_mode));
665 tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ",
666 statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid);
667 tprintf("st_blksize=%u, ", statbuf.st_blksize);
668 tprintf("st_blocks=%u, ", statbuf.st_blocks);
671 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
672 switch (statbuf.st_mode & S_IFMT) {
673 case S_IFCHR: case S_IFBLK:
674 tprintf("st_rdev=makedev(%lu, %lu), ",
675 (unsigned long) major(statbuf.st_rdev),
676 (unsigned long) minor(statbuf.st_rdev));
679 tprintf("st_size=%u, ", statbuf.st_size);
683 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
684 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
685 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
690 #endif /* POWERPC64 */
692 #include "xlat/fileflags.h"
695 realprintstat(struct tcb *tcp, struct stat *statbuf)
698 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
699 (unsigned long) major(statbuf->st_dev),
700 (unsigned long) minor(statbuf->st_dev),
701 (unsigned long) statbuf->st_ino,
702 sprintmode(statbuf->st_mode));
703 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
704 (unsigned long) statbuf->st_nlink,
705 (unsigned long) statbuf->st_uid,
706 (unsigned long) statbuf->st_gid);
707 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
708 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
710 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
711 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
715 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
716 switch (statbuf->st_mode & S_IFMT) {
717 case S_IFCHR: case S_IFBLK:
718 #ifdef HAVE_STRUCT_STAT_ST_RDEV
719 tprintf("st_rdev=makedev(%lu, %lu), ",
720 (unsigned long) major(statbuf->st_rdev),
721 (unsigned long) minor(statbuf->st_rdev));
722 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
723 tprintf("st_size=makedev(%lu, %lu), ",
724 (unsigned long) major(statbuf->st_size),
725 (unsigned long) minor(statbuf->st_size));
726 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
729 tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size);
733 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
734 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
735 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
736 #if HAVE_STRUCT_STAT_ST_FLAGS
737 tprints(", st_flags=");
738 printflags(fileflags, statbuf->st_flags, "UF_???");
740 #if HAVE_STRUCT_STAT_ST_ACLCNT
741 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
743 #if HAVE_STRUCT_STAT_ST_LEVEL
744 tprintf(", st_level=%ld", statbuf->st_level);
746 #if HAVE_STRUCT_STAT_ST_FSTYPE
747 tprintf(", st_fstype=%.*s",
748 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
750 #if HAVE_STRUCT_STAT_ST_GEN
751 tprintf(", st_gen=%u", statbuf->st_gen);
761 printstat(struct tcb *tcp, long addr)
769 if (syserror(tcp) || !verbose(tcp)) {
770 tprintf("%#lx", addr);
774 #if defined(SPARC) || defined(SPARC64)
775 if (current_personality == 1) {
776 printstatsol(tcp, addr);
780 else if (current_personality == 2) {
781 printstat_sparc64(tcp, addr);
785 #endif /* SPARC[64] */
787 #if defined POWERPC64
788 if (current_personality == 1) {
789 printstat_powerpc32(tcp, addr);
794 if (umove(tcp, addr, &statbuf) < 0) {
799 realprintstat(tcp, &statbuf);
802 # define printstat printstat64
805 #if !defined HAVE_STAT64 && (defined AARCH64 || defined X86_64)
807 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
808 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
809 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
810 * __GNUC__ is needed for the required __attribute__ below.
812 * Similarly, aarch64 has a unified `struct stat' but its arm personality
813 * needs `struct stat64' (which also expects a 32-bit `long' but which
814 * shouldn't be packed).
817 unsigned long long st_dev;
818 unsigned char __pad0[4];
819 unsigned int __st_ino;
820 unsigned int st_mode;
821 unsigned int st_nlink;
824 unsigned long long st_rdev;
825 unsigned char __pad3[4];
827 unsigned int st_blksize;
828 unsigned long long st_blocks;
829 unsigned int st_atime;
830 unsigned int st_atime_nsec;
831 unsigned int st_mtime;
832 unsigned int st_mtime_nsec;
833 unsigned int st_ctime;
834 unsigned int st_ctime_nsec;
835 unsigned long long st_ino;
838 __attribute__((packed))
839 # define STAT64_SIZE 96
841 # define STAT64_SIZE 104
844 # define HAVE_STAT64 1
849 printstat64(struct tcb *tcp, long addr)
854 struct stat64 statbuf;
858 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
865 if (syserror(tcp) || !verbose(tcp)) {
866 tprintf("%#lx", addr);
870 #if defined(SPARC) || defined(SPARC64)
871 if (current_personality == 1) {
872 printstatsol(tcp, addr);
876 else if (current_personality == 2) {
877 printstat_sparc64(tcp, addr);
881 #endif /* SPARC[64] */
884 if (current_personality != 0) {
885 printstat(tcp, addr);
890 if (current_personality != 1) {
891 printstat(tcp, addr);
896 if (umove(tcp, addr, &statbuf) < 0) {
902 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
903 (unsigned long) major(statbuf.st_dev),
904 (unsigned long) minor(statbuf.st_dev),
905 (unsigned long long) statbuf.st_ino,
906 sprintmode(statbuf.st_mode));
907 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
908 (unsigned long) statbuf.st_nlink,
909 (unsigned long) statbuf.st_uid,
910 (unsigned long) statbuf.st_gid);
911 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
912 tprintf("st_blksize=%lu, ",
913 (unsigned long) statbuf.st_blksize);
914 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
915 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
916 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
917 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
920 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
921 switch (statbuf.st_mode & S_IFMT) {
922 case S_IFCHR: case S_IFBLK:
923 #ifdef HAVE_STRUCT_STAT_ST_RDEV
924 tprintf("st_rdev=makedev(%lu, %lu), ",
925 (unsigned long) major(statbuf.st_rdev),
926 (unsigned long) minor(statbuf.st_rdev));
927 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
928 tprintf("st_size=makedev(%lu, %lu), ",
929 (unsigned long) major(statbuf.st_size),
930 (unsigned long) minor(statbuf.st_size));
931 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
934 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
938 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
939 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
940 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
941 #if HAVE_STRUCT_STAT_ST_FLAGS
942 tprints(", st_flags=");
943 printflags(fileflags, statbuf.st_flags, "UF_???");
945 #if HAVE_STRUCT_STAT_ST_ACLCNT
946 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
948 #if HAVE_STRUCT_STAT_ST_LEVEL
949 tprintf(", st_level=%ld", statbuf.st_level);
951 #if HAVE_STRUCT_STAT_ST_FSTYPE
952 tprintf(", st_fstype=%.*s",
953 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
955 #if HAVE_STRUCT_STAT_ST_GEN
956 tprintf(", st_gen=%u", statbuf.st_gen);
963 #endif /* HAVE_STAT64 */
965 #if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
967 convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
969 newbuf->st_dev = oldbuf->st_dev;
970 newbuf->st_ino = oldbuf->st_ino;
971 newbuf->st_mode = oldbuf->st_mode;
972 newbuf->st_nlink = oldbuf->st_nlink;
973 newbuf->st_uid = oldbuf->st_uid;
974 newbuf->st_gid = oldbuf->st_gid;
975 newbuf->st_rdev = oldbuf->st_rdev;
976 newbuf->st_size = oldbuf->st_size;
977 newbuf->st_atime = oldbuf->st_atime;
978 newbuf->st_mtime = oldbuf->st_mtime;
979 newbuf->st_ctime = oldbuf->st_ctime;
980 newbuf->st_blksize = 0; /* not supported in old_stat */
981 newbuf->st_blocks = 0; /* not supported in old_stat */
985 printoldstat(struct tcb *tcp, long addr)
987 struct __old_kernel_stat statbuf;
988 struct stat newstatbuf;
994 if (syserror(tcp) || !verbose(tcp)) {
995 tprintf("%#lx", addr);
999 # if defined(SPARC) || defined(SPARC64)
1000 if (current_personality == 1) {
1001 printstatsol(tcp, addr);
1006 if (umove(tcp, addr, &statbuf) < 0) {
1011 convertoldstat(&statbuf, &newstatbuf);
1012 realprintstat(tcp, &newstatbuf);
1017 sys_stat(struct tcb *tcp)
1019 if (entering(tcp)) {
1020 printpath(tcp, tcp->u_arg[0]);
1023 printstat(tcp, tcp->u_arg[1]);
1030 printstat64_x32(struct tcb *tcp, long addr)
1032 struct stat64 statbuf;
1038 if (syserror(tcp) || !verbose(tcp)) {
1039 tprintf("%#lx", addr);
1043 if (umove(tcp, addr, &statbuf) < 0) {
1049 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1050 (unsigned long) major(statbuf.st_dev),
1051 (unsigned long) minor(statbuf.st_dev),
1052 (unsigned long long) statbuf.st_ino,
1053 sprintmode(statbuf.st_mode));
1054 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1055 (unsigned long) statbuf.st_nlink,
1056 (unsigned long) statbuf.st_uid,
1057 (unsigned long) statbuf.st_gid);
1058 tprintf("st_blksize=%lu, ",
1059 (unsigned long) statbuf.st_blksize);
1060 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
1063 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1064 switch (statbuf.st_mode & S_IFMT) {
1065 case S_IFCHR: case S_IFBLK:
1066 tprintf("st_rdev=makedev(%lu, %lu), ",
1067 (unsigned long) major(statbuf.st_rdev),
1068 (unsigned long) minor(statbuf.st_rdev));
1071 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1075 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1076 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
1077 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
1086 sys_stat64(struct tcb *tcp)
1089 if (entering(tcp)) {
1090 printpath(tcp, tcp->u_arg[0]);
1094 printstat64_x32(tcp, tcp->u_arg[1]);
1096 printstat64(tcp, tcp->u_arg[1]);
1101 return printargs(tcp);
1105 #ifndef AT_SYMLINK_NOFOLLOW
1106 # define AT_SYMLINK_NOFOLLOW 0x100
1108 #ifndef AT_REMOVEDIR
1109 # define AT_REMOVEDIR 0x200
1111 #ifndef AT_SYMLINK_FOLLOW
1112 # define AT_SYMLINK_FOLLOW 0x400
1114 #ifndef AT_NO_AUTOMOUNT
1115 # define AT_NO_AUTOMOUNT 0x800
1117 #ifndef AT_EMPTY_PATH
1118 # define AT_EMPTY_PATH 0x1000
1121 #include "xlat/at_flags.h"
1124 sys_newfstatat(struct tcb *tcp)
1126 if (entering(tcp)) {
1127 print_dirfd(tcp, tcp->u_arg[0]);
1128 printpath(tcp, tcp->u_arg[1]);
1132 if (current_personality == 0)
1133 printstat(tcp, tcp->u_arg[2]);
1135 printstat64(tcp, tcp->u_arg[2]);
1136 #elif defined HAVE_STAT64
1137 printstat64(tcp, tcp->u_arg[2]);
1139 printstat(tcp, tcp->u_arg[2]);
1142 printflags(at_flags, tcp->u_arg[3], "AT_???");
1147 #if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1149 sys_oldstat(struct tcb *tcp)
1151 if (entering(tcp)) {
1152 printpath(tcp, tcp->u_arg[0]);
1155 printoldstat(tcp, tcp->u_arg[1]);
1162 sys_fstat(struct tcb *tcp)
1164 if (entering(tcp)) {
1165 printfd(tcp, tcp->u_arg[0]);
1168 printstat(tcp, tcp->u_arg[1]);
1174 sys_fstat64(struct tcb *tcp)
1177 if (entering(tcp)) {
1178 printfd(tcp, tcp->u_arg[0]);
1182 printstat64_x32(tcp, tcp->u_arg[1]);
1184 printstat64(tcp, tcp->u_arg[1]);
1189 return printargs(tcp);
1193 #if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1195 sys_oldfstat(struct tcb *tcp)
1197 if (entering(tcp)) {
1198 printfd(tcp, tcp->u_arg[0]);
1201 printoldstat(tcp, tcp->u_arg[1]);
1207 #if defined(SPARC) || defined(SPARC64)
1210 sys_xstat(struct tcb *tcp)
1212 if (entering(tcp)) {
1213 tprintf("%ld, ", tcp->u_arg[0]);
1214 printpath(tcp, tcp->u_arg[1]);
1218 if (tcp->u_arg[0] == _STAT64_VER)
1219 printstat64(tcp, tcp->u_arg[2]);
1222 printstat(tcp, tcp->u_arg[2]);
1228 sys_fxstat(struct tcb *tcp)
1231 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1234 if (tcp->u_arg[0] == _STAT64_VER)
1235 printstat64(tcp, tcp->u_arg[2]);
1238 printstat(tcp, tcp->u_arg[2]);
1244 sys_lxstat(struct tcb *tcp)
1246 if (entering(tcp)) {
1247 tprintf("%ld, ", tcp->u_arg[0]);
1248 printpath(tcp, tcp->u_arg[1]);
1252 if (tcp->u_arg[0] == _STAT64_VER)
1253 printstat64(tcp, tcp->u_arg[2]);
1256 printstat(tcp, tcp->u_arg[2]);
1261 #endif /* SPARC[64] */
1265 sys_chdir(struct tcb *tcp)
1267 if (entering(tcp)) {
1268 printpath(tcp, tcp->u_arg[0]);
1274 sys_link(struct tcb *tcp)
1276 if (entering(tcp)) {
1277 printpath(tcp, tcp->u_arg[0]);
1279 printpath(tcp, tcp->u_arg[1]);
1285 sys_linkat(struct tcb *tcp)
1287 if (entering(tcp)) {
1288 print_dirfd(tcp, tcp->u_arg[0]);
1289 printpath(tcp, tcp->u_arg[1]);
1291 print_dirfd(tcp, tcp->u_arg[2]);
1292 printpath(tcp, tcp->u_arg[3]);
1294 printflags(at_flags, tcp->u_arg[4], "AT_???");
1300 sys_unlinkat(struct tcb *tcp)
1302 if (entering(tcp)) {
1303 print_dirfd(tcp, tcp->u_arg[0]);
1304 printpath(tcp, tcp->u_arg[1]);
1306 printflags(at_flags, tcp->u_arg[2], "AT_???");
1312 sys_symlinkat(struct tcb *tcp)
1314 if (entering(tcp)) {
1315 printpath(tcp, tcp->u_arg[0]);
1317 print_dirfd(tcp, tcp->u_arg[1]);
1318 printpath(tcp, tcp->u_arg[2]);
1324 decode_readlink(struct tcb *tcp, int offset)
1326 if (entering(tcp)) {
1327 printpath(tcp, tcp->u_arg[offset]);
1331 tprintf("%#lx", tcp->u_arg[offset + 1]);
1333 /* Used to use printpathn(), but readlink
1334 * neither includes NUL in the returned count,
1335 * nor actually writes it into memory.
1336 * printpathn() would decide on printing
1337 * "..." continuation based on garbage
1338 * past return buffer's end.
1340 printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
1341 tprintf(", %lu", tcp->u_arg[offset + 2]);
1347 sys_readlink(struct tcb *tcp)
1349 return decode_readlink(tcp, 0);
1353 sys_readlinkat(struct tcb *tcp)
1356 print_dirfd(tcp, tcp->u_arg[0]);
1357 return decode_readlink(tcp, 1);
1361 decode_renameat(struct tcb *tcp)
1363 print_dirfd(tcp, tcp->u_arg[0]);
1364 printpath(tcp, tcp->u_arg[1]);
1366 print_dirfd(tcp, tcp->u_arg[2]);
1367 printpath(tcp, tcp->u_arg[3]);
1371 sys_renameat(struct tcb *tcp)
1373 if (entering(tcp)) {
1374 decode_renameat(tcp);
1379 #include "xlat/rename_flags.h"
1382 sys_renameat2(struct tcb *tcp)
1384 if (entering(tcp)) {
1385 decode_renameat(tcp);
1387 printflags(rename_flags, tcp->u_arg[4], "RENAME_??");