3 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
4 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
5 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
6 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #define dirent kernel_dirent
39 #define dirent64 kernel_dirent64
40 #include <linux/types.h>
41 #include <linux/dirent.h>
45 #define kernel_dirent dirent
51 unsigned short st_dev;
53 unsigned short st_mode;
55 unsigned short st_uid;
56 unsigned short st_gid;
57 unsigned short st_rdev;
60 unsigned int __unused1;
62 unsigned int __unused2;
64 unsigned int __unused3;
67 unsigned int __unused4[2];
74 unsigned int st_nlink;
84 unsigned long __unused4[2];
87 # define stat kernel_stat
88 # include <asm/stat.h>
100 # define dev_t __kernel_dev_t
101 # define ino_t __kernel_ino_t
102 # define mode_t __kernel_mode_t
103 # define nlink_t __kernel_nlink_t
104 # define uid_t __kernel_uid_t
105 # define gid_t __kernel_gid_t
106 # define off_t __kernel_off_t
107 # define loff_t __kernel_loff_t
109 # include <asm/stat.h>
122 # define mode_t mode_t
123 # define nlink_t nlink_t
127 # define loff_t loff_t
129 # ifdef HPPA /* asm-parisc/stat.h defines stat64 */
132 # define stat libc_stat
133 # define stat64 libc_stat64
134 # include <sys/stat.h>
137 /* These might be macros. */
142 # define stat64 hpux_stat64
145 # include <sys/stat.h>
151 # include <sys/cred.h>
154 #ifdef HAVE_SYS_VFS_H
158 #ifdef HAVE_LINUX_XATTR_H
159 #include <linux/xattr.h>
161 #define XATTR_CREATE 1
162 #define XATTR_REPLACE 2
166 #include <sys/param.h>
167 #include <sys/mount.h>
168 #include <sys/stat.h>
171 #if HAVE_LONG_LONG_OFF_T
173 * Ugly hacks for systems that have typedef long long off_t
177 #define HAVE_STAT64 1 /* Ugly hack */
179 #define sys_stat64 sys_stat
180 #define sys_fstat64 sys_fstat
181 #define sys_lstat64 sys_lstat
182 #define sys_lseek64 sys_lseek
183 #define sys_truncate64 sys_truncate
184 #define sys_ftruncate64 sys_ftruncate
187 #ifdef MAJOR_IN_SYSMACROS
188 #include <sys/sysmacros.h>
191 #ifdef MAJOR_IN_MKDEV
192 #include <sys/mkdev.h>
195 #ifdef HAVE_SYS_ASYNCH_H
196 #include <sys/asynch.h>
204 * This is a really dirty trick but it should always work. Traditional
205 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
206 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
208 const struct xlat openmodes[] = {
209 { O_RDWR+1, "O_RDWR" },
210 { O_RDONLY+1, "O_RDONLY" },
211 { O_WRONLY+1, "O_WRONLY" },
212 { O_NONBLOCK, "O_NONBLOCK" },
213 { O_APPEND, "O_APPEND" },
214 { O_CREAT, "O_CREAT" },
215 { O_TRUNC, "O_TRUNC" },
216 { O_EXCL, "O_EXCL" },
217 { O_NOCTTY, "O_NOCTTY" },
219 { O_SYNC, "O_SYNC" },
222 { O_ASYNC, "O_ASYNC" },
225 { O_DSYNC, "O_DSYNC" },
228 { O_RSYNC, "O_RSYNC" },
231 { O_NDELAY, "O_NDELAY" },
234 { O_PRIV, "O_PRIV" },
237 { O_DIRECT, "O_DIRECT" },
240 { O_LARGEFILE, "O_LARGEFILE" },
243 { O_DIRECTORY, "O_DIRECTORY" },
246 { O_NOFOLLOW, "O_NOFOLLOW" },
250 { FNDELAY, "FNDELAY" },
253 { FAPPEND, "FAPPEND" },
259 { FDEFER, "FDEFER" },
262 { FASYNC, "FASYNC" },
265 { FSHLOCK, "FSHLOCK" },
268 { FEXLOCK, "FEXLOCK" },
271 { FCREAT, "FCREAT" },
274 { FTRUNC, "FTRUNC" },
286 { FNOCTTY, "FNOCTTY" },
289 { O_SHLOCK, "O_SHLOCK" },
292 { O_EXLOCK, "O_EXLOCK" },
302 printpath(tcp, tcp->u_arg[0]);
305 printflags(openmodes, tcp->u_arg[1] + 1);
306 if (tcp->u_arg[1] & O_CREAT) {
308 tprintf(", %#lo", tcp->u_arg[2]);
315 const struct xlat openmodessol[] = {
319 { 0x80, "O_NONBLOCK" },
321 { 0x100, "O_CREAT" },
322 { 0x200, "O_TRUNC" },
324 { 0x800, "O_NOCTTY" },
327 { 0x8000, "O_RSYNC" },
329 { 0x1000, "O_PRIV" },
338 printpath(tcp, tcp->u_arg[0]);
341 printflags(openmodessol, tcp->u_arg[1] + 1);
342 if (tcp->u_arg[1] & 0x100) {
344 tprintf(", %#lo", tcp->u_arg[2]);
357 printpath(tcp, tcp->u_arg[0]);
358 tprintf(", %#lo", tcp->u_arg[1]);
363 static const struct xlat access_flags[] = {
369 { EFF_ONLY_OK, "EFF_ONLY_OK" },
382 printpath(tcp, tcp->u_arg[0]);
384 printflags(access_flags, tcp->u_arg[1]);
394 tprintf("%#lo", tcp->u_arg[0]);
399 static const struct xlat whence[] = {
400 { SEEK_SET, "SEEK_SET" },
401 { SEEK_CUR, "SEEK_CUR" },
402 { SEEK_END, "SEEK_END" },
406 #ifndef HAVE_LONG_LONG_OFF_T
415 tprintf("%ld, ", tcp->u_arg[0]);
416 offset = tcp->u_arg[1];
417 _whence = tcp->u_arg[2];
418 if (_whence == SEEK_SET)
419 tprintf("%lu, ", offset);
421 tprintf("%ld, ", offset);
422 printxval(whence, _whence, "SEEK_???");
424 return RVAL_UDECIMAL;
435 * This one call takes explicitly two 32-bit arguments hi, lo,
436 * rather than one 64-bit argument for which LONG_LONG works
437 * appropriate for the native byte order.
439 if (tcp->u_arg[4] == SEEK_SET)
440 tprintf("%ld, %llu, ", tcp->u_arg[0],
441 (((long long int) tcp->u_arg[1]) << 32
442 | (unsigned long long) (unsigned) tcp->u_arg[2]));
444 tprintf("%ld, %lld, ", tcp->u_arg[0],
445 (((long long int) tcp->u_arg[1]) << 32
446 | (unsigned long long) (unsigned) tcp->u_arg[2]));
450 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
451 tprintf("%#lx, ", tcp->u_arg[3]);
453 tprintf("[%llu], ", off);
454 printxval(whence, tcp->u_arg[4], "SEEK_???");
464 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
465 # if defined IA64 || defined X86_64 || defined ALPHA
466 (long long int) tcp->u_arg[1], tcp->u_arg[2]
468 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]
476 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
483 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
484 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
485 if (tcp->u_arg[3] == SEEK_SET)
486 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
488 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
489 printxval(whence, tcp->u_arg[3], "SEEK_???");
491 return RVAL_LUDECIMAL;
495 #ifndef HAVE_LONG_LONG_OFF_T
501 printpath(tcp, tcp->u_arg[0]);
502 tprintf(", %lu", tcp->u_arg[1]);
508 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
515 printpath(tcp, tcp->u_arg[0]);
516 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
522 #ifndef HAVE_LONG_LONG_OFF_T
528 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
534 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
541 tprintf("%ld, %llu", tcp->u_arg[0],
542 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
550 static const struct xlat modetypes[] = {
551 { S_IFREG, "S_IFREG" },
552 { S_IFSOCK, "S_IFSOCK" },
553 { S_IFIFO, "S_IFIFO" },
554 { S_IFLNK, "S_IFLNK" },
555 { S_IFDIR, "S_IFDIR" },
556 { S_IFBLK, "S_IFBLK" },
557 { S_IFCHR, "S_IFCHR" },
568 if ((mode & S_IFMT) == 0)
570 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
571 sprintf(buf, "%#o", mode);
574 sprintf(buf, "%s%s%s%s", s,
575 (mode & S_ISUID) ? "|S_ISUID" : "",
576 (mode & S_ISGID) ? "|S_ISGID" : "",
577 (mode & S_ISVTX) ? "|S_ISVTX" : "");
578 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
580 sprintf(buf + strlen(buf), "|%#o", mode);
581 s = (*buf == '|') ? buf + 1 : buf;
597 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
598 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
599 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
611 int st_pad1[3]; /* network id */
620 int st_pad3; /* st_size, off_t expansion */
621 timestruct_t st_atime;
622 timestruct_t st_mtime;
623 timestruct_t st_ctime;
627 int st_pad4[8]; /* expansion area */
631 printstatsol(tcp, addr)
635 struct solstat statbuf;
641 if (syserror(tcp) || !verbose(tcp)) {
642 tprintf("%#lx", addr);
645 if (umove(tcp, addr, &statbuf) < 0) {
650 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
651 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
652 (unsigned long) (statbuf.st_dev & 0x3ffff),
653 (unsigned long) statbuf.st_ino,
654 sprintmode(statbuf.st_mode));
655 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
656 (unsigned long) statbuf.st_nlink,
657 (unsigned long) statbuf.st_uid,
658 (unsigned long) statbuf.st_gid);
659 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
660 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
663 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
664 switch (statbuf.st_mode & S_IFMT) {
665 case S_IFCHR: case S_IFBLK:
666 tprintf("st_rdev=makedev(%lu, %lu), ",
667 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
668 (unsigned long) (statbuf.st_rdev & 0x3ffff));
671 tprintf("st_size=%u, ", statbuf.st_size);
675 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
676 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
677 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
683 #if defined (SPARC64)
685 printstat_sparc64(tcp, addr)
689 struct stat_sparc64 statbuf;
695 if (syserror(tcp) || !verbose(tcp)) {
696 tprintf("%#lx", addr);
699 if (umove(tcp, addr, &statbuf) < 0) {
705 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
706 (unsigned long) major(statbuf.st_dev),
707 (unsigned long) minor(statbuf.st_dev),
708 (unsigned long) statbuf.st_ino,
709 sprintmode(statbuf.st_mode));
710 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
711 (unsigned long) statbuf.st_nlink,
712 (unsigned long) statbuf.st_uid,
713 (unsigned long) statbuf.st_gid);
714 tprintf("st_blksize=%lu, ",
715 (unsigned long) statbuf.st_blksize);
716 tprintf("st_blocks=%lu, ",
717 (unsigned long) statbuf.st_blocks);
720 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
721 switch (statbuf.st_mode & S_IFMT) {
722 case S_IFCHR: case S_IFBLK:
723 tprintf("st_rdev=makedev(%lu, %lu), ",
724 (unsigned long) major(statbuf.st_rdev),
725 (unsigned long) minor(statbuf.st_rdev));
728 tprintf("st_size=%lu, ", statbuf.st_size);
732 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
733 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
734 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
741 #endif /* LINUXSPARC */
743 const struct xlat fileflags[] = {
745 { UF_NODUMP, "UF_NODUMP" },
746 { UF_IMMUTABLE, "UF_IMMUTABLE" },
747 { UF_APPEND, "UF_APPEND" },
748 { UF_OPAQUE, "UF_OPAQUE" },
749 { UF_NOUNLINK, "UF_NOUNLINK" },
750 { SF_ARCHIVED, "SF_ARCHIVED" },
751 { SF_IMMUTABLE, "SF_IMMUTABLE" },
752 { SF_APPEND, "SF_APPEND" },
753 { SF_NOUNLINK, "SF_NOUNLINK" },
756 { _S_ISMLD, "_S_ISMLD" },
759 { _S_ISMOUNTED, "_S_ISMOUNTED" },
771 printpath(tcp, tcp->u_arg[0]);
774 printflags(fileflags, tcp->u_arg[1]);
786 tprintf("%ld, ", tcp->u_arg[0]);
788 printflags(fileflags, tcp->u_arg[1]);
796 #ifndef HAVE_LONG_LONG_OFF_T
798 realprintstat(tcp, statbuf)
800 struct stat *statbuf;
803 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
804 (unsigned long) major(statbuf->st_dev),
805 (unsigned long) minor(statbuf->st_dev),
806 (unsigned long) statbuf->st_ino,
807 sprintmode(statbuf->st_mode));
808 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
809 (unsigned long) statbuf->st_nlink,
810 (unsigned long) statbuf->st_uid,
811 (unsigned long) statbuf->st_gid);
812 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
813 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
814 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
815 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
816 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
817 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
820 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
821 switch (statbuf->st_mode & S_IFMT) {
822 case S_IFCHR: case S_IFBLK:
823 #ifdef HAVE_STRUCT_STAT_ST_RDEV
824 tprintf("st_rdev=makedev(%lu, %lu), ",
825 (unsigned long) major(statbuf->st_rdev),
826 (unsigned long) minor(statbuf->st_rdev));
827 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
828 tprintf("st_size=makedev(%lu, %lu), ",
829 (unsigned long) major(statbuf->st_size),
830 (unsigned long) minor(statbuf->st_size));
831 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
834 tprintf("st_size=%lu, ", statbuf->st_size);
838 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
839 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
840 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
841 #if HAVE_STRUCT_STAT_ST_FLAGS
842 tprintf(", st_flags=");
843 if (statbuf->st_flags) {
844 printflags(fileflags, statbuf->st_flags);
848 #if HAVE_STRUCT_STAT_ST_ACLCNT
849 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
851 #if HAVE_STRUCT_STAT_ST_LEVEL
852 tprintf(", st_level=%ld", statbuf->st_level);
854 #if HAVE_STRUCT_STAT_ST_FSTYPE
855 tprintf(", st_fstype=%.*s",
856 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
858 #if HAVE_STRUCT_STAT_ST_GEN
859 tprintf(", st_gen=%u", statbuf->st_gen);
876 if (current_personality == 1) {
877 printstatsol(tcp, addr);
881 else if (current_personality == 2) {
882 printstat_sparc64(tcp, addr);
886 #endif /* LINUXSPARC */
892 if (syserror(tcp) || !verbose(tcp)) {
893 tprintf("%#lx", addr);
896 if (umove(tcp, addr, &statbuf) < 0) {
901 realprintstat(tcp, &statbuf);
903 #endif /* !HAVE_LONG_LONG_OFF_T */
907 printstat64(tcp, addr)
911 struct stat64 statbuf;
914 if (current_personality == 1) {
915 printstatsol(tcp, addr);
919 else if (current_personality == 2) {
920 printstat_sparc64(tcp, addr);
924 #endif /* LINUXSPARC */
930 if (syserror(tcp) || !verbose(tcp)) {
931 tprintf("%#lx", addr);
934 if (umove(tcp, addr, &statbuf) < 0) {
940 #ifdef HAVE_LONG_LONG
941 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
943 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
945 (unsigned long) major(statbuf.st_dev),
946 (unsigned long) minor(statbuf.st_dev),
947 #ifdef HAVE_LONG_LONG
948 (unsigned long long) statbuf.st_ino,
950 (unsigned long) statbuf.st_ino,
952 sprintmode(statbuf.st_mode));
953 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
954 (unsigned long) statbuf.st_nlink,
955 (unsigned long) statbuf.st_uid,
956 (unsigned long) statbuf.st_gid);
957 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
958 tprintf("st_blksize=%lu, ",
959 (unsigned long) statbuf.st_blksize);
960 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
961 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
962 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
963 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
966 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
967 switch (statbuf.st_mode & S_IFMT) {
968 case S_IFCHR: case S_IFBLK:
969 #ifdef HAVE_STRUCT_STAT_ST_RDEV
970 tprintf("st_rdev=makedev(%lu, %lu), ",
971 (unsigned long) major(statbuf.st_rdev),
972 (unsigned long) minor(statbuf.st_rdev));
973 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
974 tprintf("st_size=makedev(%lu, %lu), ",
975 (unsigned long) major(statbuf.st_size),
976 (unsigned long) minor(statbuf.st_size));
977 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
980 tprintf("st_size=%llu, ", statbuf.st_size);
984 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
985 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
986 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
987 #if HAVE_STRUCT_STAT_ST_FLAGS
988 tprintf(", st_flags=");
989 if (statbuf.st_flags) {
990 printflags(fileflags, statbuf.st_flags);
994 #if HAVE_STRUCT_STAT_ST_ACLCNT
995 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
997 #if HAVE_STRUCT_STAT_ST_LEVEL
998 tprintf(", st_level=%ld", statbuf.st_level);
1000 #if HAVE_STRUCT_STAT_ST_FSTYPE
1001 tprintf(", st_fstype=%.*s",
1002 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1004 #if HAVE_STRUCT_STAT_ST_GEN
1005 tprintf(", st_gen=%u", statbuf.st_gen);
1012 #endif /* HAVE_STAT64 */
1014 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1016 convertoldstat(oldbuf, newbuf)
1017 const struct __old_kernel_stat *oldbuf;
1018 struct stat *newbuf;
1020 newbuf->st_dev=oldbuf->st_dev;
1021 newbuf->st_ino=oldbuf->st_ino;
1022 newbuf->st_mode=oldbuf->st_mode;
1023 newbuf->st_nlink=oldbuf->st_nlink;
1024 newbuf->st_uid=oldbuf->st_uid;
1025 newbuf->st_gid=oldbuf->st_gid;
1026 newbuf->st_rdev=oldbuf->st_rdev;
1027 newbuf->st_size=oldbuf->st_size;
1028 newbuf->st_atime=oldbuf->st_atime;
1029 newbuf->st_mtime=oldbuf->st_mtime;
1030 newbuf->st_ctime=oldbuf->st_ctime;
1031 newbuf->st_blksize=0; /* not supported in old_stat */
1032 newbuf->st_blocks=0; /* not supported in old_stat */
1037 printoldstat(tcp, addr)
1041 struct __old_kernel_stat statbuf;
1042 struct stat newstatbuf;
1045 if (current_personality == 1) {
1046 printstatsol(tcp, addr);
1049 #endif /* LINUXSPARC */
1055 if (syserror(tcp) || !verbose(tcp)) {
1056 tprintf("%#lx", addr);
1059 if (umove(tcp, addr, &statbuf) < 0) {
1064 convertoldstat(&statbuf, &newstatbuf);
1065 realprintstat(tcp, &newstatbuf);
1067 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1069 #ifndef HAVE_LONG_LONG_OFF_T
1074 if (entering(tcp)) {
1075 printpath(tcp, tcp->u_arg[0]);
1078 printstat(tcp, tcp->u_arg[1]);
1089 if (entering(tcp)) {
1090 printpath(tcp, tcp->u_arg[0]);
1093 printstat64(tcp, tcp->u_arg[1]);
1097 return printargs(tcp);
1101 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1106 if (entering(tcp)) {
1107 printpath(tcp, tcp->u_arg[0]);
1110 printoldstat(tcp, tcp->u_arg[1]);
1114 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1116 #ifndef HAVE_LONG_LONG_OFF_T
1122 tprintf("%ld, ", tcp->u_arg[0]);
1124 printstat(tcp, tcp->u_arg[1]);
1136 tprintf("%ld, ", tcp->u_arg[0]);
1138 printstat64(tcp, tcp->u_arg[1]);
1142 return printargs(tcp);
1146 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1152 tprintf("%ld, ", tcp->u_arg[0]);
1154 printoldstat(tcp, tcp->u_arg[1]);
1158 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1160 #ifndef HAVE_LONG_LONG_OFF_T
1165 if (entering(tcp)) {
1166 printpath(tcp, tcp->u_arg[0]);
1169 printstat(tcp, tcp->u_arg[1]);
1180 if (entering(tcp)) {
1181 printpath(tcp, tcp->u_arg[0]);
1184 printstat64(tcp, tcp->u_arg[1]);
1188 return printargs(tcp);
1192 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1197 if (entering(tcp)) {
1198 printpath(tcp, tcp->u_arg[0]);
1201 printoldstat(tcp, tcp->u_arg[1]);
1205 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1208 #if defined(SVR4) || defined(LINUXSPARC)
1214 if (entering(tcp)) {
1215 tprintf("%ld, ", tcp->u_arg[0]);
1216 printpath(tcp, tcp->u_arg[1]);
1220 if (tcp->u_arg[0] == _STAT64_VER)
1221 printstat64 (tcp, tcp->u_arg[2]);
1224 printstat(tcp, tcp->u_arg[2]);
1234 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1237 if (tcp->u_arg[0] == _STAT64_VER)
1238 printstat64 (tcp, tcp->u_arg[2]);
1241 printstat(tcp, tcp->u_arg[2]);
1250 if (entering(tcp)) {
1251 tprintf("%ld, ", tcp->u_arg[0]);
1252 printpath(tcp, tcp->u_arg[1]);
1256 if (tcp->u_arg[0] == _STAT64_VER)
1257 printstat64 (tcp, tcp->u_arg[2]);
1260 printstat(tcp, tcp->u_arg[2]);
1269 int mode = tcp->u_arg[2];
1271 if (entering(tcp)) {
1272 tprintf("%ld, ", tcp->u_arg[0]);
1273 printpath(tcp, tcp->u_arg[1]);
1274 tprintf(", %s", sprintmode(mode));
1275 switch (mode & S_IFMT) {
1276 case S_IFCHR: case S_IFBLK:
1278 tprintf(", makedev(%lu, %lu)",
1279 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1280 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1282 tprintf(", makedev(%lu, %lu)",
1283 (unsigned long) major(tcp->u_arg[3]),
1284 (unsigned long) minor(tcp->u_arg[3]));
1294 #ifdef HAVE_SYS_ACL_H
1296 #include <sys/acl.h>
1298 const struct xlat aclcmds[] = {
1300 { SETACL, "SETACL" },
1303 { GETACL, "GETACL" },
1306 { GETACLCNT, "GETACLCNT" },
1309 { ACL_GET, "ACL_GET" },
1312 { ACL_SET, "ACL_SET" },
1315 { ACL_CNT, "ACL_CNT" },
1324 if (entering(tcp)) {
1325 printpath(tcp, tcp->u_arg[0]);
1327 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1328 tprintf(", %ld", tcp->u_arg[2]);
1330 * FIXME - dump out the list of aclent_t's pointed to
1331 * by "tcp->u_arg[3]" if it's not NULL.
1334 tprintf(", %#lx", tcp->u_arg[3]);
1346 if (entering(tcp)) {
1347 tprintf("%ld, ", tcp->u_arg[0]);
1348 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1349 tprintf(", %ld", tcp->u_arg[2]);
1351 * FIXME - dump out the list of aclent_t's pointed to
1352 * by "tcp->u_arg[3]" if it's not NULL.
1355 tprintf(", %#lx", tcp->u_arg[3]);
1363 const struct xlat aclipc[] = {
1365 { IPC_SHM, "IPC_SHM" },
1368 { IPC_SEM, "IPC_SEM" },
1371 { IPC_MSG, "IPC_MSG" },
1381 if (entering(tcp)) {
1382 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1383 tprintf(", %#lx, ", tcp->u_arg[1]);
1384 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1385 tprintf(", %ld", tcp->u_arg[3]);
1387 * FIXME - dump out the list of aclent_t's pointed to
1388 * by "tcp->u_arg[4]" if it's not NULL.
1391 tprintf(", %#lx", tcp->u_arg[4]);
1400 #endif /* HAVE_SYS_ACL_H */
1402 #endif /* SVR4 || LINUXSPARC */
1406 static const struct xlat fsmagic[] = {
1407 { 0x73757245, "CODA_SUPER_MAGIC" },
1408 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1409 { 0x1373, "DEVFS_SUPER_MAGIC" },
1410 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1411 { 0x414A53, "EFS_SUPER_MAGIC" },
1412 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1413 { 0xef53, "EXT2_SUPER_MAGIC" },
1414 { 0x137d, "EXT_SUPER_MAGIC" },
1415 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1416 { 0x9660, "ISOFS_SUPER_MAGIC" },
1417 { 0x137f, "MINIX_SUPER_MAGIC" },
1418 { 0x138f, "MINIX_SUPER_MAGIC2" },
1419 { 0x2468, "MINIX2_SUPER_MAGIC" },
1420 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1421 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1422 { 0x564c, "NCP_SUPER_MAGIC" },
1423 { 0x6969, "NFS_SUPER_MAGIC" },
1424 { 0x9fa0, "PROC_SUPER_MAGIC" },
1425 { 0x002f, "QNX4_SUPER_MAGIC" },
1426 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1427 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1428 { 0x517b, "SMB_SUPER_MAGIC" },
1429 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1430 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1431 { 0x00011954, "UFS_MAGIC" },
1432 { 0x54190100, "UFS_CIGAM" },
1433 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1434 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1435 { 0x62656572, "SYSFS_MAGIC" },
1447 static char buf[32];
1451 s = xlookup(fsmagic, magic);
1453 sprintf(buf, "\"%s\"", s);
1457 sprintf(buf, "%#x", magic);
1462 printstatfs(tcp, addr)
1466 struct statfs statbuf;
1468 if (syserror(tcp) || !verbose(tcp)) {
1469 tprintf("%#lx", addr);
1472 if (umove(tcp, addr, &statbuf) < 0) {
1478 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1479 sprintfstype(statbuf.f_type),
1480 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1481 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1482 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1483 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1486 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1487 sprintfstype(statbuf.f_type),
1488 (unsigned long)statbuf.f_bsize,
1489 (unsigned long)statbuf.f_blocks,
1490 (unsigned long)statbuf.f_bfree);
1491 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1492 (unsigned long)statbuf.f_bavail,
1493 (unsigned long)statbuf.f_files,
1494 (unsigned long)statbuf.f_ffree,
1495 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1497 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1500 #ifdef _STATFS_F_FRSIZE
1501 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1510 if (entering(tcp)) {
1511 printpath(tcp, tcp->u_arg[0]);
1514 printstatfs(tcp, tcp->u_arg[1]);
1523 if (entering(tcp)) {
1524 tprintf("%lu, ", tcp->u_arg[0]);
1526 printstatfs(tcp, tcp->u_arg[1]);
1533 printstatfs64(tcp, addr)
1537 struct statfs64 statbuf;
1539 if (syserror(tcp) || !verbose(tcp)) {
1540 tprintf("%#lx", addr);
1543 if (umove(tcp, addr, &statbuf) < 0) {
1549 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1550 sprintfstype(statbuf.f_type),
1551 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1552 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1553 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1554 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1557 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1558 sprintfstype(statbuf.f_type),
1559 (unsigned long)statbuf.f_bsize,
1560 (unsigned long)statbuf.f_blocks,
1561 (unsigned long)statbuf.f_bfree);
1562 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1563 (unsigned long)statbuf.f_bavail,
1564 (unsigned long)statbuf.f_files,
1565 (unsigned long)statbuf.f_ffree,
1566 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1567 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1569 #ifdef _STATFS_F_FRSIZE
1570 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1579 if (entering(tcp)) {
1580 printpath(tcp, tcp->u_arg[0]);
1581 tprintf(", %lu, ", tcp->u_arg[1]);
1583 if (tcp->u_arg[1] == sizeof (struct statfs64))
1584 printstatfs64(tcp, tcp->u_arg[2]);
1595 if (entering(tcp)) {
1596 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1598 if (tcp->u_arg[1] == sizeof (struct statfs64))
1599 printstatfs64(tcp, tcp->u_arg[2]);
1607 #if defined(LINUX) && defined(__alpha)
1613 if (entering(tcp)) {
1614 printpath(tcp, tcp->u_arg[0]);
1617 printstatfs(tcp, tcp->u_arg[1]);
1618 tprintf(", %lu", tcp->u_arg[2]);
1627 if (entering(tcp)) {
1628 tprintf("%lu, ", tcp->u_arg[0]);
1630 printstatfs(tcp, tcp->u_arg[1]);
1631 tprintf(", %lu", tcp->u_arg[2]);
1635 #endif /* LINUX && __alpha */
1645 struct ustat statbuf;
1647 if (entering(tcp)) {
1648 tprintf("makedev(%lu, %lu), ",
1649 (long) major(tcp->u_arg[0]),
1650 (long) minor(tcp->u_arg[0]));
1653 if (syserror(tcp) || !verbose(tcp))
1654 tprintf("%#lx", tcp->u_arg[1]);
1655 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1658 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1659 statbuf.f_tfree, statbuf.f_tinode);
1660 tprintf("f_fname=\"%.*s\", ",
1661 (int) sizeof(statbuf.f_fname),
1663 tprintf("f_fpack=\"%.*s\"}",
1664 (int) sizeof(statbuf.f_fpack),
1677 if (entering(tcp)) {
1678 printpath(tcp, tcp->u_arg[0]);
1680 printpath(tcp, tcp->u_arg[1]);
1691 if (entering(tcp)) {
1692 printpath(tcp, tcp->u_arg[0]);
1701 if (entering(tcp)) {
1702 printpath(tcp, tcp->u_arg[0]);
1703 tprintf(", %#lo", tcp->u_arg[1]);
1712 if (entering(tcp)) {
1713 printpath(tcp, tcp->u_arg[0]);
1722 if (entering(tcp)) {
1723 tprintf("%ld", tcp->u_arg[0]);
1732 if (entering(tcp)) {
1733 printpath(tcp, tcp->u_arg[0]);
1742 if (entering(tcp)) {
1743 tprintf("%ld", tcp->u_arg[0]);
1752 if (entering(tcp)) {
1753 printpath(tcp, tcp->u_arg[0]);
1755 printpath(tcp, tcp->u_arg[1]);
1764 if (entering(tcp)) {
1765 printpath(tcp, tcp->u_arg[0]);
1774 if (entering(tcp)) {
1775 printpath(tcp, tcp->u_arg[0]);
1777 printpath(tcp, tcp->u_arg[1]);
1786 if (entering(tcp)) {
1787 printpath(tcp, tcp->u_arg[0]);
1791 tprintf("%#lx", tcp->u_arg[1]);
1793 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1794 tprintf(", %lu", tcp->u_arg[2]);
1803 if (entering(tcp)) {
1804 printpath(tcp, tcp->u_arg[0]);
1806 printpath(tcp, tcp->u_arg[1]);
1815 if (entering(tcp)) {
1816 printpath(tcp, tcp->u_arg[0]);
1817 printuid(", ", tcp->u_arg[1]);
1818 printuid(", ", tcp->u_arg[2]);
1827 if (entering(tcp)) {
1828 tprintf("%ld", tcp->u_arg[0]);
1829 printuid(", ", tcp->u_arg[1]);
1830 printuid(", ", tcp->u_arg[2]);
1839 if (entering(tcp)) {
1840 printpath(tcp, tcp->u_arg[0]);
1841 tprintf(", %#lo", tcp->u_arg[1]);
1850 if (entering(tcp)) {
1851 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1861 if (entering(tcp)) {
1862 printpath(tcp, tcp->u_arg[0]);
1864 printtv32(tcp, tcp->u_arg[1]);
1874 if (entering(tcp)) {
1875 printpath(tcp, tcp->u_arg[0]);
1877 printtv(tcp, tcp->u_arg[1]);
1888 if (entering(tcp)) {
1889 printpath(tcp, tcp->u_arg[0]);
1893 else if (!verbose(tcp))
1894 tprintf("%#lx", tcp->u_arg[1]);
1895 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1899 tprintf("[%s,", sprinttime(ut[0]));
1900 tprintf(" %s]", sprinttime(ut[1]));
1910 int mode = tcp->u_arg[1];
1912 if (entering(tcp)) {
1913 printpath(tcp, tcp->u_arg[0]);
1914 tprintf(", %s", sprintmode(mode));
1915 switch (mode & S_IFMT) {
1916 case S_IFCHR: case S_IFBLK:
1918 if (current_personality == 1)
1919 tprintf(", makedev(%lu, %lu)",
1920 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1921 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1924 tprintf(", makedev(%lu, %lu)",
1925 (unsigned long) major(tcp->u_arg[2]),
1926 (unsigned long) minor(tcp->u_arg[2]));
1939 if (entering(tcp)) {
1940 printpath(tcp, tcp->u_arg[0]);
1941 tprintf(", %#lo", tcp->u_arg[1]);
1950 if (entering(tcp)) {
1951 tprintf("%ld", tcp->u_arg[0]);
1965 if (!verbose(tcp)) {
1966 tprintf("%#lx", addr);
1969 if (umove(tcp, addr, &d) < 0) {
1973 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1975 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1983 if (entering(tcp)) {
1984 tprintf("%lu, ", tcp->u_arg[0]);
1986 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1987 tprintf("%#lx", tcp->u_arg[1]);
1989 printdir(tcp, tcp->u_arg[1]);
1990 /* Not much point in printing this out, it is always 1. */
1991 if (tcp->u_arg[2] != 1)
1992 tprintf(", %lu", tcp->u_arg[2]);
1999 #if defined FREEBSD || defined LINUX
2000 const struct xlat direnttypes[] = {
2001 { DT_UNKNOWN, "DT_UNKNOWN" },
2002 { DT_FIFO, "DT_FIFO" },
2003 { DT_CHR, "DT_CHR" },
2004 { DT_DIR, "DT_DIR" },
2005 { DT_BLK, "DT_BLK" },
2006 { DT_REG, "DT_REG" },
2007 { DT_LNK, "DT_LNK" },
2008 { DT_SOCK, "DT_SOCK" },
2009 { DT_WHT, "DT_WHT" },
2019 int i, len, dents = 0;
2022 if (entering(tcp)) {
2023 tprintf("%lu, ", tcp->u_arg[0]);
2026 if (syserror(tcp) || !verbose(tcp)) {
2027 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2031 if ((buf = malloc(len)) == NULL) {
2032 tprintf("out of memory\n");
2035 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2036 tprintf("{...}, %lu", tcp->u_arg[2]);
2042 for (i = 0; i < len;) {
2043 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2046 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2047 i ? " " : "", d->d_ino, d->d_off);
2048 tprintf("d_reclen=%u, d_name=\"%s\"}",
2049 d->d_reclen, d->d_name);
2054 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2056 (unsigned long) d->d_ino,
2057 (unsigned long) d->d_off);
2058 tprintf("d_reclen=%u, d_name=\"%s\"}",
2059 d->d_reclen, d->d_name);
2064 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2065 i ? " " : "", d->d_off, d->d_fileno,
2067 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2068 d->d_namlen, d->d_namlen, d->d_name);
2073 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2074 i ? " " : "", d->d_fileno, d->d_reclen);
2075 printxval(direnttypes, d->d_type, "DT_???");
2076 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2077 d->d_namlen, d->d_namlen, d->d_name);
2079 #endif /* FREEBSD */
2081 tprintf("/* d_reclen == 0, problem here */");
2090 tprintf("/* %u entries */", dents);
2091 tprintf(", %lu", tcp->u_arg[2]);
2097 #if _LFS64_LARGEFILE
2102 int i, len, dents = 0;
2105 if (entering(tcp)) {
2106 tprintf("%lu, ", tcp->u_arg[0]);
2109 if (syserror(tcp) || !verbose(tcp)) {
2110 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2114 if ((buf = malloc(len)) == NULL) {
2115 tprintf("out of memory\n");
2118 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2119 tprintf("{...}, %lu", tcp->u_arg[2]);
2125 for (i = 0; i < len;) {
2126 struct dirent64 *d = (struct dirent64 *) &buf[i];
2127 #if defined(LINUX) || defined(SVR4)
2129 tprintf("%s{d_ino=%llu, d_off=%llu, ",
2135 printxval(direnttypes, d->d_type, "DT_???");
2138 tprintf("d_reclen=%u, d_name=\"%s\"}",
2139 d->d_reclen, d->d_name);
2141 #endif /* LINUX || SVR4 */
2144 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2145 i ? " " : "", d->d_off, d->d_fileno,
2147 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2148 d->d_namlen, d->d_namlen, d->d_name);
2157 tprintf("/* %u entries */", dents);
2158 tprintf(", %lu", tcp->u_arg[2]);
2166 sys_getdirentries(tcp)
2169 int i, len, dents = 0;
2173 if (entering(tcp)) {
2174 tprintf("%lu, ", tcp->u_arg[0]);
2177 if (syserror(tcp) || !verbose(tcp)) {
2178 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2182 if ((buf = malloc(len)) == NULL) {
2183 tprintf("out of memory\n");
2186 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2187 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
2193 for (i = 0; i < len;) {
2194 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2196 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2197 i ? " " : "", d->d_fileno, d->d_reclen);
2198 printxval(direnttypes, d->d_type, "DT_???");
2199 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2200 d->d_namlen, d->d_namlen, d->d_name);
2208 tprintf("/* %u entries */", dents);
2210 tprintf(", %lu", tcp->u_arg[2]);
2211 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2212 tprintf(", %#lx", tcp->u_arg[3]);
2214 tprintf(", [%lu]", basep);
2226 tprintf("%#lx", tcp->u_arg[0]);
2228 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2229 tprintf(", %lu", tcp->u_arg[1]);
2242 tprintf("%#lx", tcp->u_arg[0]);
2244 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2245 tprintf(", %lu", tcp->u_arg[1]);
2251 #ifdef HAVE_SYS_ASYNCH_H
2257 struct aio_result_t res;
2259 if (entering(tcp)) {
2260 tprintf("%lu, ", tcp->u_arg[0]);
2263 tprintf("%#lx", tcp->u_arg[1]);
2265 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2266 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2267 printxval(whence, tcp->u_arg[4], "L_???");
2268 if (syserror(tcp) || tcp->u_arg[5] == 0
2269 || umove(tcp, tcp->u_arg[5], &res) < 0)
2270 tprintf(", %#lx", tcp->u_arg[5]);
2272 tprintf(", {aio_return %d aio_errno %d}",
2273 res.aio_return, res.aio_errno);
2282 struct aio_result_t res;
2284 if (entering(tcp)) {
2285 tprintf("%lu, ", tcp->u_arg[0]);
2286 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2287 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2288 printxval(whence, tcp->u_arg[4], "L_???");
2291 if (tcp->u_arg[5] == 0)
2293 else if (syserror(tcp)
2294 || umove(tcp, tcp->u_arg[5], &res) < 0)
2295 tprintf(", %#lx", tcp->u_arg[5]);
2297 tprintf(", {aio_return %d aio_errno %d}",
2298 res.aio_return, res.aio_errno);
2308 printtv(tcp, tcp->u_arg[0]);
2316 struct aio_result_t res;
2319 if (tcp->u_arg[0] == 0)
2321 else if (syserror(tcp)
2322 || umove(tcp, tcp->u_arg[0], &res) < 0)
2323 tprintf("%#lx", tcp->u_arg[0]);
2325 tprintf("{aio_return %d aio_errno %d}",
2326 res.aio_return, res.aio_errno);
2331 #endif /* HAVE_SYS_ASYNCH_H */
2333 const struct xlat xattrflags[] = {
2335 { XATTR_CREATE, "XATTR_CREATE" },
2336 { XATTR_REPLACE, "XATTR_REPLACE" },
2342 print_xattr_val(tcp, failed, arg, insize, size)
2348 unsigned char buf[4 * size + 1];
2349 if (!failed && umoven(tcp, arg, size, &buf[3 * size]) >= 0) {
2350 unsigned char *out = buf;
2351 unsigned char *in = &buf[3 * size];
2353 for (i = 0; i < size; ++i)
2357 #define tohex(n) "0123456789abcdef"[n]
2360 *out++ = tohex(in[i] / 16);
2361 *out++ = tohex(in[i] % 16);
2363 /* Don't print terminating NUL if there is one. */
2364 if (in[i - 1] == '\0')
2367 tprintf(", \"%s\", %zd", buf, insize);
2369 tprintf(", 0x%lx, %zd", arg, insize);
2376 if (entering(tcp)) {
2377 printpath(tcp, tcp->u_arg[0]);
2379 printstr(tcp, tcp->u_arg[1], -1);
2380 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2382 printflags(xattrflags, tcp->u_arg[4]);
2391 if (entering(tcp)) {
2392 tprintf("%ld, ", tcp->u_arg[0]);
2393 printstr(tcp, tcp->u_arg[1], -1);
2394 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2396 printflags(xattrflags, tcp->u_arg[4]);
2405 if (entering(tcp)) {
2406 printpath(tcp, tcp->u_arg[0]);
2408 printstr(tcp, tcp->u_arg[1], -1);
2410 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2420 if (entering(tcp)) {
2421 tprintf("%ld, ", tcp->u_arg[0]);
2422 printstr(tcp, tcp->u_arg[1], -1);
2424 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2434 if (entering(tcp)) {
2435 printpath(tcp, tcp->u_arg[0]);
2437 /* XXX Print value in format */
2438 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2447 if (entering(tcp)) {
2448 tprintf("%ld", tcp->u_arg[0]);
2450 /* XXX Print value in format */
2451 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2457 sys_removexattr(tcp)
2460 if (entering(tcp)) {
2461 printpath(tcp, tcp->u_arg[0]);
2463 printstr(tcp, tcp->u_arg[1], -1);
2469 sys_fremovexattr(tcp)
2472 if (entering(tcp)) {
2473 tprintf("%ld, ", tcp->u_arg[0]);
2474 printstr(tcp, tcp->u_arg[1], -1);
2480 static const struct xlat advise[] = {
2481 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2482 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2483 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2484 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2485 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2486 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2496 if (entering(tcp)) {
2497 tprintf("%ld, %lld, %ld, ",
2499 # if defined IA64 || defined X86_64 || defined ALPHA
2500 (long long int) tcp->u_arg[1], tcp->u_arg[2]);
2501 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2503 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]);
2504 printxval(advise, tcp->u_arg[4], "POSIX_FADV_???");
2513 sys_fadvise64_64(tcp)
2516 if (entering(tcp)) {
2517 tprintf("%ld, %lld, %lld, ",
2519 # if defined IA64 || defined X86_64 || defined ALPHA
2520 (long long int) tcp->u_arg[1], (long long int) tcp->u_arg[2]);
2521 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2523 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]),
2524 LONG_LONG(tcp->u_arg[3], tcp->u_arg[4]));
2525 printxval(advise, tcp->u_arg[5], "POSIX_FADV_???");