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" },
277 { FNDELAY, "FNDELAY" },
280 { FAPPEND, "FAPPEND" },
286 { FDEFER, "FDEFER" },
289 { FASYNC, "FASYNC" },
292 { FSHLOCK, "FSHLOCK" },
295 { FEXLOCK, "FEXLOCK" },
298 { FCREAT, "FCREAT" },
301 { FTRUNC, "FTRUNC" },
313 { FNOCTTY, "FNOCTTY" },
316 { O_SHLOCK, "O_SHLOCK" },
319 { O_EXLOCK, "O_EXLOCK" },
327 # define AT_FDCWD -100
334 tprintf("AT_FDCWD, ");
336 tprintf("%ld, ", fd);
341 * Pity stpcpy() is not standardized...
344 str_append(char *dst, const char *src)
346 while ((*dst = *src++) != '\0')
352 * low bits of the open(2) flags define access mode,
353 * other bits are real flags.
356 sprint_open_modes(mode_t flags)
358 static char outstr[1024];
362 const struct xlat *x;
364 p = str_append(outstr, "flags ");
365 str = xlookup(open_access_modes, flags & 3);
367 p = str_append(p, str);
374 for (x = open_mode_flags; x->str; x++) {
375 if ((flags & x->val) == x->val) {
378 p = str_append(p, x->str);
385 /* flags is still nonzero */
388 sprintf(p, "%#x", flags);
393 tprint_open_modes(mode_t flags)
395 tprintf(sprint_open_modes(flags) + sizeof("flags"));
399 decode_open(struct tcb *tcp, int offset)
402 printpath(tcp, tcp->u_arg[offset]);
405 tprint_open_modes(tcp->u_arg[offset + 1]);
406 if (tcp->u_arg[offset + 1] & O_CREAT) {
408 tprintf(", %#lo", tcp->u_arg[offset + 2]);
415 sys_open(struct tcb *tcp)
417 return decode_open(tcp, 0);
422 sys_openat(struct tcb *tcp)
425 print_dirfd(tcp->u_arg[0]);
426 return decode_open(tcp, 1);
431 static const struct xlat openmodessol[] = {
435 { 0x80, "O_NONBLOCK" },
437 { 0x100, "O_CREAT" },
438 { 0x200, "O_TRUNC" },
440 { 0x800, "O_NOCTTY" },
443 { 0x8000, "O_RSYNC" },
445 { 0x1000, "O_PRIV" },
450 solaris_open(struct tcb *tcp)
453 printpath(tcp, tcp->u_arg[0]);
456 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
457 if (tcp->u_arg[1] & 0x100) {
459 tprintf(", %#lo", tcp->u_arg[2]);
468 sys_creat(struct tcb *tcp)
471 printpath(tcp, tcp->u_arg[0]);
472 tprintf(", %#lo", tcp->u_arg[1]);
477 static const struct xlat access_flags[] = {
483 { EFF_ONLY_OK, "EFF_ONLY_OK" },
492 decode_access(struct tcb *tcp, int offset)
495 printpath(tcp, tcp->u_arg[offset]);
497 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK");
503 sys_access(struct tcb *tcp)
505 return decode_access(tcp, 0);
510 sys_faccessat(struct tcb *tcp)
513 print_dirfd(tcp->u_arg[0]);
514 return decode_access(tcp, 1);
519 sys_umask(struct tcb *tcp)
522 tprintf("%#lo", tcp->u_arg[0]);
527 static const struct xlat whence[] = {
528 { SEEK_SET, "SEEK_SET" },
529 { SEEK_CUR, "SEEK_CUR" },
530 { SEEK_END, "SEEK_END" },
534 #ifndef HAVE_LONG_LONG_OFF_T
535 #if defined (LINUX_MIPSN32)
537 sys_lseek(struct tcb *tcp)
543 tprintf("%ld, ", tcp->u_arg[0]);
544 offset = tcp->ext_arg[1];
545 _whence = tcp->u_arg[2];
546 if (_whence == SEEK_SET)
547 tprintf("%llu, ", offset);
549 tprintf("%lld, ", offset);
550 printxval(whence, _whence, "SEEK_???");
552 return RVAL_UDECIMAL;
554 #else /* !LINUX_MIPSN32 */
556 sys_lseek(struct tcb *tcp)
562 tprintf("%ld, ", tcp->u_arg[0]);
563 offset = tcp->u_arg[1];
564 _whence = tcp->u_arg[2];
565 if (_whence == SEEK_SET)
566 tprintf("%lu, ", offset);
568 tprintf("%ld, ", offset);
569 printxval(whence, _whence, "SEEK_???");
571 return RVAL_UDECIMAL;
573 #endif /* LINUX_MIPSN32 */
578 sys_llseek(struct tcb *tcp)
582 * This one call takes explicitly two 32-bit arguments hi, lo,
583 * rather than one 64-bit argument for which LONG_LONG works
584 * appropriate for the native byte order.
586 if (tcp->u_arg[4] == SEEK_SET)
587 tprintf("%ld, %llu, ", tcp->u_arg[0],
588 (((long long int) tcp->u_arg[1]) << 32
589 | (unsigned long long) (unsigned) tcp->u_arg[2]));
591 tprintf("%ld, %lld, ", tcp->u_arg[0],
592 (((long long int) tcp->u_arg[1]) << 32
593 | (unsigned long long) (unsigned) tcp->u_arg[2]));
597 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
598 tprintf("%#lx, ", tcp->u_arg[3]);
600 tprintf("[%llu], ", off);
601 printxval(whence, tcp->u_arg[4], "SEEK_???");
607 sys_readahead(struct tcb *tcp)
610 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
611 # if defined LINUX_MIPSN32
612 tcp->ext_arg[1], tcp->u_arg[2]
613 # elif defined IA64 || defined X86_64 || defined ALPHA || defined LINUX_MIPSN64
614 (long long int) tcp->u_arg[1], tcp->u_arg[2]
616 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]
624 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
626 sys_lseek64(struct tcb *tcp)
630 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
631 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
632 if (tcp->u_arg[3] == SEEK_SET)
633 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
635 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
636 printxval(whence, tcp->u_arg[3], "SEEK_???");
638 return RVAL_LUDECIMAL;
642 #ifndef HAVE_LONG_LONG_OFF_T
644 sys_truncate(struct tcb *tcp)
647 printpath(tcp, tcp->u_arg[0]);
648 tprintf(", %lu", tcp->u_arg[1]);
654 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
656 sys_truncate64(struct tcb *tcp)
660 printpath(tcp, tcp->u_arg[0]);
661 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
667 #ifndef HAVE_LONG_LONG_OFF_T
669 sys_ftruncate(struct tcb *tcp)
672 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
678 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
680 sys_ftruncate64(struct tcb *tcp)
684 tprintf("%ld, %llu", tcp->u_arg[0],
685 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
693 static const struct xlat modetypes[] = {
694 { S_IFREG, "S_IFREG" },
695 { S_IFSOCK, "S_IFSOCK" },
696 { S_IFIFO, "S_IFIFO" },
697 { S_IFLNK, "S_IFLNK" },
698 { S_IFDIR, "S_IFDIR" },
699 { S_IFBLK, "S_IFBLK" },
700 { S_IFCHR, "S_IFCHR" },
710 if ((mode & S_IFMT) == 0)
712 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
713 sprintf(buf, "%#o", mode);
716 sprintf(buf, "%s%s%s%s", s,
717 (mode & S_ISUID) ? "|S_ISUID" : "",
718 (mode & S_ISGID) ? "|S_ISGID" : "",
719 (mode & S_ISVTX) ? "|S_ISVTX" : "");
720 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
722 sprintf(buf + strlen(buf), "|%#o", mode);
723 s = (*buf == '|') ? buf + 1 : buf;
737 if ((tmp = localtime(&t)))
738 snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d",
739 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
740 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
742 snprintf(buf, sizeof buf, "%lu", (unsigned long) t);
755 int st_pad1[3]; /* network id */
764 int st_pad3; /* st_size, off_t expansion */
765 timestruct_t st_atime;
766 timestruct_t st_mtime;
767 timestruct_t st_ctime;
771 int st_pad4[8]; /* expansion area */
775 printstatsol(struct tcb *tcp, long addr)
777 struct solstat statbuf;
783 if (syserror(tcp) || !verbose(tcp)) {
784 tprintf("%#lx", addr);
787 if (umove(tcp, addr, &statbuf) < 0) {
792 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
793 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
794 (unsigned long) (statbuf.st_dev & 0x3ffff),
795 (unsigned long) statbuf.st_ino,
796 sprintmode(statbuf.st_mode));
797 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
798 (unsigned long) statbuf.st_nlink,
799 (unsigned long) statbuf.st_uid,
800 (unsigned long) statbuf.st_gid);
801 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
802 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
805 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
806 switch (statbuf.st_mode & S_IFMT) {
807 case S_IFCHR: case S_IFBLK:
808 tprintf("st_rdev=makedev(%lu, %lu), ",
809 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
810 (unsigned long) (statbuf.st_rdev & 0x3ffff));
813 tprintf("st_size=%u, ", statbuf.st_size);
817 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
818 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
819 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
825 #if defined (SPARC64)
827 printstat_sparc64(struct tcb *tcp, long addr)
829 struct stat_sparc64 statbuf;
835 if (syserror(tcp) || !verbose(tcp)) {
836 tprintf("%#lx", addr);
839 if (umove(tcp, addr, &statbuf) < 0) {
845 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
846 (unsigned long) major(statbuf.st_dev),
847 (unsigned long) minor(statbuf.st_dev),
848 (unsigned long) statbuf.st_ino,
849 sprintmode(statbuf.st_mode));
850 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
851 (unsigned long) statbuf.st_nlink,
852 (unsigned long) statbuf.st_uid,
853 (unsigned long) statbuf.st_gid);
854 tprintf("st_blksize=%lu, ",
855 (unsigned long) statbuf.st_blksize);
856 tprintf("st_blocks=%lu, ",
857 (unsigned long) statbuf.st_blocks);
860 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
861 switch (statbuf.st_mode & S_IFMT) {
862 case S_IFCHR: case S_IFBLK:
863 tprintf("st_rdev=makedev(%lu, %lu), ",
864 (unsigned long) major(statbuf.st_rdev),
865 (unsigned long) minor(statbuf.st_rdev));
868 tprintf("st_size=%lu, ", statbuf.st_size);
872 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
873 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
874 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
881 #endif /* LINUXSPARC */
883 static const struct xlat fileflags[] = {
885 { UF_NODUMP, "UF_NODUMP" },
886 { UF_IMMUTABLE, "UF_IMMUTABLE" },
887 { UF_APPEND, "UF_APPEND" },
888 { UF_OPAQUE, "UF_OPAQUE" },
889 { UF_NOUNLINK, "UF_NOUNLINK" },
890 { SF_ARCHIVED, "SF_ARCHIVED" },
891 { SF_IMMUTABLE, "SF_IMMUTABLE" },
892 { SF_APPEND, "SF_APPEND" },
893 { SF_NOUNLINK, "SF_NOUNLINK" },
896 { _S_ISMLD, "_S_ISMLD" },
899 { _S_ISMOUNTED, "_S_ISMOUNTED" },
907 sys_chflags(struct tcb *tcp)
910 printpath(tcp, tcp->u_arg[0]);
912 printflags(fileflags, tcp->u_arg[1], "UF_???");
918 sys_fchflags(struct tcb *tcp)
921 tprintf("%ld, ", tcp->u_arg[0]);
922 printflags(fileflags, tcp->u_arg[1], "UF_???");
928 #ifndef HAVE_LONG_LONG_OFF_T
930 realprintstat(struct tcb *tcp, struct stat *statbuf)
933 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
934 (unsigned long) major(statbuf->st_dev),
935 (unsigned long) minor(statbuf->st_dev),
936 (unsigned long) statbuf->st_ino,
937 sprintmode(statbuf->st_mode));
938 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
939 (unsigned long) statbuf->st_nlink,
940 (unsigned long) statbuf->st_uid,
941 (unsigned long) statbuf->st_gid);
942 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
943 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
945 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
946 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
950 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
951 switch (statbuf->st_mode & S_IFMT) {
952 case S_IFCHR: case S_IFBLK:
953 #ifdef HAVE_STRUCT_STAT_ST_RDEV
954 tprintf("st_rdev=makedev(%lu, %lu), ",
955 (unsigned long) major(statbuf->st_rdev),
956 (unsigned long) minor(statbuf->st_rdev));
957 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
958 tprintf("st_size=makedev(%lu, %lu), ",
959 (unsigned long) major(statbuf->st_size),
960 (unsigned long) minor(statbuf->st_size));
961 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
964 tprintf("st_size=%lu, ", statbuf->st_size);
968 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
969 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
970 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
971 #if HAVE_STRUCT_STAT_ST_FLAGS
972 tprintf(", st_flags=");
973 printflags(fileflags, statbuf->st_flags, "UF_???");
975 #if HAVE_STRUCT_STAT_ST_ACLCNT
976 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
978 #if HAVE_STRUCT_STAT_ST_LEVEL
979 tprintf(", st_level=%ld", statbuf->st_level);
981 #if HAVE_STRUCT_STAT_ST_FSTYPE
982 tprintf(", st_fstype=%.*s",
983 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
985 #if HAVE_STRUCT_STAT_ST_GEN
986 tprintf(", st_gen=%u", statbuf->st_gen);
996 printstat(struct tcb *tcp, long addr)
1001 if (current_personality == 1) {
1002 printstatsol(tcp, addr);
1006 else if (current_personality == 2) {
1007 printstat_sparc64(tcp, addr);
1011 #endif /* LINUXSPARC */
1017 if (syserror(tcp) || !verbose(tcp)) {
1018 tprintf("%#lx", addr);
1021 if (umove(tcp, addr, &statbuf) < 0) {
1026 realprintstat(tcp, &statbuf);
1028 #endif /* !HAVE_LONG_LONG_OFF_T */
1030 #if !defined HAVE_STAT64 && defined LINUX && defined X86_64
1032 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
1033 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
1034 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
1035 * __GNUC__ is needed for the required __attribute__ below.
1038 unsigned long long st_dev;
1039 unsigned char __pad0[4];
1040 unsigned int __st_ino;
1041 unsigned int st_mode;
1042 unsigned int st_nlink;
1043 unsigned int st_uid;
1044 unsigned int st_gid;
1045 unsigned long long st_rdev;
1046 unsigned char __pad3[4];
1048 unsigned int st_blksize;
1049 unsigned long long st_blocks;
1050 unsigned int st_atime;
1051 unsigned int st_atime_nsec;
1052 unsigned int st_mtime;
1053 unsigned int st_mtime_nsec;
1054 unsigned int st_ctime;
1055 unsigned int st_ctime_nsec;
1056 unsigned long long st_ino;
1057 } __attribute__((packed));
1058 # define HAVE_STAT64 1
1059 # define STAT64_SIZE 96
1064 printstat64(struct tcb *tcp, long addr)
1066 struct stat64 statbuf;
1069 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
1073 if (current_personality == 1) {
1074 printstatsol(tcp, addr);
1078 else if (current_personality == 2) {
1079 printstat_sparc64(tcp, addr);
1083 #endif /* LINUXSPARC */
1089 if (syserror(tcp) || !verbose(tcp)) {
1090 tprintf("%#lx", addr);
1093 if (umove(tcp, addr, &statbuf) < 0) {
1099 #ifdef HAVE_LONG_LONG
1100 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1102 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
1104 (unsigned long) major(statbuf.st_dev),
1105 (unsigned long) minor(statbuf.st_dev),
1106 #ifdef HAVE_LONG_LONG
1107 (unsigned long long) statbuf.st_ino,
1109 (unsigned long) statbuf.st_ino,
1111 sprintmode(statbuf.st_mode));
1112 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1113 (unsigned long) statbuf.st_nlink,
1114 (unsigned long) statbuf.st_uid,
1115 (unsigned long) statbuf.st_gid);
1116 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
1117 tprintf("st_blksize=%lu, ",
1118 (unsigned long) statbuf.st_blksize);
1119 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
1120 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
1121 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
1122 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
1125 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1126 switch (statbuf.st_mode & S_IFMT) {
1127 case S_IFCHR: case S_IFBLK:
1128 #ifdef HAVE_STRUCT_STAT_ST_RDEV
1129 tprintf("st_rdev=makedev(%lu, %lu), ",
1130 (unsigned long) major(statbuf.st_rdev),
1131 (unsigned long) minor(statbuf.st_rdev));
1132 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
1133 tprintf("st_size=makedev(%lu, %lu), ",
1134 (unsigned long) major(statbuf.st_size),
1135 (unsigned long) minor(statbuf.st_size));
1136 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
1139 #ifdef HAVE_LONG_LONG
1140 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1142 tprintf("st_size=%lu, ", (unsigned long) statbuf.st_size);
1147 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1148 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
1149 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
1150 #if HAVE_STRUCT_STAT_ST_FLAGS
1151 tprintf(", st_flags=");
1152 printflags(fileflags, statbuf.st_flags, "UF_???");
1154 #if HAVE_STRUCT_STAT_ST_ACLCNT
1155 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1157 #if HAVE_STRUCT_STAT_ST_LEVEL
1158 tprintf(", st_level=%ld", statbuf.st_level);
1160 #if HAVE_STRUCT_STAT_ST_FSTYPE
1161 tprintf(", st_fstype=%.*s",
1162 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1164 #if HAVE_STRUCT_STAT_ST_GEN
1165 tprintf(", st_gen=%u", statbuf.st_gen);
1172 #endif /* HAVE_STAT64 */
1174 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1176 convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
1178 newbuf->st_dev = oldbuf->st_dev;
1179 newbuf->st_ino = oldbuf->st_ino;
1180 newbuf->st_mode = oldbuf->st_mode;
1181 newbuf->st_nlink = oldbuf->st_nlink;
1182 newbuf->st_uid = oldbuf->st_uid;
1183 newbuf->st_gid = oldbuf->st_gid;
1184 newbuf->st_rdev = oldbuf->st_rdev;
1185 newbuf->st_size = oldbuf->st_size;
1186 newbuf->st_atime = oldbuf->st_atime;
1187 newbuf->st_mtime = oldbuf->st_mtime;
1188 newbuf->st_ctime = oldbuf->st_ctime;
1189 newbuf->st_blksize = 0; /* not supported in old_stat */
1190 newbuf->st_blocks = 0; /* not supported in old_stat */
1195 printoldstat(struct tcb *tcp, long addr)
1197 struct __old_kernel_stat statbuf;
1198 struct stat newstatbuf;
1201 if (current_personality == 1) {
1202 printstatsol(tcp, addr);
1205 #endif /* LINUXSPARC */
1211 if (syserror(tcp) || !verbose(tcp)) {
1212 tprintf("%#lx", addr);
1215 if (umove(tcp, addr, &statbuf) < 0) {
1220 convertoldstat(&statbuf, &newstatbuf);
1221 realprintstat(tcp, &newstatbuf);
1223 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1225 #ifndef HAVE_LONG_LONG_OFF_T
1227 sys_stat(struct tcb *tcp)
1229 if (entering(tcp)) {
1230 printpath(tcp, tcp->u_arg[0]);
1233 printstat(tcp, tcp->u_arg[1]);
1240 sys_stat64(struct tcb *tcp)
1243 if (entering(tcp)) {
1244 printpath(tcp, tcp->u_arg[0]);
1247 printstat64(tcp, tcp->u_arg[1]);
1251 return printargs(tcp);
1256 static const struct xlat fstatatflags[] = {
1257 #ifndef AT_SYMLINK_NOFOLLOW
1258 # define AT_SYMLINK_NOFOLLOW 0x100
1260 { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" },
1263 #define utimensatflags fstatatflags
1266 sys_newfstatat(struct tcb *tcp)
1268 if (entering(tcp)) {
1269 print_dirfd(tcp->u_arg[0]);
1270 printpath(tcp, tcp->u_arg[1]);
1273 #if defined HAVE_STAT64 && !(defined POWERPC && defined __powerpc64__)
1274 printstat64(tcp, tcp->u_arg[2]);
1276 printstat(tcp, tcp->u_arg[2]);
1279 printflags(fstatatflags, tcp->u_arg[3], "AT_???");
1285 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1287 sys_oldstat(struct tcb *tcp)
1289 if (entering(tcp)) {
1290 printpath(tcp, tcp->u_arg[0]);
1293 printoldstat(tcp, tcp->u_arg[1]);
1297 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1299 #ifndef HAVE_LONG_LONG_OFF_T
1301 sys_fstat(struct tcb *tcp)
1304 tprintf("%ld, ", tcp->u_arg[0]);
1306 printstat(tcp, tcp->u_arg[1]);
1313 sys_fstat64(struct tcb *tcp)
1317 tprintf("%ld, ", tcp->u_arg[0]);
1319 printstat64(tcp, tcp->u_arg[1]);
1323 return printargs(tcp);
1327 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1329 sys_oldfstat(struct tcb *tcp)
1332 tprintf("%ld, ", tcp->u_arg[0]);
1334 printoldstat(tcp, tcp->u_arg[1]);
1338 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1340 #ifndef HAVE_LONG_LONG_OFF_T
1342 sys_lstat(struct tcb *tcp)
1344 if (entering(tcp)) {
1345 printpath(tcp, tcp->u_arg[0]);
1348 printstat(tcp, tcp->u_arg[1]);
1355 sys_lstat64(struct tcb *tcp)
1358 if (entering(tcp)) {
1359 printpath(tcp, tcp->u_arg[0]);
1362 printstat64(tcp, tcp->u_arg[1]);
1366 return printargs(tcp);
1370 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1372 sys_oldlstat(struct tcb *tcp)
1374 if (entering(tcp)) {
1375 printpath(tcp, tcp->u_arg[0]);
1378 printoldstat(tcp, tcp->u_arg[1]);
1382 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1385 #if defined(SVR4) || defined(LINUXSPARC)
1388 sys_xstat(struct tcb *tcp)
1390 if (entering(tcp)) {
1391 tprintf("%ld, ", tcp->u_arg[0]);
1392 printpath(tcp, tcp->u_arg[1]);
1396 if (tcp->u_arg[0] == _STAT64_VER)
1397 printstat64 (tcp, tcp->u_arg[2]);
1400 printstat(tcp, tcp->u_arg[2]);
1406 sys_fxstat(struct tcb *tcp)
1409 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1412 if (tcp->u_arg[0] == _STAT64_VER)
1413 printstat64 (tcp, tcp->u_arg[2]);
1416 printstat(tcp, tcp->u_arg[2]);
1422 sys_lxstat(struct tcb *tcp)
1424 if (entering(tcp)) {
1425 tprintf("%ld, ", tcp->u_arg[0]);
1426 printpath(tcp, tcp->u_arg[1]);
1430 if (tcp->u_arg[0] == _STAT64_VER)
1431 printstat64 (tcp, tcp->u_arg[2]);
1434 printstat(tcp, tcp->u_arg[2]);
1440 sys_xmknod(struct tcb *tcp)
1442 int mode = tcp->u_arg[2];
1444 if (entering(tcp)) {
1445 tprintf("%ld, ", tcp->u_arg[0]);
1446 printpath(tcp, tcp->u_arg[1]);
1447 tprintf(", %s", sprintmode(mode));
1448 switch (mode & S_IFMT) {
1449 case S_IFCHR: case S_IFBLK:
1451 tprintf(", makedev(%lu, %lu)",
1452 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1453 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1455 tprintf(", makedev(%lu, %lu)",
1456 (unsigned long) major(tcp->u_arg[3]),
1457 (unsigned long) minor(tcp->u_arg[3]));
1467 #ifdef HAVE_SYS_ACL_H
1469 #include <sys/acl.h>
1471 static const struct xlat aclcmds[] = {
1473 { SETACL, "SETACL" },
1476 { GETACL, "GETACL" },
1479 { GETACLCNT, "GETACLCNT" },
1482 { ACL_GET, "ACL_GET" },
1485 { ACL_SET, "ACL_SET" },
1488 { ACL_CNT, "ACL_CNT" },
1494 sys_acl(struct tcb *tcp)
1496 if (entering(tcp)) {
1497 printpath(tcp, tcp->u_arg[0]);
1499 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1500 tprintf(", %ld", tcp->u_arg[2]);
1502 * FIXME - dump out the list of aclent_t's pointed to
1503 * by "tcp->u_arg[3]" if it's not NULL.
1506 tprintf(", %#lx", tcp->u_arg[3]);
1515 sys_facl(struct tcb *tcp)
1517 if (entering(tcp)) {
1518 tprintf("%ld, ", tcp->u_arg[0]);
1519 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1520 tprintf(", %ld", tcp->u_arg[2]);
1522 * FIXME - dump out the list of aclent_t's pointed to
1523 * by "tcp->u_arg[3]" if it's not NULL.
1526 tprintf(", %#lx", tcp->u_arg[3]);
1534 static const struct xlat aclipc[] = {
1536 { IPC_SHM, "IPC_SHM" },
1539 { IPC_SEM, "IPC_SEM" },
1542 { IPC_MSG, "IPC_MSG" },
1549 sys_aclipc(struct tcb *tcp)
1551 if (entering(tcp)) {
1552 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1553 tprintf(", %#lx, ", tcp->u_arg[1]);
1554 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1555 tprintf(", %ld", tcp->u_arg[3]);
1557 * FIXME - dump out the list of aclent_t's pointed to
1558 * by "tcp->u_arg[4]" if it's not NULL.
1561 tprintf(", %#lx", tcp->u_arg[4]);
1568 #endif /* HAVE_SYS_ACL_H */
1570 #endif /* SVR4 || LINUXSPARC */
1574 static const struct xlat fsmagic[] = {
1575 { 0x73757245, "CODA_SUPER_MAGIC" },
1576 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1577 { 0x1373, "DEVFS_SUPER_MAGIC" },
1578 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1579 { 0x414A53, "EFS_SUPER_MAGIC" },
1580 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1581 { 0xef53, "EXT2_SUPER_MAGIC" },
1582 { 0x137d, "EXT_SUPER_MAGIC" },
1583 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1584 { 0x9660, "ISOFS_SUPER_MAGIC" },
1585 { 0x137f, "MINIX_SUPER_MAGIC" },
1586 { 0x138f, "MINIX_SUPER_MAGIC2" },
1587 { 0x2468, "MINIX2_SUPER_MAGIC" },
1588 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1589 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1590 { 0x564c, "NCP_SUPER_MAGIC" },
1591 { 0x6969, "NFS_SUPER_MAGIC" },
1592 { 0x9fa0, "PROC_SUPER_MAGIC" },
1593 { 0x002f, "QNX4_SUPER_MAGIC" },
1594 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1595 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1596 { 0x517b, "SMB_SUPER_MAGIC" },
1597 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1598 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1599 { 0x00011954, "UFS_MAGIC" },
1600 { 0x54190100, "UFS_CIGAM" },
1601 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1602 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1603 { 0x62656572, "SYSFS_MAGIC" },
1612 sprintfstype(int magic)
1614 static char buf[32];
1618 s = xlookup(fsmagic, magic);
1620 sprintf(buf, "\"%s\"", s);
1624 sprintf(buf, "%#x", magic);
1629 printstatfs(struct tcb *tcp, long addr)
1631 struct statfs statbuf;
1633 if (syserror(tcp) || !verbose(tcp)) {
1634 tprintf("%#lx", addr);
1637 if (umove(tcp, addr, &statbuf) < 0) {
1643 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1644 sprintfstype(statbuf.f_type),
1645 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1646 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1647 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1648 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1651 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1652 sprintfstype(statbuf.f_type),
1653 (unsigned long)statbuf.f_bsize,
1654 (unsigned long)statbuf.f_blocks,
1655 (unsigned long)statbuf.f_bfree);
1656 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1657 (unsigned long)statbuf.f_bavail,
1658 (unsigned long)statbuf.f_files,
1659 (unsigned long)statbuf.f_ffree,
1660 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1662 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1665 #ifdef _STATFS_F_FRSIZE
1666 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1672 sys_statfs(struct tcb *tcp)
1674 if (entering(tcp)) {
1675 printpath(tcp, tcp->u_arg[0]);
1678 printstatfs(tcp, tcp->u_arg[1]);
1684 sys_fstatfs(struct tcb *tcp)
1686 if (entering(tcp)) {
1687 tprintf("%lu, ", tcp->u_arg[0]);
1689 printstatfs(tcp, tcp->u_arg[1]);
1696 printstatfs64(struct tcb *tcp, long addr)
1698 struct statfs64 statbuf;
1700 if (syserror(tcp) || !verbose(tcp)) {
1701 tprintf("%#lx", addr);
1704 if (umove(tcp, addr, &statbuf) < 0) {
1708 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
1709 sprintfstype(statbuf.f_type),
1710 (unsigned long long)statbuf.f_bsize,
1711 (unsigned long long)statbuf.f_blocks,
1712 (unsigned long long)statbuf.f_bfree);
1713 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1714 (unsigned long long)statbuf.f_bavail,
1715 (unsigned long long)statbuf.f_files,
1716 (unsigned long long)statbuf.f_ffree,
1717 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1718 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1719 #ifdef _STATFS_F_FRSIZE
1720 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
1726 sys_statfs64(struct tcb *tcp)
1728 if (entering(tcp)) {
1729 printpath(tcp, tcp->u_arg[0]);
1730 tprintf(", %lu, ", tcp->u_arg[1]);
1732 if (tcp->u_arg[1] == sizeof (struct statfs64))
1733 printstatfs64(tcp, tcp->u_arg[2]);
1741 sys_fstatfs64(struct tcb *tcp)
1743 if (entering(tcp)) {
1744 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1746 if (tcp->u_arg[1] == sizeof (struct statfs64))
1747 printstatfs64(tcp, tcp->u_arg[2]);
1755 #if defined(LINUX) && defined(__alpha)
1758 osf_statfs(struct tcb *tcp)
1760 if (entering(tcp)) {
1761 printpath(tcp, tcp->u_arg[0]);
1764 printstatfs(tcp, tcp->u_arg[1]);
1765 tprintf(", %lu", tcp->u_arg[2]);
1771 osf_fstatfs(struct tcb *tcp)
1773 if (entering(tcp)) {
1774 tprintf("%lu, ", tcp->u_arg[0]);
1776 printstatfs(tcp, tcp->u_arg[1]);
1777 tprintf(", %lu", tcp->u_arg[2]);
1781 #endif /* LINUX && __alpha */
1787 sys_ustat(struct tcb *tcp)
1789 struct ustat statbuf;
1791 if (entering(tcp)) {
1792 tprintf("makedev(%lu, %lu), ",
1793 (long) major(tcp->u_arg[0]),
1794 (long) minor(tcp->u_arg[0]));
1797 if (syserror(tcp) || !verbose(tcp))
1798 tprintf("%#lx", tcp->u_arg[1]);
1799 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1802 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1803 statbuf.f_tfree, statbuf.f_tinode);
1804 tprintf("f_fname=\"%.*s\", ",
1805 (int) sizeof(statbuf.f_fname),
1807 tprintf("f_fpack=\"%.*s\"}",
1808 (int) sizeof(statbuf.f_fpack),
1817 sys_pivotroot(struct tcb *tcp)
1819 if (entering(tcp)) {
1820 printpath(tcp, tcp->u_arg[0]);
1822 printpath(tcp, tcp->u_arg[1]);
1830 sys_chdir(struct tcb *tcp)
1832 if (entering(tcp)) {
1833 printpath(tcp, tcp->u_arg[0]);
1839 decode_mkdir(struct tcb *tcp, int offset)
1841 if (entering(tcp)) {
1842 printpath(tcp, tcp->u_arg[offset]);
1843 tprintf(", %#lo", tcp->u_arg[offset + 1]);
1849 sys_mkdir(struct tcb *tcp)
1851 return decode_mkdir(tcp, 0);
1856 sys_mkdirat(struct tcb *tcp)
1859 print_dirfd(tcp->u_arg[0]);
1860 return decode_mkdir(tcp, 1);
1865 sys_rmdir(struct tcb *tcp)
1867 if (entering(tcp)) {
1868 printpath(tcp, tcp->u_arg[0]);
1874 sys_fchdir(struct tcb *tcp)
1876 if (entering(tcp)) {
1877 tprintf("%ld", tcp->u_arg[0]);
1883 sys_chroot(struct tcb *tcp)
1885 if (entering(tcp)) {
1886 printpath(tcp, tcp->u_arg[0]);
1891 #if defined(SUNOS4) || defined(SVR4)
1893 sys_fchroot(struct tcb *tcp)
1895 if (entering(tcp)) {
1896 tprintf("%ld", tcp->u_arg[0]);
1900 #endif /* SUNOS4 || SVR4 */
1903 sys_link(struct tcb *tcp)
1905 if (entering(tcp)) {
1906 printpath(tcp, tcp->u_arg[0]);
1908 printpath(tcp, tcp->u_arg[1]);
1915 sys_linkat(struct tcb *tcp)
1917 if (entering(tcp)) {
1918 print_dirfd(tcp->u_arg[0]);
1919 printpath(tcp, tcp->u_arg[1]);
1921 print_dirfd(tcp->u_arg[2]);
1922 printpath(tcp, tcp->u_arg[3]);
1923 tprintf(", %ld", tcp->u_arg[4]);
1930 sys_unlink(struct tcb *tcp)
1932 if (entering(tcp)) {
1933 printpath(tcp, tcp->u_arg[0]);
1939 static const struct xlat unlinkatflags[] = {
1940 #ifndef AT_REMOVEDIR
1941 # define AT_REMOVEDIR 0x200
1943 { AT_REMOVEDIR, "AT_REMOVEDIR" },
1948 sys_unlinkat(struct tcb *tcp)
1950 if (entering(tcp)) {
1951 print_dirfd(tcp->u_arg[0]);
1952 printpath(tcp, tcp->u_arg[1]);
1954 printflags(unlinkatflags, tcp->u_arg[2], "AT_???");
1961 sys_symlink(struct tcb *tcp)
1963 if (entering(tcp)) {
1964 printpath(tcp, tcp->u_arg[0]);
1966 printpath(tcp, tcp->u_arg[1]);
1973 sys_symlinkat(struct tcb *tcp)
1975 if (entering(tcp)) {
1976 printpath(tcp, tcp->u_arg[0]);
1978 print_dirfd(tcp->u_arg[1]);
1979 printpath(tcp, tcp->u_arg[2]);
1986 decode_readlink(struct tcb *tcp, int offset)
1988 if (entering(tcp)) {
1989 printpath(tcp, tcp->u_arg[offset]);
1993 tprintf("%#lx", tcp->u_arg[offset + 1]);
1995 printpathn(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
1996 tprintf(", %lu", tcp->u_arg[offset + 2]);
2002 sys_readlink(struct tcb *tcp)
2004 return decode_readlink(tcp, 0);
2009 sys_readlinkat(struct tcb *tcp)
2012 print_dirfd(tcp->u_arg[0]);
2013 return decode_readlink(tcp, 1);
2018 sys_rename(struct tcb *tcp)
2020 if (entering(tcp)) {
2021 printpath(tcp, tcp->u_arg[0]);
2023 printpath(tcp, tcp->u_arg[1]);
2030 sys_renameat(struct tcb *tcp)
2032 if (entering(tcp)) {
2033 print_dirfd(tcp->u_arg[0]);
2034 printpath(tcp, tcp->u_arg[1]);
2036 print_dirfd(tcp->u_arg[2]);
2037 printpath(tcp, tcp->u_arg[3]);
2044 sys_chown(struct tcb *tcp)
2046 if (entering(tcp)) {
2047 printpath(tcp, tcp->u_arg[0]);
2048 printuid(", ", tcp->u_arg[1]);
2049 printuid(", ", tcp->u_arg[2]);
2056 sys_fchownat(struct tcb *tcp)
2058 if (entering(tcp)) {
2059 print_dirfd(tcp->u_arg[0]);
2060 printpath(tcp, tcp->u_arg[1]);
2061 printuid(", ", tcp->u_arg[2]);
2062 printuid(", ", tcp->u_arg[3]);
2064 printflags(fstatatflags, tcp->u_arg[4], "AT_???");
2071 sys_fchown(struct tcb *tcp)
2073 if (entering(tcp)) {
2074 tprintf("%ld", tcp->u_arg[0]);
2075 printuid(", ", tcp->u_arg[1]);
2076 printuid(", ", tcp->u_arg[2]);
2082 decode_chmod(struct tcb *tcp, int offset)
2084 if (entering(tcp)) {
2085 printpath(tcp, tcp->u_arg[offset]);
2086 tprintf(", %#lo", tcp->u_arg[offset + 1]);
2092 sys_chmod(struct tcb *tcp)
2094 return decode_chmod(tcp, 0);
2099 sys_fchmodat(struct tcb *tcp)
2102 print_dirfd(tcp->u_arg[0]);
2103 return decode_chmod(tcp, 1);
2108 sys_fchmod(struct tcb *tcp)
2110 if (entering(tcp)) {
2111 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
2118 sys_osf_utimes(struct tcb *tcp)
2120 if (entering(tcp)) {
2121 printpath(tcp, tcp->u_arg[0]);
2123 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
2130 decode_utimes(struct tcb *tcp, int offset, int special)
2132 if (entering(tcp)) {
2133 printpath(tcp, tcp->u_arg[offset]);
2135 if (tcp->u_arg[offset + 1] == 0)
2139 printtv_bitness(tcp, tcp->u_arg[offset + 1],
2140 BITNESS_CURRENT, special);
2142 printtv_bitness(tcp, tcp->u_arg[offset + 1]
2143 + sizeof (struct timeval),
2144 BITNESS_CURRENT, special);
2152 sys_utimes(struct tcb *tcp)
2154 return decode_utimes(tcp, 0, 0);
2159 sys_futimesat(struct tcb *tcp)
2162 print_dirfd(tcp->u_arg[0]);
2163 return decode_utimes(tcp, 1, 0);
2167 sys_utimensat(struct tcb *tcp)
2169 if (entering(tcp)) {
2170 print_dirfd(tcp->u_arg[0]);
2171 decode_utimes(tcp, 1, 1);
2173 printflags(utimensatflags, tcp->u_arg[3], "AT_???");
2180 sys_utime(struct tcb *tcp)
2187 if (entering(tcp)) {
2188 printpath(tcp, tcp->u_arg[0]);
2192 else if (!verbose(tcp))
2193 tprintf("%#lx", tcp->u_arg[1]);
2194 else if (umoven(tcp, tcp->u_arg[1],
2195 2 * personality_wordsize[current_personality],
2198 else if (personality_wordsize[current_personality]
2199 == sizeof u.utl[0]) {
2200 tprintf("[%s,", sprinttime(u.utl[0]));
2201 tprintf(" %s]", sprinttime(u.utl[1]));
2203 else if (personality_wordsize[current_personality]
2204 == sizeof u.uti[0]) {
2205 tprintf("[%s,", sprinttime(u.uti[0]));
2206 tprintf(" %s]", sprinttime(u.uti[1]));
2215 decode_mknod(struct tcb *tcp, int offset)
2217 int mode = tcp->u_arg[offset + 1];
2219 if (entering(tcp)) {
2220 printpath(tcp, tcp->u_arg[offset]);
2221 tprintf(", %s", sprintmode(mode));
2222 switch (mode & S_IFMT) {
2223 case S_IFCHR: case S_IFBLK:
2225 if (current_personality == 1)
2226 tprintf(", makedev(%lu, %lu)",
2227 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
2228 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
2231 tprintf(", makedev(%lu, %lu)",
2232 (unsigned long) major(tcp->u_arg[offset + 2]),
2233 (unsigned long) minor(tcp->u_arg[offset + 2]));
2243 sys_mknod(struct tcb *tcp)
2245 return decode_mknod(tcp, 0);
2250 sys_mknodat(struct tcb *tcp)
2253 print_dirfd(tcp->u_arg[0]);
2254 return decode_mknod(tcp, 1);
2260 sys_mkfifo(struct tcb *tcp)
2262 if (entering(tcp)) {
2263 printpath(tcp, tcp->u_arg[0]);
2264 tprintf(", %#lo", tcp->u_arg[1]);
2268 #endif /* FREEBSD */
2271 sys_fsync(struct tcb *tcp)
2273 if (entering(tcp)) {
2274 tprintf("%ld", tcp->u_arg[0]);
2282 printdir(struct tcb *tcp, long addr)
2286 if (!verbose(tcp)) {
2287 tprintf("%#lx", addr);
2290 if (umove(tcp, addr, &d) < 0) {
2294 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
2296 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
2301 sys_readdir(struct tcb *tcp)
2303 if (entering(tcp)) {
2304 tprintf("%lu, ", tcp->u_arg[0]);
2306 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
2307 tprintf("%#lx", tcp->u_arg[1]);
2309 printdir(tcp, tcp->u_arg[1]);
2310 /* Not much point in printing this out, it is always 1. */
2311 if (tcp->u_arg[2] != 1)
2312 tprintf(", %lu", tcp->u_arg[2]);
2319 #if defined FREEBSD || defined LINUX
2320 static const struct xlat direnttypes[] = {
2321 { DT_UNKNOWN, "DT_UNKNOWN" },
2322 { DT_FIFO, "DT_FIFO" },
2323 { DT_CHR, "DT_CHR" },
2324 { DT_DIR, "DT_DIR" },
2325 { DT_BLK, "DT_BLK" },
2326 { DT_REG, "DT_REG" },
2327 { DT_LNK, "DT_LNK" },
2328 { DT_SOCK, "DT_SOCK" },
2329 { DT_WHT, "DT_WHT" },
2336 sys_getdents(struct tcb *tcp)
2338 int i, len, dents = 0;
2341 if (entering(tcp)) {
2342 tprintf("%lu, ", tcp->u_arg[0]);
2345 if (syserror(tcp) || !verbose(tcp)) {
2346 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2350 if ((buf = malloc(len)) == NULL) {
2351 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2352 fprintf(stderr, "out of memory\n");
2355 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2356 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2362 for (i = 0; i < len;) {
2363 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2366 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2367 i ? " " : "", d->d_ino, d->d_off);
2368 tprintf("d_reclen=%u, d_name=\"%s\"}",
2369 d->d_reclen, d->d_name);
2374 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2376 (unsigned long) d->d_ino,
2377 (unsigned long) d->d_off);
2378 tprintf("d_reclen=%u, d_name=\"%s\"}",
2379 d->d_reclen, d->d_name);
2384 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2385 i ? " " : "", d->d_off, d->d_fileno,
2387 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2388 d->d_namlen, d->d_namlen, d->d_name);
2393 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2394 i ? " " : "", d->d_fileno, d->d_reclen);
2395 printxval(direnttypes, d->d_type, "DT_???");
2396 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2397 d->d_namlen, d->d_namlen, d->d_name);
2399 #endif /* FREEBSD */
2401 tprintf("/* d_reclen == 0, problem here */");
2410 tprintf("/* %u entries */", dents);
2411 tprintf(", %lu", tcp->u_arg[2]);
2417 #if _LFS64_LARGEFILE
2419 sys_getdents64(struct tcb *tcp)
2421 int i, len, dents = 0;
2424 if (entering(tcp)) {
2425 tprintf("%lu, ", tcp->u_arg[0]);
2428 if (syserror(tcp) || !verbose(tcp)) {
2429 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2433 if ((buf = malloc(len)) == NULL) {
2434 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2435 fprintf(stderr, "out of memory\n");
2438 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2439 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2445 for (i = 0; i < len;) {
2446 struct dirent64 *d = (struct dirent64 *) &buf[i];
2447 #if defined(LINUX) || defined(SVR4)
2449 tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ",
2455 printxval(direnttypes, d->d_type, "DT_???");
2458 tprintf("d_reclen=%u, d_name=\"%s\"}",
2459 d->d_reclen, d->d_name);
2461 #endif /* LINUX || SVR4 */
2464 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2465 i ? " " : "", d->d_off, d->d_fileno,
2467 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2468 d->d_namlen, d->d_namlen, d->d_name);
2472 tprintf("/* d_reclen == 0, problem here */");
2481 tprintf("/* %u entries */", dents);
2482 tprintf(", %lu", tcp->u_arg[2]);
2490 sys_getdirentries(struct tcb *tcp)
2492 int i, len, dents = 0;
2496 if (entering(tcp)) {
2497 tprintf("%lu, ", tcp->u_arg[0]);
2500 if (syserror(tcp) || !verbose(tcp)) {
2501 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2505 if ((buf = malloc(len)) == NULL) {
2506 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2507 fprintf(stderr, "out of memory\n");
2510 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2511 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2517 for (i = 0; i < len;) {
2518 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2520 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2521 i ? " " : "", d->d_fileno, d->d_reclen);
2522 printxval(direnttypes, d->d_type, "DT_???");
2523 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2524 d->d_namlen, d->d_namlen, d->d_name);
2527 tprintf("/* d_reclen == 0, problem here */");
2536 tprintf("/* %u entries */", dents);
2538 tprintf(", %lu", tcp->u_arg[2]);
2539 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2540 tprintf(", %#lx", tcp->u_arg[3]);
2542 tprintf(", [%lu]", basep);
2549 sys_getcwd(struct tcb *tcp)
2553 tprintf("%#lx", tcp->u_arg[0]);
2555 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2556 tprintf(", %lu", tcp->u_arg[1]);
2564 sys___getcwd(struct tcb *tcp)
2568 tprintf("%#lx", tcp->u_arg[0]);
2570 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2571 tprintf(", %lu", tcp->u_arg[1]);
2577 #ifdef HAVE_SYS_ASYNCH_H
2580 sys_aioread(struct tcb *tcp)
2582 struct aio_result_t res;
2584 if (entering(tcp)) {
2585 tprintf("%lu, ", tcp->u_arg[0]);
2588 tprintf("%#lx", tcp->u_arg[1]);
2590 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2591 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2592 printxval(whence, tcp->u_arg[4], "L_???");
2593 if (syserror(tcp) || tcp->u_arg[5] == 0
2594 || umove(tcp, tcp->u_arg[5], &res) < 0)
2595 tprintf(", %#lx", tcp->u_arg[5]);
2597 tprintf(", {aio_return %d aio_errno %d}",
2598 res.aio_return, res.aio_errno);
2604 sys_aiowrite(struct tcb *tcp)
2606 struct aio_result_t res;
2608 if (entering(tcp)) {
2609 tprintf("%lu, ", tcp->u_arg[0]);
2610 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2611 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2612 printxval(whence, tcp->u_arg[4], "L_???");
2615 if (tcp->u_arg[5] == 0)
2617 else if (syserror(tcp)
2618 || umove(tcp, tcp->u_arg[5], &res) < 0)
2619 tprintf(", %#lx", tcp->u_arg[5]);
2621 tprintf(", {aio_return %d aio_errno %d}",
2622 res.aio_return, res.aio_errno);
2628 sys_aiowait(struct tcb *tcp)
2631 printtv(tcp, tcp->u_arg[0]);
2636 sys_aiocancel(struct tcb *tcp)
2638 struct aio_result_t res;
2641 if (tcp->u_arg[0] == 0)
2643 else if (syserror(tcp)
2644 || umove(tcp, tcp->u_arg[0], &res) < 0)
2645 tprintf("%#lx", tcp->u_arg[0]);
2647 tprintf("{aio_return %d aio_errno %d}",
2648 res.aio_return, res.aio_errno);
2653 #endif /* HAVE_SYS_ASYNCH_H */
2655 static const struct xlat xattrflags[] = {
2657 { XATTR_CREATE, "XATTR_CREATE" },
2658 { XATTR_REPLACE, "XATTR_REPLACE" },
2664 print_xattr_val(struct tcb *tcp, int failed,
2666 unsigned long insize,
2670 unsigned long capacity = 4 * size + 1;
2671 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
2672 if (buf == NULL || /* probably a bogus size argument */
2673 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2677 unsigned char *out = buf;
2678 unsigned char *in = &buf[3 * size];
2680 for (i = 0; i < size; ++i) {
2684 #define tohex(n) "0123456789abcdef"[n]
2687 *out++ = tohex(in[i] / 16);
2688 *out++ = tohex(in[i] % 16);
2691 /* Don't print terminating NUL if there is one. */
2692 if (i > 0 && in[i - 1] == '\0')
2695 tprintf(", \"%s\", %ld", buf, insize);
2700 tprintf(", 0x%lx, %ld", arg, insize);
2704 sys_setxattr(struct tcb *tcp)
2706 if (entering(tcp)) {
2707 printpath(tcp, tcp->u_arg[0]);
2709 printstr(tcp, tcp->u_arg[1], -1);
2710 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2712 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2718 sys_fsetxattr(struct tcb *tcp)
2720 if (entering(tcp)) {
2721 tprintf("%ld, ", tcp->u_arg[0]);
2722 printstr(tcp, tcp->u_arg[1], -1);
2723 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2725 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2731 sys_getxattr(struct tcb *tcp)
2733 if (entering(tcp)) {
2734 printpath(tcp, tcp->u_arg[0]);
2736 printstr(tcp, tcp->u_arg[1], -1);
2738 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2745 sys_fgetxattr(struct tcb *tcp)
2747 if (entering(tcp)) {
2748 tprintf("%ld, ", tcp->u_arg[0]);
2749 printstr(tcp, tcp->u_arg[1], -1);
2751 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2758 sys_listxattr(struct tcb *tcp)
2760 if (entering(tcp)) {
2761 printpath(tcp, tcp->u_arg[0]);
2763 /* XXX Print value in format */
2764 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2770 sys_flistxattr(struct tcb *tcp)
2772 if (entering(tcp)) {
2773 tprintf("%ld", tcp->u_arg[0]);
2775 /* XXX Print value in format */
2776 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2782 sys_removexattr(struct tcb *tcp)
2784 if (entering(tcp)) {
2785 printpath(tcp, tcp->u_arg[0]);
2787 printstr(tcp, tcp->u_arg[1], -1);
2793 sys_fremovexattr(struct tcb *tcp)
2795 if (entering(tcp)) {
2796 tprintf("%ld, ", tcp->u_arg[0]);
2797 printstr(tcp, tcp->u_arg[1], -1);
2803 static const struct xlat advise[] = {
2804 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2805 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2806 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2807 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2808 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2809 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2816 sys_fadvise64(struct tcb *tcp)
2818 if (entering(tcp)) {
2819 tprintf("%ld, %lld, %ld, ",
2821 # if defined IA64 || defined X86_64 || defined ALPHA
2822 (long long int) tcp->u_arg[1], tcp->u_arg[2]);
2823 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2825 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]);
2826 printxval(advise, tcp->u_arg[4], "POSIX_FADV_???");
2835 sys_fadvise64_64(struct tcb *tcp)
2837 if (entering(tcp)) {
2838 tprintf("%ld, %lld, %lld, ",
2840 #if defined LINUX_MIPSN32
2841 tcp->ext_arg[1], tcp->ext_arg[2]);
2842 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2843 #elif defined IA64 || defined X86_64 || defined ALPHA || defined LINUX_MIPSN64
2844 (long long int) tcp->u_arg[1], (long long int) tcp->u_arg[2]);
2845 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2847 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]),
2848 LONG_LONG(tcp->u_arg[3], tcp->u_arg[4]));
2849 printxval(advise, tcp->u_arg[5], "POSIX_FADV_???");
2856 static const struct xlat inotify_modes[] = {
2857 { 0x00000001, "IN_ACCESS" },
2858 { 0x00000002, "IN_MODIFY" },
2859 { 0x00000004, "IN_ATTRIB" },
2860 { 0x00000008, "IN_CLOSE_WRITE" },
2861 { 0x00000010, "IN_CLOSE_NOWRITE" },
2862 { 0x00000020, "IN_OPEN" },
2863 { 0x00000040, "IN_MOVED_FROM" },
2864 { 0x00000080, "IN_MOVED_TO" },
2865 { 0x00000100, "IN_CREATE" },
2866 { 0x00000200, "IN_DELETE" },
2867 { 0x00000400, "IN_DELETE_SELF" },
2868 { 0x00000800, "IN_MOVE_SELF" },
2869 { 0x00002000, "IN_UNMOUNT" },
2870 { 0x00004000, "IN_Q_OVERFLOW" },
2871 { 0x00008000, "IN_IGNORED" },
2872 { 0x01000000, "IN_ONLYDIR" },
2873 { 0x02000000, "IN_DONT_FOLLOW" },
2874 { 0x20000000, "IN_MASK_ADD" },
2875 { 0x40000000, "IN_ISDIR" },
2876 { 0x80000000, "IN_ONESHOT" }
2880 sys_inotify_add_watch(struct tcb *tcp)
2882 if (entering(tcp)) {
2883 tprintf("%ld, ", tcp->u_arg[0]);
2884 printpath(tcp, tcp->u_arg[1]);
2886 printflags(inotify_modes, tcp->u_arg[2], "IN_???");
2892 sys_inotify_rm_watch(struct tcb *tcp)
2894 if (entering(tcp)) {
2895 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
2901 sys_fallocate(struct tcb *tcp)
2903 if (entering(tcp)) {
2904 tprintf("%ld, ", tcp->u_arg[0]); /* fd */
2905 tprintf("%#lo, ", tcp->u_arg[1]); /* mode */
2906 tprintf("%llu, ", LONG_LONG(tcp->u_arg[2],
2907 tcp->u_arg[3])); /* offset */
2908 tprintf("%llu", LONG_LONG(tcp->u_arg[4],
2909 tcp->u_arg[5])); /* len */