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>
212 const struct xlat open_access_modes[] = {
213 { O_RDONLY, "O_RDONLY" },
214 { O_WRONLY, "O_WRONLY" },
215 { O_RDWR, "O_RDWR" },
217 { O_ACCMODE, "O_ACCMODE" },
222 const struct xlat open_mode_flags[] = {
223 { O_CREAT, "O_CREAT" },
224 { O_EXCL, "O_EXCL" },
225 { O_NOCTTY, "O_NOCTTY" },
226 { O_TRUNC, "O_TRUNC" },
227 { O_APPEND, "O_APPEND" },
228 { O_NONBLOCK, "O_NONBLOCK" },
230 { O_SYNC, "O_SYNC" },
233 { O_ASYNC, "O_ASYNC" },
236 { O_DSYNC, "O_DSYNC" },
239 { O_RSYNC, "O_RSYNC" },
242 { O_NDELAY, "O_NDELAY" },
245 { O_PRIV, "O_PRIV" },
248 { O_DIRECT, "O_DIRECT" },
251 # if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
254 # define O_LARGEFILE 0x40000
255 # elif defined X86_64 || defined S390X
256 # define O_LARGEFILE 0100000
260 { O_LARGEFILE, "O_LARGEFILE" },
264 { O_DIRECTORY, "O_DIRECTORY" },
267 { O_NOFOLLOW, "O_NOFOLLOW" },
270 { O_NOATIME, "O_NOATIME" },
274 { FNDELAY, "FNDELAY" },
277 { FAPPEND, "FAPPEND" },
283 { FDEFER, "FDEFER" },
286 { FASYNC, "FASYNC" },
289 { FSHLOCK, "FSHLOCK" },
292 { FEXLOCK, "FEXLOCK" },
295 { FCREAT, "FCREAT" },
298 { FTRUNC, "FTRUNC" },
310 { FNOCTTY, "FNOCTTY" },
313 { O_SHLOCK, "O_SHLOCK" },
316 { O_EXLOCK, "O_EXLOCK" },
324 # define AT_FDCWD -100
331 tprintf("AT_FDCWD, ");
333 tprintf("%ld, ", fd);
338 * low bits of the open(2) flags define access mode,
339 * other bits are real flags.
342 tprint_open_modes(struct tcb *tcp, mode_t flags)
344 const char *str = xlookup(open_access_modes, flags & 3);
354 printflags(open_mode_flags, flags, "O_???");
358 decode_open(struct tcb *tcp, int offset)
361 printpath(tcp, tcp->u_arg[offset]);
364 tprint_open_modes(tcp, tcp->u_arg[offset + 1]);
365 if (tcp->u_arg[offset + 1] & O_CREAT) {
367 tprintf(", %#lo", tcp->u_arg[offset + 2]);
374 sys_open(struct tcb *tcp)
376 return decode_open(tcp, 0);
381 sys_openat(struct tcb *tcp)
384 print_dirfd(tcp->u_arg[0]);
385 return decode_open(tcp, 1);
390 static const struct xlat openmodessol[] = {
394 { 0x80, "O_NONBLOCK" },
396 { 0x100, "O_CREAT" },
397 { 0x200, "O_TRUNC" },
399 { 0x800, "O_NOCTTY" },
402 { 0x8000, "O_RSYNC" },
404 { 0x1000, "O_PRIV" },
413 printpath(tcp, tcp->u_arg[0]);
416 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
417 if (tcp->u_arg[1] & 0x100) {
419 tprintf(", %#lo", tcp->u_arg[2]);
432 printpath(tcp, tcp->u_arg[0]);
433 tprintf(", %#lo", tcp->u_arg[1]);
438 static const struct xlat access_flags[] = {
444 { EFF_ONLY_OK, "EFF_ONLY_OK" },
453 decode_access(struct tcb *tcp, int offset)
456 printpath(tcp, tcp->u_arg[offset]);
458 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK");
464 sys_access(struct tcb *tcp)
466 return decode_access(tcp, 0);
471 sys_faccessat(struct tcb *tcp)
474 print_dirfd(tcp->u_arg[0]);
475 return decode_access(tcp, 1);
484 tprintf("%#lo", tcp->u_arg[0]);
489 static const struct xlat whence[] = {
490 { SEEK_SET, "SEEK_SET" },
491 { SEEK_CUR, "SEEK_CUR" },
492 { SEEK_END, "SEEK_END" },
496 #ifndef HAVE_LONG_LONG_OFF_T
505 tprintf("%ld, ", tcp->u_arg[0]);
506 offset = tcp->u_arg[1];
507 _whence = tcp->u_arg[2];
508 if (_whence == SEEK_SET)
509 tprintf("%lu, ", offset);
511 tprintf("%ld, ", offset);
512 printxval(whence, _whence, "SEEK_???");
514 return RVAL_UDECIMAL;
525 * This one call takes explicitly two 32-bit arguments hi, lo,
526 * rather than one 64-bit argument for which LONG_LONG works
527 * appropriate for the native byte order.
529 if (tcp->u_arg[4] == SEEK_SET)
530 tprintf("%ld, %llu, ", tcp->u_arg[0],
531 (((long long int) tcp->u_arg[1]) << 32
532 | (unsigned long long) (unsigned) tcp->u_arg[2]));
534 tprintf("%ld, %lld, ", tcp->u_arg[0],
535 (((long long int) tcp->u_arg[1]) << 32
536 | (unsigned long long) (unsigned) tcp->u_arg[2]));
540 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
541 tprintf("%#lx, ", tcp->u_arg[3]);
543 tprintf("[%llu], ", off);
544 printxval(whence, tcp->u_arg[4], "SEEK_???");
554 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
555 # if defined IA64 || defined X86_64 || defined ALPHA
556 (long long int) tcp->u_arg[1], tcp->u_arg[2]
558 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]
566 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
573 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
574 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
575 if (tcp->u_arg[3] == SEEK_SET)
576 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
578 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
579 printxval(whence, tcp->u_arg[3], "SEEK_???");
581 return RVAL_LUDECIMAL;
585 #ifndef HAVE_LONG_LONG_OFF_T
591 printpath(tcp, tcp->u_arg[0]);
592 tprintf(", %lu", tcp->u_arg[1]);
598 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
605 printpath(tcp, tcp->u_arg[0]);
606 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
612 #ifndef HAVE_LONG_LONG_OFF_T
618 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
624 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
631 tprintf("%ld, %llu", tcp->u_arg[0],
632 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
640 static const struct xlat modetypes[] = {
641 { S_IFREG, "S_IFREG" },
642 { S_IFSOCK, "S_IFSOCK" },
643 { S_IFIFO, "S_IFIFO" },
644 { S_IFLNK, "S_IFLNK" },
645 { S_IFDIR, "S_IFDIR" },
646 { S_IFBLK, "S_IFBLK" },
647 { S_IFCHR, "S_IFCHR" },
658 if ((mode & S_IFMT) == 0)
660 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
661 sprintf(buf, "%#o", mode);
664 sprintf(buf, "%s%s%s%s", s,
665 (mode & S_ISUID) ? "|S_ISUID" : "",
666 (mode & S_ISGID) ? "|S_ISGID" : "",
667 (mode & S_ISVTX) ? "|S_ISVTX" : "");
668 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
670 sprintf(buf + strlen(buf), "|%#o", mode);
671 s = (*buf == '|') ? buf + 1 : buf;
687 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
688 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
689 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
701 int st_pad1[3]; /* network id */
710 int st_pad3; /* st_size, off_t expansion */
711 timestruct_t st_atime;
712 timestruct_t st_mtime;
713 timestruct_t st_ctime;
717 int st_pad4[8]; /* expansion area */
721 printstatsol(tcp, addr)
725 struct solstat statbuf;
731 if (syserror(tcp) || !verbose(tcp)) {
732 tprintf("%#lx", addr);
735 if (umove(tcp, addr, &statbuf) < 0) {
740 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
741 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
742 (unsigned long) (statbuf.st_dev & 0x3ffff),
743 (unsigned long) statbuf.st_ino,
744 sprintmode(statbuf.st_mode));
745 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
746 (unsigned long) statbuf.st_nlink,
747 (unsigned long) statbuf.st_uid,
748 (unsigned long) statbuf.st_gid);
749 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
750 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
753 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
754 switch (statbuf.st_mode & S_IFMT) {
755 case S_IFCHR: case S_IFBLK:
756 tprintf("st_rdev=makedev(%lu, %lu), ",
757 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
758 (unsigned long) (statbuf.st_rdev & 0x3ffff));
761 tprintf("st_size=%u, ", statbuf.st_size);
765 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
766 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
767 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
773 #if defined (SPARC64)
775 printstat_sparc64(tcp, addr)
779 struct stat_sparc64 statbuf;
785 if (syserror(tcp) || !verbose(tcp)) {
786 tprintf("%#lx", addr);
789 if (umove(tcp, addr, &statbuf) < 0) {
795 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
796 (unsigned long) major(statbuf.st_dev),
797 (unsigned long) minor(statbuf.st_dev),
798 (unsigned long) statbuf.st_ino,
799 sprintmode(statbuf.st_mode));
800 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
801 (unsigned long) statbuf.st_nlink,
802 (unsigned long) statbuf.st_uid,
803 (unsigned long) statbuf.st_gid);
804 tprintf("st_blksize=%lu, ",
805 (unsigned long) statbuf.st_blksize);
806 tprintf("st_blocks=%lu, ",
807 (unsigned long) statbuf.st_blocks);
810 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
811 switch (statbuf.st_mode & S_IFMT) {
812 case S_IFCHR: case S_IFBLK:
813 tprintf("st_rdev=makedev(%lu, %lu), ",
814 (unsigned long) major(statbuf.st_rdev),
815 (unsigned long) minor(statbuf.st_rdev));
818 tprintf("st_size=%lu, ", statbuf.st_size);
822 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
823 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
824 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
831 #endif /* LINUXSPARC */
833 static const struct xlat fileflags[] = {
835 { UF_NODUMP, "UF_NODUMP" },
836 { UF_IMMUTABLE, "UF_IMMUTABLE" },
837 { UF_APPEND, "UF_APPEND" },
838 { UF_OPAQUE, "UF_OPAQUE" },
839 { UF_NOUNLINK, "UF_NOUNLINK" },
840 { SF_ARCHIVED, "SF_ARCHIVED" },
841 { SF_IMMUTABLE, "SF_IMMUTABLE" },
842 { SF_APPEND, "SF_APPEND" },
843 { SF_NOUNLINK, "SF_NOUNLINK" },
846 { _S_ISMLD, "_S_ISMLD" },
849 { _S_ISMOUNTED, "_S_ISMOUNTED" },
861 printpath(tcp, tcp->u_arg[0]);
863 printflags(fileflags, tcp->u_arg[1], "UF_???");
873 tprintf("%ld, ", tcp->u_arg[0]);
874 printflags(fileflags, tcp->u_arg[1], "UF_???");
880 #ifndef HAVE_LONG_LONG_OFF_T
882 realprintstat(tcp, statbuf)
884 struct stat *statbuf;
887 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
888 (unsigned long) major(statbuf->st_dev),
889 (unsigned long) minor(statbuf->st_dev),
890 (unsigned long) statbuf->st_ino,
891 sprintmode(statbuf->st_mode));
892 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
893 (unsigned long) statbuf->st_nlink,
894 (unsigned long) statbuf->st_uid,
895 (unsigned long) statbuf->st_gid);
896 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
897 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
898 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
899 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
900 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
901 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
904 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
905 switch (statbuf->st_mode & S_IFMT) {
906 case S_IFCHR: case S_IFBLK:
907 #ifdef HAVE_STRUCT_STAT_ST_RDEV
908 tprintf("st_rdev=makedev(%lu, %lu), ",
909 (unsigned long) major(statbuf->st_rdev),
910 (unsigned long) minor(statbuf->st_rdev));
911 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
912 tprintf("st_size=makedev(%lu, %lu), ",
913 (unsigned long) major(statbuf->st_size),
914 (unsigned long) minor(statbuf->st_size));
915 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
918 tprintf("st_size=%lu, ", statbuf->st_size);
922 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
923 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
924 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
925 #if HAVE_STRUCT_STAT_ST_FLAGS
926 tprintf(", st_flags=");
927 printflags(fileflags, statbuf->st_flags, "UF_???");
929 #if HAVE_STRUCT_STAT_ST_ACLCNT
930 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
932 #if HAVE_STRUCT_STAT_ST_LEVEL
933 tprintf(", st_level=%ld", statbuf->st_level);
935 #if HAVE_STRUCT_STAT_ST_FSTYPE
936 tprintf(", st_fstype=%.*s",
937 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
939 #if HAVE_STRUCT_STAT_ST_GEN
940 tprintf(", st_gen=%u", statbuf->st_gen);
957 if (current_personality == 1) {
958 printstatsol(tcp, addr);
962 else if (current_personality == 2) {
963 printstat_sparc64(tcp, addr);
967 #endif /* LINUXSPARC */
973 if (syserror(tcp) || !verbose(tcp)) {
974 tprintf("%#lx", addr);
977 if (umove(tcp, addr, &statbuf) < 0) {
982 realprintstat(tcp, &statbuf);
984 #endif /* !HAVE_LONG_LONG_OFF_T */
988 printstat64(tcp, addr)
992 struct stat64 statbuf;
995 if (current_personality == 1) {
996 printstatsol(tcp, addr);
1000 else if (current_personality == 2) {
1001 printstat_sparc64(tcp, addr);
1005 #endif /* LINUXSPARC */
1011 if (syserror(tcp) || !verbose(tcp)) {
1012 tprintf("%#lx", addr);
1015 if (umove(tcp, addr, &statbuf) < 0) {
1021 #ifdef HAVE_LONG_LONG
1022 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1024 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
1026 (unsigned long) major(statbuf.st_dev),
1027 (unsigned long) minor(statbuf.st_dev),
1028 #ifdef HAVE_LONG_LONG
1029 (unsigned long long) statbuf.st_ino,
1031 (unsigned long) statbuf.st_ino,
1033 sprintmode(statbuf.st_mode));
1034 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1035 (unsigned long) statbuf.st_nlink,
1036 (unsigned long) statbuf.st_uid,
1037 (unsigned long) statbuf.st_gid);
1038 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
1039 tprintf("st_blksize=%lu, ",
1040 (unsigned long) statbuf.st_blksize);
1041 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
1042 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
1043 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
1044 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
1047 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1048 switch (statbuf.st_mode & S_IFMT) {
1049 case S_IFCHR: case S_IFBLK:
1050 #ifdef HAVE_STRUCT_STAT_ST_RDEV
1051 tprintf("st_rdev=makedev(%lu, %lu), ",
1052 (unsigned long) major(statbuf.st_rdev),
1053 (unsigned long) minor(statbuf.st_rdev));
1054 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
1055 tprintf("st_size=makedev(%lu, %lu), ",
1056 (unsigned long) major(statbuf.st_size),
1057 (unsigned long) minor(statbuf.st_size));
1058 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
1061 tprintf("st_size=%llu, ", statbuf.st_size);
1065 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1066 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
1067 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
1068 #if HAVE_STRUCT_STAT_ST_FLAGS
1069 tprintf(", st_flags=");
1070 printflags(fileflags, statbuf.st_flags, "UF_???");
1072 #if HAVE_STRUCT_STAT_ST_ACLCNT
1073 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1075 #if HAVE_STRUCT_STAT_ST_LEVEL
1076 tprintf(", st_level=%ld", statbuf.st_level);
1078 #if HAVE_STRUCT_STAT_ST_FSTYPE
1079 tprintf(", st_fstype=%.*s",
1080 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1082 #if HAVE_STRUCT_STAT_ST_GEN
1083 tprintf(", st_gen=%u", statbuf.st_gen);
1090 #endif /* HAVE_STAT64 */
1092 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1094 convertoldstat(oldbuf, newbuf)
1095 const struct __old_kernel_stat *oldbuf;
1096 struct stat *newbuf;
1098 newbuf->st_dev=oldbuf->st_dev;
1099 newbuf->st_ino=oldbuf->st_ino;
1100 newbuf->st_mode=oldbuf->st_mode;
1101 newbuf->st_nlink=oldbuf->st_nlink;
1102 newbuf->st_uid=oldbuf->st_uid;
1103 newbuf->st_gid=oldbuf->st_gid;
1104 newbuf->st_rdev=oldbuf->st_rdev;
1105 newbuf->st_size=oldbuf->st_size;
1106 newbuf->st_atime=oldbuf->st_atime;
1107 newbuf->st_mtime=oldbuf->st_mtime;
1108 newbuf->st_ctime=oldbuf->st_ctime;
1109 newbuf->st_blksize=0; /* not supported in old_stat */
1110 newbuf->st_blocks=0; /* not supported in old_stat */
1115 printoldstat(tcp, addr)
1119 struct __old_kernel_stat statbuf;
1120 struct stat newstatbuf;
1123 if (current_personality == 1) {
1124 printstatsol(tcp, addr);
1127 #endif /* LINUXSPARC */
1133 if (syserror(tcp) || !verbose(tcp)) {
1134 tprintf("%#lx", addr);
1137 if (umove(tcp, addr, &statbuf) < 0) {
1142 convertoldstat(&statbuf, &newstatbuf);
1143 realprintstat(tcp, &newstatbuf);
1145 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1147 #ifndef HAVE_LONG_LONG_OFF_T
1152 if (entering(tcp)) {
1153 printpath(tcp, tcp->u_arg[0]);
1156 printstat(tcp, tcp->u_arg[1]);
1167 if (entering(tcp)) {
1168 printpath(tcp, tcp->u_arg[0]);
1171 printstat64(tcp, tcp->u_arg[1]);
1175 return printargs(tcp);
1180 static const struct xlat fstatatflags[] = {
1181 #ifndef AT_SYMLINK_NOFOLLOW
1182 # define AT_SYMLINK_NOFOLLOW 0x100
1184 { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" },
1189 sys_newfstatat(struct tcb *tcp)
1191 if (entering(tcp)) {
1192 print_dirfd(tcp->u_arg[0]);
1193 printpath(tcp, tcp->u_arg[1]);
1197 printstat64(tcp, tcp->u_arg[2]);
1199 printstat(tcp, tcp->u_arg[2]);
1202 printflags(fstatatflags, tcp->u_arg[3], "AT_???");
1208 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1213 if (entering(tcp)) {
1214 printpath(tcp, tcp->u_arg[0]);
1217 printoldstat(tcp, tcp->u_arg[1]);
1221 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1223 #ifndef HAVE_LONG_LONG_OFF_T
1229 tprintf("%ld, ", tcp->u_arg[0]);
1231 printstat(tcp, tcp->u_arg[1]);
1243 tprintf("%ld, ", tcp->u_arg[0]);
1245 printstat64(tcp, tcp->u_arg[1]);
1249 return printargs(tcp);
1253 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1259 tprintf("%ld, ", tcp->u_arg[0]);
1261 printoldstat(tcp, tcp->u_arg[1]);
1265 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1267 #ifndef HAVE_LONG_LONG_OFF_T
1272 if (entering(tcp)) {
1273 printpath(tcp, tcp->u_arg[0]);
1276 printstat(tcp, tcp->u_arg[1]);
1287 if (entering(tcp)) {
1288 printpath(tcp, tcp->u_arg[0]);
1291 printstat64(tcp, tcp->u_arg[1]);
1295 return printargs(tcp);
1299 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1304 if (entering(tcp)) {
1305 printpath(tcp, tcp->u_arg[0]);
1308 printoldstat(tcp, tcp->u_arg[1]);
1312 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1315 #if defined(SVR4) || defined(LINUXSPARC)
1321 if (entering(tcp)) {
1322 tprintf("%ld, ", tcp->u_arg[0]);
1323 printpath(tcp, tcp->u_arg[1]);
1327 if (tcp->u_arg[0] == _STAT64_VER)
1328 printstat64 (tcp, tcp->u_arg[2]);
1331 printstat(tcp, tcp->u_arg[2]);
1341 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1344 if (tcp->u_arg[0] == _STAT64_VER)
1345 printstat64 (tcp, tcp->u_arg[2]);
1348 printstat(tcp, tcp->u_arg[2]);
1357 if (entering(tcp)) {
1358 tprintf("%ld, ", tcp->u_arg[0]);
1359 printpath(tcp, tcp->u_arg[1]);
1363 if (tcp->u_arg[0] == _STAT64_VER)
1364 printstat64 (tcp, tcp->u_arg[2]);
1367 printstat(tcp, tcp->u_arg[2]);
1376 int mode = tcp->u_arg[2];
1378 if (entering(tcp)) {
1379 tprintf("%ld, ", tcp->u_arg[0]);
1380 printpath(tcp, tcp->u_arg[1]);
1381 tprintf(", %s", sprintmode(mode));
1382 switch (mode & S_IFMT) {
1383 case S_IFCHR: case S_IFBLK:
1385 tprintf(", makedev(%lu, %lu)",
1386 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1387 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1389 tprintf(", makedev(%lu, %lu)",
1390 (unsigned long) major(tcp->u_arg[3]),
1391 (unsigned long) minor(tcp->u_arg[3]));
1401 #ifdef HAVE_SYS_ACL_H
1403 #include <sys/acl.h>
1405 static const struct xlat aclcmds[] = {
1407 { SETACL, "SETACL" },
1410 { GETACL, "GETACL" },
1413 { GETACLCNT, "GETACLCNT" },
1416 { ACL_GET, "ACL_GET" },
1419 { ACL_SET, "ACL_SET" },
1422 { ACL_CNT, "ACL_CNT" },
1431 if (entering(tcp)) {
1432 printpath(tcp, tcp->u_arg[0]);
1434 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1435 tprintf(", %ld", tcp->u_arg[2]);
1437 * FIXME - dump out the list of aclent_t's pointed to
1438 * by "tcp->u_arg[3]" if it's not NULL.
1441 tprintf(", %#lx", tcp->u_arg[3]);
1453 if (entering(tcp)) {
1454 tprintf("%ld, ", tcp->u_arg[0]);
1455 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1456 tprintf(", %ld", tcp->u_arg[2]);
1458 * FIXME - dump out the list of aclent_t's pointed to
1459 * by "tcp->u_arg[3]" if it's not NULL.
1462 tprintf(", %#lx", tcp->u_arg[3]);
1470 static const struct xlat aclipc[] = {
1472 { IPC_SHM, "IPC_SHM" },
1475 { IPC_SEM, "IPC_SEM" },
1478 { IPC_MSG, "IPC_MSG" },
1488 if (entering(tcp)) {
1489 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1490 tprintf(", %#lx, ", tcp->u_arg[1]);
1491 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1492 tprintf(", %ld", tcp->u_arg[3]);
1494 * FIXME - dump out the list of aclent_t's pointed to
1495 * by "tcp->u_arg[4]" if it's not NULL.
1498 tprintf(", %#lx", tcp->u_arg[4]);
1507 #endif /* HAVE_SYS_ACL_H */
1509 #endif /* SVR4 || LINUXSPARC */
1513 static const struct xlat fsmagic[] = {
1514 { 0x73757245, "CODA_SUPER_MAGIC" },
1515 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1516 { 0x1373, "DEVFS_SUPER_MAGIC" },
1517 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1518 { 0x414A53, "EFS_SUPER_MAGIC" },
1519 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1520 { 0xef53, "EXT2_SUPER_MAGIC" },
1521 { 0x137d, "EXT_SUPER_MAGIC" },
1522 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1523 { 0x9660, "ISOFS_SUPER_MAGIC" },
1524 { 0x137f, "MINIX_SUPER_MAGIC" },
1525 { 0x138f, "MINIX_SUPER_MAGIC2" },
1526 { 0x2468, "MINIX2_SUPER_MAGIC" },
1527 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1528 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1529 { 0x564c, "NCP_SUPER_MAGIC" },
1530 { 0x6969, "NFS_SUPER_MAGIC" },
1531 { 0x9fa0, "PROC_SUPER_MAGIC" },
1532 { 0x002f, "QNX4_SUPER_MAGIC" },
1533 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1534 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1535 { 0x517b, "SMB_SUPER_MAGIC" },
1536 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1537 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1538 { 0x00011954, "UFS_MAGIC" },
1539 { 0x54190100, "UFS_CIGAM" },
1540 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1541 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1542 { 0x62656572, "SYSFS_MAGIC" },
1554 static char buf[32];
1558 s = xlookup(fsmagic, magic);
1560 sprintf(buf, "\"%s\"", s);
1564 sprintf(buf, "%#x", magic);
1569 printstatfs(tcp, addr)
1573 struct statfs statbuf;
1575 if (syserror(tcp) || !verbose(tcp)) {
1576 tprintf("%#lx", addr);
1579 if (umove(tcp, addr, &statbuf) < 0) {
1585 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1586 sprintfstype(statbuf.f_type),
1587 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1588 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1589 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1590 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1593 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1594 sprintfstype(statbuf.f_type),
1595 (unsigned long)statbuf.f_bsize,
1596 (unsigned long)statbuf.f_blocks,
1597 (unsigned long)statbuf.f_bfree);
1598 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1599 (unsigned long)statbuf.f_bavail,
1600 (unsigned long)statbuf.f_files,
1601 (unsigned long)statbuf.f_ffree,
1602 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1604 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1607 #ifdef _STATFS_F_FRSIZE
1608 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1617 if (entering(tcp)) {
1618 printpath(tcp, tcp->u_arg[0]);
1621 printstatfs(tcp, tcp->u_arg[1]);
1630 if (entering(tcp)) {
1631 tprintf("%lu, ", tcp->u_arg[0]);
1633 printstatfs(tcp, tcp->u_arg[1]);
1640 printstatfs64(tcp, addr)
1644 struct statfs64 statbuf;
1646 if (syserror(tcp) || !verbose(tcp)) {
1647 tprintf("%#lx", addr);
1650 if (umove(tcp, addr, &statbuf) < 0) {
1654 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
1655 sprintfstype(statbuf.f_type),
1656 (unsigned long long)statbuf.f_bsize,
1657 (unsigned long long)statbuf.f_blocks,
1658 (unsigned long long)statbuf.f_bfree);
1659 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1660 (unsigned long long)statbuf.f_bavail,
1661 (unsigned long long)statbuf.f_files,
1662 (unsigned long long)statbuf.f_ffree,
1663 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1664 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1665 #ifdef _STATFS_F_FRSIZE
1666 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
1675 if (entering(tcp)) {
1676 printpath(tcp, tcp->u_arg[0]);
1677 tprintf(", %lu, ", tcp->u_arg[1]);
1679 if (tcp->u_arg[1] == sizeof (struct statfs64))
1680 printstatfs64(tcp, tcp->u_arg[2]);
1691 if (entering(tcp)) {
1692 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1694 if (tcp->u_arg[1] == sizeof (struct statfs64))
1695 printstatfs64(tcp, tcp->u_arg[2]);
1703 #if defined(LINUX) && defined(__alpha)
1709 if (entering(tcp)) {
1710 printpath(tcp, tcp->u_arg[0]);
1713 printstatfs(tcp, tcp->u_arg[1]);
1714 tprintf(", %lu", tcp->u_arg[2]);
1723 if (entering(tcp)) {
1724 tprintf("%lu, ", tcp->u_arg[0]);
1726 printstatfs(tcp, tcp->u_arg[1]);
1727 tprintf(", %lu", tcp->u_arg[2]);
1731 #endif /* LINUX && __alpha */
1741 struct ustat statbuf;
1743 if (entering(tcp)) {
1744 tprintf("makedev(%lu, %lu), ",
1745 (long) major(tcp->u_arg[0]),
1746 (long) minor(tcp->u_arg[0]));
1749 if (syserror(tcp) || !verbose(tcp))
1750 tprintf("%#lx", tcp->u_arg[1]);
1751 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1754 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1755 statbuf.f_tfree, statbuf.f_tinode);
1756 tprintf("f_fname=\"%.*s\", ",
1757 (int) sizeof(statbuf.f_fname),
1759 tprintf("f_fpack=\"%.*s\"}",
1760 (int) sizeof(statbuf.f_fpack),
1773 if (entering(tcp)) {
1774 printpath(tcp, tcp->u_arg[0]);
1776 printpath(tcp, tcp->u_arg[1]);
1787 if (entering(tcp)) {
1788 printpath(tcp, tcp->u_arg[0]);
1794 decode_mkdir(struct tcb *tcp, int offset)
1796 if (entering(tcp)) {
1797 printpath(tcp, tcp->u_arg[offset]);
1798 tprintf(", %#lo", tcp->u_arg[offset + 1]);
1804 sys_mkdir(struct tcb *tcp)
1806 return decode_mkdir(tcp, 0);
1811 sys_mkdirat(struct tcb *tcp)
1814 print_dirfd(tcp->u_arg[0]);
1815 return decode_mkdir(tcp, 1);
1823 if (entering(tcp)) {
1824 printpath(tcp, tcp->u_arg[0]);
1833 if (entering(tcp)) {
1834 tprintf("%ld", tcp->u_arg[0]);
1843 if (entering(tcp)) {
1844 printpath(tcp, tcp->u_arg[0]);
1849 #if defined(SUNOS4) || defined(SVR4)
1854 if (entering(tcp)) {
1855 tprintf("%ld", tcp->u_arg[0]);
1859 #endif /* SUNOS4 || SVR4 */
1865 if (entering(tcp)) {
1866 printpath(tcp, tcp->u_arg[0]);
1868 printpath(tcp, tcp->u_arg[1]);
1875 sys_linkat(struct tcb *tcp)
1877 if (entering(tcp)) {
1878 print_dirfd(tcp->u_arg[0]);
1879 printpath(tcp, tcp->u_arg[1]);
1881 print_dirfd(tcp->u_arg[2]);
1882 printpath(tcp, tcp->u_arg[3]);
1883 tprintf(", %ld", tcp->u_arg[4]);
1893 if (entering(tcp)) {
1894 printpath(tcp, tcp->u_arg[0]);
1900 static const struct xlat unlinkatflags[] = {
1901 #ifndef AT_REMOVEDIR
1902 # define AT_REMOVEDIR 0x200
1904 { AT_REMOVEDIR, "AT_REMOVEDIR" },
1909 sys_unlinkat(struct tcb *tcp)
1911 if (entering(tcp)) {
1912 print_dirfd(tcp->u_arg[0]);
1913 printpath(tcp, tcp->u_arg[1]);
1915 printflags(unlinkatflags, tcp->u_arg[2], "AT_???");
1925 if (entering(tcp)) {
1926 printpath(tcp, tcp->u_arg[0]);
1928 printpath(tcp, tcp->u_arg[1]);
1935 sys_symlinkat(struct tcb *tcp)
1937 if (entering(tcp)) {
1938 printpath(tcp, tcp->u_arg[0]);
1940 print_dirfd(tcp->u_arg[1]);
1941 printpath(tcp, tcp->u_arg[2]);
1948 decode_readlink(struct tcb *tcp, int offset)
1950 if (entering(tcp)) {
1951 printpath(tcp, tcp->u_arg[offset]);
1955 tprintf("%#lx", tcp->u_arg[offset + 1]);
1957 printpathn(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
1958 tprintf(", %lu", tcp->u_arg[offset + 2]);
1964 sys_readlink(struct tcb *tcp)
1966 return decode_readlink(tcp, 0);
1971 sys_readlinkat(struct tcb *tcp)
1974 print_dirfd(tcp->u_arg[0]);
1975 return decode_readlink(tcp, 1);
1983 if (entering(tcp)) {
1984 printpath(tcp, tcp->u_arg[0]);
1986 printpath(tcp, tcp->u_arg[1]);
1993 sys_renameat(struct tcb *tcp)
1995 if (entering(tcp)) {
1996 print_dirfd(tcp->u_arg[0]);
1997 printpath(tcp, tcp->u_arg[1]);
1999 print_dirfd(tcp->u_arg[2]);
2000 printpath(tcp, tcp->u_arg[3]);
2010 if (entering(tcp)) {
2011 printpath(tcp, tcp->u_arg[0]);
2012 printuid(", ", tcp->u_arg[1]);
2013 printuid(", ", tcp->u_arg[2]);
2020 sys_fchownat(struct tcb *tcp)
2022 if (entering(tcp)) {
2023 print_dirfd(tcp->u_arg[0]);
2024 printpath(tcp, tcp->u_arg[1]);
2025 printuid(", ", tcp->u_arg[2]);
2026 printuid(", ", tcp->u_arg[3]);
2028 printflags(fstatatflags, tcp->u_arg[4], "AT_???");
2038 if (entering(tcp)) {
2039 tprintf("%ld", tcp->u_arg[0]);
2040 printuid(", ", tcp->u_arg[1]);
2041 printuid(", ", tcp->u_arg[2]);
2047 decode_chmod(struct tcb *tcp, int offset)
2049 if (entering(tcp)) {
2050 printpath(tcp, tcp->u_arg[offset]);
2051 tprintf(", %#lo", tcp->u_arg[offset + 1]);
2057 sys_chmod(struct tcb *tcp)
2059 return decode_chmod(tcp, 0);
2064 sys_fchmodat(struct tcb *tcp)
2067 print_dirfd(tcp->u_arg[0]);
2068 return decode_chmod(tcp, 1);
2076 if (entering(tcp)) {
2077 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
2087 if (entering(tcp)) {
2088 printpath(tcp, tcp->u_arg[0]);
2090 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
2097 decode_utimes(struct tcb *tcp, int offset)
2099 if (entering(tcp)) {
2100 printpath(tcp, tcp->u_arg[offset]);
2102 printtv(tcp, tcp->u_arg[offset + 1]);
2108 sys_utimes(struct tcb *tcp)
2110 return decode_utimes(tcp, 0);
2115 sys_futimesat(struct tcb *tcp)
2118 print_dirfd(tcp->u_arg[0]);
2119 return decode_utimes(tcp, 1);
2129 if (entering(tcp)) {
2130 printpath(tcp, tcp->u_arg[0]);
2134 else if (!verbose(tcp))
2135 tprintf("%#lx", tcp->u_arg[1]);
2136 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
2140 tprintf("[%s,", sprinttime(ut[0]));
2141 tprintf(" %s]", sprinttime(ut[1]));
2148 decode_mknod(struct tcb *tcp, int offset)
2150 int mode = tcp->u_arg[offset + 1];
2152 if (entering(tcp)) {
2153 printpath(tcp, tcp->u_arg[offset]);
2154 tprintf(", %s", sprintmode(mode));
2155 switch (mode & S_IFMT) {
2156 case S_IFCHR: case S_IFBLK:
2158 if (current_personality == 1)
2159 tprintf(", makedev(%lu, %lu)",
2160 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
2161 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
2164 tprintf(", makedev(%lu, %lu)",
2165 (unsigned long) major(tcp->u_arg[offset + 2]),
2166 (unsigned long) minor(tcp->u_arg[offset + 2]));
2176 sys_mknod(struct tcb *tcp)
2178 return decode_mknod(tcp, 0);
2183 sys_mknodat(struct tcb *tcp)
2186 print_dirfd(tcp->u_arg[0]);
2187 return decode_mknod(tcp, 1);
2196 if (entering(tcp)) {
2197 printpath(tcp, tcp->u_arg[0]);
2198 tprintf(", %#lo", tcp->u_arg[1]);
2202 #endif /* FREEBSD */
2208 if (entering(tcp)) {
2209 tprintf("%ld", tcp->u_arg[0]);
2223 if (!verbose(tcp)) {
2224 tprintf("%#lx", addr);
2227 if (umove(tcp, addr, &d) < 0) {
2231 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
2233 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
2241 if (entering(tcp)) {
2242 tprintf("%lu, ", tcp->u_arg[0]);
2244 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
2245 tprintf("%#lx", tcp->u_arg[1]);
2247 printdir(tcp, tcp->u_arg[1]);
2248 /* Not much point in printing this out, it is always 1. */
2249 if (tcp->u_arg[2] != 1)
2250 tprintf(", %lu", tcp->u_arg[2]);
2257 #if defined FREEBSD || defined LINUX
2258 static const struct xlat direnttypes[] = {
2259 { DT_UNKNOWN, "DT_UNKNOWN" },
2260 { DT_FIFO, "DT_FIFO" },
2261 { DT_CHR, "DT_CHR" },
2262 { DT_DIR, "DT_DIR" },
2263 { DT_BLK, "DT_BLK" },
2264 { DT_REG, "DT_REG" },
2265 { DT_LNK, "DT_LNK" },
2266 { DT_SOCK, "DT_SOCK" },
2267 { DT_WHT, "DT_WHT" },
2277 int i, len, dents = 0;
2280 if (entering(tcp)) {
2281 tprintf("%lu, ", tcp->u_arg[0]);
2284 if (syserror(tcp) || !verbose(tcp)) {
2285 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2289 if ((buf = malloc(len)) == NULL) {
2290 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2291 fprintf(stderr, "out of memory\n");
2294 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2295 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2301 for (i = 0; i < len;) {
2302 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2305 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2306 i ? " " : "", d->d_ino, d->d_off);
2307 tprintf("d_reclen=%u, d_name=\"%s\"}",
2308 d->d_reclen, d->d_name);
2313 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2315 (unsigned long) d->d_ino,
2316 (unsigned long) d->d_off);
2317 tprintf("d_reclen=%u, d_name=\"%s\"}",
2318 d->d_reclen, d->d_name);
2323 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2324 i ? " " : "", d->d_off, d->d_fileno,
2326 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2327 d->d_namlen, d->d_namlen, d->d_name);
2332 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2333 i ? " " : "", d->d_fileno, d->d_reclen);
2334 printxval(direnttypes, d->d_type, "DT_???");
2335 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2336 d->d_namlen, d->d_namlen, d->d_name);
2338 #endif /* FREEBSD */
2340 tprintf("/* d_reclen == 0, problem here */");
2349 tprintf("/* %u entries */", dents);
2350 tprintf(", %lu", tcp->u_arg[2]);
2356 #if _LFS64_LARGEFILE
2361 int i, len, dents = 0;
2364 if (entering(tcp)) {
2365 tprintf("%lu, ", tcp->u_arg[0]);
2368 if (syserror(tcp) || !verbose(tcp)) {
2369 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2373 if ((buf = malloc(len)) == NULL) {
2374 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2375 fprintf(stderr, "out of memory\n");
2378 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2379 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2385 for (i = 0; i < len;) {
2386 struct dirent64 *d = (struct dirent64 *) &buf[i];
2387 #if defined(LINUX) || defined(SVR4)
2389 tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ",
2395 printxval(direnttypes, d->d_type, "DT_???");
2398 tprintf("d_reclen=%u, d_name=\"%s\"}",
2399 d->d_reclen, d->d_name);
2401 #endif /* LINUX || SVR4 */
2404 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2405 i ? " " : "", d->d_off, d->d_fileno,
2407 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2408 d->d_namlen, d->d_namlen, d->d_name);
2417 tprintf("/* %u entries */", dents);
2418 tprintf(", %lu", tcp->u_arg[2]);
2426 sys_getdirentries(tcp)
2429 int i, len, dents = 0;
2433 if (entering(tcp)) {
2434 tprintf("%lu, ", tcp->u_arg[0]);
2437 if (syserror(tcp) || !verbose(tcp)) {
2438 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2442 if ((buf = malloc(len)) == NULL) {
2443 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2444 fprintf(stderr, "out of memory\n");
2447 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2448 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2454 for (i = 0; i < len;) {
2455 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2457 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2458 i ? " " : "", d->d_fileno, d->d_reclen);
2459 printxval(direnttypes, d->d_type, "DT_???");
2460 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2461 d->d_namlen, d->d_namlen, d->d_name);
2469 tprintf("/* %u entries */", dents);
2471 tprintf(", %lu", tcp->u_arg[2]);
2472 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2473 tprintf(", %#lx", tcp->u_arg[3]);
2475 tprintf(", [%lu]", basep);
2487 tprintf("%#lx", tcp->u_arg[0]);
2489 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2490 tprintf(", %lu", tcp->u_arg[1]);
2503 tprintf("%#lx", tcp->u_arg[0]);
2505 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2506 tprintf(", %lu", tcp->u_arg[1]);
2512 #ifdef HAVE_SYS_ASYNCH_H
2518 struct aio_result_t res;
2520 if (entering(tcp)) {
2521 tprintf("%lu, ", tcp->u_arg[0]);
2524 tprintf("%#lx", tcp->u_arg[1]);
2526 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2527 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2528 printxval(whence, tcp->u_arg[4], "L_???");
2529 if (syserror(tcp) || tcp->u_arg[5] == 0
2530 || umove(tcp, tcp->u_arg[5], &res) < 0)
2531 tprintf(", %#lx", tcp->u_arg[5]);
2533 tprintf(", {aio_return %d aio_errno %d}",
2534 res.aio_return, res.aio_errno);
2543 struct aio_result_t res;
2545 if (entering(tcp)) {
2546 tprintf("%lu, ", tcp->u_arg[0]);
2547 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2548 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2549 printxval(whence, tcp->u_arg[4], "L_???");
2552 if (tcp->u_arg[5] == 0)
2554 else if (syserror(tcp)
2555 || umove(tcp, tcp->u_arg[5], &res) < 0)
2556 tprintf(", %#lx", tcp->u_arg[5]);
2558 tprintf(", {aio_return %d aio_errno %d}",
2559 res.aio_return, res.aio_errno);
2569 printtv(tcp, tcp->u_arg[0]);
2577 struct aio_result_t res;
2580 if (tcp->u_arg[0] == 0)
2582 else if (syserror(tcp)
2583 || umove(tcp, tcp->u_arg[0], &res) < 0)
2584 tprintf("%#lx", tcp->u_arg[0]);
2586 tprintf("{aio_return %d aio_errno %d}",
2587 res.aio_return, res.aio_errno);
2592 #endif /* HAVE_SYS_ASYNCH_H */
2594 static const struct xlat xattrflags[] = {
2596 { XATTR_CREATE, "XATTR_CREATE" },
2597 { XATTR_REPLACE, "XATTR_REPLACE" },
2603 print_xattr_val(tcp, failed, arg, insize, size)
2607 unsigned long insize, size;
2610 unsigned long capacity = 4 * size + 1;
2611 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
2612 if (buf == NULL || /* probably a bogus size argument */
2613 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2617 unsigned char *out = buf;
2618 unsigned char *in = &buf[3 * size];
2620 for (i = 0; i < size; ++i)
2624 #define tohex(n) "0123456789abcdef"[n]
2627 *out++ = tohex(in[i] / 16);
2628 *out++ = tohex(in[i] % 16);
2630 /* Don't print terminating NUL if there is one. */
2631 if (i > 0 && in[i - 1] == '\0')
2634 tprintf(", \"%s\", %ld", buf, insize);
2639 tprintf(", 0x%lx, %ld", arg, insize);
2646 if (entering(tcp)) {
2647 printpath(tcp, tcp->u_arg[0]);
2649 printstr(tcp, tcp->u_arg[1], -1);
2650 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2652 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2661 if (entering(tcp)) {
2662 tprintf("%ld, ", tcp->u_arg[0]);
2663 printstr(tcp, tcp->u_arg[1], -1);
2664 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2666 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2675 if (entering(tcp)) {
2676 printpath(tcp, tcp->u_arg[0]);
2678 printstr(tcp, tcp->u_arg[1], -1);
2680 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2690 if (entering(tcp)) {
2691 tprintf("%ld, ", tcp->u_arg[0]);
2692 printstr(tcp, tcp->u_arg[1], -1);
2694 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2704 if (entering(tcp)) {
2705 printpath(tcp, tcp->u_arg[0]);
2707 /* XXX Print value in format */
2708 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2717 if (entering(tcp)) {
2718 tprintf("%ld", tcp->u_arg[0]);
2720 /* XXX Print value in format */
2721 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2727 sys_removexattr(tcp)
2730 if (entering(tcp)) {
2731 printpath(tcp, tcp->u_arg[0]);
2733 printstr(tcp, tcp->u_arg[1], -1);
2739 sys_fremovexattr(tcp)
2742 if (entering(tcp)) {
2743 tprintf("%ld, ", tcp->u_arg[0]);
2744 printstr(tcp, tcp->u_arg[1], -1);
2750 static const struct xlat advise[] = {
2751 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2752 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2753 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2754 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2755 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2756 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2766 if (entering(tcp)) {
2767 tprintf("%ld, %lld, %ld, ",
2769 # if defined IA64 || defined X86_64 || defined ALPHA
2770 (long long int) tcp->u_arg[1], tcp->u_arg[2]);
2771 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2773 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]);
2774 printxval(advise, tcp->u_arg[4], "POSIX_FADV_???");
2783 sys_fadvise64_64(tcp)
2786 if (entering(tcp)) {
2787 tprintf("%ld, %lld, %lld, ",
2789 # if defined IA64 || defined X86_64 || defined ALPHA
2790 (long long int) tcp->u_arg[1], (long long int) tcp->u_arg[2]);
2791 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2793 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]),
2794 LONG_LONG(tcp->u_arg[3], tcp->u_arg[4]));
2795 printxval(advise, tcp->u_arg[5], "POSIX_FADV_???");
2802 static const struct xlat inotify_modes[] = {
2803 { 0x00000001, "IN_ACCESS" },
2804 { 0x00000002, "IN_MODIFY" },
2805 { 0x00000004, "IN_ATTRIB" },
2806 { 0x00000008, "IN_CLOSE_WRITE" },
2807 { 0x00000010, "IN_CLOSE_NOWRITE" },
2808 { 0x00000020, "IN_OPEN" },
2809 { 0x00000040, "IN_MOVED_FROM" },
2810 { 0x00000080, "IN_MOVED_TO" },
2811 { 0x00000100, "IN_CREATE" },
2812 { 0x00000200, "IN_DELETE" },
2813 { 0x00000400, "IN_DELETE_SELF" },
2814 { 0x00000800, "IN_MOVE_SELF" },
2815 { 0x00002000, "IN_UNMOUNT" },
2816 { 0x00004000, "IN_Q_OVERFLOW" },
2817 { 0x00008000, "IN_IGNORED" },
2818 { 0x01000000, "IN_ONLYDIR" },
2819 { 0x02000000, "IN_DONT_FOLLOW" },
2820 { 0x20000000, "IN_MASK_ADD" },
2821 { 0x40000000, "IN_ISDIR" },
2822 { 0x80000000, "IN_ONESHOT" }
2826 sys_inotify_add_watch(struct tcb *tcp)
2828 if (entering(tcp)) {
2829 tprintf("%ld, ", tcp->u_arg[0]);
2830 printpath(tcp, tcp->u_arg[1]);
2832 printflags(inotify_modes, tcp->u_arg[2], "IN_???");
2838 sys_inotify_rm_watch(struct tcb *tcp)
2840 if (entering(tcp)) {
2841 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);