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.
38 #define dirent kernel_dirent
39 #define dirent64 kernel_dirent64
40 #include <linux/types.h>
41 #include <linux/dirent.h>
45 #define kernel_dirent dirent
51 unsigned short st_dev;
53 unsigned short st_mode;
55 unsigned short st_uid;
56 unsigned short st_gid;
57 unsigned short st_rdev;
60 unsigned int __unused1;
62 unsigned int __unused2;
64 unsigned int __unused3;
67 unsigned int __unused4[2];
74 unsigned int st_nlink;
84 unsigned long __unused4[2];
87 # define stat kernel_stat
88 # include <asm/stat.h>
100 # define dev_t __kernel_dev_t
101 # define ino_t __kernel_ino_t
102 # define mode_t __kernel_mode_t
103 # define nlink_t __kernel_nlink_t
104 # define uid_t __kernel_uid_t
105 # define gid_t __kernel_gid_t
106 # define off_t __kernel_off_t
107 # define loff_t __kernel_loff_t
109 # include <asm/stat.h>
122 # define mode_t mode_t
123 # define nlink_t nlink_t
127 # define loff_t loff_t
129 # ifdef HPPA /* asm-parisc/stat.h defines stat64 */
132 # define stat libc_stat
133 # define stat64 libc_stat64
134 # include <sys/stat.h>
137 /* These might be macros. */
142 # define stat64 hpux_stat64
145 # include <sys/stat.h>
151 # include <sys/cred.h>
154 #ifdef HAVE_SYS_VFS_H
158 #ifdef HAVE_LINUX_XATTR_H
159 #include <linux/xattr.h>
161 #define XATTR_CREATE 1
162 #define XATTR_REPLACE 2
166 #include <sys/param.h>
167 #include <sys/mount.h>
168 #include <sys/stat.h>
171 #if _LFS64_LARGEFILE && (defined(LINUX) || defined(SVR4))
172 # ifdef HAVE_INTTYPES_H
173 # include <inttypes.h>
175 # define PRId64 "lld"
176 # define PRIu64 "llu"
180 #if HAVE_LONG_LONG_OFF_T
182 * Ugly hacks for systems that have typedef long long off_t
186 #define HAVE_STAT64 1 /* Ugly hack */
188 #define sys_stat64 sys_stat
189 #define sys_fstat64 sys_fstat
190 #define sys_lstat64 sys_lstat
191 #define sys_lseek64 sys_lseek
192 #define sys_truncate64 sys_truncate
193 #define sys_ftruncate64 sys_ftruncate
196 #ifdef MAJOR_IN_SYSMACROS
197 #include <sys/sysmacros.h>
200 #ifdef MAJOR_IN_MKDEV
201 #include <sys/mkdev.h>
204 #ifdef HAVE_SYS_ASYNCH_H
205 #include <sys/asynch.h>
213 * This is a really dirty trick but it should always work. Traditional
214 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
215 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
217 const struct xlat openmodes[] = {
218 { O_RDWR+1, "O_RDWR" },
219 { O_RDONLY+1, "O_RDONLY" },
220 { O_WRONLY+1, "O_WRONLY" },
221 { O_NONBLOCK, "O_NONBLOCK" },
222 { O_APPEND, "O_APPEND" },
223 { O_CREAT, "O_CREAT" },
224 { O_TRUNC, "O_TRUNC" },
225 { O_EXCL, "O_EXCL" },
226 { O_NOCTTY, "O_NOCTTY" },
228 { O_SYNC, "O_SYNC" },
231 { O_ASYNC, "O_ASYNC" },
234 { O_DSYNC, "O_DSYNC" },
237 { O_RSYNC, "O_RSYNC" },
240 { O_NDELAY, "O_NDELAY" },
243 { O_PRIV, "O_PRIV" },
246 { O_DIRECT, "O_DIRECT" },
249 # if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
252 # define O_LARGEFILE 0x40000
253 # elif defined X86_64 || defined S390X
254 # define O_LARGEFILE 0100000
258 { O_LARGEFILE, "O_LARGEFILE" },
262 { O_DIRECTORY, "O_DIRECTORY" },
265 { O_NOFOLLOW, "O_NOFOLLOW" },
268 { O_NOATIME, "O_NOATIME" },
272 { FNDELAY, "FNDELAY" },
275 { FAPPEND, "FAPPEND" },
281 { FDEFER, "FDEFER" },
284 { FASYNC, "FASYNC" },
287 { FSHLOCK, "FSHLOCK" },
290 { FEXLOCK, "FEXLOCK" },
293 { FCREAT, "FCREAT" },
296 { FTRUNC, "FTRUNC" },
308 { FNOCTTY, "FNOCTTY" },
311 { O_SHLOCK, "O_SHLOCK" },
314 { O_EXLOCK, "O_EXLOCK" },
322 # define AT_FDCWD -100
329 tprintf("AT_FDCWD, ");
331 tprintf("%ld, ", fd);
336 decode_open(struct tcb *tcp, int offset)
339 printpath(tcp, tcp->u_arg[offset]);
342 printflags(openmodes, tcp->u_arg[offset + 1] + 1, "O_???");
343 if (tcp->u_arg[offset + 1] & O_CREAT) {
345 tprintf(", %#lo", tcp->u_arg[offset + 2]);
352 sys_open(struct tcb *tcp)
354 return decode_open(tcp, 0);
359 sys_openat(struct tcb *tcp)
362 print_dirfd(tcp->u_arg[0]);
363 return decode_open(tcp, 1);
368 static const struct xlat openmodessol[] = {
372 { 0x80, "O_NONBLOCK" },
374 { 0x100, "O_CREAT" },
375 { 0x200, "O_TRUNC" },
377 { 0x800, "O_NOCTTY" },
380 { 0x8000, "O_RSYNC" },
382 { 0x1000, "O_PRIV" },
391 printpath(tcp, tcp->u_arg[0]);
394 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
395 if (tcp->u_arg[1] & 0x100) {
397 tprintf(", %#lo", tcp->u_arg[2]);
410 printpath(tcp, tcp->u_arg[0]);
411 tprintf(", %#lo", tcp->u_arg[1]);
416 static const struct xlat access_flags[] = {
422 { EFF_ONLY_OK, "EFF_ONLY_OK" },
431 decode_access(struct tcb *tcp, int offset)
434 printpath(tcp, tcp->u_arg[offset]);
436 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK");
442 sys_access(struct tcb *tcp)
444 return decode_access(tcp, 0);
449 sys_faccessat(struct tcb *tcp)
452 print_dirfd(tcp->u_arg[0]);
453 return decode_access(tcp, 1);
462 tprintf("%#lo", tcp->u_arg[0]);
467 static const struct xlat whence[] = {
468 { SEEK_SET, "SEEK_SET" },
469 { SEEK_CUR, "SEEK_CUR" },
470 { SEEK_END, "SEEK_END" },
474 #ifndef HAVE_LONG_LONG_OFF_T
483 tprintf("%ld, ", tcp->u_arg[0]);
484 offset = tcp->u_arg[1];
485 _whence = tcp->u_arg[2];
486 if (_whence == SEEK_SET)
487 tprintf("%lu, ", offset);
489 tprintf("%ld, ", offset);
490 printxval(whence, _whence, "SEEK_???");
492 return RVAL_UDECIMAL;
503 * This one call takes explicitly two 32-bit arguments hi, lo,
504 * rather than one 64-bit argument for which LONG_LONG works
505 * appropriate for the native byte order.
507 if (tcp->u_arg[4] == SEEK_SET)
508 tprintf("%ld, %llu, ", tcp->u_arg[0],
509 (((long long int) tcp->u_arg[1]) << 32
510 | (unsigned long long) (unsigned) tcp->u_arg[2]));
512 tprintf("%ld, %lld, ", tcp->u_arg[0],
513 (((long long int) tcp->u_arg[1]) << 32
514 | (unsigned long long) (unsigned) tcp->u_arg[2]));
518 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
519 tprintf("%#lx, ", tcp->u_arg[3]);
521 tprintf("[%llu], ", off);
522 printxval(whence, tcp->u_arg[4], "SEEK_???");
532 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
533 # if defined IA64 || defined X86_64 || defined ALPHA
534 (long long int) tcp->u_arg[1], tcp->u_arg[2]
536 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]
544 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
551 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
552 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
553 if (tcp->u_arg[3] == SEEK_SET)
554 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
556 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
557 printxval(whence, tcp->u_arg[3], "SEEK_???");
559 return RVAL_LUDECIMAL;
563 #ifndef HAVE_LONG_LONG_OFF_T
569 printpath(tcp, tcp->u_arg[0]);
570 tprintf(", %lu", tcp->u_arg[1]);
576 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
583 printpath(tcp, tcp->u_arg[0]);
584 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
590 #ifndef HAVE_LONG_LONG_OFF_T
596 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
602 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
609 tprintf("%ld, %llu", tcp->u_arg[0],
610 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
618 static const struct xlat modetypes[] = {
619 { S_IFREG, "S_IFREG" },
620 { S_IFSOCK, "S_IFSOCK" },
621 { S_IFIFO, "S_IFIFO" },
622 { S_IFLNK, "S_IFLNK" },
623 { S_IFDIR, "S_IFDIR" },
624 { S_IFBLK, "S_IFBLK" },
625 { S_IFCHR, "S_IFCHR" },
636 if ((mode & S_IFMT) == 0)
638 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
639 sprintf(buf, "%#o", mode);
642 sprintf(buf, "%s%s%s%s", s,
643 (mode & S_ISUID) ? "|S_ISUID" : "",
644 (mode & S_ISGID) ? "|S_ISGID" : "",
645 (mode & S_ISVTX) ? "|S_ISVTX" : "");
646 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
648 sprintf(buf + strlen(buf), "|%#o", mode);
649 s = (*buf == '|') ? buf + 1 : buf;
665 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
666 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
667 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
679 int st_pad1[3]; /* network id */
688 int st_pad3; /* st_size, off_t expansion */
689 timestruct_t st_atime;
690 timestruct_t st_mtime;
691 timestruct_t st_ctime;
695 int st_pad4[8]; /* expansion area */
699 printstatsol(tcp, addr)
703 struct solstat statbuf;
709 if (syserror(tcp) || !verbose(tcp)) {
710 tprintf("%#lx", addr);
713 if (umove(tcp, addr, &statbuf) < 0) {
718 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
719 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
720 (unsigned long) (statbuf.st_dev & 0x3ffff),
721 (unsigned long) statbuf.st_ino,
722 sprintmode(statbuf.st_mode));
723 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
724 (unsigned long) statbuf.st_nlink,
725 (unsigned long) statbuf.st_uid,
726 (unsigned long) statbuf.st_gid);
727 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
728 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
731 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
732 switch (statbuf.st_mode & S_IFMT) {
733 case S_IFCHR: case S_IFBLK:
734 tprintf("st_rdev=makedev(%lu, %lu), ",
735 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
736 (unsigned long) (statbuf.st_rdev & 0x3ffff));
739 tprintf("st_size=%u, ", statbuf.st_size);
743 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
744 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
745 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
751 #if defined (SPARC64)
753 printstat_sparc64(tcp, addr)
757 struct stat_sparc64 statbuf;
763 if (syserror(tcp) || !verbose(tcp)) {
764 tprintf("%#lx", addr);
767 if (umove(tcp, addr, &statbuf) < 0) {
773 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
774 (unsigned long) major(statbuf.st_dev),
775 (unsigned long) minor(statbuf.st_dev),
776 (unsigned long) statbuf.st_ino,
777 sprintmode(statbuf.st_mode));
778 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
779 (unsigned long) statbuf.st_nlink,
780 (unsigned long) statbuf.st_uid,
781 (unsigned long) statbuf.st_gid);
782 tprintf("st_blksize=%lu, ",
783 (unsigned long) statbuf.st_blksize);
784 tprintf("st_blocks=%lu, ",
785 (unsigned long) statbuf.st_blocks);
788 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
789 switch (statbuf.st_mode & S_IFMT) {
790 case S_IFCHR: case S_IFBLK:
791 tprintf("st_rdev=makedev(%lu, %lu), ",
792 (unsigned long) major(statbuf.st_rdev),
793 (unsigned long) minor(statbuf.st_rdev));
796 tprintf("st_size=%lu, ", statbuf.st_size);
800 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
801 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
802 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
809 #endif /* LINUXSPARC */
811 static const struct xlat fileflags[] = {
813 { UF_NODUMP, "UF_NODUMP" },
814 { UF_IMMUTABLE, "UF_IMMUTABLE" },
815 { UF_APPEND, "UF_APPEND" },
816 { UF_OPAQUE, "UF_OPAQUE" },
817 { UF_NOUNLINK, "UF_NOUNLINK" },
818 { SF_ARCHIVED, "SF_ARCHIVED" },
819 { SF_IMMUTABLE, "SF_IMMUTABLE" },
820 { SF_APPEND, "SF_APPEND" },
821 { SF_NOUNLINK, "SF_NOUNLINK" },
824 { _S_ISMLD, "_S_ISMLD" },
827 { _S_ISMOUNTED, "_S_ISMOUNTED" },
839 printpath(tcp, tcp->u_arg[0]);
841 printflags(fileflags, tcp->u_arg[1], "UF_???");
851 tprintf("%ld, ", tcp->u_arg[0]);
852 printflags(fileflags, tcp->u_arg[1], "UF_???");
858 #ifndef HAVE_LONG_LONG_OFF_T
860 realprintstat(tcp, statbuf)
862 struct stat *statbuf;
865 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
866 (unsigned long) major(statbuf->st_dev),
867 (unsigned long) minor(statbuf->st_dev),
868 (unsigned long) statbuf->st_ino,
869 sprintmode(statbuf->st_mode));
870 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
871 (unsigned long) statbuf->st_nlink,
872 (unsigned long) statbuf->st_uid,
873 (unsigned long) statbuf->st_gid);
874 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
875 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
876 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
877 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
878 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
879 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
882 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
883 switch (statbuf->st_mode & S_IFMT) {
884 case S_IFCHR: case S_IFBLK:
885 #ifdef HAVE_STRUCT_STAT_ST_RDEV
886 tprintf("st_rdev=makedev(%lu, %lu), ",
887 (unsigned long) major(statbuf->st_rdev),
888 (unsigned long) minor(statbuf->st_rdev));
889 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
890 tprintf("st_size=makedev(%lu, %lu), ",
891 (unsigned long) major(statbuf->st_size),
892 (unsigned long) minor(statbuf->st_size));
893 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
896 tprintf("st_size=%lu, ", statbuf->st_size);
900 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
901 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
902 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
903 #if HAVE_STRUCT_STAT_ST_FLAGS
904 tprintf(", st_flags=");
905 printflags(fileflags, statbuf->st_flags, "UF_???");
907 #if HAVE_STRUCT_STAT_ST_ACLCNT
908 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
910 #if HAVE_STRUCT_STAT_ST_LEVEL
911 tprintf(", st_level=%ld", statbuf->st_level);
913 #if HAVE_STRUCT_STAT_ST_FSTYPE
914 tprintf(", st_fstype=%.*s",
915 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
917 #if HAVE_STRUCT_STAT_ST_GEN
918 tprintf(", st_gen=%u", statbuf->st_gen);
935 if (current_personality == 1) {
936 printstatsol(tcp, addr);
940 else if (current_personality == 2) {
941 printstat_sparc64(tcp, addr);
945 #endif /* LINUXSPARC */
951 if (syserror(tcp) || !verbose(tcp)) {
952 tprintf("%#lx", addr);
955 if (umove(tcp, addr, &statbuf) < 0) {
960 realprintstat(tcp, &statbuf);
962 #endif /* !HAVE_LONG_LONG_OFF_T */
966 printstat64(tcp, addr)
970 struct stat64 statbuf;
973 if (current_personality == 1) {
974 printstatsol(tcp, addr);
978 else if (current_personality == 2) {
979 printstat_sparc64(tcp, addr);
983 #endif /* LINUXSPARC */
989 if (syserror(tcp) || !verbose(tcp)) {
990 tprintf("%#lx", addr);
993 if (umove(tcp, addr, &statbuf) < 0) {
999 #ifdef HAVE_LONG_LONG
1000 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1002 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
1004 (unsigned long) major(statbuf.st_dev),
1005 (unsigned long) minor(statbuf.st_dev),
1006 #ifdef HAVE_LONG_LONG
1007 (unsigned long long) statbuf.st_ino,
1009 (unsigned long) statbuf.st_ino,
1011 sprintmode(statbuf.st_mode));
1012 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1013 (unsigned long) statbuf.st_nlink,
1014 (unsigned long) statbuf.st_uid,
1015 (unsigned long) statbuf.st_gid);
1016 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
1017 tprintf("st_blksize=%lu, ",
1018 (unsigned long) statbuf.st_blksize);
1019 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
1020 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
1021 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
1022 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
1025 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1026 switch (statbuf.st_mode & S_IFMT) {
1027 case S_IFCHR: case S_IFBLK:
1028 #ifdef HAVE_STRUCT_STAT_ST_RDEV
1029 tprintf("st_rdev=makedev(%lu, %lu), ",
1030 (unsigned long) major(statbuf.st_rdev),
1031 (unsigned long) minor(statbuf.st_rdev));
1032 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
1033 tprintf("st_size=makedev(%lu, %lu), ",
1034 (unsigned long) major(statbuf.st_size),
1035 (unsigned long) minor(statbuf.st_size));
1036 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
1039 tprintf("st_size=%llu, ", statbuf.st_size);
1043 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1044 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
1045 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
1046 #if HAVE_STRUCT_STAT_ST_FLAGS
1047 tprintf(", st_flags=");
1048 printflags(fileflags, statbuf.st_flags, "UF_???");
1050 #if HAVE_STRUCT_STAT_ST_ACLCNT
1051 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1053 #if HAVE_STRUCT_STAT_ST_LEVEL
1054 tprintf(", st_level=%ld", statbuf.st_level);
1056 #if HAVE_STRUCT_STAT_ST_FSTYPE
1057 tprintf(", st_fstype=%.*s",
1058 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1060 #if HAVE_STRUCT_STAT_ST_GEN
1061 tprintf(", st_gen=%u", statbuf.st_gen);
1068 #endif /* HAVE_STAT64 */
1070 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1072 convertoldstat(oldbuf, newbuf)
1073 const struct __old_kernel_stat *oldbuf;
1074 struct stat *newbuf;
1076 newbuf->st_dev=oldbuf->st_dev;
1077 newbuf->st_ino=oldbuf->st_ino;
1078 newbuf->st_mode=oldbuf->st_mode;
1079 newbuf->st_nlink=oldbuf->st_nlink;
1080 newbuf->st_uid=oldbuf->st_uid;
1081 newbuf->st_gid=oldbuf->st_gid;
1082 newbuf->st_rdev=oldbuf->st_rdev;
1083 newbuf->st_size=oldbuf->st_size;
1084 newbuf->st_atime=oldbuf->st_atime;
1085 newbuf->st_mtime=oldbuf->st_mtime;
1086 newbuf->st_ctime=oldbuf->st_ctime;
1087 newbuf->st_blksize=0; /* not supported in old_stat */
1088 newbuf->st_blocks=0; /* not supported in old_stat */
1093 printoldstat(tcp, addr)
1097 struct __old_kernel_stat statbuf;
1098 struct stat newstatbuf;
1101 if (current_personality == 1) {
1102 printstatsol(tcp, addr);
1105 #endif /* LINUXSPARC */
1111 if (syserror(tcp) || !verbose(tcp)) {
1112 tprintf("%#lx", addr);
1115 if (umove(tcp, addr, &statbuf) < 0) {
1120 convertoldstat(&statbuf, &newstatbuf);
1121 realprintstat(tcp, &newstatbuf);
1123 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1125 #ifndef HAVE_LONG_LONG_OFF_T
1130 if (entering(tcp)) {
1131 printpath(tcp, tcp->u_arg[0]);
1134 printstat(tcp, tcp->u_arg[1]);
1145 if (entering(tcp)) {
1146 printpath(tcp, tcp->u_arg[0]);
1149 printstat64(tcp, tcp->u_arg[1]);
1153 return printargs(tcp);
1158 static const struct xlat fstatatflags[] = {
1159 #ifndef AT_SYMLINK_NOFOLLOW
1160 # define AT_SYMLINK_NOFOLLOW 0x100
1162 { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" },
1167 sys_newfstatat(struct tcb *tcp)
1169 if (entering(tcp)) {
1170 print_dirfd(tcp->u_arg[0]);
1171 printpath(tcp, tcp->u_arg[1]);
1175 printstat64(tcp, tcp->u_arg[2]);
1177 printstat(tcp, tcp->u_arg[2]);
1180 printflags(fstatatflags, tcp->u_arg[3], "AT_???");
1186 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1191 if (entering(tcp)) {
1192 printpath(tcp, tcp->u_arg[0]);
1195 printoldstat(tcp, tcp->u_arg[1]);
1199 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1201 #ifndef HAVE_LONG_LONG_OFF_T
1207 tprintf("%ld, ", tcp->u_arg[0]);
1209 printstat(tcp, tcp->u_arg[1]);
1221 tprintf("%ld, ", tcp->u_arg[0]);
1223 printstat64(tcp, tcp->u_arg[1]);
1227 return printargs(tcp);
1231 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1237 tprintf("%ld, ", tcp->u_arg[0]);
1239 printoldstat(tcp, tcp->u_arg[1]);
1243 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1245 #ifndef HAVE_LONG_LONG_OFF_T
1250 if (entering(tcp)) {
1251 printpath(tcp, tcp->u_arg[0]);
1254 printstat(tcp, tcp->u_arg[1]);
1265 if (entering(tcp)) {
1266 printpath(tcp, tcp->u_arg[0]);
1269 printstat64(tcp, tcp->u_arg[1]);
1273 return printargs(tcp);
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 */
1293 #if defined(SVR4) || defined(LINUXSPARC)
1299 if (entering(tcp)) {
1300 tprintf("%ld, ", tcp->u_arg[0]);
1301 printpath(tcp, tcp->u_arg[1]);
1305 if (tcp->u_arg[0] == _STAT64_VER)
1306 printstat64 (tcp, tcp->u_arg[2]);
1309 printstat(tcp, tcp->u_arg[2]);
1319 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1322 if (tcp->u_arg[0] == _STAT64_VER)
1323 printstat64 (tcp, tcp->u_arg[2]);
1326 printstat(tcp, tcp->u_arg[2]);
1335 if (entering(tcp)) {
1336 tprintf("%ld, ", tcp->u_arg[0]);
1337 printpath(tcp, tcp->u_arg[1]);
1341 if (tcp->u_arg[0] == _STAT64_VER)
1342 printstat64 (tcp, tcp->u_arg[2]);
1345 printstat(tcp, tcp->u_arg[2]);
1354 int mode = tcp->u_arg[2];
1356 if (entering(tcp)) {
1357 tprintf("%ld, ", tcp->u_arg[0]);
1358 printpath(tcp, tcp->u_arg[1]);
1359 tprintf(", %s", sprintmode(mode));
1360 switch (mode & S_IFMT) {
1361 case S_IFCHR: case S_IFBLK:
1363 tprintf(", makedev(%lu, %lu)",
1364 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1365 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1367 tprintf(", makedev(%lu, %lu)",
1368 (unsigned long) major(tcp->u_arg[3]),
1369 (unsigned long) minor(tcp->u_arg[3]));
1379 #ifdef HAVE_SYS_ACL_H
1381 #include <sys/acl.h>
1383 static const struct xlat aclcmds[] = {
1385 { SETACL, "SETACL" },
1388 { GETACL, "GETACL" },
1391 { GETACLCNT, "GETACLCNT" },
1394 { ACL_GET, "ACL_GET" },
1397 { ACL_SET, "ACL_SET" },
1400 { ACL_CNT, "ACL_CNT" },
1409 if (entering(tcp)) {
1410 printpath(tcp, tcp->u_arg[0]);
1412 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1413 tprintf(", %ld", tcp->u_arg[2]);
1415 * FIXME - dump out the list of aclent_t's pointed to
1416 * by "tcp->u_arg[3]" if it's not NULL.
1419 tprintf(", %#lx", tcp->u_arg[3]);
1431 if (entering(tcp)) {
1432 tprintf("%ld, ", tcp->u_arg[0]);
1433 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1434 tprintf(", %ld", tcp->u_arg[2]);
1436 * FIXME - dump out the list of aclent_t's pointed to
1437 * by "tcp->u_arg[3]" if it's not NULL.
1440 tprintf(", %#lx", tcp->u_arg[3]);
1448 static const struct xlat aclipc[] = {
1450 { IPC_SHM, "IPC_SHM" },
1453 { IPC_SEM, "IPC_SEM" },
1456 { IPC_MSG, "IPC_MSG" },
1466 if (entering(tcp)) {
1467 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1468 tprintf(", %#lx, ", tcp->u_arg[1]);
1469 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1470 tprintf(", %ld", tcp->u_arg[3]);
1472 * FIXME - dump out the list of aclent_t's pointed to
1473 * by "tcp->u_arg[4]" if it's not NULL.
1476 tprintf(", %#lx", tcp->u_arg[4]);
1485 #endif /* HAVE_SYS_ACL_H */
1487 #endif /* SVR4 || LINUXSPARC */
1491 static const struct xlat fsmagic[] = {
1492 { 0x73757245, "CODA_SUPER_MAGIC" },
1493 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1494 { 0x1373, "DEVFS_SUPER_MAGIC" },
1495 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1496 { 0x414A53, "EFS_SUPER_MAGIC" },
1497 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1498 { 0xef53, "EXT2_SUPER_MAGIC" },
1499 { 0x137d, "EXT_SUPER_MAGIC" },
1500 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1501 { 0x9660, "ISOFS_SUPER_MAGIC" },
1502 { 0x137f, "MINIX_SUPER_MAGIC" },
1503 { 0x138f, "MINIX_SUPER_MAGIC2" },
1504 { 0x2468, "MINIX2_SUPER_MAGIC" },
1505 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1506 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1507 { 0x564c, "NCP_SUPER_MAGIC" },
1508 { 0x6969, "NFS_SUPER_MAGIC" },
1509 { 0x9fa0, "PROC_SUPER_MAGIC" },
1510 { 0x002f, "QNX4_SUPER_MAGIC" },
1511 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1512 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1513 { 0x517b, "SMB_SUPER_MAGIC" },
1514 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1515 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1516 { 0x00011954, "UFS_MAGIC" },
1517 { 0x54190100, "UFS_CIGAM" },
1518 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1519 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1520 { 0x62656572, "SYSFS_MAGIC" },
1532 static char buf[32];
1536 s = xlookup(fsmagic, magic);
1538 sprintf(buf, "\"%s\"", s);
1542 sprintf(buf, "%#x", magic);
1547 printstatfs(tcp, addr)
1551 struct statfs statbuf;
1553 if (syserror(tcp) || !verbose(tcp)) {
1554 tprintf("%#lx", addr);
1557 if (umove(tcp, addr, &statbuf) < 0) {
1563 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1564 sprintfstype(statbuf.f_type),
1565 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1566 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1567 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1568 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1571 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1572 sprintfstype(statbuf.f_type),
1573 (unsigned long)statbuf.f_bsize,
1574 (unsigned long)statbuf.f_blocks,
1575 (unsigned long)statbuf.f_bfree);
1576 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1577 (unsigned long)statbuf.f_bavail,
1578 (unsigned long)statbuf.f_files,
1579 (unsigned long)statbuf.f_ffree,
1580 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1582 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1585 #ifdef _STATFS_F_FRSIZE
1586 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1595 if (entering(tcp)) {
1596 printpath(tcp, tcp->u_arg[0]);
1599 printstatfs(tcp, tcp->u_arg[1]);
1608 if (entering(tcp)) {
1609 tprintf("%lu, ", tcp->u_arg[0]);
1611 printstatfs(tcp, tcp->u_arg[1]);
1618 printstatfs64(tcp, addr)
1622 struct statfs64 statbuf;
1624 if (syserror(tcp) || !verbose(tcp)) {
1625 tprintf("%#lx", addr);
1628 if (umove(tcp, addr, &statbuf) < 0) {
1632 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
1633 sprintfstype(statbuf.f_type),
1634 (unsigned long long)statbuf.f_bsize,
1635 (unsigned long long)statbuf.f_blocks,
1636 (unsigned long long)statbuf.f_bfree);
1637 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1638 (unsigned long long)statbuf.f_bavail,
1639 (unsigned long long)statbuf.f_files,
1640 (unsigned long long)statbuf.f_ffree,
1641 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1642 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1643 #ifdef _STATFS_F_FRSIZE
1644 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
1653 if (entering(tcp)) {
1654 printpath(tcp, tcp->u_arg[0]);
1655 tprintf(", %lu, ", tcp->u_arg[1]);
1657 if (tcp->u_arg[1] == sizeof (struct statfs64))
1658 printstatfs64(tcp, tcp->u_arg[2]);
1669 if (entering(tcp)) {
1670 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1672 if (tcp->u_arg[1] == sizeof (struct statfs64))
1673 printstatfs64(tcp, tcp->u_arg[2]);
1681 #if defined(LINUX) && defined(__alpha)
1687 if (entering(tcp)) {
1688 printpath(tcp, tcp->u_arg[0]);
1691 printstatfs(tcp, tcp->u_arg[1]);
1692 tprintf(", %lu", tcp->u_arg[2]);
1701 if (entering(tcp)) {
1702 tprintf("%lu, ", tcp->u_arg[0]);
1704 printstatfs(tcp, tcp->u_arg[1]);
1705 tprintf(", %lu", tcp->u_arg[2]);
1709 #endif /* LINUX && __alpha */
1719 struct ustat statbuf;
1721 if (entering(tcp)) {
1722 tprintf("makedev(%lu, %lu), ",
1723 (long) major(tcp->u_arg[0]),
1724 (long) minor(tcp->u_arg[0]));
1727 if (syserror(tcp) || !verbose(tcp))
1728 tprintf("%#lx", tcp->u_arg[1]);
1729 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1732 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1733 statbuf.f_tfree, statbuf.f_tinode);
1734 tprintf("f_fname=\"%.*s\", ",
1735 (int) sizeof(statbuf.f_fname),
1737 tprintf("f_fpack=\"%.*s\"}",
1738 (int) sizeof(statbuf.f_fpack),
1751 if (entering(tcp)) {
1752 printpath(tcp, tcp->u_arg[0]);
1754 printpath(tcp, tcp->u_arg[1]);
1765 if (entering(tcp)) {
1766 printpath(tcp, tcp->u_arg[0]);
1772 decode_mkdir(struct tcb *tcp, int offset)
1774 if (entering(tcp)) {
1775 printpath(tcp, tcp->u_arg[offset]);
1776 tprintf(", %#lo", tcp->u_arg[offset + 1]);
1782 sys_mkdir(struct tcb *tcp)
1784 return decode_mkdir(tcp, 0);
1789 sys_mkdirat(struct tcb *tcp)
1792 print_dirfd(tcp->u_arg[0]);
1793 return decode_mkdir(tcp, 1);
1801 if (entering(tcp)) {
1802 printpath(tcp, tcp->u_arg[0]);
1811 if (entering(tcp)) {
1812 tprintf("%ld", tcp->u_arg[0]);
1821 if (entering(tcp)) {
1822 printpath(tcp, tcp->u_arg[0]);
1827 #if defined(SUNOS4) || defined(SVR4)
1832 if (entering(tcp)) {
1833 tprintf("%ld", tcp->u_arg[0]);
1837 #endif /* SUNOS4 || SVR4 */
1843 if (entering(tcp)) {
1844 printpath(tcp, tcp->u_arg[0]);
1846 printpath(tcp, tcp->u_arg[1]);
1853 sys_linkat(struct tcb *tcp)
1855 if (entering(tcp)) {
1856 print_dirfd(tcp->u_arg[0]);
1857 printpath(tcp, tcp->u_arg[1]);
1859 print_dirfd(tcp->u_arg[2]);
1860 printpath(tcp, tcp->u_arg[3]);
1861 tprintf(", %ld", tcp->u_arg[4]);
1871 if (entering(tcp)) {
1872 printpath(tcp, tcp->u_arg[0]);
1878 static const struct xlat unlinkatflags[] = {
1879 #ifndef AT_REMOVEDIR
1880 # define AT_REMOVEDIR 0x200
1882 { AT_REMOVEDIR, "AT_REMOVEDIR" },
1887 sys_unlinkat(struct tcb *tcp)
1889 if (entering(tcp)) {
1890 print_dirfd(tcp->u_arg[0]);
1891 printpath(tcp, tcp->u_arg[1]);
1893 printflags(unlinkatflags, tcp->u_arg[2], "AT_???");
1903 if (entering(tcp)) {
1904 printpath(tcp, tcp->u_arg[0]);
1906 printpath(tcp, tcp->u_arg[1]);
1913 sys_symlinkat(struct tcb *tcp)
1915 if (entering(tcp)) {
1916 printpath(tcp, tcp->u_arg[0]);
1918 print_dirfd(tcp->u_arg[1]);
1919 printpath(tcp, tcp->u_arg[2]);
1926 decode_readlink(struct tcb *tcp, int offset)
1928 if (entering(tcp)) {
1929 printpath(tcp, tcp->u_arg[offset]);
1933 tprintf("%#lx", tcp->u_arg[offset + 1]);
1935 printpathn(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
1936 tprintf(", %lu", tcp->u_arg[offset + 2]);
1942 sys_readlink(struct tcb *tcp)
1944 return decode_readlink(tcp, 0);
1949 sys_readlinkat(struct tcb *tcp)
1952 print_dirfd(tcp->u_arg[0]);
1953 return decode_readlink(tcp, 1);
1961 if (entering(tcp)) {
1962 printpath(tcp, tcp->u_arg[0]);
1964 printpath(tcp, tcp->u_arg[1]);
1971 sys_renameat(struct tcb *tcp)
1973 if (entering(tcp)) {
1974 print_dirfd(tcp->u_arg[0]);
1975 printpath(tcp, tcp->u_arg[1]);
1977 print_dirfd(tcp->u_arg[2]);
1978 printpath(tcp, tcp->u_arg[3]);
1988 if (entering(tcp)) {
1989 printpath(tcp, tcp->u_arg[0]);
1990 printuid(", ", tcp->u_arg[1]);
1991 printuid(", ", tcp->u_arg[2]);
1998 sys_fchownat(struct tcb *tcp)
2000 if (entering(tcp)) {
2001 print_dirfd(tcp->u_arg[0]);
2002 printpath(tcp, tcp->u_arg[1]);
2003 printuid(", ", tcp->u_arg[2]);
2004 printuid(", ", tcp->u_arg[3]);
2006 printflags(fstatatflags, tcp->u_arg[4], "AT_???");
2016 if (entering(tcp)) {
2017 tprintf("%ld", tcp->u_arg[0]);
2018 printuid(", ", tcp->u_arg[1]);
2019 printuid(", ", tcp->u_arg[2]);
2025 decode_chmod(struct tcb *tcp, int offset)
2027 if (entering(tcp)) {
2028 printpath(tcp, tcp->u_arg[offset]);
2029 tprintf(", %#lo", tcp->u_arg[offset + 1]);
2035 sys_chmod(struct tcb *tcp)
2037 return decode_chmod(tcp, 0);
2042 sys_fchmodat(struct tcb *tcp)
2045 print_dirfd(tcp->u_arg[0]);
2046 return decode_chmod(tcp, 1);
2054 if (entering(tcp)) {
2055 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
2065 if (entering(tcp)) {
2066 printpath(tcp, tcp->u_arg[0]);
2068 printtv32(tcp, tcp->u_arg[1]);
2075 decode_utimes(struct tcb *tcp, int offset)
2077 if (entering(tcp)) {
2078 printpath(tcp, tcp->u_arg[offset]);
2080 printtv(tcp, tcp->u_arg[offset + 1]);
2086 sys_utimes(struct tcb *tcp)
2088 return decode_utimes(tcp, 0);
2093 sys_futimesat(struct tcb *tcp)
2096 print_dirfd(tcp->u_arg[0]);
2097 return decode_utimes(tcp, 1);
2107 if (entering(tcp)) {
2108 printpath(tcp, tcp->u_arg[0]);
2112 else if (!verbose(tcp))
2113 tprintf("%#lx", tcp->u_arg[1]);
2114 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
2118 tprintf("[%s,", sprinttime(ut[0]));
2119 tprintf(" %s]", sprinttime(ut[1]));
2126 decode_mknod(struct tcb *tcp, int offset)
2128 int mode = tcp->u_arg[offset + 1];
2130 if (entering(tcp)) {
2131 printpath(tcp, tcp->u_arg[offset]);
2132 tprintf(", %s", sprintmode(mode));
2133 switch (mode & S_IFMT) {
2134 case S_IFCHR: case S_IFBLK:
2136 if (current_personality == 1)
2137 tprintf(", makedev(%lu, %lu)",
2138 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
2139 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
2142 tprintf(", makedev(%lu, %lu)",
2143 (unsigned long) major(tcp->u_arg[offset + 2]),
2144 (unsigned long) minor(tcp->u_arg[offset + 2]));
2154 sys_mknod(struct tcb *tcp)
2156 return decode_mknod(tcp, 0);
2161 sys_mknodat(struct tcb *tcp)
2164 print_dirfd(tcp->u_arg[0]);
2165 return decode_mknod(tcp, 1);
2174 if (entering(tcp)) {
2175 printpath(tcp, tcp->u_arg[0]);
2176 tprintf(", %#lo", tcp->u_arg[1]);
2180 #endif /* FREEBSD */
2186 if (entering(tcp)) {
2187 tprintf("%ld", tcp->u_arg[0]);
2201 if (!verbose(tcp)) {
2202 tprintf("%#lx", addr);
2205 if (umove(tcp, addr, &d) < 0) {
2209 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
2211 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
2219 if (entering(tcp)) {
2220 tprintf("%lu, ", tcp->u_arg[0]);
2222 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
2223 tprintf("%#lx", tcp->u_arg[1]);
2225 printdir(tcp, tcp->u_arg[1]);
2226 /* Not much point in printing this out, it is always 1. */
2227 if (tcp->u_arg[2] != 1)
2228 tprintf(", %lu", tcp->u_arg[2]);
2235 #if defined FREEBSD || defined LINUX
2236 static const struct xlat direnttypes[] = {
2237 { DT_UNKNOWN, "DT_UNKNOWN" },
2238 { DT_FIFO, "DT_FIFO" },
2239 { DT_CHR, "DT_CHR" },
2240 { DT_DIR, "DT_DIR" },
2241 { DT_BLK, "DT_BLK" },
2242 { DT_REG, "DT_REG" },
2243 { DT_LNK, "DT_LNK" },
2244 { DT_SOCK, "DT_SOCK" },
2245 { DT_WHT, "DT_WHT" },
2255 int i, len, dents = 0;
2258 if (entering(tcp)) {
2259 tprintf("%lu, ", tcp->u_arg[0]);
2262 if (syserror(tcp) || !verbose(tcp)) {
2263 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2267 if ((buf = malloc(len)) == NULL) {
2268 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2269 fprintf(stderr, "out of memory\n");
2272 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2273 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2279 for (i = 0; i < len;) {
2280 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2283 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2284 i ? " " : "", d->d_ino, d->d_off);
2285 tprintf("d_reclen=%u, d_name=\"%s\"}",
2286 d->d_reclen, d->d_name);
2291 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2293 (unsigned long) d->d_ino,
2294 (unsigned long) d->d_off);
2295 tprintf("d_reclen=%u, d_name=\"%s\"}",
2296 d->d_reclen, d->d_name);
2301 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2302 i ? " " : "", d->d_off, d->d_fileno,
2304 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2305 d->d_namlen, d->d_namlen, d->d_name);
2310 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2311 i ? " " : "", d->d_fileno, d->d_reclen);
2312 printxval(direnttypes, d->d_type, "DT_???");
2313 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2314 d->d_namlen, d->d_namlen, d->d_name);
2316 #endif /* FREEBSD */
2318 tprintf("/* d_reclen == 0, problem here */");
2327 tprintf("/* %u entries */", dents);
2328 tprintf(", %lu", tcp->u_arg[2]);
2334 #if _LFS64_LARGEFILE
2339 int i, len, dents = 0;
2342 if (entering(tcp)) {
2343 tprintf("%lu, ", tcp->u_arg[0]);
2346 if (syserror(tcp) || !verbose(tcp)) {
2347 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2351 if ((buf = malloc(len)) == NULL) {
2352 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2353 fprintf(stderr, "out of memory\n");
2356 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2357 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2363 for (i = 0; i < len;) {
2364 struct dirent64 *d = (struct dirent64 *) &buf[i];
2365 #if defined(LINUX) || defined(SVR4)
2367 tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ",
2373 printxval(direnttypes, d->d_type, "DT_???");
2376 tprintf("d_reclen=%u, d_name=\"%s\"}",
2377 d->d_reclen, d->d_name);
2379 #endif /* LINUX || SVR4 */
2382 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2383 i ? " " : "", d->d_off, d->d_fileno,
2385 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2386 d->d_namlen, d->d_namlen, d->d_name);
2395 tprintf("/* %u entries */", dents);
2396 tprintf(", %lu", tcp->u_arg[2]);
2404 sys_getdirentries(tcp)
2407 int i, len, dents = 0;
2411 if (entering(tcp)) {
2412 tprintf("%lu, ", tcp->u_arg[0]);
2415 if (syserror(tcp) || !verbose(tcp)) {
2416 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2420 if ((buf = malloc(len)) == NULL) {
2421 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2422 fprintf(stderr, "out of memory\n");
2425 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2426 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2432 for (i = 0; i < len;) {
2433 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
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);
2447 tprintf("/* %u entries */", dents);
2449 tprintf(", %lu", tcp->u_arg[2]);
2450 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2451 tprintf(", %#lx", tcp->u_arg[3]);
2453 tprintf(", [%lu]", basep);
2465 tprintf("%#lx", tcp->u_arg[0]);
2467 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2468 tprintf(", %lu", tcp->u_arg[1]);
2481 tprintf("%#lx", tcp->u_arg[0]);
2483 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2484 tprintf(", %lu", tcp->u_arg[1]);
2490 #ifdef HAVE_SYS_ASYNCH_H
2496 struct aio_result_t res;
2498 if (entering(tcp)) {
2499 tprintf("%lu, ", tcp->u_arg[0]);
2502 tprintf("%#lx", tcp->u_arg[1]);
2504 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2505 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2506 printxval(whence, tcp->u_arg[4], "L_???");
2507 if (syserror(tcp) || tcp->u_arg[5] == 0
2508 || umove(tcp, tcp->u_arg[5], &res) < 0)
2509 tprintf(", %#lx", tcp->u_arg[5]);
2511 tprintf(", {aio_return %d aio_errno %d}",
2512 res.aio_return, res.aio_errno);
2521 struct aio_result_t res;
2523 if (entering(tcp)) {
2524 tprintf("%lu, ", tcp->u_arg[0]);
2525 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2526 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2527 printxval(whence, tcp->u_arg[4], "L_???");
2530 if (tcp->u_arg[5] == 0)
2532 else if (syserror(tcp)
2533 || umove(tcp, tcp->u_arg[5], &res) < 0)
2534 tprintf(", %#lx", tcp->u_arg[5]);
2536 tprintf(", {aio_return %d aio_errno %d}",
2537 res.aio_return, res.aio_errno);
2547 printtv(tcp, tcp->u_arg[0]);
2555 struct aio_result_t res;
2558 if (tcp->u_arg[0] == 0)
2560 else if (syserror(tcp)
2561 || umove(tcp, tcp->u_arg[0], &res) < 0)
2562 tprintf("%#lx", tcp->u_arg[0]);
2564 tprintf("{aio_return %d aio_errno %d}",
2565 res.aio_return, res.aio_errno);
2570 #endif /* HAVE_SYS_ASYNCH_H */
2572 static const struct xlat xattrflags[] = {
2574 { XATTR_CREATE, "XATTR_CREATE" },
2575 { XATTR_REPLACE, "XATTR_REPLACE" },
2581 print_xattr_val(tcp, failed, arg, insize, size)
2585 unsigned long insize, size;
2588 unsigned long capacity = 4 * size + 1;
2589 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
2590 if (buf == NULL || /* probably a bogus size argument */
2591 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2595 unsigned char *out = buf;
2596 unsigned char *in = &buf[3 * size];
2598 for (i = 0; i < size; ++i)
2602 #define tohex(n) "0123456789abcdef"[n]
2605 *out++ = tohex(in[i] / 16);
2606 *out++ = tohex(in[i] % 16);
2608 /* Don't print terminating NUL if there is one. */
2609 if (i > 0 && in[i - 1] == '\0')
2612 tprintf(", \"%s\", %ld", buf, insize);
2617 tprintf(", 0x%lx, %ld", arg, insize);
2624 if (entering(tcp)) {
2625 printpath(tcp, tcp->u_arg[0]);
2627 printstr(tcp, tcp->u_arg[1], -1);
2628 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2630 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2639 if (entering(tcp)) {
2640 tprintf("%ld, ", tcp->u_arg[0]);
2641 printstr(tcp, tcp->u_arg[1], -1);
2642 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2644 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2653 if (entering(tcp)) {
2654 printpath(tcp, tcp->u_arg[0]);
2656 printstr(tcp, tcp->u_arg[1], -1);
2658 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2668 if (entering(tcp)) {
2669 tprintf("%ld, ", tcp->u_arg[0]);
2670 printstr(tcp, tcp->u_arg[1], -1);
2672 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2682 if (entering(tcp)) {
2683 printpath(tcp, tcp->u_arg[0]);
2685 /* XXX Print value in format */
2686 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2695 if (entering(tcp)) {
2696 tprintf("%ld", tcp->u_arg[0]);
2698 /* XXX Print value in format */
2699 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2705 sys_removexattr(tcp)
2708 if (entering(tcp)) {
2709 printpath(tcp, tcp->u_arg[0]);
2711 printstr(tcp, tcp->u_arg[1], -1);
2717 sys_fremovexattr(tcp)
2720 if (entering(tcp)) {
2721 tprintf("%ld, ", tcp->u_arg[0]);
2722 printstr(tcp, tcp->u_arg[1], -1);
2728 static const struct xlat advise[] = {
2729 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2730 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2731 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2732 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2733 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2734 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2744 if (entering(tcp)) {
2745 tprintf("%ld, %lld, %ld, ",
2747 # if defined IA64 || defined X86_64 || defined ALPHA
2748 (long long int) tcp->u_arg[1], tcp->u_arg[2]);
2749 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2751 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]);
2752 printxval(advise, tcp->u_arg[4], "POSIX_FADV_???");
2761 sys_fadvise64_64(tcp)
2764 if (entering(tcp)) {
2765 tprintf("%ld, %lld, %lld, ",
2767 # if defined IA64 || defined X86_64 || defined ALPHA
2768 (long long int) tcp->u_arg[1], (long long int) tcp->u_arg[2]);
2769 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2771 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]),
2772 LONG_LONG(tcp->u_arg[3], tcp->u_arg[4]));
2773 printxval(advise, tcp->u_arg[5], "POSIX_FADV_???");
2780 static const struct xlat inotify_modes[] = {
2781 { 0x00000001, "IN_ACCESS" },
2782 { 0x00000002, "IN_MODIFY" },
2783 { 0x00000004, "IN_ATTRIB" },
2784 { 0x00000008, "IN_CLOSE_WRITE" },
2785 { 0x00000010, "IN_CLOSE_NOWRITE" },
2786 { 0x00000020, "IN_OPEN" },
2787 { 0x00000040, "IN_MOVED_FROM" },
2788 { 0x00000080, "IN_MOVED_TO" },
2789 { 0x00000100, "IN_CREATE" },
2790 { 0x00000200, "IN_DELETE" },
2791 { 0x00000400, "IN_DELETE_SELF" },
2792 { 0x00000800, "IN_MOVE_SELF" },
2793 { 0x00002000, "IN_UNMOUNT" },
2794 { 0x00004000, "IN_Q_OVERFLOW" },
2795 { 0x00008000, "IN_IGNORED" },
2796 { 0x01000000, "IN_ONLYDIR" },
2797 { 0x02000000, "IN_DONT_FOLLOW" },
2798 { 0x20000000, "IN_MASK_ADD" },
2799 { 0x40000000, "IN_ISDIR" },
2800 { 0x80000000, "IN_ONESHOT" }
2804 sys_inotify_add_watch(struct tcb *tcp)
2806 if (entering(tcp)) {
2807 tprintf("%ld, ", tcp->u_arg[0]);
2808 printpath(tcp, tcp->u_arg[1]);
2810 printflags(inotify_modes, tcp->u_arg[2], "IN_???");
2816 sys_inotify_rm_watch(struct tcb *tcp)
2818 if (entering(tcp)) {
2819 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);