2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 struct kernel_dirent {
41 unsigned short d_reclen;
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" },
241 #if defined(O_NDELAY) && (O_NDELAY != O_NONBLOCK)
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" },
273 { O_CLOEXEC, "O_CLOEXEC" },
276 { FNDELAY, "FNDELAY" },
279 { FAPPEND, "FAPPEND" },
285 { FDEFER, "FDEFER" },
288 { FASYNC, "FASYNC" },
291 { FSHLOCK, "FSHLOCK" },
294 { FEXLOCK, "FEXLOCK" },
297 { FCREAT, "FCREAT" },
300 { FTRUNC, "FTRUNC" },
312 { FNOCTTY, "FNOCTTY" },
315 { O_SHLOCK, "O_SHLOCK" },
318 { O_EXLOCK, "O_EXLOCK" },
326 # define AT_FDCWD -100
329 /* The fd is an "int", so when decoding x86 on x86_64, we need to force sign
330 * extension to get the right value. We do this by declaring fd as int here.
333 print_dirfd(struct tcb *tcp, int fd)
336 tprints("AT_FDCWD, ");
345 * low bits of the open(2) flags define access mode,
346 * other bits are real flags.
349 sprint_open_modes(mode_t flags)
351 static char outstr[(1 + ARRAY_SIZE(open_mode_flags)) * sizeof("O_LARGEFILE")];
355 const struct xlat *x;
358 p = stpcpy(outstr, "flags");
359 str = xlookup(open_access_modes, flags & 3);
369 for (x = open_mode_flags; x->str; x++) {
370 if ((flags & x->val) == x->val) {
372 p = stpcpy(p, x->str);
379 /* flags is still nonzero */
381 sprintf(p, "%#x", flags);
386 tprint_open_modes(mode_t flags)
388 tprints(sprint_open_modes(flags) + sizeof("flags"));
392 decode_open(struct tcb *tcp, int offset)
395 printpath(tcp, tcp->u_arg[offset]);
398 tprint_open_modes(tcp->u_arg[offset + 1]);
399 if (tcp->u_arg[offset + 1] & O_CREAT) {
401 tprintf(", %#lo", tcp->u_arg[offset + 2]);
408 sys_open(struct tcb *tcp)
410 return decode_open(tcp, 0);
415 sys_openat(struct tcb *tcp)
418 print_dirfd(tcp, tcp->u_arg[0]);
419 return decode_open(tcp, 1);
424 static const struct xlat openmodessol[] = {
428 { 0x80, "O_NONBLOCK" },
430 { 0x100, "O_CREAT" },
431 { 0x200, "O_TRUNC" },
433 { 0x800, "O_NOCTTY" },
436 { 0x8000, "O_RSYNC" },
438 { 0x1000, "O_PRIV" },
443 solaris_open(struct tcb *tcp)
446 printpath(tcp, tcp->u_arg[0]);
449 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
450 if (tcp->u_arg[1] & 0x100) {
452 tprintf(", %#lo", tcp->u_arg[2]);
461 sys_creat(struct tcb *tcp)
464 printpath(tcp, tcp->u_arg[0]);
465 tprintf(", %#lo", tcp->u_arg[1]);
470 static const struct xlat access_flags[] = {
476 { EFF_ONLY_OK, "EFF_ONLY_OK" },
485 decode_access(struct tcb *tcp, int offset)
488 printpath(tcp, tcp->u_arg[offset]);
490 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK");
496 sys_access(struct tcb *tcp)
498 return decode_access(tcp, 0);
503 sys_faccessat(struct tcb *tcp)
506 print_dirfd(tcp, tcp->u_arg[0]);
507 return decode_access(tcp, 1);
512 sys_umask(struct tcb *tcp)
515 tprintf("%#lo", tcp->u_arg[0]);
520 static const struct xlat whence[] = {
521 { SEEK_SET, "SEEK_SET" },
522 { SEEK_CUR, "SEEK_CUR" },
523 { SEEK_END, "SEEK_END" },
527 #ifndef HAVE_LONG_LONG_OFF_T
528 #if defined (LINUX_MIPSN32)
530 sys_lseek(struct tcb *tcp)
536 printfd(tcp, tcp->u_arg[0]);
538 offset = tcp->ext_arg[1];
539 _whence = tcp->u_arg[2];
540 if (_whence == SEEK_SET)
541 tprintf("%llu, ", offset);
543 tprintf("%lld, ", offset);
544 printxval(whence, _whence, "SEEK_???");
546 return RVAL_UDECIMAL;
548 #else /* !LINUX_MIPSN32 */
550 sys_lseek(struct tcb *tcp)
556 printfd(tcp, tcp->u_arg[0]);
558 offset = tcp->u_arg[1];
559 _whence = tcp->u_arg[2];
560 if (_whence == SEEK_SET)
561 tprintf("%lu, ", offset);
563 tprintf("%ld, ", offset);
564 printxval(whence, _whence, "SEEK_???");
566 return RVAL_UDECIMAL;
568 #endif /* LINUX_MIPSN32 */
573 sys_llseek(struct tcb *tcp)
576 printfd(tcp, tcp->u_arg[0]);
578 * This one call takes explicitly two 32-bit arguments hi, lo,
579 * rather than one 64-bit argument for which LONG_LONG works
580 * appropriate for the native byte order.
582 if (tcp->u_arg[4] == SEEK_SET)
584 ((long long int) tcp->u_arg[1]) << 32 |
585 (unsigned long long) (unsigned) tcp->u_arg[2]);
588 ((long long int) tcp->u_arg[1]) << 32 |
589 (unsigned long long) (unsigned) tcp->u_arg[2]);
593 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
594 tprintf("%#lx, ", tcp->u_arg[3]);
596 tprintf("[%llu], ", off);
597 printxval(whence, tcp->u_arg[4], "SEEK_???");
603 sys_readahead(struct tcb *tcp)
607 printfd(tcp, tcp->u_arg[0]);
609 argn = printllval(tcp, "%lld", 1);
610 tprintf(", %ld", tcp->u_arg[argn]);
616 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
618 sys_lseek64(struct tcb *tcp)
622 printfd(tcp, tcp->u_arg[0]);
624 if (tcp->u_arg[3] == SEEK_SET)
625 argn = printllval(tcp, "%llu, ", 1);
627 argn = printllval(tcp, "%lld, ", 1);
628 printxval(whence, tcp->u_arg[argn], "SEEK_???");
630 return RVAL_LUDECIMAL;
634 #ifndef HAVE_LONG_LONG_OFF_T
636 sys_truncate(struct tcb *tcp)
639 printpath(tcp, tcp->u_arg[0]);
640 tprintf(", %lu", tcp->u_arg[1]);
646 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
648 sys_truncate64(struct tcb *tcp)
651 printpath(tcp, tcp->u_arg[0]);
652 printllval(tcp, ", %llu", 1);
658 #ifndef HAVE_LONG_LONG_OFF_T
660 sys_ftruncate(struct tcb *tcp)
663 printfd(tcp, tcp->u_arg[0]);
664 tprintf(", %lu", tcp->u_arg[1]);
670 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
672 sys_ftruncate64(struct tcb *tcp)
675 printfd(tcp, tcp->u_arg[0]);
677 printllval(tcp, "%llu", 1);
685 static const struct xlat modetypes[] = {
686 { S_IFREG, "S_IFREG" },
687 { S_IFSOCK, "S_IFSOCK" },
688 { S_IFIFO, "S_IFIFO" },
689 { S_IFLNK, "S_IFLNK" },
690 { S_IFDIR, "S_IFDIR" },
691 { S_IFBLK, "S_IFBLK" },
692 { S_IFCHR, "S_IFCHR" },
702 if ((mode & S_IFMT) == 0)
704 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
705 sprintf(buf, "%#o", mode);
708 sprintf(buf, "%s%s%s%s", s,
709 (mode & S_ISUID) ? "|S_ISUID" : "",
710 (mode & S_ISGID) ? "|S_ISGID" : "",
711 (mode & S_ISVTX) ? "|S_ISVTX" : "");
712 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
714 sprintf(buf + strlen(buf), "|%#o", mode);
715 s = (*buf == '|') ? buf + 1 : buf;
731 snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d",
732 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
733 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
735 snprintf(buf, sizeof buf, "%lu", (unsigned long) t);
748 int st_pad1[3]; /* network id */
757 int st_pad3; /* st_size, off_t expansion */
758 timestruct_t st_atime;
759 timestruct_t st_mtime;
760 timestruct_t st_ctime;
764 int st_pad4[8]; /* expansion area */
768 printstatsol(struct tcb *tcp, long addr)
770 struct solstat statbuf;
772 if (umove(tcp, addr, &statbuf) < 0) {
777 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
778 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
779 (unsigned long) (statbuf.st_dev & 0x3ffff),
780 (unsigned long) statbuf.st_ino,
781 sprintmode(statbuf.st_mode));
782 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
783 (unsigned long) statbuf.st_nlink,
784 (unsigned long) statbuf.st_uid,
785 (unsigned long) statbuf.st_gid);
786 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
787 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
790 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
791 switch (statbuf.st_mode & S_IFMT) {
792 case S_IFCHR: case S_IFBLK:
793 tprintf("st_rdev=makedev(%lu, %lu), ",
794 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
795 (unsigned long) (statbuf.st_rdev & 0x3ffff));
798 tprintf("st_size=%u, ", statbuf.st_size);
802 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
803 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
804 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
810 #if defined (SPARC64)
812 printstat_sparc64(struct tcb *tcp, long addr)
814 struct stat_sparc64 statbuf;
816 if (umove(tcp, addr, &statbuf) < 0) {
822 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
823 (unsigned long) major(statbuf.st_dev),
824 (unsigned long) minor(statbuf.st_dev),
825 (unsigned long) statbuf.st_ino,
826 sprintmode(statbuf.st_mode));
827 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
828 (unsigned long) statbuf.st_nlink,
829 (unsigned long) statbuf.st_uid,
830 (unsigned long) statbuf.st_gid);
831 tprintf("st_blksize=%lu, ",
832 (unsigned long) statbuf.st_blksize);
833 tprintf("st_blocks=%lu, ",
834 (unsigned long) statbuf.st_blocks);
837 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
838 switch (statbuf.st_mode & S_IFMT) {
839 case S_IFCHR: case S_IFBLK:
840 tprintf("st_rdev=makedev(%lu, %lu), ",
841 (unsigned long) major(statbuf.st_rdev),
842 (unsigned long) minor(statbuf.st_rdev));
845 tprintf("st_size=%lu, ", statbuf.st_size);
849 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
850 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
851 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
858 #endif /* LINUXSPARC */
860 #if defined LINUX && defined POWERPC64
861 struct stat_powerpc32 {
864 unsigned int st_mode;
865 unsigned short st_nlink;
868 unsigned int st_rdev;
869 unsigned int st_size;
870 unsigned int st_blksize;
871 unsigned int st_blocks;
872 unsigned int st_atime;
873 unsigned int st_atime_nsec;
874 unsigned int st_mtime;
875 unsigned int st_mtime_nsec;
876 unsigned int st_ctime;
877 unsigned int st_ctime_nsec;
878 unsigned int __unused4;
879 unsigned int __unused5;
883 printstat_powerpc32(struct tcb *tcp, long addr)
885 struct stat_powerpc32 statbuf;
887 if (umove(tcp, addr, &statbuf) < 0) {
893 tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ",
894 major(statbuf.st_dev), minor(statbuf.st_dev),
896 sprintmode(statbuf.st_mode));
897 tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ",
898 statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid);
899 tprintf("st_blksize=%u, ", statbuf.st_blksize);
900 tprintf("st_blocks=%u, ", statbuf.st_blocks);
903 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
904 switch (statbuf.st_mode & S_IFMT) {
905 case S_IFCHR: case S_IFBLK:
906 tprintf("st_rdev=makedev(%lu, %lu), ",
907 (unsigned long) major(statbuf.st_rdev),
908 (unsigned long) minor(statbuf.st_rdev));
911 tprintf("st_size=%u, ", statbuf.st_size);
915 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
916 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
917 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
923 #endif /* LINUX && POWERPC64 */
925 static const struct xlat fileflags[] = {
927 { UF_NODUMP, "UF_NODUMP" },
928 { UF_IMMUTABLE, "UF_IMMUTABLE" },
929 { UF_APPEND, "UF_APPEND" },
930 { UF_OPAQUE, "UF_OPAQUE" },
931 { UF_NOUNLINK, "UF_NOUNLINK" },
932 { SF_ARCHIVED, "SF_ARCHIVED" },
933 { SF_IMMUTABLE, "SF_IMMUTABLE" },
934 { SF_APPEND, "SF_APPEND" },
935 { SF_NOUNLINK, "SF_NOUNLINK" },
938 { _S_ISMLD, "_S_ISMLD" },
941 { _S_ISMOUNTED, "_S_ISMOUNTED" },
949 sys_chflags(struct tcb *tcp)
952 printpath(tcp, tcp->u_arg[0]);
954 printflags(fileflags, tcp->u_arg[1], "UF_???");
960 sys_fchflags(struct tcb *tcp)
963 tprintf("%ld, ", tcp->u_arg[0]);
964 printflags(fileflags, tcp->u_arg[1], "UF_???");
970 #ifndef HAVE_LONG_LONG_OFF_T
972 realprintstat(struct tcb *tcp, struct stat *statbuf)
975 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
976 (unsigned long) major(statbuf->st_dev),
977 (unsigned long) minor(statbuf->st_dev),
978 (unsigned long) statbuf->st_ino,
979 sprintmode(statbuf->st_mode));
980 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
981 (unsigned long) statbuf->st_nlink,
982 (unsigned long) statbuf->st_uid,
983 (unsigned long) statbuf->st_gid);
984 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
985 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
987 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
988 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
992 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
993 switch (statbuf->st_mode & S_IFMT) {
994 case S_IFCHR: case S_IFBLK:
995 #ifdef HAVE_STRUCT_STAT_ST_RDEV
996 tprintf("st_rdev=makedev(%lu, %lu), ",
997 (unsigned long) major(statbuf->st_rdev),
998 (unsigned long) minor(statbuf->st_rdev));
999 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
1000 tprintf("st_size=makedev(%lu, %lu), ",
1001 (unsigned long) major(statbuf->st_size),
1002 (unsigned long) minor(statbuf->st_size));
1003 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
1006 tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size);
1010 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
1011 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
1012 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
1013 #if HAVE_STRUCT_STAT_ST_FLAGS
1014 tprints(", st_flags=");
1015 printflags(fileflags, statbuf->st_flags, "UF_???");
1017 #if HAVE_STRUCT_STAT_ST_ACLCNT
1018 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
1020 #if HAVE_STRUCT_STAT_ST_LEVEL
1021 tprintf(", st_level=%ld", statbuf->st_level);
1023 #if HAVE_STRUCT_STAT_ST_FSTYPE
1024 tprintf(", st_fstype=%.*s",
1025 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
1027 #if HAVE_STRUCT_STAT_ST_GEN
1028 tprintf(", st_gen=%u", statbuf->st_gen);
1038 printstat(struct tcb *tcp, long addr)
1040 struct stat statbuf;
1046 if (syserror(tcp) || !verbose(tcp)) {
1047 tprintf("%#lx", addr);
1052 if (current_personality == 1) {
1053 printstatsol(tcp, addr);
1057 else if (current_personality == 2) {
1058 printstat_sparc64(tcp, addr);
1062 #endif /* LINUXSPARC */
1064 #if defined LINUX && defined POWERPC64
1065 if (current_personality == 1) {
1066 printstat_powerpc32(tcp, addr);
1071 if (umove(tcp, addr, &statbuf) < 0) {
1076 realprintstat(tcp, &statbuf);
1078 #endif /* !HAVE_LONG_LONG_OFF_T */
1080 #if !defined HAVE_STAT64 && defined LINUX && defined X86_64
1082 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
1083 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
1084 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
1085 * __GNUC__ is needed for the required __attribute__ below.
1088 unsigned long long st_dev;
1089 unsigned char __pad0[4];
1090 unsigned int __st_ino;
1091 unsigned int st_mode;
1092 unsigned int st_nlink;
1093 unsigned int st_uid;
1094 unsigned int st_gid;
1095 unsigned long long st_rdev;
1096 unsigned char __pad3[4];
1098 unsigned int st_blksize;
1099 unsigned long long st_blocks;
1100 unsigned int st_atime;
1101 unsigned int st_atime_nsec;
1102 unsigned int st_mtime;
1103 unsigned int st_mtime_nsec;
1104 unsigned int st_ctime;
1105 unsigned int st_ctime_nsec;
1106 unsigned long long st_ino;
1107 } __attribute__((packed));
1108 # define HAVE_STAT64 1
1109 # define STAT64_SIZE 96
1114 printstat64(struct tcb *tcp, long addr)
1116 struct stat64 statbuf;
1119 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
1126 if (syserror(tcp) || !verbose(tcp)) {
1127 tprintf("%#lx", addr);
1132 if (current_personality == 1) {
1133 printstatsol(tcp, addr);
1137 else if (current_personality == 2) {
1138 printstat_sparc64(tcp, addr);
1142 #endif /* LINUXSPARC */
1144 #if defined LINUX && defined X86_64
1145 if (current_personality == 0) {
1146 printstat(tcp, addr);
1151 if (umove(tcp, addr, &statbuf) < 0) {
1157 #ifdef HAVE_LONG_LONG
1158 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1160 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
1162 (unsigned long) major(statbuf.st_dev),
1163 (unsigned long) minor(statbuf.st_dev),
1164 #ifdef HAVE_LONG_LONG
1165 (unsigned long long) statbuf.st_ino,
1167 (unsigned long) statbuf.st_ino,
1169 sprintmode(statbuf.st_mode));
1170 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1171 (unsigned long) statbuf.st_nlink,
1172 (unsigned long) statbuf.st_uid,
1173 (unsigned long) statbuf.st_gid);
1174 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
1175 tprintf("st_blksize=%lu, ",
1176 (unsigned long) statbuf.st_blksize);
1177 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
1178 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
1179 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
1180 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
1183 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1184 switch (statbuf.st_mode & S_IFMT) {
1185 case S_IFCHR: case S_IFBLK:
1186 #ifdef HAVE_STRUCT_STAT_ST_RDEV
1187 tprintf("st_rdev=makedev(%lu, %lu), ",
1188 (unsigned long) major(statbuf.st_rdev),
1189 (unsigned long) minor(statbuf.st_rdev));
1190 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
1191 tprintf("st_size=makedev(%lu, %lu), ",
1192 (unsigned long) major(statbuf.st_size),
1193 (unsigned long) minor(statbuf.st_size));
1194 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
1197 #ifdef HAVE_LONG_LONG
1198 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1200 tprintf("st_size=%lu, ", (unsigned long) statbuf.st_size);
1205 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1206 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
1207 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
1208 #if HAVE_STRUCT_STAT_ST_FLAGS
1209 tprints(", st_flags=");
1210 printflags(fileflags, statbuf.st_flags, "UF_???");
1212 #if HAVE_STRUCT_STAT_ST_ACLCNT
1213 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1215 #if HAVE_STRUCT_STAT_ST_LEVEL
1216 tprintf(", st_level=%ld", statbuf.st_level);
1218 #if HAVE_STRUCT_STAT_ST_FSTYPE
1219 tprintf(", st_fstype=%.*s",
1220 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1222 #if HAVE_STRUCT_STAT_ST_GEN
1223 tprintf(", st_gen=%u", statbuf.st_gen);
1230 #endif /* HAVE_STAT64 */
1232 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT) \
1233 && !defined(HAVE_LONG_LONG_OFF_T)
1235 convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
1237 newbuf->st_dev = oldbuf->st_dev;
1238 newbuf->st_ino = oldbuf->st_ino;
1239 newbuf->st_mode = oldbuf->st_mode;
1240 newbuf->st_nlink = oldbuf->st_nlink;
1241 newbuf->st_uid = oldbuf->st_uid;
1242 newbuf->st_gid = oldbuf->st_gid;
1243 newbuf->st_rdev = oldbuf->st_rdev;
1244 newbuf->st_size = oldbuf->st_size;
1245 newbuf->st_atime = oldbuf->st_atime;
1246 newbuf->st_mtime = oldbuf->st_mtime;
1247 newbuf->st_ctime = oldbuf->st_ctime;
1248 newbuf->st_blksize = 0; /* not supported in old_stat */
1249 newbuf->st_blocks = 0; /* not supported in old_stat */
1254 printoldstat(struct tcb *tcp, long addr)
1256 struct __old_kernel_stat statbuf;
1257 struct stat newstatbuf;
1263 if (syserror(tcp) || !verbose(tcp)) {
1264 tprintf("%#lx", addr);
1269 if (current_personality == 1) {
1270 printstatsol(tcp, addr);
1273 #endif /* LINUXSPARC */
1275 if (umove(tcp, addr, &statbuf) < 0) {
1280 convertoldstat(&statbuf, &newstatbuf);
1281 realprintstat(tcp, &newstatbuf);
1283 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1285 #ifndef HAVE_LONG_LONG_OFF_T
1287 sys_stat(struct tcb *tcp)
1289 if (entering(tcp)) {
1290 printpath(tcp, tcp->u_arg[0]);
1293 printstat(tcp, tcp->u_arg[1]);
1300 sys_stat64(struct tcb *tcp)
1303 if (entering(tcp)) {
1304 printpath(tcp, tcp->u_arg[0]);
1307 printstat64(tcp, tcp->u_arg[1]);
1311 return printargs(tcp);
1316 static const struct xlat fstatatflags[] = {
1317 #ifndef AT_SYMLINK_NOFOLLOW
1318 # define AT_SYMLINK_NOFOLLOW 0x100
1320 { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" },
1323 #define utimensatflags fstatatflags
1326 sys_newfstatat(struct tcb *tcp)
1328 if (entering(tcp)) {
1329 print_dirfd(tcp, tcp->u_arg[0]);
1330 printpath(tcp, tcp->u_arg[1]);
1334 if (current_personality == 0)
1335 printstat(tcp, tcp->u_arg[2]);
1337 printstat64(tcp, tcp->u_arg[2]);
1338 #elif defined HAVE_STAT64
1339 printstat64(tcp, tcp->u_arg[2]);
1341 printstat(tcp, tcp->u_arg[2]);
1344 printflags(fstatatflags, tcp->u_arg[3], "AT_???");
1350 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT) \
1351 && !defined(HAVE_LONG_LONG_OFF_T)
1353 sys_oldstat(struct tcb *tcp)
1355 if (entering(tcp)) {
1356 printpath(tcp, tcp->u_arg[0]);
1359 printoldstat(tcp, tcp->u_arg[1]);
1363 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1365 #ifndef HAVE_LONG_LONG_OFF_T
1367 sys_fstat(struct tcb *tcp)
1369 if (entering(tcp)) {
1370 printfd(tcp, tcp->u_arg[0]);
1373 printstat(tcp, tcp->u_arg[1]);
1380 sys_fstat64(struct tcb *tcp)
1383 if (entering(tcp)) {
1384 printfd(tcp, tcp->u_arg[0]);
1387 printstat64(tcp, tcp->u_arg[1]);
1391 return printargs(tcp);
1395 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT) \
1396 && !defined(HAVE_LONG_LONG_OFF_T)
1398 sys_oldfstat(struct tcb *tcp)
1400 if (entering(tcp)) {
1401 printfd(tcp, tcp->u_arg[0]);
1404 printoldstat(tcp, tcp->u_arg[1]);
1408 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1410 #ifndef HAVE_LONG_LONG_OFF_T
1412 sys_lstat(struct tcb *tcp)
1414 if (entering(tcp)) {
1415 printpath(tcp, tcp->u_arg[0]);
1418 printstat(tcp, tcp->u_arg[1]);
1425 sys_lstat64(struct tcb *tcp)
1428 if (entering(tcp)) {
1429 printpath(tcp, tcp->u_arg[0]);
1432 printstat64(tcp, tcp->u_arg[1]);
1436 return printargs(tcp);
1440 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT) \
1441 && !defined(HAVE_LONG_LONG_OFF_T)
1443 sys_oldlstat(struct tcb *tcp)
1445 if (entering(tcp)) {
1446 printpath(tcp, tcp->u_arg[0]);
1449 printoldstat(tcp, tcp->u_arg[1]);
1453 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1456 #if defined(SVR4) || defined(LINUXSPARC)
1459 sys_xstat(struct tcb *tcp)
1461 if (entering(tcp)) {
1462 tprintf("%ld, ", tcp->u_arg[0]);
1463 printpath(tcp, tcp->u_arg[1]);
1467 if (tcp->u_arg[0] == _STAT64_VER)
1468 printstat64 (tcp, tcp->u_arg[2]);
1471 printstat(tcp, tcp->u_arg[2]);
1477 sys_fxstat(struct tcb *tcp)
1480 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1483 if (tcp->u_arg[0] == _STAT64_VER)
1484 printstat64 (tcp, tcp->u_arg[2]);
1487 printstat(tcp, tcp->u_arg[2]);
1493 sys_lxstat(struct tcb *tcp)
1495 if (entering(tcp)) {
1496 tprintf("%ld, ", tcp->u_arg[0]);
1497 printpath(tcp, tcp->u_arg[1]);
1501 if (tcp->u_arg[0] == _STAT64_VER)
1502 printstat64 (tcp, tcp->u_arg[2]);
1505 printstat(tcp, tcp->u_arg[2]);
1511 sys_xmknod(struct tcb *tcp)
1513 int mode = tcp->u_arg[2];
1515 if (entering(tcp)) {
1516 tprintf("%ld, ", tcp->u_arg[0]);
1517 printpath(tcp, tcp->u_arg[1]);
1518 tprintf(", %s", sprintmode(mode));
1519 switch (mode & S_IFMT) {
1520 case S_IFCHR: case S_IFBLK:
1522 tprintf(", makedev(%lu, %lu)",
1523 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1524 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1526 tprintf(", makedev(%lu, %lu)",
1527 (unsigned long) major(tcp->u_arg[3]),
1528 (unsigned long) minor(tcp->u_arg[3]));
1538 #ifdef HAVE_SYS_ACL_H
1540 #include <sys/acl.h>
1542 static const struct xlat aclcmds[] = {
1544 { SETACL, "SETACL" },
1547 { GETACL, "GETACL" },
1550 { GETACLCNT, "GETACLCNT" },
1553 { ACL_GET, "ACL_GET" },
1556 { ACL_SET, "ACL_SET" },
1559 { ACL_CNT, "ACL_CNT" },
1565 sys_acl(struct tcb *tcp)
1567 if (entering(tcp)) {
1568 printpath(tcp, tcp->u_arg[0]);
1570 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1571 tprintf(", %ld", tcp->u_arg[2]);
1573 * FIXME - dump out the list of aclent_t's pointed to
1574 * by "tcp->u_arg[3]" if it's not NULL.
1577 tprintf(", %#lx", tcp->u_arg[3]);
1586 sys_facl(struct tcb *tcp)
1588 if (entering(tcp)) {
1589 tprintf("%ld, ", tcp->u_arg[0]);
1590 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1591 tprintf(", %ld", tcp->u_arg[2]);
1593 * FIXME - dump out the list of aclent_t's pointed to
1594 * by "tcp->u_arg[3]" if it's not NULL.
1597 tprintf(", %#lx", tcp->u_arg[3]);
1605 static const struct xlat aclipc[] = {
1607 { IPC_SHM, "IPC_SHM" },
1610 { IPC_SEM, "IPC_SEM" },
1613 { IPC_MSG, "IPC_MSG" },
1620 sys_aclipc(struct tcb *tcp)
1622 if (entering(tcp)) {
1623 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1624 tprintf(", %#lx, ", tcp->u_arg[1]);
1625 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1626 tprintf(", %ld", tcp->u_arg[3]);
1628 * FIXME - dump out the list of aclent_t's pointed to
1629 * by "tcp->u_arg[4]" if it's not NULL.
1632 tprintf(", %#lx", tcp->u_arg[4]);
1639 #endif /* HAVE_SYS_ACL_H */
1641 #endif /* SVR4 || LINUXSPARC */
1645 static const struct xlat fsmagic[] = {
1646 { 0x73757245, "CODA_SUPER_MAGIC" },
1647 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1648 { 0x1373, "DEVFS_SUPER_MAGIC" },
1649 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1650 { 0x414A53, "EFS_SUPER_MAGIC" },
1651 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1652 { 0xef53, "EXT2_SUPER_MAGIC" },
1653 { 0x137d, "EXT_SUPER_MAGIC" },
1654 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1655 { 0x9660, "ISOFS_SUPER_MAGIC" },
1656 { 0x137f, "MINIX_SUPER_MAGIC" },
1657 { 0x138f, "MINIX_SUPER_MAGIC2" },
1658 { 0x2468, "MINIX2_SUPER_MAGIC" },
1659 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1660 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1661 { 0x564c, "NCP_SUPER_MAGIC" },
1662 { 0x6969, "NFS_SUPER_MAGIC" },
1663 { 0x9fa0, "PROC_SUPER_MAGIC" },
1664 { 0x002f, "QNX4_SUPER_MAGIC" },
1665 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1666 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1667 { 0x517b, "SMB_SUPER_MAGIC" },
1668 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1669 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1670 { 0x00011954, "UFS_MAGIC" },
1671 { 0x54190100, "UFS_CIGAM" },
1672 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1673 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1674 { 0x62656572, "SYSFS_MAGIC" },
1683 sprintfstype(int magic)
1685 static char buf[32];
1689 s = xlookup(fsmagic, magic);
1691 sprintf(buf, "\"%s\"", s);
1695 sprintf(buf, "%#x", magic);
1700 printstatfs(struct tcb *tcp, long addr)
1702 struct statfs statbuf;
1704 if (syserror(tcp) || !verbose(tcp)) {
1705 tprintf("%#lx", addr);
1708 if (umove(tcp, addr, &statbuf) < 0) {
1714 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1715 sprintfstype(statbuf.f_type),
1716 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1717 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1718 statbuf.f_bavail, statbuf.f_files, statbuf.f_ffree,
1719 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1722 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1723 sprintfstype(statbuf.f_type),
1724 (unsigned long)statbuf.f_bsize,
1725 (unsigned long)statbuf.f_blocks,
1726 (unsigned long)statbuf.f_bfree);
1727 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1728 (unsigned long)statbuf.f_bavail,
1729 (unsigned long)statbuf.f_files,
1730 (unsigned long)statbuf.f_ffree,
1731 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1733 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1736 #ifdef _STATFS_F_FRSIZE
1737 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1743 sys_statfs(struct tcb *tcp)
1745 if (entering(tcp)) {
1746 printpath(tcp, tcp->u_arg[0]);
1749 printstatfs(tcp, tcp->u_arg[1]);
1755 sys_fstatfs(struct tcb *tcp)
1757 if (entering(tcp)) {
1758 printfd(tcp, tcp->u_arg[0]);
1761 printstatfs(tcp, tcp->u_arg[1]);
1766 #if defined LINUX && defined HAVE_STATFS64
1768 printstatfs64(struct tcb *tcp, long addr)
1770 struct statfs64 statbuf;
1772 if (syserror(tcp) || !verbose(tcp)) {
1773 tprintf("%#lx", addr);
1776 if (umove(tcp, addr, &statbuf) < 0) {
1780 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
1781 sprintfstype(statbuf.f_type),
1782 (unsigned long long)statbuf.f_bsize,
1783 (unsigned long long)statbuf.f_blocks,
1784 (unsigned long long)statbuf.f_bfree);
1785 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1786 (unsigned long long)statbuf.f_bavail,
1787 (unsigned long long)statbuf.f_files,
1788 (unsigned long long)statbuf.f_ffree,
1789 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1790 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1791 #ifdef _STATFS_F_FRSIZE
1792 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
1794 #ifdef _STATFS_F_FLAGS
1795 tprintf(", f_flags=%llu", (unsigned long long)statbuf.f_flags);
1800 struct compat_statfs64 {
1812 uint32_t f_spare[4];
1814 #if defined(X86_64) || defined(IA64)
1815 __attribute__ ((packed, aligned(4)))
1820 printcompat_statfs64(struct tcb *tcp, long addr)
1822 struct compat_statfs64 statbuf;
1824 if (syserror(tcp) || !verbose(tcp)) {
1825 tprintf("%#lx", addr);
1828 if (umove(tcp, addr, &statbuf) < 0) {
1832 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%llu, f_bfree=%llu, ",
1833 sprintfstype(statbuf.f_type),
1834 (unsigned long)statbuf.f_bsize,
1835 (unsigned long long)statbuf.f_blocks,
1836 (unsigned long long)statbuf.f_bfree);
1837 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1838 (unsigned long long)statbuf.f_bavail,
1839 (unsigned long long)statbuf.f_files,
1840 (unsigned long long)statbuf.f_ffree,
1841 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1842 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1843 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1844 tprintf(", f_flags=%lu", (unsigned long)statbuf.f_frsize);
1849 sys_statfs64(struct tcb *tcp)
1851 if (entering(tcp)) {
1852 printpath(tcp, tcp->u_arg[0]);
1853 tprintf(", %lu, ", tcp->u_arg[1]);
1855 if (tcp->u_arg[1] == sizeof(struct statfs64))
1856 printstatfs64(tcp, tcp->u_arg[2]);
1857 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
1858 printcompat_statfs64(tcp, tcp->u_arg[2]);
1866 sys_fstatfs64(struct tcb *tcp)
1868 if (entering(tcp)) {
1869 printfd(tcp, tcp->u_arg[0]);
1870 tprintf(", %lu, ", tcp->u_arg[1]);
1872 if (tcp->u_arg[1] == sizeof(struct statfs64))
1873 printstatfs64(tcp, tcp->u_arg[2]);
1874 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
1875 printcompat_statfs64(tcp, tcp->u_arg[2]);
1883 #if defined(LINUX) && defined(__alpha)
1886 osf_statfs(struct tcb *tcp)
1888 if (entering(tcp)) {
1889 printpath(tcp, tcp->u_arg[0]);
1892 printstatfs(tcp, tcp->u_arg[1]);
1893 tprintf(", %lu", tcp->u_arg[2]);
1899 osf_fstatfs(struct tcb *tcp)
1901 if (entering(tcp)) {
1902 tprintf("%lu, ", tcp->u_arg[0]);
1904 printstatfs(tcp, tcp->u_arg[1]);
1905 tprintf(", %lu", tcp->u_arg[2]);
1909 #endif /* LINUX && __alpha */
1915 sys_ustat(struct tcb *tcp)
1917 struct ustat statbuf;
1919 if (entering(tcp)) {
1920 tprintf("makedev(%lu, %lu), ",
1921 (long) major(tcp->u_arg[0]),
1922 (long) minor(tcp->u_arg[0]));
1925 if (syserror(tcp) || !verbose(tcp))
1926 tprintf("%#lx", tcp->u_arg[1]);
1927 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1930 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1931 statbuf.f_tfree, statbuf.f_tinode);
1932 tprintf("f_fname=\"%.*s\", ",
1933 (int) sizeof(statbuf.f_fname),
1935 tprintf("f_fpack=\"%.*s\"}",
1936 (int) sizeof(statbuf.f_fpack),
1946 sys_chdir(struct tcb *tcp)
1948 if (entering(tcp)) {
1949 printpath(tcp, tcp->u_arg[0]);
1955 decode_mkdir(struct tcb *tcp, int offset)
1957 if (entering(tcp)) {
1958 printpath(tcp, tcp->u_arg[offset]);
1959 tprintf(", %#lo", tcp->u_arg[offset + 1]);
1965 sys_mkdir(struct tcb *tcp)
1967 return decode_mkdir(tcp, 0);
1972 sys_mkdirat(struct tcb *tcp)
1975 print_dirfd(tcp, tcp->u_arg[0]);
1976 return decode_mkdir(tcp, 1);
1981 sys_link(struct tcb *tcp)
1983 if (entering(tcp)) {
1984 printpath(tcp, tcp->u_arg[0]);
1986 printpath(tcp, tcp->u_arg[1]);
1993 sys_linkat(struct tcb *tcp)
1995 if (entering(tcp)) {
1996 print_dirfd(tcp, tcp->u_arg[0]);
1997 printpath(tcp, tcp->u_arg[1]);
1999 print_dirfd(tcp, tcp->u_arg[2]);
2000 printpath(tcp, tcp->u_arg[3]);
2002 printfd(tcp, tcp->u_arg[4]);
2009 static const struct xlat unlinkatflags[] = {
2010 #ifndef AT_REMOVEDIR
2011 # define AT_REMOVEDIR 0x200
2013 { AT_REMOVEDIR, "AT_REMOVEDIR" },
2018 sys_unlinkat(struct tcb *tcp)
2020 if (entering(tcp)) {
2021 print_dirfd(tcp, tcp->u_arg[0]);
2022 printpath(tcp, tcp->u_arg[1]);
2024 printflags(unlinkatflags, tcp->u_arg[2], "AT_???");
2032 sys_symlinkat(struct tcb *tcp)
2034 if (entering(tcp)) {
2035 printpath(tcp, tcp->u_arg[0]);
2037 print_dirfd(tcp, tcp->u_arg[1]);
2038 printpath(tcp, tcp->u_arg[2]);
2045 decode_readlink(struct tcb *tcp, int offset)
2047 if (entering(tcp)) {
2048 printpath(tcp, tcp->u_arg[offset]);
2052 tprintf("%#lx", tcp->u_arg[offset + 1]);
2054 /* Used to use printpathn(), but readlink
2055 * neither includes NUL in the returned count,
2056 * nor actually writes it into memory.
2057 * printpathn() would decide on printing
2058 * "..." continuation based on garbage
2059 * past return buffer's end.
2061 printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
2062 tprintf(", %lu", tcp->u_arg[offset + 2]);
2068 sys_readlink(struct tcb *tcp)
2070 return decode_readlink(tcp, 0);
2075 sys_readlinkat(struct tcb *tcp)
2078 print_dirfd(tcp, tcp->u_arg[0]);
2079 return decode_readlink(tcp, 1);
2085 sys_renameat(struct tcb *tcp)
2087 if (entering(tcp)) {
2088 print_dirfd(tcp, tcp->u_arg[0]);
2089 printpath(tcp, tcp->u_arg[1]);
2091 print_dirfd(tcp, tcp->u_arg[2]);
2092 printpath(tcp, tcp->u_arg[3]);
2099 sys_chown(struct tcb *tcp)
2101 if (entering(tcp)) {
2102 printpath(tcp, tcp->u_arg[0]);
2103 printuid(", ", tcp->u_arg[1]);
2104 printuid(", ", tcp->u_arg[2]);
2111 sys_fchownat(struct tcb *tcp)
2113 if (entering(tcp)) {
2114 print_dirfd(tcp, tcp->u_arg[0]);
2115 printpath(tcp, tcp->u_arg[1]);
2116 printuid(", ", tcp->u_arg[2]);
2117 printuid(", ", tcp->u_arg[3]);
2119 printflags(fstatatflags, tcp->u_arg[4], "AT_???");
2126 sys_fchown(struct tcb *tcp)
2128 if (entering(tcp)) {
2129 printfd(tcp, tcp->u_arg[0]);
2130 printuid(", ", tcp->u_arg[1]);
2131 printuid(", ", tcp->u_arg[2]);
2137 decode_chmod(struct tcb *tcp, int offset)
2139 if (entering(tcp)) {
2140 printpath(tcp, tcp->u_arg[offset]);
2141 tprintf(", %#lo", tcp->u_arg[offset + 1]);
2147 sys_chmod(struct tcb *tcp)
2149 return decode_chmod(tcp, 0);
2154 sys_fchmodat(struct tcb *tcp)
2157 print_dirfd(tcp, tcp->u_arg[0]);
2158 return decode_chmod(tcp, 1);
2163 sys_fchmod(struct tcb *tcp)
2165 if (entering(tcp)) {
2166 printfd(tcp, tcp->u_arg[0]);
2167 tprintf(", %#lo", tcp->u_arg[1]);
2174 sys_osf_utimes(struct tcb *tcp)
2176 if (entering(tcp)) {
2177 printpath(tcp, tcp->u_arg[0]);
2179 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
2186 decode_utimes(struct tcb *tcp, int offset, int special)
2188 if (entering(tcp)) {
2189 printpath(tcp, tcp->u_arg[offset]);
2191 if (tcp->u_arg[offset + 1] == 0)
2195 printtv_bitness(tcp, tcp->u_arg[offset + 1],
2196 BITNESS_CURRENT, special);
2198 printtv_bitness(tcp, tcp->u_arg[offset + 1]
2199 + sizeof(struct timeval),
2200 BITNESS_CURRENT, special);
2208 sys_utimes(struct tcb *tcp)
2210 return decode_utimes(tcp, 0, 0);
2215 sys_futimesat(struct tcb *tcp)
2218 print_dirfd(tcp, tcp->u_arg[0]);
2219 return decode_utimes(tcp, 1, 0);
2223 sys_utimensat(struct tcb *tcp)
2225 if (entering(tcp)) {
2226 print_dirfd(tcp, tcp->u_arg[0]);
2227 decode_utimes(tcp, 1, 1);
2229 printflags(utimensatflags, tcp->u_arg[3], "AT_???");
2236 sys_utime(struct tcb *tcp)
2243 if (entering(tcp)) {
2244 printpath(tcp, tcp->u_arg[0]);
2248 else if (!verbose(tcp))
2249 tprintf("%#lx", tcp->u_arg[1]);
2250 else if (umoven(tcp, tcp->u_arg[1],
2251 2 * personality_wordsize[current_personality],
2254 else if (personality_wordsize[current_personality]
2255 == sizeof u.utl[0]) {
2256 tprintf("[%s,", sprinttime(u.utl[0]));
2257 tprintf(" %s]", sprinttime(u.utl[1]));
2259 else if (personality_wordsize[current_personality]
2260 == sizeof u.uti[0]) {
2261 tprintf("[%s,", sprinttime(u.uti[0]));
2262 tprintf(" %s]", sprinttime(u.uti[1]));
2271 decode_mknod(struct tcb *tcp, int offset)
2273 int mode = tcp->u_arg[offset + 1];
2275 if (entering(tcp)) {
2276 printpath(tcp, tcp->u_arg[offset]);
2277 tprintf(", %s", sprintmode(mode));
2278 switch (mode & S_IFMT) {
2279 case S_IFCHR: case S_IFBLK:
2281 if (current_personality == 1)
2282 tprintf(", makedev(%lu, %lu)",
2283 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
2284 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
2287 tprintf(", makedev(%lu, %lu)",
2288 (unsigned long) major(tcp->u_arg[offset + 2]),
2289 (unsigned long) minor(tcp->u_arg[offset + 2]));
2299 sys_mknod(struct tcb *tcp)
2301 return decode_mknod(tcp, 0);
2306 sys_mknodat(struct tcb *tcp)
2309 print_dirfd(tcp, tcp->u_arg[0]);
2310 return decode_mknod(tcp, 1);
2316 sys_mkfifo(struct tcb *tcp)
2318 if (entering(tcp)) {
2319 printpath(tcp, tcp->u_arg[0]);
2320 tprintf(", %#lo", tcp->u_arg[1]);
2324 #endif /* FREEBSD */
2327 sys_fsync(struct tcb *tcp)
2329 if (entering(tcp)) {
2330 printfd(tcp, tcp->u_arg[0]);
2338 printdir(struct tcb *tcp, long addr)
2342 if (!verbose(tcp)) {
2343 tprintf("%#lx", addr);
2346 if (umove(tcp, addr, &d) < 0) {
2350 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
2352 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
2357 sys_readdir(struct tcb *tcp)
2359 if (entering(tcp)) {
2360 printfd(tcp, tcp->u_arg[0]);
2363 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
2364 tprintf("%#lx", tcp->u_arg[1]);
2366 printdir(tcp, tcp->u_arg[1]);
2367 /* Not much point in printing this out, it is always 1. */
2368 if (tcp->u_arg[2] != 1)
2369 tprintf(", %lu", tcp->u_arg[2]);
2376 #if defined FREEBSD || defined LINUX
2377 static const struct xlat direnttypes[] = {
2378 { DT_UNKNOWN, "DT_UNKNOWN" },
2379 { DT_FIFO, "DT_FIFO" },
2380 { DT_CHR, "DT_CHR" },
2381 { DT_DIR, "DT_DIR" },
2382 { DT_BLK, "DT_BLK" },
2383 { DT_REG, "DT_REG" },
2384 { DT_LNK, "DT_LNK" },
2385 { DT_SOCK, "DT_SOCK" },
2386 { DT_WHT, "DT_WHT" },
2393 sys_getdents(struct tcb *tcp)
2395 int i, len, dents = 0;
2398 if (entering(tcp)) {
2399 printfd(tcp, tcp->u_arg[0]);
2403 if (syserror(tcp) || !verbose(tcp)) {
2404 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2408 /* Beware of insanely large or negative values in tcp->u_rval */
2409 if (tcp->u_rval > 1024*1024)
2411 if (tcp->u_rval < 0)
2413 buf = len ? malloc(len) : NULL;
2415 die_out_of_memory();
2416 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2417 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2423 for (i = 0; i < len;) {
2424 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2427 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2428 i ? " " : "", d->d_ino, d->d_off);
2429 tprintf("d_reclen=%u, d_name=\"%s\"}",
2430 d->d_reclen, d->d_name);
2435 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2437 (unsigned long) d->d_ino,
2438 (unsigned long) d->d_off);
2439 tprintf("d_reclen=%u, d_name=\"%s\"}",
2440 d->d_reclen, d->d_name);
2445 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2446 i ? " " : "", d->d_off, d->d_fileno,
2448 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2449 d->d_namlen, d->d_namlen, d->d_name);
2454 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2455 i ? " " : "", d->d_fileno, d->d_reclen);
2456 printxval(direnttypes, d->d_type, "DT_???");
2457 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2458 d->d_namlen, d->d_namlen, d->d_name);
2460 #endif /* FREEBSD */
2462 tprints("/* d_reclen == 0, problem here */");
2471 tprintf("/* %u entries */", dents);
2472 tprintf(", %lu", tcp->u_arg[2]);
2478 #if _LFS64_LARGEFILE
2480 sys_getdents64(struct tcb *tcp)
2482 int i, len, dents = 0;
2485 if (entering(tcp)) {
2486 printfd(tcp, tcp->u_arg[0]);
2490 if (syserror(tcp) || !verbose(tcp)) {
2491 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2496 /* Beware of insanely large or negative tcp->u_rval */
2497 if (tcp->u_rval > 1024*1024)
2499 if (tcp->u_rval < 0)
2501 buf = len ? malloc(len) : NULL;
2503 die_out_of_memory();
2505 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2506 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2512 for (i = 0; i < len;) {
2513 struct dirent64 *d = (struct dirent64 *) &buf[i];
2514 #if defined(LINUX) || defined(SVR4)
2516 tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ",
2522 printxval(direnttypes, d->d_type, "DT_???");
2525 tprintf("d_reclen=%u, d_name=\"%s\"}",
2526 d->d_reclen, d->d_name);
2528 #endif /* LINUX || SVR4 */
2531 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2532 i ? " " : "", d->d_off, d->d_fileno,
2534 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2535 d->d_namlen, d->d_namlen, d->d_name);
2539 tprints("/* d_reclen == 0, problem here */");
2548 tprintf("/* %u entries */", dents);
2549 tprintf(", %lu", tcp->u_arg[2]);
2557 sys_getdirentries(struct tcb *tcp)
2559 int i, len, dents = 0;
2563 if (entering(tcp)) {
2564 printfd(tcp, tcp->u_arg[0]);
2568 if (syserror(tcp) || !verbose(tcp)) {
2569 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2574 /* Beware of insanely large or negative tcp->u_rval */
2575 if (tcp->u_rval > 1024*1024)
2577 if (tcp->u_rval < 0)
2581 die_out_of_memory();
2583 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2584 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2590 for (i = 0; i < len;) {
2591 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2593 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2594 i ? " " : "", d->d_fileno, d->d_reclen);
2595 printxval(direnttypes, d->d_type, "DT_???");
2596 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2597 d->d_namlen, d->d_namlen, d->d_name);
2600 tprints("/* d_reclen == 0, problem here */");
2609 tprintf("/* %u entries */", dents);
2611 tprintf(", %lu", tcp->u_arg[2]);
2612 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2613 tprintf(", %#lx", tcp->u_arg[3]);
2615 tprintf(", [%lu]", basep);
2622 sys_getcwd(struct tcb *tcp)
2626 tprintf("%#lx", tcp->u_arg[0]);
2628 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2629 tprintf(", %lu", tcp->u_arg[1]);
2637 sys___getcwd(struct tcb *tcp)
2641 tprintf("%#lx", tcp->u_arg[0]);
2643 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2644 tprintf(", %lu", tcp->u_arg[1]);
2650 #ifdef HAVE_SYS_ASYNCH_H
2653 sys_aioread(struct tcb *tcp)
2655 struct aio_result_t res;
2657 if (entering(tcp)) {
2658 tprintf("%lu, ", tcp->u_arg[0]);
2661 tprintf("%#lx", tcp->u_arg[1]);
2663 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2664 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2665 printxval(whence, tcp->u_arg[4], "L_???");
2666 if (syserror(tcp) || tcp->u_arg[5] == 0
2667 || umove(tcp, tcp->u_arg[5], &res) < 0)
2668 tprintf(", %#lx", tcp->u_arg[5]);
2670 tprintf(", {aio_return %d aio_errno %d}",
2671 res.aio_return, res.aio_errno);
2677 sys_aiowrite(struct tcb *tcp)
2679 struct aio_result_t res;
2681 if (entering(tcp)) {
2682 tprintf("%lu, ", tcp->u_arg[0]);
2683 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2684 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2685 printxval(whence, tcp->u_arg[4], "L_???");
2688 if (tcp->u_arg[5] == 0)
2690 else if (syserror(tcp)
2691 || umove(tcp, tcp->u_arg[5], &res) < 0)
2692 tprintf(", %#lx", tcp->u_arg[5]);
2694 tprintf(", {aio_return %d aio_errno %d}",
2695 res.aio_return, res.aio_errno);
2701 sys_aiowait(struct tcb *tcp)
2704 printtv(tcp, tcp->u_arg[0]);
2709 sys_aiocancel(struct tcb *tcp)
2711 struct aio_result_t res;
2714 if (tcp->u_arg[0] == 0)
2716 else if (syserror(tcp)
2717 || umove(tcp, tcp->u_arg[0], &res) < 0)
2718 tprintf("%#lx", tcp->u_arg[0]);
2720 tprintf("{aio_return %d aio_errno %d}",
2721 res.aio_return, res.aio_errno);
2726 #endif /* HAVE_SYS_ASYNCH_H */
2728 static const struct xlat xattrflags[] = {
2730 { XATTR_CREATE, "XATTR_CREATE" },
2731 { XATTR_REPLACE, "XATTR_REPLACE" },
2737 print_xattr_val(struct tcb *tcp, int failed,
2739 unsigned long insize,
2743 unsigned long capacity = 4 * size + 1;
2744 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
2745 if (buf == NULL || /* probably a bogus size argument */
2746 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2750 unsigned char *out = buf;
2751 unsigned char *in = &buf[3 * size];
2753 for (i = 0; i < size; ++i) {
2757 #define tohex(n) "0123456789abcdef"[n]
2760 *out++ = tohex(in[i] / 16);
2761 *out++ = tohex(in[i] % 16);
2764 /* Don't print terminating NUL if there is one. */
2765 if (i > 0 && in[i - 1] == '\0')
2768 tprintf(", \"%s\", %ld", buf, insize);
2773 tprintf(", 0x%lx, %ld", arg, insize);
2777 sys_setxattr(struct tcb *tcp)
2779 if (entering(tcp)) {
2780 printpath(tcp, tcp->u_arg[0]);
2782 printstr(tcp, tcp->u_arg[1], -1);
2783 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2785 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2791 sys_fsetxattr(struct tcb *tcp)
2793 if (entering(tcp)) {
2794 printfd(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_???");
2805 sys_getxattr(struct tcb *tcp)
2807 if (entering(tcp)) {
2808 printpath(tcp, tcp->u_arg[0]);
2810 printstr(tcp, tcp->u_arg[1], -1);
2812 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2819 sys_fgetxattr(struct tcb *tcp)
2821 if (entering(tcp)) {
2822 printfd(tcp, tcp->u_arg[0]);
2824 printstr(tcp, tcp->u_arg[1], -1);
2826 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2833 sys_listxattr(struct tcb *tcp)
2835 if (entering(tcp)) {
2836 printpath(tcp, tcp->u_arg[0]);
2838 /* XXX Print value in format */
2839 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2845 sys_flistxattr(struct tcb *tcp)
2847 if (entering(tcp)) {
2848 printfd(tcp, tcp->u_arg[0]);
2850 /* XXX Print value in format */
2851 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2857 sys_removexattr(struct tcb *tcp)
2859 if (entering(tcp)) {
2860 printpath(tcp, tcp->u_arg[0]);
2862 printstr(tcp, tcp->u_arg[1], -1);
2868 sys_fremovexattr(struct tcb *tcp)
2870 if (entering(tcp)) {
2871 printfd(tcp, tcp->u_arg[0]);
2873 printstr(tcp, tcp->u_arg[1], -1);
2879 static const struct xlat advise[] = {
2880 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2881 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2882 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2883 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2884 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2885 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2892 sys_fadvise64(struct tcb *tcp)
2894 if (entering(tcp)) {
2896 printfd(tcp, tcp->u_arg[0]);
2898 argn = printllval(tcp, "%lld", 1);
2899 tprintf(", %ld, ", tcp->u_arg[argn++]);
2900 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
2908 sys_fadvise64_64(struct tcb *tcp)
2910 if (entering(tcp)) {
2912 printfd(tcp, tcp->u_arg[0]);
2914 #if defined ARM || defined POWERPC
2915 argn = printllval(tcp, "%lld, ", 2);
2917 argn = printllval(tcp, "%lld, ", 1);
2919 argn = printllval(tcp, "%lld, ", argn);
2920 #if defined ARM || defined POWERPC
2921 printxval(advise, tcp->u_arg[1], "POSIX_FADV_???");
2923 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
2930 static const struct xlat inotify_modes[] = {
2931 { 0x00000001, "IN_ACCESS" },
2932 { 0x00000002, "IN_MODIFY" },
2933 { 0x00000004, "IN_ATTRIB" },
2934 { 0x00000008, "IN_CLOSE_WRITE"},
2935 { 0x00000010, "IN_CLOSE_NOWRITE"},
2936 { 0x00000020, "IN_OPEN" },
2937 { 0x00000040, "IN_MOVED_FROM" },
2938 { 0x00000080, "IN_MOVED_TO" },
2939 { 0x00000100, "IN_CREATE" },
2940 { 0x00000200, "IN_DELETE" },
2941 { 0x00000400, "IN_DELETE_SELF"},
2942 { 0x00000800, "IN_MOVE_SELF" },
2943 { 0x00002000, "IN_UNMOUNT" },
2944 { 0x00004000, "IN_Q_OVERFLOW" },
2945 { 0x00008000, "IN_IGNORED" },
2946 { 0x01000000, "IN_ONLYDIR" },
2947 { 0x02000000, "IN_DONT_FOLLOW"},
2948 { 0x20000000, "IN_MASK_ADD" },
2949 { 0x40000000, "IN_ISDIR" },
2950 { 0x80000000, "IN_ONESHOT" },
2954 static const struct xlat inotify_init_flags[] = {
2955 { 0x00000800, "IN_NONBLOCK" },
2956 { 0x00080000, "IN_CLOEXEC" },
2961 sys_inotify_add_watch(struct tcb *tcp)
2963 if (entering(tcp)) {
2964 printfd(tcp, tcp->u_arg[0]);
2966 printpath(tcp, tcp->u_arg[1]);
2968 printflags(inotify_modes, tcp->u_arg[2], "IN_???");
2974 sys_inotify_rm_watch(struct tcb *tcp)
2976 if (entering(tcp)) {
2977 printfd(tcp, tcp->u_arg[0]);
2978 tprintf(", %ld", tcp->u_arg[1]);
2984 sys_inotify_init1(struct tcb *tcp)
2987 printflags(inotify_init_flags, tcp->u_arg[0], "IN_???");
2992 sys_fallocate(struct tcb *tcp)
2994 if (entering(tcp)) {
2996 printfd(tcp, tcp->u_arg[0]); /* fd */
2998 tprintf("%#lo, ", tcp->u_arg[1]); /* mode */
2999 argn = printllval(tcp, "%llu, ", 2); /* offset */
3000 printllval(tcp, "%llu", argn); /* len */