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_???");
457 #if defined(SPARC) || defined(SPARC64)
465 int st_pad1[3]; /* network id */
474 int st_pad3; /* st_size, off_t expansion */
475 timestruct_t st_atime;
476 timestruct_t st_mtime;
477 timestruct_t st_ctime;
481 int st_pad4[8]; /* expansion area */
485 printstatsol(struct tcb *tcp, long addr)
487 struct solstat statbuf;
489 if (umove(tcp, addr, &statbuf) < 0) {
494 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
495 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
496 (unsigned long) (statbuf.st_dev & 0x3ffff),
497 (unsigned long) statbuf.st_ino,
498 sprintmode(statbuf.st_mode));
499 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
500 (unsigned long) statbuf.st_nlink,
501 (unsigned long) statbuf.st_uid,
502 (unsigned long) statbuf.st_gid);
503 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
504 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
507 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
508 switch (statbuf.st_mode & S_IFMT) {
509 case S_IFCHR: case S_IFBLK:
510 tprintf("st_rdev=makedev(%lu, %lu), ",
511 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
512 (unsigned long) (statbuf.st_rdev & 0x3ffff));
515 tprintf("st_size=%u, ", statbuf.st_size);
519 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
520 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
521 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
527 # if defined(SPARC64)
529 printstat_sparc64(struct tcb *tcp, long addr)
531 struct stat_sparc64 statbuf;
533 if (umove(tcp, addr, &statbuf) < 0) {
539 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
540 (unsigned long) major(statbuf.st_dev),
541 (unsigned long) minor(statbuf.st_dev),
542 (unsigned long) statbuf.st_ino,
543 sprintmode(statbuf.st_mode));
544 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
545 (unsigned long) statbuf.st_nlink,
546 (unsigned long) statbuf.st_uid,
547 (unsigned long) statbuf.st_gid);
548 tprintf("st_blksize=%lu, ",
549 (unsigned long) statbuf.st_blksize);
550 tprintf("st_blocks=%lu, ",
551 (unsigned long) statbuf.st_blocks);
554 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
555 switch (statbuf.st_mode & S_IFMT) {
556 case S_IFCHR: case S_IFBLK:
557 tprintf("st_rdev=makedev(%lu, %lu), ",
558 (unsigned long) major(statbuf.st_rdev),
559 (unsigned long) minor(statbuf.st_rdev));
562 tprintf("st_size=%lu, ", statbuf.st_size);
566 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
567 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
568 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
573 # endif /* SPARC64 */
574 #endif /* SPARC[64] */
576 #if defined POWERPC64
577 struct stat_powerpc32 {
580 unsigned int st_mode;
581 unsigned short st_nlink;
584 unsigned int st_rdev;
585 unsigned int st_size;
586 unsigned int st_blksize;
587 unsigned int st_blocks;
588 unsigned int st_atime;
589 unsigned int st_atime_nsec;
590 unsigned int st_mtime;
591 unsigned int st_mtime_nsec;
592 unsigned int st_ctime;
593 unsigned int st_ctime_nsec;
594 unsigned int __unused4;
595 unsigned int __unused5;
599 printstat_powerpc32(struct tcb *tcp, long addr)
601 struct stat_powerpc32 statbuf;
603 if (umove(tcp, addr, &statbuf) < 0) {
609 tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ",
610 major(statbuf.st_dev), minor(statbuf.st_dev),
612 sprintmode(statbuf.st_mode));
613 tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ",
614 statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid);
615 tprintf("st_blksize=%u, ", statbuf.st_blksize);
616 tprintf("st_blocks=%u, ", statbuf.st_blocks);
619 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
620 switch (statbuf.st_mode & S_IFMT) {
621 case S_IFCHR: case S_IFBLK:
622 tprintf("st_rdev=makedev(%lu, %lu), ",
623 (unsigned long) major(statbuf.st_rdev),
624 (unsigned long) minor(statbuf.st_rdev));
627 tprintf("st_size=%u, ", statbuf.st_size);
631 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
632 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
633 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
638 #endif /* POWERPC64 */
640 #include "xlat/fileflags.h"
643 realprintstat(struct tcb *tcp, struct stat *statbuf)
646 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
647 (unsigned long) major(statbuf->st_dev),
648 (unsigned long) minor(statbuf->st_dev),
649 (unsigned long) statbuf->st_ino,
650 sprintmode(statbuf->st_mode));
651 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
652 (unsigned long) statbuf->st_nlink,
653 (unsigned long) statbuf->st_uid,
654 (unsigned long) statbuf->st_gid);
655 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
656 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
658 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
659 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
663 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
664 switch (statbuf->st_mode & S_IFMT) {
665 case S_IFCHR: case S_IFBLK:
666 #ifdef HAVE_STRUCT_STAT_ST_RDEV
667 tprintf("st_rdev=makedev(%lu, %lu), ",
668 (unsigned long) major(statbuf->st_rdev),
669 (unsigned long) minor(statbuf->st_rdev));
670 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
671 tprintf("st_size=makedev(%lu, %lu), ",
672 (unsigned long) major(statbuf->st_size),
673 (unsigned long) minor(statbuf->st_size));
674 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
677 tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size);
681 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
682 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
683 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
684 #if HAVE_STRUCT_STAT_ST_FLAGS
685 tprints(", st_flags=");
686 printflags(fileflags, statbuf->st_flags, "UF_???");
688 #if HAVE_STRUCT_STAT_ST_ACLCNT
689 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
691 #if HAVE_STRUCT_STAT_ST_LEVEL
692 tprintf(", st_level=%ld", statbuf->st_level);
694 #if HAVE_STRUCT_STAT_ST_FSTYPE
695 tprintf(", st_fstype=%.*s",
696 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
698 #if HAVE_STRUCT_STAT_ST_GEN
699 tprintf(", st_gen=%u", statbuf->st_gen);
709 printstat(struct tcb *tcp, long addr)
717 if (syserror(tcp) || !verbose(tcp)) {
718 tprintf("%#lx", addr);
722 #if defined(SPARC) || defined(SPARC64)
723 if (current_personality == 1) {
724 printstatsol(tcp, addr);
728 else if (current_personality == 2) {
729 printstat_sparc64(tcp, addr);
733 #endif /* SPARC[64] */
735 #if defined POWERPC64
736 if (current_personality == 1) {
737 printstat_powerpc32(tcp, addr);
742 if (umove(tcp, addr, &statbuf) < 0) {
747 realprintstat(tcp, &statbuf);
750 # define printstat printstat64
753 #if !defined HAVE_STAT64 && (defined AARCH64 || defined X86_64)
755 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
756 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
757 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
758 * __GNUC__ is needed for the required __attribute__ below.
760 * Similarly, aarch64 has a unified `struct stat' but its arm personality
761 * needs `struct stat64' (which also expects a 32-bit `long' but which
762 * shouldn't be packed).
765 unsigned long long st_dev;
766 unsigned char __pad0[4];
767 unsigned int __st_ino;
768 unsigned int st_mode;
769 unsigned int st_nlink;
772 unsigned long long st_rdev;
773 unsigned char __pad3[4];
775 unsigned int st_blksize;
776 unsigned long long st_blocks;
777 unsigned int st_atime;
778 unsigned int st_atime_nsec;
779 unsigned int st_mtime;
780 unsigned int st_mtime_nsec;
781 unsigned int st_ctime;
782 unsigned int st_ctime_nsec;
783 unsigned long long st_ino;
786 __attribute__((packed))
787 # define STAT64_SIZE 96
789 # define STAT64_SIZE 104
792 # define HAVE_STAT64 1
797 printstat64(struct tcb *tcp, long addr)
802 struct stat64 statbuf;
806 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
813 if (syserror(tcp) || !verbose(tcp)) {
814 tprintf("%#lx", addr);
818 #if defined(SPARC) || defined(SPARC64)
819 if (current_personality == 1) {
820 printstatsol(tcp, addr);
824 else if (current_personality == 2) {
825 printstat_sparc64(tcp, addr);
829 #endif /* SPARC[64] */
832 if (current_personality != 0) {
833 printstat(tcp, addr);
838 if (current_personality != 1) {
839 printstat(tcp, addr);
844 if (umove(tcp, addr, &statbuf) < 0) {
850 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
851 (unsigned long) major(statbuf.st_dev),
852 (unsigned long) minor(statbuf.st_dev),
853 (unsigned long long) statbuf.st_ino,
854 sprintmode(statbuf.st_mode));
855 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
856 (unsigned long) statbuf.st_nlink,
857 (unsigned long) statbuf.st_uid,
858 (unsigned long) statbuf.st_gid);
859 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
860 tprintf("st_blksize=%lu, ",
861 (unsigned long) statbuf.st_blksize);
862 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
863 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
864 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
865 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
868 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
869 switch (statbuf.st_mode & S_IFMT) {
870 case S_IFCHR: case S_IFBLK:
871 #ifdef HAVE_STRUCT_STAT_ST_RDEV
872 tprintf("st_rdev=makedev(%lu, %lu), ",
873 (unsigned long) major(statbuf.st_rdev),
874 (unsigned long) minor(statbuf.st_rdev));
875 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
876 tprintf("st_size=makedev(%lu, %lu), ",
877 (unsigned long) major(statbuf.st_size),
878 (unsigned long) minor(statbuf.st_size));
879 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
882 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
886 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
887 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
888 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
889 #if HAVE_STRUCT_STAT_ST_FLAGS
890 tprints(", st_flags=");
891 printflags(fileflags, statbuf.st_flags, "UF_???");
893 #if HAVE_STRUCT_STAT_ST_ACLCNT
894 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
896 #if HAVE_STRUCT_STAT_ST_LEVEL
897 tprintf(", st_level=%ld", statbuf.st_level);
899 #if HAVE_STRUCT_STAT_ST_FSTYPE
900 tprintf(", st_fstype=%.*s",
901 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
903 #if HAVE_STRUCT_STAT_ST_GEN
904 tprintf(", st_gen=%u", statbuf.st_gen);
911 #endif /* HAVE_STAT64 */
913 #if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
915 convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
917 newbuf->st_dev = oldbuf->st_dev;
918 newbuf->st_ino = oldbuf->st_ino;
919 newbuf->st_mode = oldbuf->st_mode;
920 newbuf->st_nlink = oldbuf->st_nlink;
921 newbuf->st_uid = oldbuf->st_uid;
922 newbuf->st_gid = oldbuf->st_gid;
923 newbuf->st_rdev = oldbuf->st_rdev;
924 newbuf->st_size = oldbuf->st_size;
925 newbuf->st_atime = oldbuf->st_atime;
926 newbuf->st_mtime = oldbuf->st_mtime;
927 newbuf->st_ctime = oldbuf->st_ctime;
928 newbuf->st_blksize = 0; /* not supported in old_stat */
929 newbuf->st_blocks = 0; /* not supported in old_stat */
933 printoldstat(struct tcb *tcp, long addr)
935 struct __old_kernel_stat statbuf;
936 struct stat newstatbuf;
942 if (syserror(tcp) || !verbose(tcp)) {
943 tprintf("%#lx", addr);
947 # if defined(SPARC) || defined(SPARC64)
948 if (current_personality == 1) {
949 printstatsol(tcp, addr);
954 if (umove(tcp, addr, &statbuf) < 0) {
959 convertoldstat(&statbuf, &newstatbuf);
960 realprintstat(tcp, &newstatbuf);
965 sys_stat(struct tcb *tcp)
968 printpath(tcp, tcp->u_arg[0]);
971 printstat(tcp, tcp->u_arg[1]);
978 printstat64_x32(struct tcb *tcp, long addr)
980 struct stat64 statbuf;
986 if (syserror(tcp) || !verbose(tcp)) {
987 tprintf("%#lx", addr);
991 if (umove(tcp, addr, &statbuf) < 0) {
997 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
998 (unsigned long) major(statbuf.st_dev),
999 (unsigned long) minor(statbuf.st_dev),
1000 (unsigned long long) statbuf.st_ino,
1001 sprintmode(statbuf.st_mode));
1002 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1003 (unsigned long) statbuf.st_nlink,
1004 (unsigned long) statbuf.st_uid,
1005 (unsigned long) statbuf.st_gid);
1006 tprintf("st_blksize=%lu, ",
1007 (unsigned long) statbuf.st_blksize);
1008 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
1011 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1012 switch (statbuf.st_mode & S_IFMT) {
1013 case S_IFCHR: case S_IFBLK:
1014 tprintf("st_rdev=makedev(%lu, %lu), ",
1015 (unsigned long) major(statbuf.st_rdev),
1016 (unsigned long) minor(statbuf.st_rdev));
1019 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1023 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1024 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
1025 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
1034 sys_stat64(struct tcb *tcp)
1037 if (entering(tcp)) {
1038 printpath(tcp, tcp->u_arg[0]);
1042 printstat64_x32(tcp, tcp->u_arg[1]);
1044 printstat64(tcp, tcp->u_arg[1]);
1049 return printargs(tcp);
1054 sys_newfstatat(struct tcb *tcp)
1056 if (entering(tcp)) {
1057 print_dirfd(tcp, tcp->u_arg[0]);
1058 printpath(tcp, tcp->u_arg[1]);
1062 if (current_personality == 0)
1063 printstat(tcp, tcp->u_arg[2]);
1065 printstat64(tcp, tcp->u_arg[2]);
1066 #elif defined HAVE_STAT64
1067 printstat64(tcp, tcp->u_arg[2]);
1069 printstat(tcp, tcp->u_arg[2]);
1072 printflags(at_flags, tcp->u_arg[3], "AT_???");
1077 #if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1079 sys_oldstat(struct tcb *tcp)
1081 if (entering(tcp)) {
1082 printpath(tcp, tcp->u_arg[0]);
1085 printoldstat(tcp, tcp->u_arg[1]);
1092 sys_fstat(struct tcb *tcp)
1094 if (entering(tcp)) {
1095 printfd(tcp, tcp->u_arg[0]);
1098 printstat(tcp, tcp->u_arg[1]);
1104 sys_fstat64(struct tcb *tcp)
1107 if (entering(tcp)) {
1108 printfd(tcp, tcp->u_arg[0]);
1112 printstat64_x32(tcp, tcp->u_arg[1]);
1114 printstat64(tcp, tcp->u_arg[1]);
1119 return printargs(tcp);
1123 #if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1125 sys_oldfstat(struct tcb *tcp)
1127 if (entering(tcp)) {
1128 printfd(tcp, tcp->u_arg[0]);
1131 printoldstat(tcp, tcp->u_arg[1]);
1137 #if defined(SPARC) || defined(SPARC64)
1140 sys_xstat(struct tcb *tcp)
1142 if (entering(tcp)) {
1143 tprintf("%ld, ", tcp->u_arg[0]);
1144 printpath(tcp, tcp->u_arg[1]);
1148 if (tcp->u_arg[0] == _STAT64_VER)
1149 printstat64(tcp, tcp->u_arg[2]);
1152 printstat(tcp, tcp->u_arg[2]);
1158 sys_fxstat(struct tcb *tcp)
1161 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1164 if (tcp->u_arg[0] == _STAT64_VER)
1165 printstat64(tcp, tcp->u_arg[2]);
1168 printstat(tcp, tcp->u_arg[2]);
1174 sys_lxstat(struct tcb *tcp)
1176 if (entering(tcp)) {
1177 tprintf("%ld, ", tcp->u_arg[0]);
1178 printpath(tcp, tcp->u_arg[1]);
1182 if (tcp->u_arg[0] == _STAT64_VER)
1183 printstat64(tcp, tcp->u_arg[2]);
1186 printstat(tcp, tcp->u_arg[2]);
1191 #endif /* SPARC[64] */