3 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
4 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
5 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
6 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 struct kernel_dirent {
42 unsigned short d_reclen;
46 # define kernel_dirent dirent
52 unsigned short st_dev;
54 unsigned short st_mode;
56 unsigned short st_uid;
57 unsigned short st_gid;
58 unsigned short st_rdev;
61 unsigned int __unused1;
63 unsigned int __unused2;
65 unsigned int __unused3;
68 unsigned int __unused4[2];
75 unsigned int st_nlink;
85 unsigned long __unused4[2];
88 # define stat kernel_stat
89 # include <asm/stat.h>
101 # define dev_t __kernel_dev_t
102 # define ino_t __kernel_ino_t
103 # define mode_t __kernel_mode_t
104 # define nlink_t __kernel_nlink_t
105 # define uid_t __kernel_uid_t
106 # define gid_t __kernel_gid_t
107 # define off_t __kernel_off_t
108 # define loff_t __kernel_loff_t
110 # include <asm/stat.h>
123 # define mode_t mode_t
124 # define nlink_t nlink_t
128 # define loff_t loff_t
130 # ifdef HPPA /* asm-parisc/stat.h defines stat64 */
133 # define stat libc_stat
134 # define stat64 libc_stat64
135 # include <sys/stat.h>
138 /* These might be macros. */
143 # define stat64 hpux_stat64
146 # include <sys/stat.h>
152 # include <sys/cred.h>
155 #ifdef HAVE_SYS_VFS_H
159 #ifdef HAVE_LINUX_XATTR_H
160 #include <linux/xattr.h>
162 #define XATTR_CREATE 1
163 #define XATTR_REPLACE 2
167 #include <sys/param.h>
168 #include <sys/mount.h>
169 #include <sys/stat.h>
172 #if _LFS64_LARGEFILE && (defined(LINUX) || defined(SVR4))
173 # ifdef HAVE_INTTYPES_H
174 # include <inttypes.h>
176 # define PRId64 "lld"
177 # define PRIu64 "llu"
181 #if HAVE_LONG_LONG_OFF_T
183 * Ugly hacks for systems that have typedef long long off_t
187 #define HAVE_STAT64 1 /* Ugly hack */
189 #define sys_stat64 sys_stat
190 #define sys_fstat64 sys_fstat
191 #define sys_lstat64 sys_lstat
192 #define sys_lseek64 sys_lseek
193 #define sys_truncate64 sys_truncate
194 #define sys_ftruncate64 sys_ftruncate
197 #ifdef MAJOR_IN_SYSMACROS
198 #include <sys/sysmacros.h>
201 #ifdef MAJOR_IN_MKDEV
202 #include <sys/mkdev.h>
205 #ifdef HAVE_SYS_ASYNCH_H
206 #include <sys/asynch.h>
213 const struct xlat open_access_modes[] = {
214 { O_RDONLY, "O_RDONLY" },
215 { O_WRONLY, "O_WRONLY" },
216 { O_RDWR, "O_RDWR" },
218 { O_ACCMODE, "O_ACCMODE" },
223 const struct xlat open_mode_flags[] = {
224 { O_CREAT, "O_CREAT" },
225 { O_EXCL, "O_EXCL" },
226 { O_NOCTTY, "O_NOCTTY" },
227 { O_TRUNC, "O_TRUNC" },
228 { O_APPEND, "O_APPEND" },
229 { O_NONBLOCK, "O_NONBLOCK" },
231 { O_SYNC, "O_SYNC" },
234 { O_ASYNC, "O_ASYNC" },
237 { O_DSYNC, "O_DSYNC" },
240 { O_RSYNC, "O_RSYNC" },
243 { O_NDELAY, "O_NDELAY" },
246 { O_PRIV, "O_PRIV" },
249 { O_DIRECT, "O_DIRECT" },
252 # if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
255 # define O_LARGEFILE 0x40000
256 # elif defined X86_64 || defined S390X
257 # define O_LARGEFILE 0100000
261 { O_LARGEFILE, "O_LARGEFILE" },
265 { O_DIRECTORY, "O_DIRECTORY" },
268 { O_NOFOLLOW, "O_NOFOLLOW" },
271 { O_NOATIME, "O_NOATIME" },
274 { O_CLOEXEC, "O_CLOEXEC" },
278 { FNDELAY, "FNDELAY" },
281 { FAPPEND, "FAPPEND" },
287 { FDEFER, "FDEFER" },
290 { FASYNC, "FASYNC" },
293 { FSHLOCK, "FSHLOCK" },
296 { FEXLOCK, "FEXLOCK" },
299 { FCREAT, "FCREAT" },
302 { FTRUNC, "FTRUNC" },
314 { FNOCTTY, "FNOCTTY" },
317 { O_SHLOCK, "O_SHLOCK" },
320 { O_EXLOCK, "O_EXLOCK" },
328 # define AT_FDCWD -100
335 tprintf("AT_FDCWD, ");
337 tprintf("%ld, ", fd);
342 * low bits of the open(2) flags define access mode,
343 * other bits are real flags.
346 tprint_open_modes(struct tcb *tcp, mode_t flags)
348 const char *str = xlookup(open_access_modes, flags & 3);
358 printflags(open_mode_flags, flags, "O_???");
362 decode_open(struct tcb *tcp, int offset)
365 printpath(tcp, tcp->u_arg[offset]);
368 tprint_open_modes(tcp, tcp->u_arg[offset + 1]);
369 if (tcp->u_arg[offset + 1] & O_CREAT) {
371 tprintf(", %#lo", tcp->u_arg[offset + 2]);
378 sys_open(struct tcb *tcp)
380 return decode_open(tcp, 0);
385 sys_openat(struct tcb *tcp)
388 print_dirfd(tcp->u_arg[0]);
389 return decode_open(tcp, 1);
394 static const struct xlat openmodessol[] = {
398 { 0x80, "O_NONBLOCK" },
400 { 0x100, "O_CREAT" },
401 { 0x200, "O_TRUNC" },
403 { 0x800, "O_NOCTTY" },
406 { 0x8000, "O_RSYNC" },
408 { 0x1000, "O_PRIV" },
417 printpath(tcp, tcp->u_arg[0]);
420 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
421 if (tcp->u_arg[1] & 0x100) {
423 tprintf(", %#lo", tcp->u_arg[2]);
436 printpath(tcp, tcp->u_arg[0]);
437 tprintf(", %#lo", tcp->u_arg[1]);
442 static const struct xlat access_flags[] = {
448 { EFF_ONLY_OK, "EFF_ONLY_OK" },
457 decode_access(struct tcb *tcp, int offset)
460 printpath(tcp, tcp->u_arg[offset]);
462 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK");
468 sys_access(struct tcb *tcp)
470 return decode_access(tcp, 0);
475 sys_faccessat(struct tcb *tcp)
478 print_dirfd(tcp->u_arg[0]);
479 return decode_access(tcp, 1);
488 tprintf("%#lo", tcp->u_arg[0]);
493 static const struct xlat whence[] = {
494 { SEEK_SET, "SEEK_SET" },
495 { SEEK_CUR, "SEEK_CUR" },
496 { SEEK_END, "SEEK_END" },
500 #ifndef HAVE_LONG_LONG_OFF_T
501 #if defined (LINUX_MIPSN32)
510 tprintf("%ld, ", tcp->u_arg[0]);
511 offset = tcp->ext_arg[1];
512 _whence = tcp->u_arg[2];
513 if (_whence == SEEK_SET)
514 tprintf("%llu, ", offset);
516 tprintf("%lld, ", offset);
517 printxval(whence, _whence, "SEEK_???");
519 return RVAL_UDECIMAL;
521 #else /* !LINUX_MIPSN32 */
530 tprintf("%ld, ", tcp->u_arg[0]);
531 offset = tcp->u_arg[1];
532 _whence = tcp->u_arg[2];
533 if (_whence == SEEK_SET)
534 tprintf("%lu, ", offset);
536 tprintf("%ld, ", offset);
537 printxval(whence, _whence, "SEEK_???");
539 return RVAL_UDECIMAL;
541 #endif /* LINUX_MIPSN32 */
551 * This one call takes explicitly two 32-bit arguments hi, lo,
552 * rather than one 64-bit argument for which LONG_LONG works
553 * appropriate for the native byte order.
555 if (tcp->u_arg[4] == SEEK_SET)
556 tprintf("%ld, %llu, ", tcp->u_arg[0],
557 (((long long int) tcp->u_arg[1]) << 32
558 | (unsigned long long) (unsigned) tcp->u_arg[2]));
560 tprintf("%ld, %lld, ", tcp->u_arg[0],
561 (((long long int) tcp->u_arg[1]) << 32
562 | (unsigned long long) (unsigned) tcp->u_arg[2]));
566 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
567 tprintf("%#lx, ", tcp->u_arg[3]);
569 tprintf("[%llu], ", off);
570 printxval(whence, tcp->u_arg[4], "SEEK_???");
580 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
581 # if defined LINUX_MIPSN32
582 tcp->ext_arg[1], tcp->u_arg[2]
583 # elif defined IA64 || defined X86_64 || defined ALPHA || defined LINUX_MIPSN64
584 (long long int) tcp->u_arg[1], tcp->u_arg[2]
586 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]
594 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
601 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
602 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
603 if (tcp->u_arg[3] == SEEK_SET)
604 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
606 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
607 printxval(whence, tcp->u_arg[3], "SEEK_???");
609 return RVAL_LUDECIMAL;
613 #ifndef HAVE_LONG_LONG_OFF_T
619 printpath(tcp, tcp->u_arg[0]);
620 tprintf(", %lu", tcp->u_arg[1]);
626 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
633 printpath(tcp, tcp->u_arg[0]);
634 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
640 #ifndef HAVE_LONG_LONG_OFF_T
646 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
652 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
659 tprintf("%ld, %llu", tcp->u_arg[0],
660 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
668 static const struct xlat modetypes[] = {
669 { S_IFREG, "S_IFREG" },
670 { S_IFSOCK, "S_IFSOCK" },
671 { S_IFIFO, "S_IFIFO" },
672 { S_IFLNK, "S_IFLNK" },
673 { S_IFDIR, "S_IFDIR" },
674 { S_IFBLK, "S_IFBLK" },
675 { S_IFCHR, "S_IFCHR" },
686 if ((mode & S_IFMT) == 0)
688 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
689 sprintf(buf, "%#o", mode);
692 sprintf(buf, "%s%s%s%s", s,
693 (mode & S_ISUID) ? "|S_ISUID" : "",
694 (mode & S_ISGID) ? "|S_ISGID" : "",
695 (mode & S_ISVTX) ? "|S_ISVTX" : "");
696 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
698 sprintf(buf + strlen(buf), "|%#o", mode);
699 s = (*buf == '|') ? buf + 1 : buf;
713 if ((tmp = localtime(&t)))
714 snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d",
715 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
716 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
718 snprintf(buf, sizeof buf, "%lu", (unsigned long) t);
731 int st_pad1[3]; /* network id */
740 int st_pad3; /* st_size, off_t expansion */
741 timestruct_t st_atime;
742 timestruct_t st_mtime;
743 timestruct_t st_ctime;
747 int st_pad4[8]; /* expansion area */
751 printstatsol(struct tcb *tcp, long addr)
753 struct solstat statbuf;
759 if (syserror(tcp) || !verbose(tcp)) {
760 tprintf("%#lx", addr);
763 if (umove(tcp, addr, &statbuf) < 0) {
768 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
769 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
770 (unsigned long) (statbuf.st_dev & 0x3ffff),
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 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
778 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
781 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
782 switch (statbuf.st_mode & S_IFMT) {
783 case S_IFCHR: case S_IFBLK:
784 tprintf("st_rdev=makedev(%lu, %lu), ",
785 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
786 (unsigned long) (statbuf.st_rdev & 0x3ffff));
789 tprintf("st_size=%u, ", statbuf.st_size);
793 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
794 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
795 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
801 #if defined (SPARC64)
803 printstat_sparc64(tcp, addr)
807 struct stat_sparc64 statbuf;
813 if (syserror(tcp) || !verbose(tcp)) {
814 tprintf("%#lx", addr);
817 if (umove(tcp, addr, &statbuf) < 0) {
823 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
824 (unsigned long) major(statbuf.st_dev),
825 (unsigned long) minor(statbuf.st_dev),
826 (unsigned long) statbuf.st_ino,
827 sprintmode(statbuf.st_mode));
828 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
829 (unsigned long) statbuf.st_nlink,
830 (unsigned long) statbuf.st_uid,
831 (unsigned long) statbuf.st_gid);
832 tprintf("st_blksize=%lu, ",
833 (unsigned long) statbuf.st_blksize);
834 tprintf("st_blocks=%lu, ",
835 (unsigned long) statbuf.st_blocks);
838 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
839 switch (statbuf.st_mode & S_IFMT) {
840 case S_IFCHR: case S_IFBLK:
841 tprintf("st_rdev=makedev(%lu, %lu), ",
842 (unsigned long) major(statbuf.st_rdev),
843 (unsigned long) minor(statbuf.st_rdev));
846 tprintf("st_size=%lu, ", statbuf.st_size);
850 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
851 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
852 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
859 #endif /* LINUXSPARC */
861 static const struct xlat fileflags[] = {
863 { UF_NODUMP, "UF_NODUMP" },
864 { UF_IMMUTABLE, "UF_IMMUTABLE" },
865 { UF_APPEND, "UF_APPEND" },
866 { UF_OPAQUE, "UF_OPAQUE" },
867 { UF_NOUNLINK, "UF_NOUNLINK" },
868 { SF_ARCHIVED, "SF_ARCHIVED" },
869 { SF_IMMUTABLE, "SF_IMMUTABLE" },
870 { SF_APPEND, "SF_APPEND" },
871 { SF_NOUNLINK, "SF_NOUNLINK" },
874 { _S_ISMLD, "_S_ISMLD" },
877 { _S_ISMOUNTED, "_S_ISMOUNTED" },
889 printpath(tcp, tcp->u_arg[0]);
891 printflags(fileflags, tcp->u_arg[1], "UF_???");
901 tprintf("%ld, ", tcp->u_arg[0]);
902 printflags(fileflags, tcp->u_arg[1], "UF_???");
908 #ifndef HAVE_LONG_LONG_OFF_T
910 realprintstat(tcp, statbuf)
912 struct stat *statbuf;
915 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
916 (unsigned long) major(statbuf->st_dev),
917 (unsigned long) minor(statbuf->st_dev),
918 (unsigned long) statbuf->st_ino,
919 sprintmode(statbuf->st_mode));
920 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
921 (unsigned long) statbuf->st_nlink,
922 (unsigned long) statbuf->st_uid,
923 (unsigned long) statbuf->st_gid);
924 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
925 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
926 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
927 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
928 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
929 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
932 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
933 switch (statbuf->st_mode & S_IFMT) {
934 case S_IFCHR: case S_IFBLK:
935 #ifdef HAVE_STRUCT_STAT_ST_RDEV
936 tprintf("st_rdev=makedev(%lu, %lu), ",
937 (unsigned long) major(statbuf->st_rdev),
938 (unsigned long) minor(statbuf->st_rdev));
939 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
940 tprintf("st_size=makedev(%lu, %lu), ",
941 (unsigned long) major(statbuf->st_size),
942 (unsigned long) minor(statbuf->st_size));
943 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
946 tprintf("st_size=%lu, ", statbuf->st_size);
950 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
951 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
952 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
953 #if HAVE_STRUCT_STAT_ST_FLAGS
954 tprintf(", st_flags=");
955 printflags(fileflags, statbuf->st_flags, "UF_???");
957 #if HAVE_STRUCT_STAT_ST_ACLCNT
958 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
960 #if HAVE_STRUCT_STAT_ST_LEVEL
961 tprintf(", st_level=%ld", statbuf->st_level);
963 #if HAVE_STRUCT_STAT_ST_FSTYPE
964 tprintf(", st_fstype=%.*s",
965 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
967 #if HAVE_STRUCT_STAT_ST_GEN
968 tprintf(", st_gen=%u", statbuf->st_gen);
985 if (current_personality == 1) {
986 printstatsol(tcp, addr);
990 else if (current_personality == 2) {
991 printstat_sparc64(tcp, addr);
995 #endif /* LINUXSPARC */
1001 if (syserror(tcp) || !verbose(tcp)) {
1002 tprintf("%#lx", addr);
1005 if (umove(tcp, addr, &statbuf) < 0) {
1010 realprintstat(tcp, &statbuf);
1012 #endif /* !HAVE_LONG_LONG_OFF_T */
1014 #if !defined HAVE_STAT64 && defined LINUX && defined X86_64
1016 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
1017 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
1018 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
1019 * __GNUC__ is needed for the required __attribute__ below.
1022 unsigned long long st_dev;
1023 unsigned char __pad0[4];
1024 unsigned int __st_ino;
1025 unsigned int st_mode;
1026 unsigned int st_nlink;
1027 unsigned int st_uid;
1028 unsigned int st_gid;
1029 unsigned long long st_rdev;
1030 unsigned char __pad3[4];
1032 unsigned int st_blksize;
1033 unsigned long long st_blocks;
1034 unsigned int st_atime;
1035 unsigned int st_atime_nsec;
1036 unsigned int st_mtime;
1037 unsigned int st_mtime_nsec;
1038 unsigned int st_ctime;
1039 unsigned int st_ctime_nsec;
1040 unsigned long long st_ino;
1041 } __attribute__((packed));
1042 # define HAVE_STAT64 1
1043 # define STAT64_SIZE 96
1048 printstat64(tcp, addr)
1052 struct stat64 statbuf;
1055 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
1059 if (current_personality == 1) {
1060 printstatsol(tcp, addr);
1064 else if (current_personality == 2) {
1065 printstat_sparc64(tcp, addr);
1069 #endif /* LINUXSPARC */
1075 if (syserror(tcp) || !verbose(tcp)) {
1076 tprintf("%#lx", addr);
1079 if (umove(tcp, addr, &statbuf) < 0) {
1085 #ifdef HAVE_LONG_LONG
1086 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1088 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
1090 (unsigned long) major(statbuf.st_dev),
1091 (unsigned long) minor(statbuf.st_dev),
1092 #ifdef HAVE_LONG_LONG
1093 (unsigned long long) statbuf.st_ino,
1095 (unsigned long) statbuf.st_ino,
1097 sprintmode(statbuf.st_mode));
1098 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1099 (unsigned long) statbuf.st_nlink,
1100 (unsigned long) statbuf.st_uid,
1101 (unsigned long) statbuf.st_gid);
1102 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
1103 tprintf("st_blksize=%lu, ",
1104 (unsigned long) statbuf.st_blksize);
1105 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
1106 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
1107 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
1108 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
1111 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1112 switch (statbuf.st_mode & S_IFMT) {
1113 case S_IFCHR: case S_IFBLK:
1114 #ifdef HAVE_STRUCT_STAT_ST_RDEV
1115 tprintf("st_rdev=makedev(%lu, %lu), ",
1116 (unsigned long) major(statbuf.st_rdev),
1117 (unsigned long) minor(statbuf.st_rdev));
1118 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
1119 tprintf("st_size=makedev(%lu, %lu), ",
1120 (unsigned long) major(statbuf.st_size),
1121 (unsigned long) minor(statbuf.st_size));
1122 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
1125 #ifdef HAVE_LONG_LONG
1126 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1128 tprintf("st_size=%lu, ", (unsigned long) statbuf.st_size);
1133 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1134 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
1135 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
1136 #if HAVE_STRUCT_STAT_ST_FLAGS
1137 tprintf(", st_flags=");
1138 printflags(fileflags, statbuf.st_flags, "UF_???");
1140 #if HAVE_STRUCT_STAT_ST_ACLCNT
1141 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1143 #if HAVE_STRUCT_STAT_ST_LEVEL
1144 tprintf(", st_level=%ld", statbuf.st_level);
1146 #if HAVE_STRUCT_STAT_ST_FSTYPE
1147 tprintf(", st_fstype=%.*s",
1148 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1150 #if HAVE_STRUCT_STAT_ST_GEN
1151 tprintf(", st_gen=%u", statbuf.st_gen);
1158 #endif /* HAVE_STAT64 */
1160 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1162 convertoldstat(oldbuf, newbuf)
1163 const struct __old_kernel_stat *oldbuf;
1164 struct stat *newbuf;
1166 newbuf->st_dev=oldbuf->st_dev;
1167 newbuf->st_ino=oldbuf->st_ino;
1168 newbuf->st_mode=oldbuf->st_mode;
1169 newbuf->st_nlink=oldbuf->st_nlink;
1170 newbuf->st_uid=oldbuf->st_uid;
1171 newbuf->st_gid=oldbuf->st_gid;
1172 newbuf->st_rdev=oldbuf->st_rdev;
1173 newbuf->st_size=oldbuf->st_size;
1174 newbuf->st_atime=oldbuf->st_atime;
1175 newbuf->st_mtime=oldbuf->st_mtime;
1176 newbuf->st_ctime=oldbuf->st_ctime;
1177 newbuf->st_blksize=0; /* not supported in old_stat */
1178 newbuf->st_blocks=0; /* not supported in old_stat */
1183 printoldstat(tcp, addr)
1187 struct __old_kernel_stat statbuf;
1188 struct stat newstatbuf;
1191 if (current_personality == 1) {
1192 printstatsol(tcp, addr);
1195 #endif /* LINUXSPARC */
1201 if (syserror(tcp) || !verbose(tcp)) {
1202 tprintf("%#lx", addr);
1205 if (umove(tcp, addr, &statbuf) < 0) {
1210 convertoldstat(&statbuf, &newstatbuf);
1211 realprintstat(tcp, &newstatbuf);
1213 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1215 #ifndef HAVE_LONG_LONG_OFF_T
1220 if (entering(tcp)) {
1221 printpath(tcp, tcp->u_arg[0]);
1224 printstat(tcp, tcp->u_arg[1]);
1235 if (entering(tcp)) {
1236 printpath(tcp, tcp->u_arg[0]);
1239 printstat64(tcp, tcp->u_arg[1]);
1243 return printargs(tcp);
1248 static const struct xlat fstatatflags[] = {
1249 #ifndef AT_SYMLINK_NOFOLLOW
1250 # define AT_SYMLINK_NOFOLLOW 0x100
1252 { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" },
1255 #define utimensatflags fstatatflags
1258 sys_newfstatat(struct tcb *tcp)
1260 if (entering(tcp)) {
1261 print_dirfd(tcp->u_arg[0]);
1262 printpath(tcp, tcp->u_arg[1]);
1265 #if defined HAVE_STAT64 && !(defined POWERPC && defined __powerpc64__)
1266 printstat64(tcp, tcp->u_arg[2]);
1268 printstat(tcp, tcp->u_arg[2]);
1271 printflags(fstatatflags, tcp->u_arg[3], "AT_???");
1277 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1282 if (entering(tcp)) {
1283 printpath(tcp, tcp->u_arg[0]);
1286 printoldstat(tcp, tcp->u_arg[1]);
1290 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1292 #ifndef HAVE_LONG_LONG_OFF_T
1298 tprintf("%ld, ", tcp->u_arg[0]);
1300 printstat(tcp, tcp->u_arg[1]);
1312 tprintf("%ld, ", tcp->u_arg[0]);
1314 printstat64(tcp, tcp->u_arg[1]);
1318 return printargs(tcp);
1322 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1328 tprintf("%ld, ", tcp->u_arg[0]);
1330 printoldstat(tcp, tcp->u_arg[1]);
1334 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1336 #ifndef HAVE_LONG_LONG_OFF_T
1341 if (entering(tcp)) {
1342 printpath(tcp, tcp->u_arg[0]);
1345 printstat(tcp, tcp->u_arg[1]);
1356 if (entering(tcp)) {
1357 printpath(tcp, tcp->u_arg[0]);
1360 printstat64(tcp, tcp->u_arg[1]);
1364 return printargs(tcp);
1368 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1373 if (entering(tcp)) {
1374 printpath(tcp, tcp->u_arg[0]);
1377 printoldstat(tcp, tcp->u_arg[1]);
1381 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1384 #if defined(SVR4) || defined(LINUXSPARC)
1390 if (entering(tcp)) {
1391 tprintf("%ld, ", tcp->u_arg[0]);
1392 printpath(tcp, tcp->u_arg[1]);
1396 if (tcp->u_arg[0] == _STAT64_VER)
1397 printstat64 (tcp, tcp->u_arg[2]);
1400 printstat(tcp, tcp->u_arg[2]);
1410 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1413 if (tcp->u_arg[0] == _STAT64_VER)
1414 printstat64 (tcp, tcp->u_arg[2]);
1417 printstat(tcp, tcp->u_arg[2]);
1426 if (entering(tcp)) {
1427 tprintf("%ld, ", tcp->u_arg[0]);
1428 printpath(tcp, tcp->u_arg[1]);
1432 if (tcp->u_arg[0] == _STAT64_VER)
1433 printstat64 (tcp, tcp->u_arg[2]);
1436 printstat(tcp, tcp->u_arg[2]);
1445 int mode = tcp->u_arg[2];
1447 if (entering(tcp)) {
1448 tprintf("%ld, ", tcp->u_arg[0]);
1449 printpath(tcp, tcp->u_arg[1]);
1450 tprintf(", %s", sprintmode(mode));
1451 switch (mode & S_IFMT) {
1452 case S_IFCHR: case S_IFBLK:
1454 tprintf(", makedev(%lu, %lu)",
1455 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1456 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1458 tprintf(", makedev(%lu, %lu)",
1459 (unsigned long) major(tcp->u_arg[3]),
1460 (unsigned long) minor(tcp->u_arg[3]));
1470 #ifdef HAVE_SYS_ACL_H
1472 #include <sys/acl.h>
1474 static const struct xlat aclcmds[] = {
1476 { SETACL, "SETACL" },
1479 { GETACL, "GETACL" },
1482 { GETACLCNT, "GETACLCNT" },
1485 { ACL_GET, "ACL_GET" },
1488 { ACL_SET, "ACL_SET" },
1491 { ACL_CNT, "ACL_CNT" },
1500 if (entering(tcp)) {
1501 printpath(tcp, tcp->u_arg[0]);
1503 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1504 tprintf(", %ld", tcp->u_arg[2]);
1506 * FIXME - dump out the list of aclent_t's pointed to
1507 * by "tcp->u_arg[3]" if it's not NULL.
1510 tprintf(", %#lx", tcp->u_arg[3]);
1522 if (entering(tcp)) {
1523 tprintf("%ld, ", tcp->u_arg[0]);
1524 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1525 tprintf(", %ld", tcp->u_arg[2]);
1527 * FIXME - dump out the list of aclent_t's pointed to
1528 * by "tcp->u_arg[3]" if it's not NULL.
1531 tprintf(", %#lx", tcp->u_arg[3]);
1539 static const struct xlat aclipc[] = {
1541 { IPC_SHM, "IPC_SHM" },
1544 { IPC_SEM, "IPC_SEM" },
1547 { IPC_MSG, "IPC_MSG" },
1557 if (entering(tcp)) {
1558 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1559 tprintf(", %#lx, ", tcp->u_arg[1]);
1560 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1561 tprintf(", %ld", tcp->u_arg[3]);
1563 * FIXME - dump out the list of aclent_t's pointed to
1564 * by "tcp->u_arg[4]" if it's not NULL.
1567 tprintf(", %#lx", tcp->u_arg[4]);
1576 #endif /* HAVE_SYS_ACL_H */
1578 #endif /* SVR4 || LINUXSPARC */
1582 static const struct xlat fsmagic[] = {
1583 { 0x73757245, "CODA_SUPER_MAGIC" },
1584 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1585 { 0x1373, "DEVFS_SUPER_MAGIC" },
1586 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1587 { 0x414A53, "EFS_SUPER_MAGIC" },
1588 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1589 { 0xef53, "EXT2_SUPER_MAGIC" },
1590 { 0x137d, "EXT_SUPER_MAGIC" },
1591 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1592 { 0x9660, "ISOFS_SUPER_MAGIC" },
1593 { 0x137f, "MINIX_SUPER_MAGIC" },
1594 { 0x138f, "MINIX_SUPER_MAGIC2" },
1595 { 0x2468, "MINIX2_SUPER_MAGIC" },
1596 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1597 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1598 { 0x564c, "NCP_SUPER_MAGIC" },
1599 { 0x6969, "NFS_SUPER_MAGIC" },
1600 { 0x9fa0, "PROC_SUPER_MAGIC" },
1601 { 0x002f, "QNX4_SUPER_MAGIC" },
1602 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1603 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1604 { 0x517b, "SMB_SUPER_MAGIC" },
1605 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1606 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1607 { 0x00011954, "UFS_MAGIC" },
1608 { 0x54190100, "UFS_CIGAM" },
1609 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1610 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1611 { 0x62656572, "SYSFS_MAGIC" },
1623 static char buf[32];
1627 s = xlookup(fsmagic, magic);
1629 sprintf(buf, "\"%s\"", s);
1633 sprintf(buf, "%#x", magic);
1638 printstatfs(tcp, addr)
1642 struct statfs statbuf;
1644 if (syserror(tcp) || !verbose(tcp)) {
1645 tprintf("%#lx", addr);
1648 if (umove(tcp, addr, &statbuf) < 0) {
1654 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1655 sprintfstype(statbuf.f_type),
1656 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1657 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1658 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1659 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1662 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1663 sprintfstype(statbuf.f_type),
1664 (unsigned long)statbuf.f_bsize,
1665 (unsigned long)statbuf.f_blocks,
1666 (unsigned long)statbuf.f_bfree);
1667 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1668 (unsigned long)statbuf.f_bavail,
1669 (unsigned long)statbuf.f_files,
1670 (unsigned long)statbuf.f_ffree,
1671 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1673 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1676 #ifdef _STATFS_F_FRSIZE
1677 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1686 if (entering(tcp)) {
1687 printpath(tcp, tcp->u_arg[0]);
1690 printstatfs(tcp, tcp->u_arg[1]);
1699 if (entering(tcp)) {
1700 tprintf("%lu, ", tcp->u_arg[0]);
1702 printstatfs(tcp, tcp->u_arg[1]);
1709 printstatfs64(tcp, addr)
1713 struct statfs64 statbuf;
1715 if (syserror(tcp) || !verbose(tcp)) {
1716 tprintf("%#lx", addr);
1719 if (umove(tcp, addr, &statbuf) < 0) {
1723 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
1724 sprintfstype(statbuf.f_type),
1725 (unsigned long long)statbuf.f_bsize,
1726 (unsigned long long)statbuf.f_blocks,
1727 (unsigned long long)statbuf.f_bfree);
1728 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1729 (unsigned long long)statbuf.f_bavail,
1730 (unsigned long long)statbuf.f_files,
1731 (unsigned long long)statbuf.f_ffree,
1732 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1733 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1734 #ifdef _STATFS_F_FRSIZE
1735 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
1744 if (entering(tcp)) {
1745 printpath(tcp, tcp->u_arg[0]);
1746 tprintf(", %lu, ", tcp->u_arg[1]);
1748 if (tcp->u_arg[1] == sizeof (struct statfs64))
1749 printstatfs64(tcp, tcp->u_arg[2]);
1760 if (entering(tcp)) {
1761 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1763 if (tcp->u_arg[1] == sizeof (struct statfs64))
1764 printstatfs64(tcp, tcp->u_arg[2]);
1772 #if defined(LINUX) && defined(__alpha)
1778 if (entering(tcp)) {
1779 printpath(tcp, tcp->u_arg[0]);
1782 printstatfs(tcp, tcp->u_arg[1]);
1783 tprintf(", %lu", tcp->u_arg[2]);
1792 if (entering(tcp)) {
1793 tprintf("%lu, ", tcp->u_arg[0]);
1795 printstatfs(tcp, tcp->u_arg[1]);
1796 tprintf(", %lu", tcp->u_arg[2]);
1800 #endif /* LINUX && __alpha */
1810 struct ustat statbuf;
1812 if (entering(tcp)) {
1813 tprintf("makedev(%lu, %lu), ",
1814 (long) major(tcp->u_arg[0]),
1815 (long) minor(tcp->u_arg[0]));
1818 if (syserror(tcp) || !verbose(tcp))
1819 tprintf("%#lx", tcp->u_arg[1]);
1820 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1823 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1824 statbuf.f_tfree, statbuf.f_tinode);
1825 tprintf("f_fname=\"%.*s\", ",
1826 (int) sizeof(statbuf.f_fname),
1828 tprintf("f_fpack=\"%.*s\"}",
1829 (int) sizeof(statbuf.f_fpack),
1842 if (entering(tcp)) {
1843 printpath(tcp, tcp->u_arg[0]);
1845 printpath(tcp, tcp->u_arg[1]);
1856 if (entering(tcp)) {
1857 printpath(tcp, tcp->u_arg[0]);
1863 decode_mkdir(struct tcb *tcp, int offset)
1865 if (entering(tcp)) {
1866 printpath(tcp, tcp->u_arg[offset]);
1867 tprintf(", %#lo", tcp->u_arg[offset + 1]);
1873 sys_mkdir(struct tcb *tcp)
1875 return decode_mkdir(tcp, 0);
1880 sys_mkdirat(struct tcb *tcp)
1883 print_dirfd(tcp->u_arg[0]);
1884 return decode_mkdir(tcp, 1);
1892 if (entering(tcp)) {
1893 printpath(tcp, tcp->u_arg[0]);
1902 if (entering(tcp)) {
1903 tprintf("%ld", tcp->u_arg[0]);
1912 if (entering(tcp)) {
1913 printpath(tcp, tcp->u_arg[0]);
1918 #if defined(SUNOS4) || defined(SVR4)
1923 if (entering(tcp)) {
1924 tprintf("%ld", tcp->u_arg[0]);
1928 #endif /* SUNOS4 || SVR4 */
1934 if (entering(tcp)) {
1935 printpath(tcp, tcp->u_arg[0]);
1937 printpath(tcp, tcp->u_arg[1]);
1944 sys_linkat(struct tcb *tcp)
1946 if (entering(tcp)) {
1947 print_dirfd(tcp->u_arg[0]);
1948 printpath(tcp, tcp->u_arg[1]);
1950 print_dirfd(tcp->u_arg[2]);
1951 printpath(tcp, tcp->u_arg[3]);
1952 tprintf(", %ld", tcp->u_arg[4]);
1962 if (entering(tcp)) {
1963 printpath(tcp, tcp->u_arg[0]);
1969 static const struct xlat unlinkatflags[] = {
1970 #ifndef AT_REMOVEDIR
1971 # define AT_REMOVEDIR 0x200
1973 { AT_REMOVEDIR, "AT_REMOVEDIR" },
1978 sys_unlinkat(struct tcb *tcp)
1980 if (entering(tcp)) {
1981 print_dirfd(tcp->u_arg[0]);
1982 printpath(tcp, tcp->u_arg[1]);
1984 printflags(unlinkatflags, tcp->u_arg[2], "AT_???");
1994 if (entering(tcp)) {
1995 printpath(tcp, tcp->u_arg[0]);
1997 printpath(tcp, tcp->u_arg[1]);
2004 sys_symlinkat(struct tcb *tcp)
2006 if (entering(tcp)) {
2007 printpath(tcp, tcp->u_arg[0]);
2009 print_dirfd(tcp->u_arg[1]);
2010 printpath(tcp, tcp->u_arg[2]);
2017 decode_readlink(struct tcb *tcp, int offset)
2019 if (entering(tcp)) {
2020 printpath(tcp, tcp->u_arg[offset]);
2024 tprintf("%#lx", tcp->u_arg[offset + 1]);
2026 printpathn(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
2027 tprintf(", %lu", tcp->u_arg[offset + 2]);
2033 sys_readlink(struct tcb *tcp)
2035 return decode_readlink(tcp, 0);
2040 sys_readlinkat(struct tcb *tcp)
2043 print_dirfd(tcp->u_arg[0]);
2044 return decode_readlink(tcp, 1);
2052 if (entering(tcp)) {
2053 printpath(tcp, tcp->u_arg[0]);
2055 printpath(tcp, tcp->u_arg[1]);
2062 sys_renameat(struct tcb *tcp)
2064 if (entering(tcp)) {
2065 print_dirfd(tcp->u_arg[0]);
2066 printpath(tcp, tcp->u_arg[1]);
2068 print_dirfd(tcp->u_arg[2]);
2069 printpath(tcp, tcp->u_arg[3]);
2079 if (entering(tcp)) {
2080 printpath(tcp, tcp->u_arg[0]);
2081 printuid(", ", tcp->u_arg[1]);
2082 printuid(", ", tcp->u_arg[2]);
2089 sys_fchownat(struct tcb *tcp)
2091 if (entering(tcp)) {
2092 print_dirfd(tcp->u_arg[0]);
2093 printpath(tcp, tcp->u_arg[1]);
2094 printuid(", ", tcp->u_arg[2]);
2095 printuid(", ", tcp->u_arg[3]);
2097 printflags(fstatatflags, tcp->u_arg[4], "AT_???");
2107 if (entering(tcp)) {
2108 tprintf("%ld", tcp->u_arg[0]);
2109 printuid(", ", tcp->u_arg[1]);
2110 printuid(", ", tcp->u_arg[2]);
2116 decode_chmod(struct tcb *tcp, int offset)
2118 if (entering(tcp)) {
2119 printpath(tcp, tcp->u_arg[offset]);
2120 tprintf(", %#lo", tcp->u_arg[offset + 1]);
2126 sys_chmod(struct tcb *tcp)
2128 return decode_chmod(tcp, 0);
2133 sys_fchmodat(struct tcb *tcp)
2136 print_dirfd(tcp->u_arg[0]);
2137 return decode_chmod(tcp, 1);
2145 if (entering(tcp)) {
2146 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
2156 if (entering(tcp)) {
2157 printpath(tcp, tcp->u_arg[0]);
2159 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
2166 decode_utimes(struct tcb *tcp, int offset, int special)
2168 if (entering(tcp)) {
2169 printpath(tcp, tcp->u_arg[offset]);
2171 if (tcp->u_arg[offset + 1] == 0)
2175 printtv_bitness(tcp, tcp->u_arg[offset + 1],
2176 BITNESS_CURRENT, special);
2178 printtv_bitness(tcp, tcp->u_arg[offset + 1]
2179 + sizeof (struct timeval),
2180 BITNESS_CURRENT, special);
2188 sys_utimes(struct tcb *tcp)
2190 return decode_utimes(tcp, 0, 0);
2195 sys_futimesat(struct tcb *tcp)
2198 print_dirfd(tcp->u_arg[0]);
2199 return decode_utimes(tcp, 1, 0);
2203 sys_utimensat(struct tcb *tcp)
2205 if (entering(tcp)) {
2206 print_dirfd(tcp->u_arg[0]);
2207 decode_utimes(tcp, 1, 1);
2209 printflags(utimensatflags, tcp->u_arg[3], "AT_???");
2224 if (entering(tcp)) {
2225 printpath(tcp, tcp->u_arg[0]);
2229 else if (!verbose(tcp))
2230 tprintf("%#lx", tcp->u_arg[1]);
2231 else if (umoven(tcp, tcp->u_arg[1],
2232 2 * personality_wordsize[current_personality],
2235 else if (personality_wordsize[current_personality]
2236 == sizeof u.utl[0]) {
2237 tprintf("[%s,", sprinttime(u.utl[0]));
2238 tprintf(" %s]", sprinttime(u.utl[1]));
2240 else if (personality_wordsize[current_personality]
2241 == sizeof u.uti[0]) {
2242 tprintf("[%s,", sprinttime(u.uti[0]));
2243 tprintf(" %s]", sprinttime(u.uti[1]));
2252 decode_mknod(struct tcb *tcp, int offset)
2254 int mode = tcp->u_arg[offset + 1];
2256 if (entering(tcp)) {
2257 printpath(tcp, tcp->u_arg[offset]);
2258 tprintf(", %s", sprintmode(mode));
2259 switch (mode & S_IFMT) {
2260 case S_IFCHR: case S_IFBLK:
2262 if (current_personality == 1)
2263 tprintf(", makedev(%lu, %lu)",
2264 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
2265 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
2268 tprintf(", makedev(%lu, %lu)",
2269 (unsigned long) major(tcp->u_arg[offset + 2]),
2270 (unsigned long) minor(tcp->u_arg[offset + 2]));
2280 sys_mknod(struct tcb *tcp)
2282 return decode_mknod(tcp, 0);
2287 sys_mknodat(struct tcb *tcp)
2290 print_dirfd(tcp->u_arg[0]);
2291 return decode_mknod(tcp, 1);
2300 if (entering(tcp)) {
2301 printpath(tcp, tcp->u_arg[0]);
2302 tprintf(", %#lo", tcp->u_arg[1]);
2306 #endif /* FREEBSD */
2312 if (entering(tcp)) {
2313 tprintf("%ld", tcp->u_arg[0]);
2327 if (!verbose(tcp)) {
2328 tprintf("%#lx", addr);
2331 if (umove(tcp, addr, &d) < 0) {
2335 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
2337 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
2345 if (entering(tcp)) {
2346 tprintf("%lu, ", tcp->u_arg[0]);
2348 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
2349 tprintf("%#lx", tcp->u_arg[1]);
2351 printdir(tcp, tcp->u_arg[1]);
2352 /* Not much point in printing this out, it is always 1. */
2353 if (tcp->u_arg[2] != 1)
2354 tprintf(", %lu", tcp->u_arg[2]);
2361 #if defined FREEBSD || defined LINUX
2362 static const struct xlat direnttypes[] = {
2363 { DT_UNKNOWN, "DT_UNKNOWN" },
2364 { DT_FIFO, "DT_FIFO" },
2365 { DT_CHR, "DT_CHR" },
2366 { DT_DIR, "DT_DIR" },
2367 { DT_BLK, "DT_BLK" },
2368 { DT_REG, "DT_REG" },
2369 { DT_LNK, "DT_LNK" },
2370 { DT_SOCK, "DT_SOCK" },
2371 { DT_WHT, "DT_WHT" },
2378 sys_getdents(struct tcb *tcp)
2380 int i, len, dents = 0;
2383 if (entering(tcp)) {
2384 tprintf("%lu, ", tcp->u_arg[0]);
2387 if (syserror(tcp) || !verbose(tcp)) {
2388 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2392 if ((buf = malloc(len)) == NULL) {
2393 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2394 fprintf(stderr, "out of memory\n");
2397 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2398 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2404 for (i = 0; i < len;) {
2405 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2408 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2409 i ? " " : "", d->d_ino, d->d_off);
2410 tprintf("d_reclen=%u, d_name=\"%s\"}",
2411 d->d_reclen, d->d_name);
2416 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2418 (unsigned long) d->d_ino,
2419 (unsigned long) d->d_off);
2420 tprintf("d_reclen=%u, d_name=\"%s\"}",
2421 d->d_reclen, d->d_name);
2426 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2427 i ? " " : "", d->d_off, d->d_fileno,
2429 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2430 d->d_namlen, d->d_namlen, d->d_name);
2435 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2436 i ? " " : "", d->d_fileno, d->d_reclen);
2437 printxval(direnttypes, d->d_type, "DT_???");
2438 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2439 d->d_namlen, d->d_namlen, d->d_name);
2441 #endif /* FREEBSD */
2443 tprintf("/* d_reclen == 0, problem here */");
2452 tprintf("/* %u entries */", dents);
2453 tprintf(", %lu", tcp->u_arg[2]);
2459 #if _LFS64_LARGEFILE
2461 sys_getdents64(struct tcb *tcp)
2463 int i, len, dents = 0;
2466 if (entering(tcp)) {
2467 tprintf("%lu, ", tcp->u_arg[0]);
2470 if (syserror(tcp) || !verbose(tcp)) {
2471 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2475 if ((buf = malloc(len)) == NULL) {
2476 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2477 fprintf(stderr, "out of memory\n");
2480 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2481 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2487 for (i = 0; i < len;) {
2488 struct dirent64 *d = (struct dirent64 *) &buf[i];
2489 #if defined(LINUX) || defined(SVR4)
2491 tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ",
2497 printxval(direnttypes, d->d_type, "DT_???");
2500 tprintf("d_reclen=%u, d_name=\"%s\"}",
2501 d->d_reclen, d->d_name);
2503 #endif /* LINUX || SVR4 */
2506 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2507 i ? " " : "", d->d_off, d->d_fileno,
2509 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2510 d->d_namlen, d->d_namlen, d->d_name);
2514 tprintf("/* d_reclen == 0, problem here */");
2523 tprintf("/* %u entries */", dents);
2524 tprintf(", %lu", tcp->u_arg[2]);
2532 sys_getdirentries(struct tcb *tcp)
2534 int i, len, dents = 0;
2538 if (entering(tcp)) {
2539 tprintf("%lu, ", tcp->u_arg[0]);
2542 if (syserror(tcp) || !verbose(tcp)) {
2543 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2547 if ((buf = malloc(len)) == NULL) {
2548 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2549 fprintf(stderr, "out of memory\n");
2552 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2553 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2559 for (i = 0; i < len;) {
2560 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2562 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2563 i ? " " : "", d->d_fileno, d->d_reclen);
2564 printxval(direnttypes, d->d_type, "DT_???");
2565 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2566 d->d_namlen, d->d_namlen, d->d_name);
2569 tprintf("/* d_reclen == 0, problem here */");
2578 tprintf("/* %u entries */", dents);
2580 tprintf(", %lu", tcp->u_arg[2]);
2581 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2582 tprintf(", %#lx", tcp->u_arg[3]);
2584 tprintf(", [%lu]", basep);
2596 tprintf("%#lx", tcp->u_arg[0]);
2598 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2599 tprintf(", %lu", tcp->u_arg[1]);
2612 tprintf("%#lx", tcp->u_arg[0]);
2614 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2615 tprintf(", %lu", tcp->u_arg[1]);
2621 #ifdef HAVE_SYS_ASYNCH_H
2627 struct aio_result_t res;
2629 if (entering(tcp)) {
2630 tprintf("%lu, ", tcp->u_arg[0]);
2633 tprintf("%#lx", tcp->u_arg[1]);
2635 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2636 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2637 printxval(whence, tcp->u_arg[4], "L_???");
2638 if (syserror(tcp) || tcp->u_arg[5] == 0
2639 || umove(tcp, tcp->u_arg[5], &res) < 0)
2640 tprintf(", %#lx", tcp->u_arg[5]);
2642 tprintf(", {aio_return %d aio_errno %d}",
2643 res.aio_return, res.aio_errno);
2652 struct aio_result_t res;
2654 if (entering(tcp)) {
2655 tprintf("%lu, ", tcp->u_arg[0]);
2656 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2657 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2658 printxval(whence, tcp->u_arg[4], "L_???");
2661 if (tcp->u_arg[5] == 0)
2663 else if (syserror(tcp)
2664 || umove(tcp, tcp->u_arg[5], &res) < 0)
2665 tprintf(", %#lx", tcp->u_arg[5]);
2667 tprintf(", {aio_return %d aio_errno %d}",
2668 res.aio_return, res.aio_errno);
2678 printtv(tcp, tcp->u_arg[0]);
2686 struct aio_result_t res;
2689 if (tcp->u_arg[0] == 0)
2691 else if (syserror(tcp)
2692 || umove(tcp, tcp->u_arg[0], &res) < 0)
2693 tprintf("%#lx", tcp->u_arg[0]);
2695 tprintf("{aio_return %d aio_errno %d}",
2696 res.aio_return, res.aio_errno);
2701 #endif /* HAVE_SYS_ASYNCH_H */
2703 static const struct xlat xattrflags[] = {
2705 { XATTR_CREATE, "XATTR_CREATE" },
2706 { XATTR_REPLACE, "XATTR_REPLACE" },
2712 print_xattr_val(tcp, failed, arg, insize, size)
2716 unsigned long insize, size;
2719 unsigned long capacity = 4 * size + 1;
2720 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
2721 if (buf == NULL || /* probably a bogus size argument */
2722 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2726 unsigned char *out = buf;
2727 unsigned char *in = &buf[3 * size];
2729 for (i = 0; i < size; ++i)
2733 #define tohex(n) "0123456789abcdef"[n]
2736 *out++ = tohex(in[i] / 16);
2737 *out++ = tohex(in[i] % 16);
2739 /* Don't print terminating NUL if there is one. */
2740 if (i > 0 && in[i - 1] == '\0')
2743 tprintf(", \"%s\", %ld", buf, insize);
2748 tprintf(", 0x%lx, %ld", arg, insize);
2755 if (entering(tcp)) {
2756 printpath(tcp, tcp->u_arg[0]);
2758 printstr(tcp, tcp->u_arg[1], -1);
2759 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2761 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2770 if (entering(tcp)) {
2771 tprintf("%ld, ", tcp->u_arg[0]);
2772 printstr(tcp, tcp->u_arg[1], -1);
2773 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2775 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2784 if (entering(tcp)) {
2785 printpath(tcp, tcp->u_arg[0]);
2787 printstr(tcp, tcp->u_arg[1], -1);
2789 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2799 if (entering(tcp)) {
2800 tprintf("%ld, ", tcp->u_arg[0]);
2801 printstr(tcp, tcp->u_arg[1], -1);
2803 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2813 if (entering(tcp)) {
2814 printpath(tcp, tcp->u_arg[0]);
2816 /* XXX Print value in format */
2817 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2826 if (entering(tcp)) {
2827 tprintf("%ld", tcp->u_arg[0]);
2829 /* XXX Print value in format */
2830 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2836 sys_removexattr(tcp)
2839 if (entering(tcp)) {
2840 printpath(tcp, tcp->u_arg[0]);
2842 printstr(tcp, tcp->u_arg[1], -1);
2848 sys_fremovexattr(tcp)
2851 if (entering(tcp)) {
2852 tprintf("%ld, ", tcp->u_arg[0]);
2853 printstr(tcp, tcp->u_arg[1], -1);
2859 static const struct xlat advise[] = {
2860 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2861 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2862 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2863 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2864 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2865 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2875 if (entering(tcp)) {
2876 tprintf("%ld, %lld, %ld, ",
2878 # if defined IA64 || defined X86_64 || defined ALPHA
2879 (long long int) tcp->u_arg[1], tcp->u_arg[2]);
2880 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2882 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]);
2883 printxval(advise, tcp->u_arg[4], "POSIX_FADV_???");
2892 sys_fadvise64_64(tcp)
2895 if (entering(tcp)) {
2896 tprintf("%ld, %lld, %lld, ",
2898 #if defined LINUX_MIPSN32
2899 tcp->ext_arg[1], tcp->ext_arg[2]);
2900 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2901 #elif defined IA64 || defined X86_64 || defined ALPHA || defined LINUX_MIPSN64
2902 (long long int) tcp->u_arg[1], (long long int) tcp->u_arg[2]);
2903 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2905 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]),
2906 LONG_LONG(tcp->u_arg[3], tcp->u_arg[4]));
2907 printxval(advise, tcp->u_arg[5], "POSIX_FADV_???");
2914 static const struct xlat inotify_modes[] = {
2915 { 0x00000001, "IN_ACCESS" },
2916 { 0x00000002, "IN_MODIFY" },
2917 { 0x00000004, "IN_ATTRIB" },
2918 { 0x00000008, "IN_CLOSE_WRITE" },
2919 { 0x00000010, "IN_CLOSE_NOWRITE" },
2920 { 0x00000020, "IN_OPEN" },
2921 { 0x00000040, "IN_MOVED_FROM" },
2922 { 0x00000080, "IN_MOVED_TO" },
2923 { 0x00000100, "IN_CREATE" },
2924 { 0x00000200, "IN_DELETE" },
2925 { 0x00000400, "IN_DELETE_SELF" },
2926 { 0x00000800, "IN_MOVE_SELF" },
2927 { 0x00002000, "IN_UNMOUNT" },
2928 { 0x00004000, "IN_Q_OVERFLOW" },
2929 { 0x00008000, "IN_IGNORED" },
2930 { 0x01000000, "IN_ONLYDIR" },
2931 { 0x02000000, "IN_DONT_FOLLOW" },
2932 { 0x20000000, "IN_MASK_ADD" },
2933 { 0x40000000, "IN_ISDIR" },
2934 { 0x80000000, "IN_ONESHOT" }
2938 sys_inotify_add_watch(struct tcb *tcp)
2940 if (entering(tcp)) {
2941 tprintf("%ld, ", tcp->u_arg[0]);
2942 printpath(tcp, tcp->u_arg[1]);
2944 printflags(inotify_modes, tcp->u_arg[2], "IN_???");
2950 sys_inotify_rm_watch(struct tcb *tcp)
2952 if (entering(tcp)) {
2953 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
2959 sys_fallocate(struct tcb *tcp)
2961 if (entering(tcp)) {
2962 tprintf("%ld, ", tcp->u_arg[0]); /* fd */
2963 tprintf("%#lo, ", tcp->u_arg[1]); /* mode */
2964 tprintf("%llu, ", LONG_LONG(tcp->u_arg[2],
2965 tcp->u_arg[3])); /* offset */
2966 tprintf("%llu", LONG_LONG(tcp->u_arg[4],
2967 tcp->u_arg[5])); /* len */