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" },
242 #if defined(O_NDELAY) && (O_NDELAY != O_NONBLOCK)
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 * Pity stpcpy() is not standardized...
345 str_append(char *dst, const char *src)
347 while ((*dst = *src++) != '\0')
353 * low bits of the open(2) flags define access mode,
354 * other bits are real flags.
357 sprint_open_modes(mode_t flags)
359 static char outstr[1024];
363 const struct xlat *x;
365 p = str_append(outstr, "flags ");
366 str = xlookup(open_access_modes, flags & 3);
368 p = str_append(p, str);
375 for (x = open_mode_flags; x->str; x++) {
376 if ((flags & x->val) == x->val) {
379 p = str_append(p, x->str);
386 /* flags is still nonzero */
389 sprintf(p, "%#x", flags);
394 tprint_open_modes(mode_t flags)
396 tprintf(sprint_open_modes(flags) + sizeof("flags"));
400 decode_open(struct tcb *tcp, int offset)
403 printpath(tcp, tcp->u_arg[offset]);
406 tprint_open_modes(tcp->u_arg[offset + 1]);
407 if (tcp->u_arg[offset + 1] & O_CREAT) {
409 tprintf(", %#lo", tcp->u_arg[offset + 2]);
416 sys_open(struct tcb *tcp)
418 return decode_open(tcp, 0);
423 sys_openat(struct tcb *tcp)
426 print_dirfd(tcp->u_arg[0]);
427 return decode_open(tcp, 1);
432 static const struct xlat openmodessol[] = {
436 { 0x80, "O_NONBLOCK" },
438 { 0x100, "O_CREAT" },
439 { 0x200, "O_TRUNC" },
441 { 0x800, "O_NOCTTY" },
444 { 0x8000, "O_RSYNC" },
446 { 0x1000, "O_PRIV" },
455 printpath(tcp, tcp->u_arg[0]);
458 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
459 if (tcp->u_arg[1] & 0x100) {
461 tprintf(", %#lo", tcp->u_arg[2]);
474 printpath(tcp, tcp->u_arg[0]);
475 tprintf(", %#lo", tcp->u_arg[1]);
480 static const struct xlat access_flags[] = {
486 { EFF_ONLY_OK, "EFF_ONLY_OK" },
495 decode_access(struct tcb *tcp, int offset)
498 printpath(tcp, tcp->u_arg[offset]);
500 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK");
506 sys_access(struct tcb *tcp)
508 return decode_access(tcp, 0);
513 sys_faccessat(struct tcb *tcp)
516 print_dirfd(tcp->u_arg[0]);
517 return decode_access(tcp, 1);
526 tprintf("%#lo", tcp->u_arg[0]);
531 static const struct xlat whence[] = {
532 { SEEK_SET, "SEEK_SET" },
533 { SEEK_CUR, "SEEK_CUR" },
534 { SEEK_END, "SEEK_END" },
538 #ifndef HAVE_LONG_LONG_OFF_T
539 #if defined (LINUX_MIPSN32)
548 tprintf("%ld, ", tcp->u_arg[0]);
549 offset = tcp->ext_arg[1];
550 _whence = tcp->u_arg[2];
551 if (_whence == SEEK_SET)
552 tprintf("%llu, ", offset);
554 tprintf("%lld, ", offset);
555 printxval(whence, _whence, "SEEK_???");
557 return RVAL_UDECIMAL;
559 #else /* !LINUX_MIPSN32 */
568 tprintf("%ld, ", tcp->u_arg[0]);
569 offset = tcp->u_arg[1];
570 _whence = tcp->u_arg[2];
571 if (_whence == SEEK_SET)
572 tprintf("%lu, ", offset);
574 tprintf("%ld, ", offset);
575 printxval(whence, _whence, "SEEK_???");
577 return RVAL_UDECIMAL;
579 #endif /* LINUX_MIPSN32 */
589 * This one call takes explicitly two 32-bit arguments hi, lo,
590 * rather than one 64-bit argument for which LONG_LONG works
591 * appropriate for the native byte order.
593 if (tcp->u_arg[4] == SEEK_SET)
594 tprintf("%ld, %llu, ", tcp->u_arg[0],
595 (((long long int) tcp->u_arg[1]) << 32
596 | (unsigned long long) (unsigned) tcp->u_arg[2]));
598 tprintf("%ld, %lld, ", tcp->u_arg[0],
599 (((long long int) tcp->u_arg[1]) << 32
600 | (unsigned long long) (unsigned) tcp->u_arg[2]));
604 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
605 tprintf("%#lx, ", tcp->u_arg[3]);
607 tprintf("[%llu], ", off);
608 printxval(whence, tcp->u_arg[4], "SEEK_???");
618 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
619 # if defined LINUX_MIPSN32
620 tcp->ext_arg[1], tcp->u_arg[2]
621 # elif defined IA64 || defined X86_64 || defined ALPHA || defined LINUX_MIPSN64
622 (long long int) tcp->u_arg[1], tcp->u_arg[2]
624 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]
632 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
639 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
640 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
641 if (tcp->u_arg[3] == SEEK_SET)
642 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
644 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
645 printxval(whence, tcp->u_arg[3], "SEEK_???");
647 return RVAL_LUDECIMAL;
651 #ifndef HAVE_LONG_LONG_OFF_T
657 printpath(tcp, tcp->u_arg[0]);
658 tprintf(", %lu", tcp->u_arg[1]);
664 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
671 printpath(tcp, tcp->u_arg[0]);
672 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
678 #ifndef HAVE_LONG_LONG_OFF_T
684 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
690 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
697 tprintf("%ld, %llu", tcp->u_arg[0],
698 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
706 static const struct xlat modetypes[] = {
707 { S_IFREG, "S_IFREG" },
708 { S_IFSOCK, "S_IFSOCK" },
709 { S_IFIFO, "S_IFIFO" },
710 { S_IFLNK, "S_IFLNK" },
711 { S_IFDIR, "S_IFDIR" },
712 { S_IFBLK, "S_IFBLK" },
713 { S_IFCHR, "S_IFCHR" },
724 if ((mode & S_IFMT) == 0)
726 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
727 sprintf(buf, "%#o", mode);
730 sprintf(buf, "%s%s%s%s", s,
731 (mode & S_ISUID) ? "|S_ISUID" : "",
732 (mode & S_ISGID) ? "|S_ISGID" : "",
733 (mode & S_ISVTX) ? "|S_ISVTX" : "");
734 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
736 sprintf(buf + strlen(buf), "|%#o", mode);
737 s = (*buf == '|') ? buf + 1 : buf;
751 if ((tmp = localtime(&t)))
752 snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d",
753 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
754 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
756 snprintf(buf, sizeof buf, "%lu", (unsigned long) t);
769 int st_pad1[3]; /* network id */
778 int st_pad3; /* st_size, off_t expansion */
779 timestruct_t st_atime;
780 timestruct_t st_mtime;
781 timestruct_t st_ctime;
785 int st_pad4[8]; /* expansion area */
789 printstatsol(struct tcb *tcp, long addr)
791 struct solstat statbuf;
797 if (syserror(tcp) || !verbose(tcp)) {
798 tprintf("%#lx", addr);
801 if (umove(tcp, addr, &statbuf) < 0) {
806 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
807 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
808 (unsigned long) (statbuf.st_dev & 0x3ffff),
809 (unsigned long) statbuf.st_ino,
810 sprintmode(statbuf.st_mode));
811 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
812 (unsigned long) statbuf.st_nlink,
813 (unsigned long) statbuf.st_uid,
814 (unsigned long) statbuf.st_gid);
815 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
816 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
819 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
820 switch (statbuf.st_mode & S_IFMT) {
821 case S_IFCHR: case S_IFBLK:
822 tprintf("st_rdev=makedev(%lu, %lu), ",
823 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
824 (unsigned long) (statbuf.st_rdev & 0x3ffff));
827 tprintf("st_size=%u, ", statbuf.st_size);
831 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
832 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
833 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
839 #if defined (SPARC64)
841 printstat_sparc64(tcp, addr)
845 struct stat_sparc64 statbuf;
851 if (syserror(tcp) || !verbose(tcp)) {
852 tprintf("%#lx", addr);
855 if (umove(tcp, addr, &statbuf) < 0) {
861 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
862 (unsigned long) major(statbuf.st_dev),
863 (unsigned long) minor(statbuf.st_dev),
864 (unsigned long) statbuf.st_ino,
865 sprintmode(statbuf.st_mode));
866 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
867 (unsigned long) statbuf.st_nlink,
868 (unsigned long) statbuf.st_uid,
869 (unsigned long) statbuf.st_gid);
870 tprintf("st_blksize=%lu, ",
871 (unsigned long) statbuf.st_blksize);
872 tprintf("st_blocks=%lu, ",
873 (unsigned long) statbuf.st_blocks);
876 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
877 switch (statbuf.st_mode & S_IFMT) {
878 case S_IFCHR: case S_IFBLK:
879 tprintf("st_rdev=makedev(%lu, %lu), ",
880 (unsigned long) major(statbuf.st_rdev),
881 (unsigned long) minor(statbuf.st_rdev));
884 tprintf("st_size=%lu, ", statbuf.st_size);
888 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
889 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
890 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
897 #endif /* LINUXSPARC */
899 static const struct xlat fileflags[] = {
901 { UF_NODUMP, "UF_NODUMP" },
902 { UF_IMMUTABLE, "UF_IMMUTABLE" },
903 { UF_APPEND, "UF_APPEND" },
904 { UF_OPAQUE, "UF_OPAQUE" },
905 { UF_NOUNLINK, "UF_NOUNLINK" },
906 { SF_ARCHIVED, "SF_ARCHIVED" },
907 { SF_IMMUTABLE, "SF_IMMUTABLE" },
908 { SF_APPEND, "SF_APPEND" },
909 { SF_NOUNLINK, "SF_NOUNLINK" },
912 { _S_ISMLD, "_S_ISMLD" },
915 { _S_ISMOUNTED, "_S_ISMOUNTED" },
927 printpath(tcp, tcp->u_arg[0]);
929 printflags(fileflags, tcp->u_arg[1], "UF_???");
939 tprintf("%ld, ", tcp->u_arg[0]);
940 printflags(fileflags, tcp->u_arg[1], "UF_???");
946 #ifndef HAVE_LONG_LONG_OFF_T
948 realprintstat(tcp, statbuf)
950 struct stat *statbuf;
953 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
954 (unsigned long) major(statbuf->st_dev),
955 (unsigned long) minor(statbuf->st_dev),
956 (unsigned long) statbuf->st_ino,
957 sprintmode(statbuf->st_mode));
958 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
959 (unsigned long) statbuf->st_nlink,
960 (unsigned long) statbuf->st_uid,
961 (unsigned long) statbuf->st_gid);
962 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
963 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
964 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
965 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
966 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
967 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
970 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
971 switch (statbuf->st_mode & S_IFMT) {
972 case S_IFCHR: case S_IFBLK:
973 #ifdef HAVE_STRUCT_STAT_ST_RDEV
974 tprintf("st_rdev=makedev(%lu, %lu), ",
975 (unsigned long) major(statbuf->st_rdev),
976 (unsigned long) minor(statbuf->st_rdev));
977 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
978 tprintf("st_size=makedev(%lu, %lu), ",
979 (unsigned long) major(statbuf->st_size),
980 (unsigned long) minor(statbuf->st_size));
981 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
984 tprintf("st_size=%lu, ", statbuf->st_size);
988 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
989 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
990 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
991 #if HAVE_STRUCT_STAT_ST_FLAGS
992 tprintf(", st_flags=");
993 printflags(fileflags, statbuf->st_flags, "UF_???");
995 #if HAVE_STRUCT_STAT_ST_ACLCNT
996 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
998 #if HAVE_STRUCT_STAT_ST_LEVEL
999 tprintf(", st_level=%ld", statbuf->st_level);
1001 #if HAVE_STRUCT_STAT_ST_FSTYPE
1002 tprintf(", st_fstype=%.*s",
1003 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
1005 #if HAVE_STRUCT_STAT_ST_GEN
1006 tprintf(", st_gen=%u", statbuf->st_gen);
1016 printstat(tcp, addr)
1020 struct stat statbuf;
1023 if (current_personality == 1) {
1024 printstatsol(tcp, addr);
1028 else if (current_personality == 2) {
1029 printstat_sparc64(tcp, addr);
1033 #endif /* LINUXSPARC */
1039 if (syserror(tcp) || !verbose(tcp)) {
1040 tprintf("%#lx", addr);
1043 if (umove(tcp, addr, &statbuf) < 0) {
1048 realprintstat(tcp, &statbuf);
1050 #endif /* !HAVE_LONG_LONG_OFF_T */
1052 #if !defined HAVE_STAT64 && defined LINUX && defined X86_64
1054 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
1055 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
1056 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
1057 * __GNUC__ is needed for the required __attribute__ below.
1060 unsigned long long st_dev;
1061 unsigned char __pad0[4];
1062 unsigned int __st_ino;
1063 unsigned int st_mode;
1064 unsigned int st_nlink;
1065 unsigned int st_uid;
1066 unsigned int st_gid;
1067 unsigned long long st_rdev;
1068 unsigned char __pad3[4];
1070 unsigned int st_blksize;
1071 unsigned long long st_blocks;
1072 unsigned int st_atime;
1073 unsigned int st_atime_nsec;
1074 unsigned int st_mtime;
1075 unsigned int st_mtime_nsec;
1076 unsigned int st_ctime;
1077 unsigned int st_ctime_nsec;
1078 unsigned long long st_ino;
1079 } __attribute__((packed));
1080 # define HAVE_STAT64 1
1081 # define STAT64_SIZE 96
1086 printstat64(tcp, addr)
1090 struct stat64 statbuf;
1093 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
1097 if (current_personality == 1) {
1098 printstatsol(tcp, addr);
1102 else if (current_personality == 2) {
1103 printstat_sparc64(tcp, addr);
1107 #endif /* LINUXSPARC */
1113 if (syserror(tcp) || !verbose(tcp)) {
1114 tprintf("%#lx", addr);
1117 if (umove(tcp, addr, &statbuf) < 0) {
1123 #ifdef HAVE_LONG_LONG
1124 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1126 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
1128 (unsigned long) major(statbuf.st_dev),
1129 (unsigned long) minor(statbuf.st_dev),
1130 #ifdef HAVE_LONG_LONG
1131 (unsigned long long) statbuf.st_ino,
1133 (unsigned long) statbuf.st_ino,
1135 sprintmode(statbuf.st_mode));
1136 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1137 (unsigned long) statbuf.st_nlink,
1138 (unsigned long) statbuf.st_uid,
1139 (unsigned long) statbuf.st_gid);
1140 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
1141 tprintf("st_blksize=%lu, ",
1142 (unsigned long) statbuf.st_blksize);
1143 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
1144 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
1145 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
1146 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
1149 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1150 switch (statbuf.st_mode & S_IFMT) {
1151 case S_IFCHR: case S_IFBLK:
1152 #ifdef HAVE_STRUCT_STAT_ST_RDEV
1153 tprintf("st_rdev=makedev(%lu, %lu), ",
1154 (unsigned long) major(statbuf.st_rdev),
1155 (unsigned long) minor(statbuf.st_rdev));
1156 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
1157 tprintf("st_size=makedev(%lu, %lu), ",
1158 (unsigned long) major(statbuf.st_size),
1159 (unsigned long) minor(statbuf.st_size));
1160 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
1163 #ifdef HAVE_LONG_LONG
1164 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1166 tprintf("st_size=%lu, ", (unsigned long) statbuf.st_size);
1171 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1172 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
1173 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
1174 #if HAVE_STRUCT_STAT_ST_FLAGS
1175 tprintf(", st_flags=");
1176 printflags(fileflags, statbuf.st_flags, "UF_???");
1178 #if HAVE_STRUCT_STAT_ST_ACLCNT
1179 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1181 #if HAVE_STRUCT_STAT_ST_LEVEL
1182 tprintf(", st_level=%ld", statbuf.st_level);
1184 #if HAVE_STRUCT_STAT_ST_FSTYPE
1185 tprintf(", st_fstype=%.*s",
1186 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1188 #if HAVE_STRUCT_STAT_ST_GEN
1189 tprintf(", st_gen=%u", statbuf.st_gen);
1196 #endif /* HAVE_STAT64 */
1198 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1200 convertoldstat(oldbuf, newbuf)
1201 const struct __old_kernel_stat *oldbuf;
1202 struct stat *newbuf;
1204 newbuf->st_dev=oldbuf->st_dev;
1205 newbuf->st_ino=oldbuf->st_ino;
1206 newbuf->st_mode=oldbuf->st_mode;
1207 newbuf->st_nlink=oldbuf->st_nlink;
1208 newbuf->st_uid=oldbuf->st_uid;
1209 newbuf->st_gid=oldbuf->st_gid;
1210 newbuf->st_rdev=oldbuf->st_rdev;
1211 newbuf->st_size=oldbuf->st_size;
1212 newbuf->st_atime=oldbuf->st_atime;
1213 newbuf->st_mtime=oldbuf->st_mtime;
1214 newbuf->st_ctime=oldbuf->st_ctime;
1215 newbuf->st_blksize=0; /* not supported in old_stat */
1216 newbuf->st_blocks=0; /* not supported in old_stat */
1221 printoldstat(tcp, addr)
1225 struct __old_kernel_stat statbuf;
1226 struct stat newstatbuf;
1229 if (current_personality == 1) {
1230 printstatsol(tcp, addr);
1233 #endif /* LINUXSPARC */
1239 if (syserror(tcp) || !verbose(tcp)) {
1240 tprintf("%#lx", addr);
1243 if (umove(tcp, addr, &statbuf) < 0) {
1248 convertoldstat(&statbuf, &newstatbuf);
1249 realprintstat(tcp, &newstatbuf);
1251 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1253 #ifndef HAVE_LONG_LONG_OFF_T
1258 if (entering(tcp)) {
1259 printpath(tcp, tcp->u_arg[0]);
1262 printstat(tcp, tcp->u_arg[1]);
1273 if (entering(tcp)) {
1274 printpath(tcp, tcp->u_arg[0]);
1277 printstat64(tcp, tcp->u_arg[1]);
1281 return printargs(tcp);
1286 static const struct xlat fstatatflags[] = {
1287 #ifndef AT_SYMLINK_NOFOLLOW
1288 # define AT_SYMLINK_NOFOLLOW 0x100
1290 { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" },
1293 #define utimensatflags fstatatflags
1296 sys_newfstatat(struct tcb *tcp)
1298 if (entering(tcp)) {
1299 print_dirfd(tcp->u_arg[0]);
1300 printpath(tcp, tcp->u_arg[1]);
1303 #if defined HAVE_STAT64 && !(defined POWERPC && defined __powerpc64__)
1304 printstat64(tcp, tcp->u_arg[2]);
1306 printstat(tcp, tcp->u_arg[2]);
1309 printflags(fstatatflags, tcp->u_arg[3], "AT_???");
1315 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1320 if (entering(tcp)) {
1321 printpath(tcp, tcp->u_arg[0]);
1324 printoldstat(tcp, tcp->u_arg[1]);
1328 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1330 #ifndef HAVE_LONG_LONG_OFF_T
1336 tprintf("%ld, ", tcp->u_arg[0]);
1338 printstat(tcp, tcp->u_arg[1]);
1350 tprintf("%ld, ", tcp->u_arg[0]);
1352 printstat64(tcp, tcp->u_arg[1]);
1356 return printargs(tcp);
1360 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1366 tprintf("%ld, ", tcp->u_arg[0]);
1368 printoldstat(tcp, tcp->u_arg[1]);
1372 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1374 #ifndef HAVE_LONG_LONG_OFF_T
1379 if (entering(tcp)) {
1380 printpath(tcp, tcp->u_arg[0]);
1383 printstat(tcp, tcp->u_arg[1]);
1394 if (entering(tcp)) {
1395 printpath(tcp, tcp->u_arg[0]);
1398 printstat64(tcp, tcp->u_arg[1]);
1402 return printargs(tcp);
1406 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1411 if (entering(tcp)) {
1412 printpath(tcp, tcp->u_arg[0]);
1415 printoldstat(tcp, tcp->u_arg[1]);
1419 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1422 #if defined(SVR4) || defined(LINUXSPARC)
1428 if (entering(tcp)) {
1429 tprintf("%ld, ", tcp->u_arg[0]);
1430 printpath(tcp, tcp->u_arg[1]);
1434 if (tcp->u_arg[0] == _STAT64_VER)
1435 printstat64 (tcp, tcp->u_arg[2]);
1438 printstat(tcp, tcp->u_arg[2]);
1448 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1451 if (tcp->u_arg[0] == _STAT64_VER)
1452 printstat64 (tcp, tcp->u_arg[2]);
1455 printstat(tcp, tcp->u_arg[2]);
1464 if (entering(tcp)) {
1465 tprintf("%ld, ", tcp->u_arg[0]);
1466 printpath(tcp, tcp->u_arg[1]);
1470 if (tcp->u_arg[0] == _STAT64_VER)
1471 printstat64 (tcp, tcp->u_arg[2]);
1474 printstat(tcp, tcp->u_arg[2]);
1483 int mode = tcp->u_arg[2];
1485 if (entering(tcp)) {
1486 tprintf("%ld, ", tcp->u_arg[0]);
1487 printpath(tcp, tcp->u_arg[1]);
1488 tprintf(", %s", sprintmode(mode));
1489 switch (mode & S_IFMT) {
1490 case S_IFCHR: case S_IFBLK:
1492 tprintf(", makedev(%lu, %lu)",
1493 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1494 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1496 tprintf(", makedev(%lu, %lu)",
1497 (unsigned long) major(tcp->u_arg[3]),
1498 (unsigned long) minor(tcp->u_arg[3]));
1508 #ifdef HAVE_SYS_ACL_H
1510 #include <sys/acl.h>
1512 static const struct xlat aclcmds[] = {
1514 { SETACL, "SETACL" },
1517 { GETACL, "GETACL" },
1520 { GETACLCNT, "GETACLCNT" },
1523 { ACL_GET, "ACL_GET" },
1526 { ACL_SET, "ACL_SET" },
1529 { ACL_CNT, "ACL_CNT" },
1538 if (entering(tcp)) {
1539 printpath(tcp, tcp->u_arg[0]);
1541 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1542 tprintf(", %ld", tcp->u_arg[2]);
1544 * FIXME - dump out the list of aclent_t's pointed to
1545 * by "tcp->u_arg[3]" if it's not NULL.
1548 tprintf(", %#lx", tcp->u_arg[3]);
1560 if (entering(tcp)) {
1561 tprintf("%ld, ", tcp->u_arg[0]);
1562 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1563 tprintf(", %ld", tcp->u_arg[2]);
1565 * FIXME - dump out the list of aclent_t's pointed to
1566 * by "tcp->u_arg[3]" if it's not NULL.
1569 tprintf(", %#lx", tcp->u_arg[3]);
1577 static const struct xlat aclipc[] = {
1579 { IPC_SHM, "IPC_SHM" },
1582 { IPC_SEM, "IPC_SEM" },
1585 { IPC_MSG, "IPC_MSG" },
1595 if (entering(tcp)) {
1596 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1597 tprintf(", %#lx, ", tcp->u_arg[1]);
1598 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1599 tprintf(", %ld", tcp->u_arg[3]);
1601 * FIXME - dump out the list of aclent_t's pointed to
1602 * by "tcp->u_arg[4]" if it's not NULL.
1605 tprintf(", %#lx", tcp->u_arg[4]);
1614 #endif /* HAVE_SYS_ACL_H */
1616 #endif /* SVR4 || LINUXSPARC */
1620 static const struct xlat fsmagic[] = {
1621 { 0x73757245, "CODA_SUPER_MAGIC" },
1622 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1623 { 0x1373, "DEVFS_SUPER_MAGIC" },
1624 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1625 { 0x414A53, "EFS_SUPER_MAGIC" },
1626 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1627 { 0xef53, "EXT2_SUPER_MAGIC" },
1628 { 0x137d, "EXT_SUPER_MAGIC" },
1629 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1630 { 0x9660, "ISOFS_SUPER_MAGIC" },
1631 { 0x137f, "MINIX_SUPER_MAGIC" },
1632 { 0x138f, "MINIX_SUPER_MAGIC2" },
1633 { 0x2468, "MINIX2_SUPER_MAGIC" },
1634 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1635 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1636 { 0x564c, "NCP_SUPER_MAGIC" },
1637 { 0x6969, "NFS_SUPER_MAGIC" },
1638 { 0x9fa0, "PROC_SUPER_MAGIC" },
1639 { 0x002f, "QNX4_SUPER_MAGIC" },
1640 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1641 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1642 { 0x517b, "SMB_SUPER_MAGIC" },
1643 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1644 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1645 { 0x00011954, "UFS_MAGIC" },
1646 { 0x54190100, "UFS_CIGAM" },
1647 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1648 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1649 { 0x62656572, "SYSFS_MAGIC" },
1661 static char buf[32];
1665 s = xlookup(fsmagic, magic);
1667 sprintf(buf, "\"%s\"", s);
1671 sprintf(buf, "%#x", magic);
1676 printstatfs(tcp, addr)
1680 struct statfs statbuf;
1682 if (syserror(tcp) || !verbose(tcp)) {
1683 tprintf("%#lx", addr);
1686 if (umove(tcp, addr, &statbuf) < 0) {
1692 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1693 sprintfstype(statbuf.f_type),
1694 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1695 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1696 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1697 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1700 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1701 sprintfstype(statbuf.f_type),
1702 (unsigned long)statbuf.f_bsize,
1703 (unsigned long)statbuf.f_blocks,
1704 (unsigned long)statbuf.f_bfree);
1705 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1706 (unsigned long)statbuf.f_bavail,
1707 (unsigned long)statbuf.f_files,
1708 (unsigned long)statbuf.f_ffree,
1709 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1711 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1714 #ifdef _STATFS_F_FRSIZE
1715 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1724 if (entering(tcp)) {
1725 printpath(tcp, tcp->u_arg[0]);
1728 printstatfs(tcp, tcp->u_arg[1]);
1737 if (entering(tcp)) {
1738 tprintf("%lu, ", tcp->u_arg[0]);
1740 printstatfs(tcp, tcp->u_arg[1]);
1747 printstatfs64(tcp, addr)
1751 struct statfs64 statbuf;
1753 if (syserror(tcp) || !verbose(tcp)) {
1754 tprintf("%#lx", addr);
1757 if (umove(tcp, addr, &statbuf) < 0) {
1761 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
1762 sprintfstype(statbuf.f_type),
1763 (unsigned long long)statbuf.f_bsize,
1764 (unsigned long long)statbuf.f_blocks,
1765 (unsigned long long)statbuf.f_bfree);
1766 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1767 (unsigned long long)statbuf.f_bavail,
1768 (unsigned long long)statbuf.f_files,
1769 (unsigned long long)statbuf.f_ffree,
1770 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1771 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1772 #ifdef _STATFS_F_FRSIZE
1773 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
1782 if (entering(tcp)) {
1783 printpath(tcp, tcp->u_arg[0]);
1784 tprintf(", %lu, ", tcp->u_arg[1]);
1786 if (tcp->u_arg[1] == sizeof (struct statfs64))
1787 printstatfs64(tcp, tcp->u_arg[2]);
1798 if (entering(tcp)) {
1799 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1801 if (tcp->u_arg[1] == sizeof (struct statfs64))
1802 printstatfs64(tcp, tcp->u_arg[2]);
1810 #if defined(LINUX) && defined(__alpha)
1816 if (entering(tcp)) {
1817 printpath(tcp, tcp->u_arg[0]);
1820 printstatfs(tcp, tcp->u_arg[1]);
1821 tprintf(", %lu", tcp->u_arg[2]);
1830 if (entering(tcp)) {
1831 tprintf("%lu, ", tcp->u_arg[0]);
1833 printstatfs(tcp, tcp->u_arg[1]);
1834 tprintf(", %lu", tcp->u_arg[2]);
1838 #endif /* LINUX && __alpha */
1848 struct ustat statbuf;
1850 if (entering(tcp)) {
1851 tprintf("makedev(%lu, %lu), ",
1852 (long) major(tcp->u_arg[0]),
1853 (long) minor(tcp->u_arg[0]));
1856 if (syserror(tcp) || !verbose(tcp))
1857 tprintf("%#lx", tcp->u_arg[1]);
1858 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1861 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1862 statbuf.f_tfree, statbuf.f_tinode);
1863 tprintf("f_fname=\"%.*s\", ",
1864 (int) sizeof(statbuf.f_fname),
1866 tprintf("f_fpack=\"%.*s\"}",
1867 (int) sizeof(statbuf.f_fpack),
1880 if (entering(tcp)) {
1881 printpath(tcp, tcp->u_arg[0]);
1883 printpath(tcp, tcp->u_arg[1]);
1894 if (entering(tcp)) {
1895 printpath(tcp, tcp->u_arg[0]);
1901 decode_mkdir(struct tcb *tcp, int offset)
1903 if (entering(tcp)) {
1904 printpath(tcp, tcp->u_arg[offset]);
1905 tprintf(", %#lo", tcp->u_arg[offset + 1]);
1911 sys_mkdir(struct tcb *tcp)
1913 return decode_mkdir(tcp, 0);
1918 sys_mkdirat(struct tcb *tcp)
1921 print_dirfd(tcp->u_arg[0]);
1922 return decode_mkdir(tcp, 1);
1930 if (entering(tcp)) {
1931 printpath(tcp, tcp->u_arg[0]);
1940 if (entering(tcp)) {
1941 tprintf("%ld", tcp->u_arg[0]);
1950 if (entering(tcp)) {
1951 printpath(tcp, tcp->u_arg[0]);
1956 #if defined(SUNOS4) || defined(SVR4)
1961 if (entering(tcp)) {
1962 tprintf("%ld", tcp->u_arg[0]);
1966 #endif /* SUNOS4 || SVR4 */
1972 if (entering(tcp)) {
1973 printpath(tcp, tcp->u_arg[0]);
1975 printpath(tcp, tcp->u_arg[1]);
1982 sys_linkat(struct tcb *tcp)
1984 if (entering(tcp)) {
1985 print_dirfd(tcp->u_arg[0]);
1986 printpath(tcp, tcp->u_arg[1]);
1988 print_dirfd(tcp->u_arg[2]);
1989 printpath(tcp, tcp->u_arg[3]);
1990 tprintf(", %ld", tcp->u_arg[4]);
2000 if (entering(tcp)) {
2001 printpath(tcp, tcp->u_arg[0]);
2007 static const struct xlat unlinkatflags[] = {
2008 #ifndef AT_REMOVEDIR
2009 # define AT_REMOVEDIR 0x200
2011 { AT_REMOVEDIR, "AT_REMOVEDIR" },
2016 sys_unlinkat(struct tcb *tcp)
2018 if (entering(tcp)) {
2019 print_dirfd(tcp->u_arg[0]);
2020 printpath(tcp, tcp->u_arg[1]);
2022 printflags(unlinkatflags, tcp->u_arg[2], "AT_???");
2032 if (entering(tcp)) {
2033 printpath(tcp, tcp->u_arg[0]);
2035 printpath(tcp, tcp->u_arg[1]);
2042 sys_symlinkat(struct tcb *tcp)
2044 if (entering(tcp)) {
2045 printpath(tcp, tcp->u_arg[0]);
2047 print_dirfd(tcp->u_arg[1]);
2048 printpath(tcp, tcp->u_arg[2]);
2055 decode_readlink(struct tcb *tcp, int offset)
2057 if (entering(tcp)) {
2058 printpath(tcp, tcp->u_arg[offset]);
2062 tprintf("%#lx", tcp->u_arg[offset + 1]);
2064 printpathn(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
2065 tprintf(", %lu", tcp->u_arg[offset + 2]);
2071 sys_readlink(struct tcb *tcp)
2073 return decode_readlink(tcp, 0);
2078 sys_readlinkat(struct tcb *tcp)
2081 print_dirfd(tcp->u_arg[0]);
2082 return decode_readlink(tcp, 1);
2090 if (entering(tcp)) {
2091 printpath(tcp, tcp->u_arg[0]);
2093 printpath(tcp, tcp->u_arg[1]);
2100 sys_renameat(struct tcb *tcp)
2102 if (entering(tcp)) {
2103 print_dirfd(tcp->u_arg[0]);
2104 printpath(tcp, tcp->u_arg[1]);
2106 print_dirfd(tcp->u_arg[2]);
2107 printpath(tcp, tcp->u_arg[3]);
2117 if (entering(tcp)) {
2118 printpath(tcp, tcp->u_arg[0]);
2119 printuid(", ", tcp->u_arg[1]);
2120 printuid(", ", tcp->u_arg[2]);
2127 sys_fchownat(struct tcb *tcp)
2129 if (entering(tcp)) {
2130 print_dirfd(tcp->u_arg[0]);
2131 printpath(tcp, tcp->u_arg[1]);
2132 printuid(", ", tcp->u_arg[2]);
2133 printuid(", ", tcp->u_arg[3]);
2135 printflags(fstatatflags, tcp->u_arg[4], "AT_???");
2145 if (entering(tcp)) {
2146 tprintf("%ld", tcp->u_arg[0]);
2147 printuid(", ", tcp->u_arg[1]);
2148 printuid(", ", tcp->u_arg[2]);
2154 decode_chmod(struct tcb *tcp, int offset)
2156 if (entering(tcp)) {
2157 printpath(tcp, tcp->u_arg[offset]);
2158 tprintf(", %#lo", tcp->u_arg[offset + 1]);
2164 sys_chmod(struct tcb *tcp)
2166 return decode_chmod(tcp, 0);
2171 sys_fchmodat(struct tcb *tcp)
2174 print_dirfd(tcp->u_arg[0]);
2175 return decode_chmod(tcp, 1);
2183 if (entering(tcp)) {
2184 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
2194 if (entering(tcp)) {
2195 printpath(tcp, tcp->u_arg[0]);
2197 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
2204 decode_utimes(struct tcb *tcp, int offset, int special)
2206 if (entering(tcp)) {
2207 printpath(tcp, tcp->u_arg[offset]);
2209 if (tcp->u_arg[offset + 1] == 0)
2213 printtv_bitness(tcp, tcp->u_arg[offset + 1],
2214 BITNESS_CURRENT, special);
2216 printtv_bitness(tcp, tcp->u_arg[offset + 1]
2217 + sizeof (struct timeval),
2218 BITNESS_CURRENT, special);
2226 sys_utimes(struct tcb *tcp)
2228 return decode_utimes(tcp, 0, 0);
2233 sys_futimesat(struct tcb *tcp)
2236 print_dirfd(tcp->u_arg[0]);
2237 return decode_utimes(tcp, 1, 0);
2241 sys_utimensat(struct tcb *tcp)
2243 if (entering(tcp)) {
2244 print_dirfd(tcp->u_arg[0]);
2245 decode_utimes(tcp, 1, 1);
2247 printflags(utimensatflags, tcp->u_arg[3], "AT_???");
2262 if (entering(tcp)) {
2263 printpath(tcp, tcp->u_arg[0]);
2267 else if (!verbose(tcp))
2268 tprintf("%#lx", tcp->u_arg[1]);
2269 else if (umoven(tcp, tcp->u_arg[1],
2270 2 * personality_wordsize[current_personality],
2273 else if (personality_wordsize[current_personality]
2274 == sizeof u.utl[0]) {
2275 tprintf("[%s,", sprinttime(u.utl[0]));
2276 tprintf(" %s]", sprinttime(u.utl[1]));
2278 else if (personality_wordsize[current_personality]
2279 == sizeof u.uti[0]) {
2280 tprintf("[%s,", sprinttime(u.uti[0]));
2281 tprintf(" %s]", sprinttime(u.uti[1]));
2290 decode_mknod(struct tcb *tcp, int offset)
2292 int mode = tcp->u_arg[offset + 1];
2294 if (entering(tcp)) {
2295 printpath(tcp, tcp->u_arg[offset]);
2296 tprintf(", %s", sprintmode(mode));
2297 switch (mode & S_IFMT) {
2298 case S_IFCHR: case S_IFBLK:
2300 if (current_personality == 1)
2301 tprintf(", makedev(%lu, %lu)",
2302 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
2303 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
2306 tprintf(", makedev(%lu, %lu)",
2307 (unsigned long) major(tcp->u_arg[offset + 2]),
2308 (unsigned long) minor(tcp->u_arg[offset + 2]));
2318 sys_mknod(struct tcb *tcp)
2320 return decode_mknod(tcp, 0);
2325 sys_mknodat(struct tcb *tcp)
2328 print_dirfd(tcp->u_arg[0]);
2329 return decode_mknod(tcp, 1);
2338 if (entering(tcp)) {
2339 printpath(tcp, tcp->u_arg[0]);
2340 tprintf(", %#lo", tcp->u_arg[1]);
2344 #endif /* FREEBSD */
2350 if (entering(tcp)) {
2351 tprintf("%ld", tcp->u_arg[0]);
2365 if (!verbose(tcp)) {
2366 tprintf("%#lx", addr);
2369 if (umove(tcp, addr, &d) < 0) {
2373 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
2375 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
2383 if (entering(tcp)) {
2384 tprintf("%lu, ", tcp->u_arg[0]);
2386 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
2387 tprintf("%#lx", tcp->u_arg[1]);
2389 printdir(tcp, tcp->u_arg[1]);
2390 /* Not much point in printing this out, it is always 1. */
2391 if (tcp->u_arg[2] != 1)
2392 tprintf(", %lu", tcp->u_arg[2]);
2399 #if defined FREEBSD || defined LINUX
2400 static const struct xlat direnttypes[] = {
2401 { DT_UNKNOWN, "DT_UNKNOWN" },
2402 { DT_FIFO, "DT_FIFO" },
2403 { DT_CHR, "DT_CHR" },
2404 { DT_DIR, "DT_DIR" },
2405 { DT_BLK, "DT_BLK" },
2406 { DT_REG, "DT_REG" },
2407 { DT_LNK, "DT_LNK" },
2408 { DT_SOCK, "DT_SOCK" },
2409 { DT_WHT, "DT_WHT" },
2416 sys_getdents(struct tcb *tcp)
2418 int i, len, dents = 0;
2421 if (entering(tcp)) {
2422 tprintf("%lu, ", tcp->u_arg[0]);
2425 if (syserror(tcp) || !verbose(tcp)) {
2426 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2430 if ((buf = malloc(len)) == NULL) {
2431 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2432 fprintf(stderr, "out of memory\n");
2435 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2436 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2442 for (i = 0; i < len;) {
2443 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2446 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2447 i ? " " : "", d->d_ino, d->d_off);
2448 tprintf("d_reclen=%u, d_name=\"%s\"}",
2449 d->d_reclen, d->d_name);
2454 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2456 (unsigned long) d->d_ino,
2457 (unsigned long) d->d_off);
2458 tprintf("d_reclen=%u, d_name=\"%s\"}",
2459 d->d_reclen, d->d_name);
2464 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2465 i ? " " : "", d->d_off, d->d_fileno,
2467 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2468 d->d_namlen, d->d_namlen, d->d_name);
2473 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2474 i ? " " : "", d->d_fileno, d->d_reclen);
2475 printxval(direnttypes, d->d_type, "DT_???");
2476 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2477 d->d_namlen, d->d_namlen, d->d_name);
2479 #endif /* FREEBSD */
2481 tprintf("/* d_reclen == 0, problem here */");
2490 tprintf("/* %u entries */", dents);
2491 tprintf(", %lu", tcp->u_arg[2]);
2497 #if _LFS64_LARGEFILE
2499 sys_getdents64(struct tcb *tcp)
2501 int i, len, dents = 0;
2504 if (entering(tcp)) {
2505 tprintf("%lu, ", tcp->u_arg[0]);
2508 if (syserror(tcp) || !verbose(tcp)) {
2509 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2513 if ((buf = malloc(len)) == NULL) {
2514 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2515 fprintf(stderr, "out of memory\n");
2518 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2519 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2525 for (i = 0; i < len;) {
2526 struct dirent64 *d = (struct dirent64 *) &buf[i];
2527 #if defined(LINUX) || defined(SVR4)
2529 tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ",
2535 printxval(direnttypes, d->d_type, "DT_???");
2538 tprintf("d_reclen=%u, d_name=\"%s\"}",
2539 d->d_reclen, d->d_name);
2541 #endif /* LINUX || SVR4 */
2544 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2545 i ? " " : "", d->d_off, d->d_fileno,
2547 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2548 d->d_namlen, d->d_namlen, d->d_name);
2552 tprintf("/* d_reclen == 0, problem here */");
2561 tprintf("/* %u entries */", dents);
2562 tprintf(", %lu", tcp->u_arg[2]);
2570 sys_getdirentries(struct tcb *tcp)
2572 int i, len, dents = 0;
2576 if (entering(tcp)) {
2577 tprintf("%lu, ", tcp->u_arg[0]);
2580 if (syserror(tcp) || !verbose(tcp)) {
2581 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2585 if ((buf = malloc(len)) == NULL) {
2586 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2587 fprintf(stderr, "out of memory\n");
2590 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2591 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2597 for (i = 0; i < len;) {
2598 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2600 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2601 i ? " " : "", d->d_fileno, d->d_reclen);
2602 printxval(direnttypes, d->d_type, "DT_???");
2603 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2604 d->d_namlen, d->d_namlen, d->d_name);
2607 tprintf("/* d_reclen == 0, problem here */");
2616 tprintf("/* %u entries */", dents);
2618 tprintf(", %lu", tcp->u_arg[2]);
2619 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2620 tprintf(", %#lx", tcp->u_arg[3]);
2622 tprintf(", [%lu]", basep);
2634 tprintf("%#lx", tcp->u_arg[0]);
2636 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2637 tprintf(", %lu", tcp->u_arg[1]);
2650 tprintf("%#lx", tcp->u_arg[0]);
2652 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2653 tprintf(", %lu", tcp->u_arg[1]);
2659 #ifdef HAVE_SYS_ASYNCH_H
2665 struct aio_result_t res;
2667 if (entering(tcp)) {
2668 tprintf("%lu, ", tcp->u_arg[0]);
2671 tprintf("%#lx", tcp->u_arg[1]);
2673 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2674 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2675 printxval(whence, tcp->u_arg[4], "L_???");
2676 if (syserror(tcp) || tcp->u_arg[5] == 0
2677 || umove(tcp, tcp->u_arg[5], &res) < 0)
2678 tprintf(", %#lx", tcp->u_arg[5]);
2680 tprintf(", {aio_return %d aio_errno %d}",
2681 res.aio_return, res.aio_errno);
2690 struct aio_result_t res;
2692 if (entering(tcp)) {
2693 tprintf("%lu, ", tcp->u_arg[0]);
2694 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2695 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2696 printxval(whence, tcp->u_arg[4], "L_???");
2699 if (tcp->u_arg[5] == 0)
2701 else if (syserror(tcp)
2702 || umove(tcp, tcp->u_arg[5], &res) < 0)
2703 tprintf(", %#lx", tcp->u_arg[5]);
2705 tprintf(", {aio_return %d aio_errno %d}",
2706 res.aio_return, res.aio_errno);
2716 printtv(tcp, tcp->u_arg[0]);
2724 struct aio_result_t res;
2727 if (tcp->u_arg[0] == 0)
2729 else if (syserror(tcp)
2730 || umove(tcp, tcp->u_arg[0], &res) < 0)
2731 tprintf("%#lx", tcp->u_arg[0]);
2733 tprintf("{aio_return %d aio_errno %d}",
2734 res.aio_return, res.aio_errno);
2739 #endif /* HAVE_SYS_ASYNCH_H */
2741 static const struct xlat xattrflags[] = {
2743 { XATTR_CREATE, "XATTR_CREATE" },
2744 { XATTR_REPLACE, "XATTR_REPLACE" },
2750 print_xattr_val(tcp, failed, arg, insize, size)
2754 unsigned long insize, size;
2757 unsigned long capacity = 4 * size + 1;
2758 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
2759 if (buf == NULL || /* probably a bogus size argument */
2760 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2764 unsigned char *out = buf;
2765 unsigned char *in = &buf[3 * size];
2767 for (i = 0; i < size; ++i)
2771 #define tohex(n) "0123456789abcdef"[n]
2774 *out++ = tohex(in[i] / 16);
2775 *out++ = tohex(in[i] % 16);
2777 /* Don't print terminating NUL if there is one. */
2778 if (i > 0 && in[i - 1] == '\0')
2781 tprintf(", \"%s\", %ld", buf, insize);
2786 tprintf(", 0x%lx, %ld", arg, insize);
2793 if (entering(tcp)) {
2794 printpath(tcp, tcp->u_arg[0]);
2796 printstr(tcp, tcp->u_arg[1], -1);
2797 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2799 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2808 if (entering(tcp)) {
2809 tprintf("%ld, ", tcp->u_arg[0]);
2810 printstr(tcp, tcp->u_arg[1], -1);
2811 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2813 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2822 if (entering(tcp)) {
2823 printpath(tcp, tcp->u_arg[0]);
2825 printstr(tcp, tcp->u_arg[1], -1);
2827 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2837 if (entering(tcp)) {
2838 tprintf("%ld, ", tcp->u_arg[0]);
2839 printstr(tcp, tcp->u_arg[1], -1);
2841 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2851 if (entering(tcp)) {
2852 printpath(tcp, tcp->u_arg[0]);
2854 /* XXX Print value in format */
2855 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2864 if (entering(tcp)) {
2865 tprintf("%ld", tcp->u_arg[0]);
2867 /* XXX Print value in format */
2868 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2874 sys_removexattr(tcp)
2877 if (entering(tcp)) {
2878 printpath(tcp, tcp->u_arg[0]);
2880 printstr(tcp, tcp->u_arg[1], -1);
2886 sys_fremovexattr(tcp)
2889 if (entering(tcp)) {
2890 tprintf("%ld, ", tcp->u_arg[0]);
2891 printstr(tcp, tcp->u_arg[1], -1);
2897 static const struct xlat advise[] = {
2898 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2899 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2900 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2901 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2902 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2903 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2913 if (entering(tcp)) {
2914 tprintf("%ld, %lld, %ld, ",
2916 # if defined IA64 || defined X86_64 || defined ALPHA
2917 (long long int) tcp->u_arg[1], tcp->u_arg[2]);
2918 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2920 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]);
2921 printxval(advise, tcp->u_arg[4], "POSIX_FADV_???");
2930 sys_fadvise64_64(tcp)
2933 if (entering(tcp)) {
2934 tprintf("%ld, %lld, %lld, ",
2936 #if defined LINUX_MIPSN32
2937 tcp->ext_arg[1], tcp->ext_arg[2]);
2938 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2939 #elif defined IA64 || defined X86_64 || defined ALPHA || defined LINUX_MIPSN64
2940 (long long int) tcp->u_arg[1], (long long int) tcp->u_arg[2]);
2941 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2943 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]),
2944 LONG_LONG(tcp->u_arg[3], tcp->u_arg[4]));
2945 printxval(advise, tcp->u_arg[5], "POSIX_FADV_???");
2952 static const struct xlat inotify_modes[] = {
2953 { 0x00000001, "IN_ACCESS" },
2954 { 0x00000002, "IN_MODIFY" },
2955 { 0x00000004, "IN_ATTRIB" },
2956 { 0x00000008, "IN_CLOSE_WRITE" },
2957 { 0x00000010, "IN_CLOSE_NOWRITE" },
2958 { 0x00000020, "IN_OPEN" },
2959 { 0x00000040, "IN_MOVED_FROM" },
2960 { 0x00000080, "IN_MOVED_TO" },
2961 { 0x00000100, "IN_CREATE" },
2962 { 0x00000200, "IN_DELETE" },
2963 { 0x00000400, "IN_DELETE_SELF" },
2964 { 0x00000800, "IN_MOVE_SELF" },
2965 { 0x00002000, "IN_UNMOUNT" },
2966 { 0x00004000, "IN_Q_OVERFLOW" },
2967 { 0x00008000, "IN_IGNORED" },
2968 { 0x01000000, "IN_ONLYDIR" },
2969 { 0x02000000, "IN_DONT_FOLLOW" },
2970 { 0x20000000, "IN_MASK_ADD" },
2971 { 0x40000000, "IN_ISDIR" },
2972 { 0x80000000, "IN_ONESHOT" }
2976 sys_inotify_add_watch(struct tcb *tcp)
2978 if (entering(tcp)) {
2979 tprintf("%ld, ", tcp->u_arg[0]);
2980 printpath(tcp, tcp->u_arg[1]);
2982 printflags(inotify_modes, tcp->u_arg[2], "IN_???");
2988 sys_inotify_rm_watch(struct tcb *tcp)
2990 if (entering(tcp)) {
2991 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
2997 sys_fallocate(struct tcb *tcp)
2999 if (entering(tcp)) {
3000 tprintf("%ld, ", tcp->u_arg[0]); /* fd */
3001 tprintf("%#lo, ", tcp->u_arg[1]); /* mode */
3002 tprintf("%llu, ", LONG_LONG(tcp->u_arg[2],
3003 tcp->u_arg[3])); /* offset */
3004 tprintf("%llu", LONG_LONG(tcp->u_arg[4],
3005 tcp->u_arg[5])); /* len */