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 # if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
243 # define O_LARGEFILE 0x40000
244 # elif defined X86_64 || defined S390X
245 # define O_LARGEFILE 0100000
248 { O_LARGEFILE, "O_LARGEFILE" },
251 { O_DIRECTORY, "O_DIRECTORY" },
254 { O_NOFOLLOW, "O_NOFOLLOW" },
258 { FNDELAY, "FNDELAY" },
261 { FAPPEND, "FAPPEND" },
267 { FDEFER, "FDEFER" },
270 { FASYNC, "FASYNC" },
273 { FSHLOCK, "FSHLOCK" },
276 { FEXLOCK, "FEXLOCK" },
279 { FCREAT, "FCREAT" },
282 { FTRUNC, "FTRUNC" },
294 { FNOCTTY, "FNOCTTY" },
297 { O_SHLOCK, "O_SHLOCK" },
300 { O_EXLOCK, "O_EXLOCK" },
310 printpath(tcp, tcp->u_arg[0]);
313 printflags(openmodes, tcp->u_arg[1] + 1);
314 if (tcp->u_arg[1] & O_CREAT) {
316 tprintf(", %#lo", tcp->u_arg[2]);
323 const struct xlat openmodessol[] = {
327 { 0x80, "O_NONBLOCK" },
329 { 0x100, "O_CREAT" },
330 { 0x200, "O_TRUNC" },
332 { 0x800, "O_NOCTTY" },
335 { 0x8000, "O_RSYNC" },
337 { 0x1000, "O_PRIV" },
346 printpath(tcp, tcp->u_arg[0]);
349 printflags(openmodessol, tcp->u_arg[1] + 1);
350 if (tcp->u_arg[1] & 0x100) {
352 tprintf(", %#lo", tcp->u_arg[2]);
365 printpath(tcp, tcp->u_arg[0]);
366 tprintf(", %#lo", tcp->u_arg[1]);
371 static const struct xlat access_flags[] = {
377 { EFF_ONLY_OK, "EFF_ONLY_OK" },
390 printpath(tcp, tcp->u_arg[0]);
392 printflags(access_flags, tcp->u_arg[1]);
402 tprintf("%#lo", tcp->u_arg[0]);
407 static const struct xlat whence[] = {
408 { SEEK_SET, "SEEK_SET" },
409 { SEEK_CUR, "SEEK_CUR" },
410 { SEEK_END, "SEEK_END" },
414 #ifndef HAVE_LONG_LONG_OFF_T
423 tprintf("%ld, ", tcp->u_arg[0]);
424 offset = tcp->u_arg[1];
425 _whence = tcp->u_arg[2];
426 if (_whence == SEEK_SET)
427 tprintf("%lu, ", offset);
429 tprintf("%ld, ", offset);
430 printxval(whence, _whence, "SEEK_???");
432 return RVAL_UDECIMAL;
443 * This one call takes explicitly two 32-bit arguments hi, lo,
444 * rather than one 64-bit argument for which LONG_LONG works
445 * appropriate for the native byte order.
447 if (tcp->u_arg[4] == SEEK_SET)
448 tprintf("%ld, %llu, ", tcp->u_arg[0],
449 (((long long int) tcp->u_arg[1]) << 32
450 | (unsigned long long) (unsigned) tcp->u_arg[2]));
452 tprintf("%ld, %lld, ", tcp->u_arg[0],
453 (((long long int) tcp->u_arg[1]) << 32
454 | (unsigned long long) (unsigned) tcp->u_arg[2]));
458 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
459 tprintf("%#lx, ", tcp->u_arg[3]);
461 tprintf("[%llu], ", off);
462 printxval(whence, tcp->u_arg[4], "SEEK_???");
472 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
473 # if defined IA64 || defined X86_64 || defined ALPHA
474 (long long int) tcp->u_arg[1], tcp->u_arg[2]
476 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]
484 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
491 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
492 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
493 if (tcp->u_arg[3] == SEEK_SET)
494 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
496 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
497 printxval(whence, tcp->u_arg[3], "SEEK_???");
499 return RVAL_LUDECIMAL;
503 #ifndef HAVE_LONG_LONG_OFF_T
509 printpath(tcp, tcp->u_arg[0]);
510 tprintf(", %lu", tcp->u_arg[1]);
516 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
523 printpath(tcp, tcp->u_arg[0]);
524 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
530 #ifndef HAVE_LONG_LONG_OFF_T
536 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
542 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
549 tprintf("%ld, %llu", tcp->u_arg[0],
550 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
558 static const struct xlat modetypes[] = {
559 { S_IFREG, "S_IFREG" },
560 { S_IFSOCK, "S_IFSOCK" },
561 { S_IFIFO, "S_IFIFO" },
562 { S_IFLNK, "S_IFLNK" },
563 { S_IFDIR, "S_IFDIR" },
564 { S_IFBLK, "S_IFBLK" },
565 { S_IFCHR, "S_IFCHR" },
576 if ((mode & S_IFMT) == 0)
578 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
579 sprintf(buf, "%#o", mode);
582 sprintf(buf, "%s%s%s%s", s,
583 (mode & S_ISUID) ? "|S_ISUID" : "",
584 (mode & S_ISGID) ? "|S_ISGID" : "",
585 (mode & S_ISVTX) ? "|S_ISVTX" : "");
586 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
588 sprintf(buf + strlen(buf), "|%#o", mode);
589 s = (*buf == '|') ? buf + 1 : buf;
605 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
606 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
607 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
619 int st_pad1[3]; /* network id */
628 int st_pad3; /* st_size, off_t expansion */
629 timestruct_t st_atime;
630 timestruct_t st_mtime;
631 timestruct_t st_ctime;
635 int st_pad4[8]; /* expansion area */
639 printstatsol(tcp, addr)
643 struct solstat statbuf;
649 if (syserror(tcp) || !verbose(tcp)) {
650 tprintf("%#lx", addr);
653 if (umove(tcp, addr, &statbuf) < 0) {
658 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
659 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
660 (unsigned long) (statbuf.st_dev & 0x3ffff),
661 (unsigned long) statbuf.st_ino,
662 sprintmode(statbuf.st_mode));
663 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
664 (unsigned long) statbuf.st_nlink,
665 (unsigned long) statbuf.st_uid,
666 (unsigned long) statbuf.st_gid);
667 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
668 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
671 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
672 switch (statbuf.st_mode & S_IFMT) {
673 case S_IFCHR: case S_IFBLK:
674 tprintf("st_rdev=makedev(%lu, %lu), ",
675 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
676 (unsigned long) (statbuf.st_rdev & 0x3ffff));
679 tprintf("st_size=%u, ", statbuf.st_size);
683 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
684 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
685 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
691 #if defined (SPARC64)
693 printstat_sparc64(tcp, addr)
697 struct stat_sparc64 statbuf;
703 if (syserror(tcp) || !verbose(tcp)) {
704 tprintf("%#lx", addr);
707 if (umove(tcp, addr, &statbuf) < 0) {
713 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
714 (unsigned long) major(statbuf.st_dev),
715 (unsigned long) minor(statbuf.st_dev),
716 (unsigned long) statbuf.st_ino,
717 sprintmode(statbuf.st_mode));
718 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
719 (unsigned long) statbuf.st_nlink,
720 (unsigned long) statbuf.st_uid,
721 (unsigned long) statbuf.st_gid);
722 tprintf("st_blksize=%lu, ",
723 (unsigned long) statbuf.st_blksize);
724 tprintf("st_blocks=%lu, ",
725 (unsigned long) statbuf.st_blocks);
728 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
729 switch (statbuf.st_mode & S_IFMT) {
730 case S_IFCHR: case S_IFBLK:
731 tprintf("st_rdev=makedev(%lu, %lu), ",
732 (unsigned long) major(statbuf.st_rdev),
733 (unsigned long) minor(statbuf.st_rdev));
736 tprintf("st_size=%lu, ", statbuf.st_size);
740 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
741 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
742 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
749 #endif /* LINUXSPARC */
751 const struct xlat fileflags[] = {
753 { UF_NODUMP, "UF_NODUMP" },
754 { UF_IMMUTABLE, "UF_IMMUTABLE" },
755 { UF_APPEND, "UF_APPEND" },
756 { UF_OPAQUE, "UF_OPAQUE" },
757 { UF_NOUNLINK, "UF_NOUNLINK" },
758 { SF_ARCHIVED, "SF_ARCHIVED" },
759 { SF_IMMUTABLE, "SF_IMMUTABLE" },
760 { SF_APPEND, "SF_APPEND" },
761 { SF_NOUNLINK, "SF_NOUNLINK" },
764 { _S_ISMLD, "_S_ISMLD" },
767 { _S_ISMOUNTED, "_S_ISMOUNTED" },
779 printpath(tcp, tcp->u_arg[0]);
782 printflags(fileflags, tcp->u_arg[1]);
794 tprintf("%ld, ", tcp->u_arg[0]);
796 printflags(fileflags, tcp->u_arg[1]);
804 #ifndef HAVE_LONG_LONG_OFF_T
806 realprintstat(tcp, statbuf)
808 struct stat *statbuf;
811 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
812 (unsigned long) major(statbuf->st_dev),
813 (unsigned long) minor(statbuf->st_dev),
814 (unsigned long) statbuf->st_ino,
815 sprintmode(statbuf->st_mode));
816 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
817 (unsigned long) statbuf->st_nlink,
818 (unsigned long) statbuf->st_uid,
819 (unsigned long) statbuf->st_gid);
820 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
821 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
822 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
823 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
824 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
825 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
828 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
829 switch (statbuf->st_mode & S_IFMT) {
830 case S_IFCHR: case S_IFBLK:
831 #ifdef HAVE_STRUCT_STAT_ST_RDEV
832 tprintf("st_rdev=makedev(%lu, %lu), ",
833 (unsigned long) major(statbuf->st_rdev),
834 (unsigned long) minor(statbuf->st_rdev));
835 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
836 tprintf("st_size=makedev(%lu, %lu), ",
837 (unsigned long) major(statbuf->st_size),
838 (unsigned long) minor(statbuf->st_size));
839 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
842 tprintf("st_size=%lu, ", statbuf->st_size);
846 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
847 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
848 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
849 #if HAVE_STRUCT_STAT_ST_FLAGS
850 tprintf(", st_flags=");
851 if (statbuf->st_flags) {
852 printflags(fileflags, statbuf->st_flags);
856 #if HAVE_STRUCT_STAT_ST_ACLCNT
857 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
859 #if HAVE_STRUCT_STAT_ST_LEVEL
860 tprintf(", st_level=%ld", statbuf->st_level);
862 #if HAVE_STRUCT_STAT_ST_FSTYPE
863 tprintf(", st_fstype=%.*s",
864 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
866 #if HAVE_STRUCT_STAT_ST_GEN
867 tprintf(", st_gen=%u", statbuf->st_gen);
884 if (current_personality == 1) {
885 printstatsol(tcp, addr);
889 else if (current_personality == 2) {
890 printstat_sparc64(tcp, addr);
894 #endif /* LINUXSPARC */
900 if (syserror(tcp) || !verbose(tcp)) {
901 tprintf("%#lx", addr);
904 if (umove(tcp, addr, &statbuf) < 0) {
909 realprintstat(tcp, &statbuf);
911 #endif /* !HAVE_LONG_LONG_OFF_T */
915 printstat64(tcp, addr)
919 struct stat64 statbuf;
922 if (current_personality == 1) {
923 printstatsol(tcp, addr);
927 else if (current_personality == 2) {
928 printstat_sparc64(tcp, addr);
932 #endif /* LINUXSPARC */
938 if (syserror(tcp) || !verbose(tcp)) {
939 tprintf("%#lx", addr);
942 if (umove(tcp, addr, &statbuf) < 0) {
948 #ifdef HAVE_LONG_LONG
949 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
951 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
953 (unsigned long) major(statbuf.st_dev),
954 (unsigned long) minor(statbuf.st_dev),
955 #ifdef HAVE_LONG_LONG
956 (unsigned long long) statbuf.st_ino,
958 (unsigned long) statbuf.st_ino,
960 sprintmode(statbuf.st_mode));
961 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
962 (unsigned long) statbuf.st_nlink,
963 (unsigned long) statbuf.st_uid,
964 (unsigned long) statbuf.st_gid);
965 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
966 tprintf("st_blksize=%lu, ",
967 (unsigned long) statbuf.st_blksize);
968 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
969 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
970 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
971 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
974 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
975 switch (statbuf.st_mode & S_IFMT) {
976 case S_IFCHR: case S_IFBLK:
977 #ifdef HAVE_STRUCT_STAT_ST_RDEV
978 tprintf("st_rdev=makedev(%lu, %lu), ",
979 (unsigned long) major(statbuf.st_rdev),
980 (unsigned long) minor(statbuf.st_rdev));
981 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
982 tprintf("st_size=makedev(%lu, %lu), ",
983 (unsigned long) major(statbuf.st_size),
984 (unsigned long) minor(statbuf.st_size));
985 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
988 tprintf("st_size=%llu, ", statbuf.st_size);
992 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
993 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
994 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
995 #if HAVE_STRUCT_STAT_ST_FLAGS
996 tprintf(", st_flags=");
997 if (statbuf.st_flags) {
998 printflags(fileflags, statbuf.st_flags);
1002 #if HAVE_STRUCT_STAT_ST_ACLCNT
1003 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1005 #if HAVE_STRUCT_STAT_ST_LEVEL
1006 tprintf(", st_level=%ld", statbuf.st_level);
1008 #if HAVE_STRUCT_STAT_ST_FSTYPE
1009 tprintf(", st_fstype=%.*s",
1010 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1012 #if HAVE_STRUCT_STAT_ST_GEN
1013 tprintf(", st_gen=%u", statbuf.st_gen);
1020 #endif /* HAVE_STAT64 */
1022 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1024 convertoldstat(oldbuf, newbuf)
1025 const struct __old_kernel_stat *oldbuf;
1026 struct stat *newbuf;
1028 newbuf->st_dev=oldbuf->st_dev;
1029 newbuf->st_ino=oldbuf->st_ino;
1030 newbuf->st_mode=oldbuf->st_mode;
1031 newbuf->st_nlink=oldbuf->st_nlink;
1032 newbuf->st_uid=oldbuf->st_uid;
1033 newbuf->st_gid=oldbuf->st_gid;
1034 newbuf->st_rdev=oldbuf->st_rdev;
1035 newbuf->st_size=oldbuf->st_size;
1036 newbuf->st_atime=oldbuf->st_atime;
1037 newbuf->st_mtime=oldbuf->st_mtime;
1038 newbuf->st_ctime=oldbuf->st_ctime;
1039 newbuf->st_blksize=0; /* not supported in old_stat */
1040 newbuf->st_blocks=0; /* not supported in old_stat */
1045 printoldstat(tcp, addr)
1049 struct __old_kernel_stat statbuf;
1050 struct stat newstatbuf;
1053 if (current_personality == 1) {
1054 printstatsol(tcp, addr);
1057 #endif /* LINUXSPARC */
1063 if (syserror(tcp) || !verbose(tcp)) {
1064 tprintf("%#lx", addr);
1067 if (umove(tcp, addr, &statbuf) < 0) {
1072 convertoldstat(&statbuf, &newstatbuf);
1073 realprintstat(tcp, &newstatbuf);
1075 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1077 #ifndef HAVE_LONG_LONG_OFF_T
1082 if (entering(tcp)) {
1083 printpath(tcp, tcp->u_arg[0]);
1086 printstat(tcp, tcp->u_arg[1]);
1097 if (entering(tcp)) {
1098 printpath(tcp, tcp->u_arg[0]);
1101 printstat64(tcp, tcp->u_arg[1]);
1105 return printargs(tcp);
1109 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1114 if (entering(tcp)) {
1115 printpath(tcp, tcp->u_arg[0]);
1118 printoldstat(tcp, tcp->u_arg[1]);
1122 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1124 #ifndef HAVE_LONG_LONG_OFF_T
1130 tprintf("%ld, ", tcp->u_arg[0]);
1132 printstat(tcp, tcp->u_arg[1]);
1144 tprintf("%ld, ", tcp->u_arg[0]);
1146 printstat64(tcp, tcp->u_arg[1]);
1150 return printargs(tcp);
1154 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1160 tprintf("%ld, ", tcp->u_arg[0]);
1162 printoldstat(tcp, tcp->u_arg[1]);
1166 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1168 #ifndef HAVE_LONG_LONG_OFF_T
1173 if (entering(tcp)) {
1174 printpath(tcp, tcp->u_arg[0]);
1177 printstat(tcp, tcp->u_arg[1]);
1188 if (entering(tcp)) {
1189 printpath(tcp, tcp->u_arg[0]);
1192 printstat64(tcp, tcp->u_arg[1]);
1196 return printargs(tcp);
1200 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1205 if (entering(tcp)) {
1206 printpath(tcp, tcp->u_arg[0]);
1209 printoldstat(tcp, tcp->u_arg[1]);
1213 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1216 #if defined(SVR4) || defined(LINUXSPARC)
1222 if (entering(tcp)) {
1223 tprintf("%ld, ", tcp->u_arg[0]);
1224 printpath(tcp, tcp->u_arg[1]);
1228 if (tcp->u_arg[0] == _STAT64_VER)
1229 printstat64 (tcp, tcp->u_arg[2]);
1232 printstat(tcp, tcp->u_arg[2]);
1242 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1245 if (tcp->u_arg[0] == _STAT64_VER)
1246 printstat64 (tcp, tcp->u_arg[2]);
1249 printstat(tcp, tcp->u_arg[2]);
1258 if (entering(tcp)) {
1259 tprintf("%ld, ", tcp->u_arg[0]);
1260 printpath(tcp, tcp->u_arg[1]);
1264 if (tcp->u_arg[0] == _STAT64_VER)
1265 printstat64 (tcp, tcp->u_arg[2]);
1268 printstat(tcp, tcp->u_arg[2]);
1277 int mode = tcp->u_arg[2];
1279 if (entering(tcp)) {
1280 tprintf("%ld, ", tcp->u_arg[0]);
1281 printpath(tcp, tcp->u_arg[1]);
1282 tprintf(", %s", sprintmode(mode));
1283 switch (mode & S_IFMT) {
1284 case S_IFCHR: case S_IFBLK:
1286 tprintf(", makedev(%lu, %lu)",
1287 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1288 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1290 tprintf(", makedev(%lu, %lu)",
1291 (unsigned long) major(tcp->u_arg[3]),
1292 (unsigned long) minor(tcp->u_arg[3]));
1302 #ifdef HAVE_SYS_ACL_H
1304 #include <sys/acl.h>
1306 const struct xlat aclcmds[] = {
1308 { SETACL, "SETACL" },
1311 { GETACL, "GETACL" },
1314 { GETACLCNT, "GETACLCNT" },
1317 { ACL_GET, "ACL_GET" },
1320 { ACL_SET, "ACL_SET" },
1323 { ACL_CNT, "ACL_CNT" },
1332 if (entering(tcp)) {
1333 printpath(tcp, tcp->u_arg[0]);
1335 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1336 tprintf(", %ld", tcp->u_arg[2]);
1338 * FIXME - dump out the list of aclent_t's pointed to
1339 * by "tcp->u_arg[3]" if it's not NULL.
1342 tprintf(", %#lx", tcp->u_arg[3]);
1354 if (entering(tcp)) {
1355 tprintf("%ld, ", tcp->u_arg[0]);
1356 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1357 tprintf(", %ld", tcp->u_arg[2]);
1359 * FIXME - dump out the list of aclent_t's pointed to
1360 * by "tcp->u_arg[3]" if it's not NULL.
1363 tprintf(", %#lx", tcp->u_arg[3]);
1371 const struct xlat aclipc[] = {
1373 { IPC_SHM, "IPC_SHM" },
1376 { IPC_SEM, "IPC_SEM" },
1379 { IPC_MSG, "IPC_MSG" },
1389 if (entering(tcp)) {
1390 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1391 tprintf(", %#lx, ", tcp->u_arg[1]);
1392 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1393 tprintf(", %ld", tcp->u_arg[3]);
1395 * FIXME - dump out the list of aclent_t's pointed to
1396 * by "tcp->u_arg[4]" if it's not NULL.
1399 tprintf(", %#lx", tcp->u_arg[4]);
1408 #endif /* HAVE_SYS_ACL_H */
1410 #endif /* SVR4 || LINUXSPARC */
1414 static const struct xlat fsmagic[] = {
1415 { 0x73757245, "CODA_SUPER_MAGIC" },
1416 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1417 { 0x1373, "DEVFS_SUPER_MAGIC" },
1418 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1419 { 0x414A53, "EFS_SUPER_MAGIC" },
1420 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1421 { 0xef53, "EXT2_SUPER_MAGIC" },
1422 { 0x137d, "EXT_SUPER_MAGIC" },
1423 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1424 { 0x9660, "ISOFS_SUPER_MAGIC" },
1425 { 0x137f, "MINIX_SUPER_MAGIC" },
1426 { 0x138f, "MINIX_SUPER_MAGIC2" },
1427 { 0x2468, "MINIX2_SUPER_MAGIC" },
1428 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1429 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1430 { 0x564c, "NCP_SUPER_MAGIC" },
1431 { 0x6969, "NFS_SUPER_MAGIC" },
1432 { 0x9fa0, "PROC_SUPER_MAGIC" },
1433 { 0x002f, "QNX4_SUPER_MAGIC" },
1434 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1435 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1436 { 0x517b, "SMB_SUPER_MAGIC" },
1437 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1438 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1439 { 0x00011954, "UFS_MAGIC" },
1440 { 0x54190100, "UFS_CIGAM" },
1441 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1442 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1443 { 0x62656572, "SYSFS_MAGIC" },
1455 static char buf[32];
1459 s = xlookup(fsmagic, magic);
1461 sprintf(buf, "\"%s\"", s);
1465 sprintf(buf, "%#x", magic);
1470 printstatfs(tcp, addr)
1474 struct statfs statbuf;
1476 if (syserror(tcp) || !verbose(tcp)) {
1477 tprintf("%#lx", addr);
1480 if (umove(tcp, addr, &statbuf) < 0) {
1486 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1487 sprintfstype(statbuf.f_type),
1488 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1489 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1490 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1491 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1494 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1495 sprintfstype(statbuf.f_type),
1496 (unsigned long)statbuf.f_bsize,
1497 (unsigned long)statbuf.f_blocks,
1498 (unsigned long)statbuf.f_bfree);
1499 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1500 (unsigned long)statbuf.f_bavail,
1501 (unsigned long)statbuf.f_files,
1502 (unsigned long)statbuf.f_ffree,
1503 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1505 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1508 #ifdef _STATFS_F_FRSIZE
1509 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1518 if (entering(tcp)) {
1519 printpath(tcp, tcp->u_arg[0]);
1522 printstatfs(tcp, tcp->u_arg[1]);
1531 if (entering(tcp)) {
1532 tprintf("%lu, ", tcp->u_arg[0]);
1534 printstatfs(tcp, tcp->u_arg[1]);
1541 printstatfs64(tcp, addr)
1545 struct statfs64 statbuf;
1547 if (syserror(tcp) || !verbose(tcp)) {
1548 tprintf("%#lx", addr);
1551 if (umove(tcp, addr, &statbuf) < 0) {
1557 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1558 sprintfstype(statbuf.f_type),
1559 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1560 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1561 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1562 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1565 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1566 sprintfstype(statbuf.f_type),
1567 (unsigned long)statbuf.f_bsize,
1568 (unsigned long)statbuf.f_blocks,
1569 (unsigned long)statbuf.f_bfree);
1570 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1571 (unsigned long)statbuf.f_bavail,
1572 (unsigned long)statbuf.f_files,
1573 (unsigned long)statbuf.f_ffree,
1574 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1575 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1577 #ifdef _STATFS_F_FRSIZE
1578 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1587 if (entering(tcp)) {
1588 printpath(tcp, tcp->u_arg[0]);
1589 tprintf(", %lu, ", tcp->u_arg[1]);
1591 if (tcp->u_arg[1] == sizeof (struct statfs64))
1592 printstatfs64(tcp, tcp->u_arg[2]);
1603 if (entering(tcp)) {
1604 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1606 if (tcp->u_arg[1] == sizeof (struct statfs64))
1607 printstatfs64(tcp, tcp->u_arg[2]);
1615 #if defined(LINUX) && defined(__alpha)
1621 if (entering(tcp)) {
1622 printpath(tcp, tcp->u_arg[0]);
1625 printstatfs(tcp, tcp->u_arg[1]);
1626 tprintf(", %lu", tcp->u_arg[2]);
1635 if (entering(tcp)) {
1636 tprintf("%lu, ", tcp->u_arg[0]);
1638 printstatfs(tcp, tcp->u_arg[1]);
1639 tprintf(", %lu", tcp->u_arg[2]);
1643 #endif /* LINUX && __alpha */
1653 struct ustat statbuf;
1655 if (entering(tcp)) {
1656 tprintf("makedev(%lu, %lu), ",
1657 (long) major(tcp->u_arg[0]),
1658 (long) minor(tcp->u_arg[0]));
1661 if (syserror(tcp) || !verbose(tcp))
1662 tprintf("%#lx", tcp->u_arg[1]);
1663 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1666 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1667 statbuf.f_tfree, statbuf.f_tinode);
1668 tprintf("f_fname=\"%.*s\", ",
1669 (int) sizeof(statbuf.f_fname),
1671 tprintf("f_fpack=\"%.*s\"}",
1672 (int) sizeof(statbuf.f_fpack),
1685 if (entering(tcp)) {
1686 printpath(tcp, tcp->u_arg[0]);
1688 printpath(tcp, tcp->u_arg[1]);
1699 if (entering(tcp)) {
1700 printpath(tcp, tcp->u_arg[0]);
1709 if (entering(tcp)) {
1710 printpath(tcp, tcp->u_arg[0]);
1711 tprintf(", %#lo", tcp->u_arg[1]);
1720 if (entering(tcp)) {
1721 printpath(tcp, tcp->u_arg[0]);
1730 if (entering(tcp)) {
1731 tprintf("%ld", tcp->u_arg[0]);
1740 if (entering(tcp)) {
1741 printpath(tcp, tcp->u_arg[0]);
1750 if (entering(tcp)) {
1751 tprintf("%ld", tcp->u_arg[0]);
1760 if (entering(tcp)) {
1761 printpath(tcp, tcp->u_arg[0]);
1763 printpath(tcp, tcp->u_arg[1]);
1772 if (entering(tcp)) {
1773 printpath(tcp, tcp->u_arg[0]);
1782 if (entering(tcp)) {
1783 printpath(tcp, tcp->u_arg[0]);
1785 printpath(tcp, tcp->u_arg[1]);
1794 if (entering(tcp)) {
1795 printpath(tcp, tcp->u_arg[0]);
1799 tprintf("%#lx", tcp->u_arg[1]);
1801 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1802 tprintf(", %lu", tcp->u_arg[2]);
1811 if (entering(tcp)) {
1812 printpath(tcp, tcp->u_arg[0]);
1814 printpath(tcp, tcp->u_arg[1]);
1823 if (entering(tcp)) {
1824 printpath(tcp, tcp->u_arg[0]);
1825 printuid(", ", tcp->u_arg[1]);
1826 printuid(", ", tcp->u_arg[2]);
1835 if (entering(tcp)) {
1836 tprintf("%ld", tcp->u_arg[0]);
1837 printuid(", ", tcp->u_arg[1]);
1838 printuid(", ", tcp->u_arg[2]);
1847 if (entering(tcp)) {
1848 printpath(tcp, tcp->u_arg[0]);
1849 tprintf(", %#lo", tcp->u_arg[1]);
1858 if (entering(tcp)) {
1859 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1869 if (entering(tcp)) {
1870 printpath(tcp, tcp->u_arg[0]);
1872 printtv32(tcp, tcp->u_arg[1]);
1882 if (entering(tcp)) {
1883 printpath(tcp, tcp->u_arg[0]);
1885 printtv(tcp, tcp->u_arg[1]);
1896 if (entering(tcp)) {
1897 printpath(tcp, tcp->u_arg[0]);
1901 else if (!verbose(tcp))
1902 tprintf("%#lx", tcp->u_arg[1]);
1903 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1907 tprintf("[%s,", sprinttime(ut[0]));
1908 tprintf(" %s]", sprinttime(ut[1]));
1918 int mode = tcp->u_arg[1];
1920 if (entering(tcp)) {
1921 printpath(tcp, tcp->u_arg[0]);
1922 tprintf(", %s", sprintmode(mode));
1923 switch (mode & S_IFMT) {
1924 case S_IFCHR: case S_IFBLK:
1926 if (current_personality == 1)
1927 tprintf(", makedev(%lu, %lu)",
1928 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1929 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1932 tprintf(", makedev(%lu, %lu)",
1933 (unsigned long) major(tcp->u_arg[2]),
1934 (unsigned long) minor(tcp->u_arg[2]));
1947 if (entering(tcp)) {
1948 printpath(tcp, tcp->u_arg[0]);
1949 tprintf(", %#lo", tcp->u_arg[1]);
1958 if (entering(tcp)) {
1959 tprintf("%ld", tcp->u_arg[0]);
1973 if (!verbose(tcp)) {
1974 tprintf("%#lx", addr);
1977 if (umove(tcp, addr, &d) < 0) {
1981 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1983 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1991 if (entering(tcp)) {
1992 tprintf("%lu, ", tcp->u_arg[0]);
1994 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1995 tprintf("%#lx", tcp->u_arg[1]);
1997 printdir(tcp, tcp->u_arg[1]);
1998 /* Not much point in printing this out, it is always 1. */
1999 if (tcp->u_arg[2] != 1)
2000 tprintf(", %lu", tcp->u_arg[2]);
2007 #if defined FREEBSD || defined LINUX
2008 const struct xlat direnttypes[] = {
2009 { DT_UNKNOWN, "DT_UNKNOWN" },
2010 { DT_FIFO, "DT_FIFO" },
2011 { DT_CHR, "DT_CHR" },
2012 { DT_DIR, "DT_DIR" },
2013 { DT_BLK, "DT_BLK" },
2014 { DT_REG, "DT_REG" },
2015 { DT_LNK, "DT_LNK" },
2016 { DT_SOCK, "DT_SOCK" },
2017 { DT_WHT, "DT_WHT" },
2027 int i, len, dents = 0;
2030 if (entering(tcp)) {
2031 tprintf("%lu, ", tcp->u_arg[0]);
2034 if (syserror(tcp) || !verbose(tcp)) {
2035 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2039 if ((buf = malloc(len)) == NULL) {
2040 tprintf("out of memory\n");
2043 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2044 tprintf("{...}, %lu", tcp->u_arg[2]);
2050 for (i = 0; i < len;) {
2051 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2054 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2055 i ? " " : "", d->d_ino, d->d_off);
2056 tprintf("d_reclen=%u, d_name=\"%s\"}",
2057 d->d_reclen, d->d_name);
2062 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2064 (unsigned long) d->d_ino,
2065 (unsigned long) d->d_off);
2066 tprintf("d_reclen=%u, d_name=\"%s\"}",
2067 d->d_reclen, d->d_name);
2072 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2073 i ? " " : "", d->d_off, d->d_fileno,
2075 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2076 d->d_namlen, d->d_namlen, d->d_name);
2081 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2082 i ? " " : "", d->d_fileno, d->d_reclen);
2083 printxval(direnttypes, d->d_type, "DT_???");
2084 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2085 d->d_namlen, d->d_namlen, d->d_name);
2087 #endif /* FREEBSD */
2089 tprintf("/* d_reclen == 0, problem here */");
2098 tprintf("/* %u entries */", dents);
2099 tprintf(", %lu", tcp->u_arg[2]);
2105 #if _LFS64_LARGEFILE
2110 int i, len, dents = 0;
2113 if (entering(tcp)) {
2114 tprintf("%lu, ", tcp->u_arg[0]);
2117 if (syserror(tcp) || !verbose(tcp)) {
2118 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2122 if ((buf = malloc(len)) == NULL) {
2123 tprintf("out of memory\n");
2126 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2127 tprintf("{...}, %lu", tcp->u_arg[2]);
2133 for (i = 0; i < len;) {
2134 struct dirent64 *d = (struct dirent64 *) &buf[i];
2135 #if defined(LINUX) || defined(SVR4)
2137 tprintf("%s{d_ino=%llu, d_off=%llu, ",
2143 printxval(direnttypes, d->d_type, "DT_???");
2146 tprintf("d_reclen=%u, d_name=\"%s\"}",
2147 d->d_reclen, d->d_name);
2149 #endif /* LINUX || SVR4 */
2152 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2153 i ? " " : "", d->d_off, d->d_fileno,
2155 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2156 d->d_namlen, d->d_namlen, d->d_name);
2165 tprintf("/* %u entries */", dents);
2166 tprintf(", %lu", tcp->u_arg[2]);
2174 sys_getdirentries(tcp)
2177 int i, len, dents = 0;
2181 if (entering(tcp)) {
2182 tprintf("%lu, ", tcp->u_arg[0]);
2185 if (syserror(tcp) || !verbose(tcp)) {
2186 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2190 if ((buf = malloc(len)) == NULL) {
2191 tprintf("out of memory\n");
2194 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2195 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
2201 for (i = 0; i < len;) {
2202 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2204 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2205 i ? " " : "", d->d_fileno, d->d_reclen);
2206 printxval(direnttypes, d->d_type, "DT_???");
2207 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2208 d->d_namlen, d->d_namlen, d->d_name);
2216 tprintf("/* %u entries */", dents);
2218 tprintf(", %lu", tcp->u_arg[2]);
2219 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2220 tprintf(", %#lx", tcp->u_arg[3]);
2222 tprintf(", [%lu]", basep);
2234 tprintf("%#lx", tcp->u_arg[0]);
2236 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2237 tprintf(", %lu", tcp->u_arg[1]);
2250 tprintf("%#lx", tcp->u_arg[0]);
2252 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2253 tprintf(", %lu", tcp->u_arg[1]);
2259 #ifdef HAVE_SYS_ASYNCH_H
2265 struct aio_result_t res;
2267 if (entering(tcp)) {
2268 tprintf("%lu, ", tcp->u_arg[0]);
2271 tprintf("%#lx", tcp->u_arg[1]);
2273 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2274 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2275 printxval(whence, tcp->u_arg[4], "L_???");
2276 if (syserror(tcp) || tcp->u_arg[5] == 0
2277 || umove(tcp, tcp->u_arg[5], &res) < 0)
2278 tprintf(", %#lx", tcp->u_arg[5]);
2280 tprintf(", {aio_return %d aio_errno %d}",
2281 res.aio_return, res.aio_errno);
2290 struct aio_result_t res;
2292 if (entering(tcp)) {
2293 tprintf("%lu, ", tcp->u_arg[0]);
2294 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2295 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2296 printxval(whence, tcp->u_arg[4], "L_???");
2299 if (tcp->u_arg[5] == 0)
2301 else if (syserror(tcp)
2302 || umove(tcp, tcp->u_arg[5], &res) < 0)
2303 tprintf(", %#lx", tcp->u_arg[5]);
2305 tprintf(", {aio_return %d aio_errno %d}",
2306 res.aio_return, res.aio_errno);
2316 printtv(tcp, tcp->u_arg[0]);
2324 struct aio_result_t res;
2327 if (tcp->u_arg[0] == 0)
2329 else if (syserror(tcp)
2330 || umove(tcp, tcp->u_arg[0], &res) < 0)
2331 tprintf("%#lx", tcp->u_arg[0]);
2333 tprintf("{aio_return %d aio_errno %d}",
2334 res.aio_return, res.aio_errno);
2339 #endif /* HAVE_SYS_ASYNCH_H */
2341 const struct xlat xattrflags[] = {
2343 { XATTR_CREATE, "XATTR_CREATE" },
2344 { XATTR_REPLACE, "XATTR_REPLACE" },
2350 print_xattr_val(tcp, failed, arg, insize, size)
2357 unsigned char *buf = malloc(4 * size + 1);
2358 if (buf == NULL || /* probably a bogus size argument */
2359 umoven(tcp, arg, size, &buf[3 * size]) < 0) {
2363 unsigned char *out = buf;
2364 unsigned char *in = &buf[3 * size];
2366 for (i = 0; i < size; ++i)
2370 #define tohex(n) "0123456789abcdef"[n]
2373 *out++ = tohex(in[i] / 16);
2374 *out++ = tohex(in[i] % 16);
2376 /* Don't print terminating NUL if there is one. */
2377 if (in[i - 1] == '\0')
2380 tprintf(", \"%s\", %ld", buf, insize);
2385 tprintf(", 0x%lx, %ld", arg, insize);
2392 if (entering(tcp)) {
2393 printpath(tcp, tcp->u_arg[0]);
2395 printstr(tcp, tcp->u_arg[1], -1);
2396 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2398 printflags(xattrflags, tcp->u_arg[4]);
2407 if (entering(tcp)) {
2408 tprintf("%ld, ", tcp->u_arg[0]);
2409 printstr(tcp, tcp->u_arg[1], -1);
2410 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2412 printflags(xattrflags, tcp->u_arg[4]);
2421 if (entering(tcp)) {
2422 printpath(tcp, tcp->u_arg[0]);
2424 printstr(tcp, tcp->u_arg[1], -1);
2426 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2436 if (entering(tcp)) {
2437 tprintf("%ld, ", tcp->u_arg[0]);
2438 printstr(tcp, tcp->u_arg[1], -1);
2440 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2450 if (entering(tcp)) {
2451 printpath(tcp, tcp->u_arg[0]);
2453 /* XXX Print value in format */
2454 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2463 if (entering(tcp)) {
2464 tprintf("%ld", tcp->u_arg[0]);
2466 /* XXX Print value in format */
2467 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2473 sys_removexattr(tcp)
2476 if (entering(tcp)) {
2477 printpath(tcp, tcp->u_arg[0]);
2479 printstr(tcp, tcp->u_arg[1], -1);
2485 sys_fremovexattr(tcp)
2488 if (entering(tcp)) {
2489 tprintf("%ld, ", tcp->u_arg[0]);
2490 printstr(tcp, tcp->u_arg[1], -1);
2496 static const struct xlat advise[] = {
2497 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2498 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2499 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2500 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2501 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2502 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2512 if (entering(tcp)) {
2513 tprintf("%ld, %lld, %ld, ",
2515 # if defined IA64 || defined X86_64 || defined ALPHA
2516 (long long int) tcp->u_arg[1], tcp->u_arg[2]);
2517 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2519 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]);
2520 printxval(advise, tcp->u_arg[4], "POSIX_FADV_???");
2529 sys_fadvise64_64(tcp)
2532 if (entering(tcp)) {
2533 tprintf("%ld, %lld, %lld, ",
2535 # if defined IA64 || defined X86_64 || defined ALPHA
2536 (long long int) tcp->u_arg[1], (long long int) tcp->u_arg[2]);
2537 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2539 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]),
2540 LONG_LONG(tcp->u_arg[3], tcp->u_arg[4]));
2541 printxval(advise, tcp->u_arg[5], "POSIX_FADV_???");