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;
434 if (tcp->u_arg[4] == SEEK_SET)
435 tprintf("%ld, %llu, ", tcp->u_arg[0],
436 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]));
438 tprintf("%ld, %lld, ", tcp->u_arg[0],
439 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]));
443 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
444 tprintf("%#lx, ", tcp->u_arg[3]);
446 tprintf("[%llu], ", off);
447 printxval(whence, tcp->u_arg[4], "SEEK_???");
457 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
458 # if defined IA64 || defined X86_64 || defined ALPHA
459 (long long int) tcp->u_arg[1], tcp->u_arg[2]
461 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]
469 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
476 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
477 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
478 if (tcp->u_arg[3] == SEEK_SET)
479 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
481 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
482 printxval(whence, tcp->u_arg[3], "SEEK_???");
484 return RVAL_LUDECIMAL;
488 #ifndef HAVE_LONG_LONG_OFF_T
494 printpath(tcp, tcp->u_arg[0]);
495 tprintf(", %lu", tcp->u_arg[1]);
501 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
508 printpath(tcp, tcp->u_arg[0]);
509 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
515 #ifndef HAVE_LONG_LONG_OFF_T
521 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
527 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
534 tprintf("%ld, %llu", tcp->u_arg[0],
535 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
543 static const struct xlat modetypes[] = {
544 { S_IFREG, "S_IFREG" },
545 { S_IFSOCK, "S_IFSOCK" },
546 { S_IFIFO, "S_IFIFO" },
547 { S_IFLNK, "S_IFLNK" },
548 { S_IFDIR, "S_IFDIR" },
549 { S_IFBLK, "S_IFBLK" },
550 { S_IFCHR, "S_IFCHR" },
561 if ((mode & S_IFMT) == 0)
563 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
564 sprintf(buf, "%#o", mode);
567 sprintf(buf, "%s%s%s%s", s,
568 (mode & S_ISUID) ? "|S_ISUID" : "",
569 (mode & S_ISGID) ? "|S_ISGID" : "",
570 (mode & S_ISVTX) ? "|S_ISVTX" : "");
571 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
573 sprintf(buf + strlen(buf), "|%#o", mode);
574 s = (*buf == '|') ? buf + 1 : buf;
590 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
591 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
592 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
604 int st_pad1[3]; /* network id */
613 int st_pad3; /* st_size, off_t expansion */
614 timestruct_t st_atime;
615 timestruct_t st_mtime;
616 timestruct_t st_ctime;
620 int st_pad4[8]; /* expansion area */
624 printstatsol(tcp, addr)
628 struct solstat statbuf;
634 if (syserror(tcp) || !verbose(tcp)) {
635 tprintf("%#lx", addr);
638 if (umove(tcp, addr, &statbuf) < 0) {
643 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
644 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
645 (unsigned long) (statbuf.st_dev & 0x3ffff),
646 (unsigned long) statbuf.st_ino,
647 sprintmode(statbuf.st_mode));
648 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
649 (unsigned long) statbuf.st_nlink,
650 (unsigned long) statbuf.st_uid,
651 (unsigned long) statbuf.st_gid);
652 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
653 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
656 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
657 switch (statbuf.st_mode & S_IFMT) {
658 case S_IFCHR: case S_IFBLK:
659 tprintf("st_rdev=makedev(%lu, %lu), ",
660 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
661 (unsigned long) (statbuf.st_rdev & 0x3ffff));
664 tprintf("st_size=%u, ", statbuf.st_size);
668 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
669 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
670 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
676 #if defined (SPARC64)
678 printstat_sparc64(tcp, addr)
682 struct stat_sparc64 statbuf;
688 if (syserror(tcp) || !verbose(tcp)) {
689 tprintf("%#lx", addr);
692 if (umove(tcp, addr, &statbuf) < 0) {
698 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
699 (unsigned long) major(statbuf.st_dev),
700 (unsigned long) minor(statbuf.st_dev),
701 (unsigned long) statbuf.st_ino,
702 sprintmode(statbuf.st_mode));
703 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
704 (unsigned long) statbuf.st_nlink,
705 (unsigned long) statbuf.st_uid,
706 (unsigned long) statbuf.st_gid);
707 tprintf("st_blksize=%lu, ",
708 (unsigned long) statbuf.st_blksize);
709 tprintf("st_blocks=%lu, ",
710 (unsigned long) statbuf.st_blocks);
713 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
714 switch (statbuf.st_mode & S_IFMT) {
715 case S_IFCHR: case S_IFBLK:
716 tprintf("st_rdev=makedev(%lu, %lu), ",
717 (unsigned long) major(statbuf.st_rdev),
718 (unsigned long) minor(statbuf.st_rdev));
721 tprintf("st_size=%lu, ", statbuf.st_size);
725 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
726 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
727 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
734 #endif /* LINUXSPARC */
736 const struct xlat fileflags[] = {
738 { UF_NODUMP, "UF_NODUMP" },
739 { UF_IMMUTABLE, "UF_IMMUTABLE" },
740 { UF_APPEND, "UF_APPEND" },
741 { UF_OPAQUE, "UF_OPAQUE" },
742 { UF_NOUNLINK, "UF_NOUNLINK" },
743 { SF_ARCHIVED, "SF_ARCHIVED" },
744 { SF_IMMUTABLE, "SF_IMMUTABLE" },
745 { SF_APPEND, "SF_APPEND" },
746 { SF_NOUNLINK, "SF_NOUNLINK" },
749 { _S_ISMLD, "_S_ISMLD" },
752 { _S_ISMOUNTED, "_S_ISMOUNTED" },
764 printpath(tcp, tcp->u_arg[0]);
767 printflags(fileflags, tcp->u_arg[1]);
779 tprintf("%ld, ", tcp->u_arg[0]);
781 printflags(fileflags, tcp->u_arg[1]);
789 #ifndef HAVE_LONG_LONG_OFF_T
791 realprintstat(tcp, statbuf)
793 struct stat *statbuf;
796 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
797 (unsigned long) major(statbuf->st_dev),
798 (unsigned long) minor(statbuf->st_dev),
799 (unsigned long) statbuf->st_ino,
800 sprintmode(statbuf->st_mode));
801 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
802 (unsigned long) statbuf->st_nlink,
803 (unsigned long) statbuf->st_uid,
804 (unsigned long) statbuf->st_gid);
805 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
806 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
807 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
808 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
809 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
810 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
813 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
814 switch (statbuf->st_mode & S_IFMT) {
815 case S_IFCHR: case S_IFBLK:
816 #ifdef HAVE_STRUCT_STAT_ST_RDEV
817 tprintf("st_rdev=makedev(%lu, %lu), ",
818 (unsigned long) major(statbuf->st_rdev),
819 (unsigned long) minor(statbuf->st_rdev));
820 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
821 tprintf("st_size=makedev(%lu, %lu), ",
822 (unsigned long) major(statbuf->st_size),
823 (unsigned long) minor(statbuf->st_size));
824 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
827 tprintf("st_size=%lu, ", statbuf->st_size);
831 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
832 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
833 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
834 #if HAVE_STRUCT_STAT_ST_FLAGS
835 tprintf(", st_flags=");
836 if (statbuf->st_flags) {
837 printflags(fileflags, statbuf->st_flags);
841 #if HAVE_STRUCT_STAT_ST_ACLCNT
842 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
844 #if HAVE_STRUCT_STAT_ST_LEVEL
845 tprintf(", st_level=%ld", statbuf->st_level);
847 #if HAVE_STRUCT_STAT_ST_FSTYPE
848 tprintf(", st_fstype=%.*s",
849 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
851 #if HAVE_STRUCT_STAT_ST_GEN
852 tprintf(", st_gen=%u", statbuf->st_gen);
869 if (current_personality == 1) {
870 printstatsol(tcp, addr);
874 else if (current_personality == 2) {
875 printstat_sparc64(tcp, addr);
879 #endif /* LINUXSPARC */
885 if (syserror(tcp) || !verbose(tcp)) {
886 tprintf("%#lx", addr);
889 if (umove(tcp, addr, &statbuf) < 0) {
894 realprintstat(tcp, &statbuf);
896 #endif /* !HAVE_LONG_LONG_OFF_T */
900 printstat64(tcp, addr)
904 struct stat64 statbuf;
907 if (current_personality == 1) {
908 printstatsol(tcp, addr);
912 else if (current_personality == 2) {
913 printstat_sparc64(tcp, addr);
917 #endif /* LINUXSPARC */
923 if (syserror(tcp) || !verbose(tcp)) {
924 tprintf("%#lx", addr);
927 if (umove(tcp, addr, &statbuf) < 0) {
933 #ifdef HAVE_LONG_LONG
934 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
936 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
938 (unsigned long) major(statbuf.st_dev),
939 (unsigned long) minor(statbuf.st_dev),
940 #ifdef HAVE_LONG_LONG
941 (unsigned long long) statbuf.st_ino,
943 (unsigned long) statbuf.st_ino,
945 sprintmode(statbuf.st_mode));
946 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
947 (unsigned long) statbuf.st_nlink,
948 (unsigned long) statbuf.st_uid,
949 (unsigned long) statbuf.st_gid);
950 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
951 tprintf("st_blksize=%lu, ",
952 (unsigned long) statbuf.st_blksize);
953 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
954 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
955 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
956 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
959 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
960 switch (statbuf.st_mode & S_IFMT) {
961 case S_IFCHR: case S_IFBLK:
962 #ifdef HAVE_STRUCT_STAT_ST_RDEV
963 tprintf("st_rdev=makedev(%lu, %lu), ",
964 (unsigned long) major(statbuf.st_rdev),
965 (unsigned long) minor(statbuf.st_rdev));
966 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
967 tprintf("st_size=makedev(%lu, %lu), ",
968 (unsigned long) major(statbuf.st_size),
969 (unsigned long) minor(statbuf.st_size));
970 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
973 tprintf("st_size=%llu, ", statbuf.st_size);
977 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
978 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
979 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
980 #if HAVE_STRUCT_STAT_ST_FLAGS
981 tprintf(", st_flags=");
982 if (statbuf.st_flags) {
983 printflags(fileflags, statbuf.st_flags);
987 #if HAVE_STRUCT_STAT_ST_ACLCNT
988 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
990 #if HAVE_STRUCT_STAT_ST_LEVEL
991 tprintf(", st_level=%ld", statbuf.st_level);
993 #if HAVE_STRUCT_STAT_ST_FSTYPE
994 tprintf(", st_fstype=%.*s",
995 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
997 #if HAVE_STRUCT_STAT_ST_GEN
998 tprintf(", st_gen=%u", statbuf.st_gen);
1005 #endif /* HAVE_STAT64 */
1007 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1009 convertoldstat(oldbuf, newbuf)
1010 const struct __old_kernel_stat *oldbuf;
1011 struct stat *newbuf;
1013 newbuf->st_dev=oldbuf->st_dev;
1014 newbuf->st_ino=oldbuf->st_ino;
1015 newbuf->st_mode=oldbuf->st_mode;
1016 newbuf->st_nlink=oldbuf->st_nlink;
1017 newbuf->st_uid=oldbuf->st_uid;
1018 newbuf->st_gid=oldbuf->st_gid;
1019 newbuf->st_rdev=oldbuf->st_rdev;
1020 newbuf->st_size=oldbuf->st_size;
1021 newbuf->st_atime=oldbuf->st_atime;
1022 newbuf->st_mtime=oldbuf->st_mtime;
1023 newbuf->st_ctime=oldbuf->st_ctime;
1024 newbuf->st_blksize=0; /* not supported in old_stat */
1025 newbuf->st_blocks=0; /* not supported in old_stat */
1030 printoldstat(tcp, addr)
1034 struct __old_kernel_stat statbuf;
1035 struct stat newstatbuf;
1038 if (current_personality == 1) {
1039 printstatsol(tcp, addr);
1042 #endif /* LINUXSPARC */
1048 if (syserror(tcp) || !verbose(tcp)) {
1049 tprintf("%#lx", addr);
1052 if (umove(tcp, addr, &statbuf) < 0) {
1057 convertoldstat(&statbuf, &newstatbuf);
1058 realprintstat(tcp, &newstatbuf);
1060 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1062 #ifndef HAVE_LONG_LONG_OFF_T
1067 if (entering(tcp)) {
1068 printpath(tcp, tcp->u_arg[0]);
1071 printstat(tcp, tcp->u_arg[1]);
1082 if (entering(tcp)) {
1083 printpath(tcp, tcp->u_arg[0]);
1086 printstat64(tcp, tcp->u_arg[1]);
1090 return printargs(tcp);
1094 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1099 if (entering(tcp)) {
1100 printpath(tcp, tcp->u_arg[0]);
1103 printoldstat(tcp, tcp->u_arg[1]);
1107 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1109 #ifndef HAVE_LONG_LONG_OFF_T
1115 tprintf("%ld, ", tcp->u_arg[0]);
1117 printstat(tcp, tcp->u_arg[1]);
1129 tprintf("%ld, ", tcp->u_arg[0]);
1131 printstat64(tcp, tcp->u_arg[1]);
1135 return printargs(tcp);
1139 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1145 tprintf("%ld, ", tcp->u_arg[0]);
1147 printoldstat(tcp, tcp->u_arg[1]);
1151 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1153 #ifndef HAVE_LONG_LONG_OFF_T
1158 if (entering(tcp)) {
1159 printpath(tcp, tcp->u_arg[0]);
1162 printstat(tcp, tcp->u_arg[1]);
1173 if (entering(tcp)) {
1174 printpath(tcp, tcp->u_arg[0]);
1177 printstat64(tcp, tcp->u_arg[1]);
1181 return printargs(tcp);
1185 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1190 if (entering(tcp)) {
1191 printpath(tcp, tcp->u_arg[0]);
1194 printoldstat(tcp, tcp->u_arg[1]);
1198 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1201 #if defined(SVR4) || defined(LINUXSPARC)
1207 if (entering(tcp)) {
1208 tprintf("%ld, ", tcp->u_arg[0]);
1209 printpath(tcp, tcp->u_arg[1]);
1213 if (tcp->u_arg[0] == _STAT64_VER)
1214 printstat64 (tcp, tcp->u_arg[2]);
1217 printstat(tcp, tcp->u_arg[2]);
1227 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1230 if (tcp->u_arg[0] == _STAT64_VER)
1231 printstat64 (tcp, tcp->u_arg[2]);
1234 printstat(tcp, tcp->u_arg[2]);
1243 if (entering(tcp)) {
1244 tprintf("%ld, ", tcp->u_arg[0]);
1245 printpath(tcp, tcp->u_arg[1]);
1249 if (tcp->u_arg[0] == _STAT64_VER)
1250 printstat64 (tcp, tcp->u_arg[2]);
1253 printstat(tcp, tcp->u_arg[2]);
1262 int mode = tcp->u_arg[2];
1264 if (entering(tcp)) {
1265 tprintf("%ld, ", tcp->u_arg[0]);
1266 printpath(tcp, tcp->u_arg[1]);
1267 tprintf(", %s", sprintmode(mode));
1268 switch (mode & S_IFMT) {
1269 case S_IFCHR: case S_IFBLK:
1271 tprintf(", makedev(%lu, %lu)",
1272 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1273 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1275 tprintf(", makedev(%lu, %lu)",
1276 (unsigned long) major(tcp->u_arg[3]),
1277 (unsigned long) minor(tcp->u_arg[3]));
1287 #ifdef HAVE_SYS_ACL_H
1289 #include <sys/acl.h>
1291 const struct xlat aclcmds[] = {
1293 { SETACL, "SETACL" },
1296 { GETACL, "GETACL" },
1299 { GETACLCNT, "GETACLCNT" },
1302 { ACL_GET, "ACL_GET" },
1305 { ACL_SET, "ACL_SET" },
1308 { ACL_CNT, "ACL_CNT" },
1317 if (entering(tcp)) {
1318 printpath(tcp, tcp->u_arg[0]);
1320 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1321 tprintf(", %ld", tcp->u_arg[2]);
1323 * FIXME - dump out the list of aclent_t's pointed to
1324 * by "tcp->u_arg[3]" if it's not NULL.
1327 tprintf(", %#lx", tcp->u_arg[3]);
1339 if (entering(tcp)) {
1340 tprintf("%ld, ", tcp->u_arg[0]);
1341 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1342 tprintf(", %ld", tcp->u_arg[2]);
1344 * FIXME - dump out the list of aclent_t's pointed to
1345 * by "tcp->u_arg[3]" if it's not NULL.
1348 tprintf(", %#lx", tcp->u_arg[3]);
1356 const struct xlat aclipc[] = {
1358 { IPC_SHM, "IPC_SHM" },
1361 { IPC_SEM, "IPC_SEM" },
1364 { IPC_MSG, "IPC_MSG" },
1374 if (entering(tcp)) {
1375 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1376 tprintf(", %#lx, ", tcp->u_arg[1]);
1377 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1378 tprintf(", %ld", tcp->u_arg[3]);
1380 * FIXME - dump out the list of aclent_t's pointed to
1381 * by "tcp->u_arg[4]" if it's not NULL.
1384 tprintf(", %#lx", tcp->u_arg[4]);
1393 #endif /* HAVE_SYS_ACL_H */
1395 #endif /* SVR4 || LINUXSPARC */
1399 static const struct xlat fsmagic[] = {
1400 { 0x73757245, "CODA_SUPER_MAGIC" },
1401 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1402 { 0x1373, "DEVFS_SUPER_MAGIC" },
1403 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1404 { 0x414A53, "EFS_SUPER_MAGIC" },
1405 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1406 { 0xef53, "EXT2_SUPER_MAGIC" },
1407 { 0x137d, "EXT_SUPER_MAGIC" },
1408 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1409 { 0x9660, "ISOFS_SUPER_MAGIC" },
1410 { 0x137f, "MINIX_SUPER_MAGIC" },
1411 { 0x138f, "MINIX_SUPER_MAGIC2" },
1412 { 0x2468, "MINIX2_SUPER_MAGIC" },
1413 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1414 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1415 { 0x564c, "NCP_SUPER_MAGIC" },
1416 { 0x6969, "NFS_SUPER_MAGIC" },
1417 { 0x9fa0, "PROC_SUPER_MAGIC" },
1418 { 0x002f, "QNX4_SUPER_MAGIC" },
1419 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1420 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1421 { 0x517b, "SMB_SUPER_MAGIC" },
1422 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1423 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1424 { 0x00011954, "UFS_MAGIC" },
1425 { 0x54190100, "UFS_CIGAM" },
1426 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1427 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1428 { 0x62656572, "SYSFS_MAGIC" },
1440 static char buf[32];
1444 s = xlookup(fsmagic, magic);
1446 sprintf(buf, "\"%s\"", s);
1450 sprintf(buf, "%#x", magic);
1455 printstatfs(tcp, addr)
1459 struct statfs statbuf;
1461 if (syserror(tcp) || !verbose(tcp)) {
1462 tprintf("%#lx", addr);
1465 if (umove(tcp, addr, &statbuf) < 0) {
1471 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1472 sprintfstype(statbuf.f_type),
1473 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1474 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1475 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1476 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1479 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1480 sprintfstype(statbuf.f_type),
1481 (unsigned long)statbuf.f_bsize,
1482 (unsigned long)statbuf.f_blocks,
1483 (unsigned long)statbuf.f_bfree);
1484 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1485 (unsigned long)statbuf.f_bavail,
1486 (unsigned long)statbuf.f_files,
1487 (unsigned long)statbuf.f_ffree,
1488 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1490 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1493 #ifdef _STATFS_F_FRSIZE
1494 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1503 if (entering(tcp)) {
1504 printpath(tcp, tcp->u_arg[0]);
1507 printstatfs(tcp, tcp->u_arg[1]);
1516 if (entering(tcp)) {
1517 tprintf("%lu, ", tcp->u_arg[0]);
1519 printstatfs(tcp, tcp->u_arg[1]);
1526 printstatfs64(tcp, addr)
1530 struct statfs64 statbuf;
1532 if (syserror(tcp) || !verbose(tcp)) {
1533 tprintf("%#lx", addr);
1536 if (umove(tcp, addr, &statbuf) < 0) {
1542 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1543 sprintfstype(statbuf.f_type),
1544 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1545 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1546 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1547 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1550 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1551 sprintfstype(statbuf.f_type),
1552 (unsigned long)statbuf.f_bsize,
1553 (unsigned long)statbuf.f_blocks,
1554 (unsigned long)statbuf.f_bfree);
1555 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1556 (unsigned long)statbuf.f_bavail,
1557 (unsigned long)statbuf.f_files,
1558 (unsigned long)statbuf.f_ffree,
1559 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1560 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1562 #ifdef _STATFS_F_FRSIZE
1563 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1572 if (entering(tcp)) {
1573 printpath(tcp, tcp->u_arg[0]);
1574 tprintf(", %lu, ", tcp->u_arg[1]);
1576 if (tcp->u_arg[1] == sizeof (struct statfs64))
1577 printstatfs64(tcp, tcp->u_arg[2]);
1588 if (entering(tcp)) {
1589 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1591 if (tcp->u_arg[1] == sizeof (struct statfs64))
1592 printstatfs64(tcp, tcp->u_arg[2]);
1600 #if defined(LINUX) && defined(__alpha)
1606 if (entering(tcp)) {
1607 printpath(tcp, tcp->u_arg[0]);
1610 printstatfs(tcp, tcp->u_arg[1]);
1611 tprintf(", %lu", tcp->u_arg[2]);
1620 if (entering(tcp)) {
1621 tprintf("%lu, ", tcp->u_arg[0]);
1623 printstatfs(tcp, tcp->u_arg[1]);
1624 tprintf(", %lu", tcp->u_arg[2]);
1628 #endif /* LINUX && __alpha */
1638 struct ustat statbuf;
1640 if (entering(tcp)) {
1641 tprintf("makedev(%lu, %lu), ",
1642 (long) major(tcp->u_arg[0]),
1643 (long) minor(tcp->u_arg[0]));
1646 if (syserror(tcp) || !verbose(tcp))
1647 tprintf("%#lx", tcp->u_arg[1]);
1648 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1651 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1652 statbuf.f_tfree, statbuf.f_tinode);
1653 tprintf("f_fname=\"%.*s\", ",
1654 (int) sizeof(statbuf.f_fname),
1656 tprintf("f_fpack=\"%.*s\"}",
1657 (int) sizeof(statbuf.f_fpack),
1670 if (entering(tcp)) {
1671 printpath(tcp, tcp->u_arg[0]);
1673 printpath(tcp, tcp->u_arg[1]);
1684 if (entering(tcp)) {
1685 printpath(tcp, tcp->u_arg[0]);
1694 if (entering(tcp)) {
1695 printpath(tcp, tcp->u_arg[0]);
1696 tprintf(", %#lo", tcp->u_arg[1]);
1705 if (entering(tcp)) {
1706 printpath(tcp, tcp->u_arg[0]);
1715 if (entering(tcp)) {
1716 tprintf("%ld", tcp->u_arg[0]);
1725 if (entering(tcp)) {
1726 printpath(tcp, tcp->u_arg[0]);
1735 if (entering(tcp)) {
1736 tprintf("%ld", tcp->u_arg[0]);
1745 if (entering(tcp)) {
1746 printpath(tcp, tcp->u_arg[0]);
1748 printpath(tcp, tcp->u_arg[1]);
1757 if (entering(tcp)) {
1758 printpath(tcp, tcp->u_arg[0]);
1767 if (entering(tcp)) {
1768 printpath(tcp, tcp->u_arg[0]);
1770 printpath(tcp, tcp->u_arg[1]);
1779 if (entering(tcp)) {
1780 printpath(tcp, tcp->u_arg[0]);
1784 tprintf("%#lx", tcp->u_arg[1]);
1786 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1787 tprintf(", %lu", tcp->u_arg[2]);
1796 if (entering(tcp)) {
1797 printpath(tcp, tcp->u_arg[0]);
1799 printpath(tcp, tcp->u_arg[1]);
1808 if (entering(tcp)) {
1809 printpath(tcp, tcp->u_arg[0]);
1810 printuid(", ", tcp->u_arg[1]);
1811 printuid(", ", tcp->u_arg[2]);
1820 if (entering(tcp)) {
1821 tprintf("%ld", tcp->u_arg[0]);
1822 printuid(", ", tcp->u_arg[1]);
1823 printuid(", ", tcp->u_arg[2]);
1832 if (entering(tcp)) {
1833 printpath(tcp, tcp->u_arg[0]);
1834 tprintf(", %#lo", tcp->u_arg[1]);
1843 if (entering(tcp)) {
1844 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1854 if (entering(tcp)) {
1855 printpath(tcp, tcp->u_arg[0]);
1857 printtv32(tcp, tcp->u_arg[1]);
1867 if (entering(tcp)) {
1868 printpath(tcp, tcp->u_arg[0]);
1870 printtv(tcp, tcp->u_arg[1]);
1881 if (entering(tcp)) {
1882 printpath(tcp, tcp->u_arg[0]);
1886 else if (!verbose(tcp))
1887 tprintf("%#lx", tcp->u_arg[1]);
1888 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1892 tprintf("[%s,", sprinttime(ut[0]));
1893 tprintf(" %s]", sprinttime(ut[1]));
1903 int mode = tcp->u_arg[1];
1905 if (entering(tcp)) {
1906 printpath(tcp, tcp->u_arg[0]);
1907 tprintf(", %s", sprintmode(mode));
1908 switch (mode & S_IFMT) {
1909 case S_IFCHR: case S_IFBLK:
1911 if (current_personality == 1)
1912 tprintf(", makedev(%lu, %lu)",
1913 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1914 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1917 tprintf(", makedev(%lu, %lu)",
1918 (unsigned long) major(tcp->u_arg[2]),
1919 (unsigned long) minor(tcp->u_arg[2]));
1932 if (entering(tcp)) {
1933 printpath(tcp, tcp->u_arg[0]);
1934 tprintf(", %#lo", tcp->u_arg[1]);
1943 if (entering(tcp)) {
1944 tprintf("%ld", tcp->u_arg[0]);
1958 if (!verbose(tcp)) {
1959 tprintf("%#lx", addr);
1962 if (umove(tcp, addr, &d) < 0) {
1966 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1968 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1976 if (entering(tcp)) {
1977 tprintf("%lu, ", tcp->u_arg[0]);
1979 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1980 tprintf("%#lx", tcp->u_arg[1]);
1982 printdir(tcp, tcp->u_arg[1]);
1983 /* Not much point in printing this out, it is always 1. */
1984 if (tcp->u_arg[2] != 1)
1985 tprintf(", %lu", tcp->u_arg[2]);
1992 #if defined FREEBSD || defined LINUX
1993 const struct xlat direnttypes[] = {
1994 { DT_UNKNOWN, "DT_UNKNOWN" },
1995 { DT_FIFO, "DT_FIFO" },
1996 { DT_CHR, "DT_CHR" },
1997 { DT_DIR, "DT_DIR" },
1998 { DT_BLK, "DT_BLK" },
1999 { DT_REG, "DT_REG" },
2000 { DT_LNK, "DT_LNK" },
2001 { DT_SOCK, "DT_SOCK" },
2002 { DT_WHT, "DT_WHT" },
2012 int i, len, dents = 0;
2015 if (entering(tcp)) {
2016 tprintf("%lu, ", tcp->u_arg[0]);
2019 if (syserror(tcp) || !verbose(tcp)) {
2020 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2024 if ((buf = malloc(len)) == NULL) {
2025 tprintf("out of memory\n");
2028 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2029 tprintf("{...}, %lu", tcp->u_arg[2]);
2035 for (i = 0; i < len;) {
2036 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2039 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2040 i ? " " : "", d->d_ino, d->d_off);
2041 tprintf("d_reclen=%u, d_name=\"%s\"}",
2042 d->d_reclen, d->d_name);
2047 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2049 (unsigned long) d->d_ino,
2050 (unsigned long) d->d_off);
2051 tprintf("d_reclen=%u, d_name=\"%s\"}",
2052 d->d_reclen, d->d_name);
2057 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2058 i ? " " : "", d->d_off, d->d_fileno,
2060 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2061 d->d_namlen, d->d_namlen, d->d_name);
2066 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2067 i ? " " : "", d->d_fileno, d->d_reclen);
2068 printxval(direnttypes, d->d_type, "DT_???");
2069 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2070 d->d_namlen, d->d_namlen, d->d_name);
2072 #endif /* FREEBSD */
2074 tprintf("/* d_reclen == 0, problem here */");
2083 tprintf("/* %u entries */", dents);
2084 tprintf(", %lu", tcp->u_arg[2]);
2090 #if _LFS64_LARGEFILE
2095 int i, len, dents = 0;
2098 if (entering(tcp)) {
2099 tprintf("%lu, ", tcp->u_arg[0]);
2102 if (syserror(tcp) || !verbose(tcp)) {
2103 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2107 if ((buf = malloc(len)) == NULL) {
2108 tprintf("out of memory\n");
2111 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2112 tprintf("{...}, %lu", tcp->u_arg[2]);
2118 for (i = 0; i < len;) {
2119 struct dirent64 *d = (struct dirent64 *) &buf[i];
2120 #if defined(LINUX) || defined(SVR4)
2122 tprintf("%s{d_ino=%llu, d_off=%llu, ",
2128 printxval(direnttypes, d->d_type, "DT_???");
2131 tprintf("d_reclen=%u, d_name=\"%s\"}",
2132 d->d_reclen, d->d_name);
2134 #endif /* LINUX || SVR4 */
2137 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2138 i ? " " : "", d->d_off, d->d_fileno,
2140 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2141 d->d_namlen, d->d_namlen, d->d_name);
2150 tprintf("/* %u entries */", dents);
2151 tprintf(", %lu", tcp->u_arg[2]);
2159 sys_getdirentries(tcp)
2162 int i, len, dents = 0;
2166 if (entering(tcp)) {
2167 tprintf("%lu, ", tcp->u_arg[0]);
2170 if (syserror(tcp) || !verbose(tcp)) {
2171 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2175 if ((buf = malloc(len)) == NULL) {
2176 tprintf("out of memory\n");
2179 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2180 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
2186 for (i = 0; i < len;) {
2187 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2189 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2190 i ? " " : "", d->d_fileno, d->d_reclen);
2191 printxval(direnttypes, d->d_type, "DT_???");
2192 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2193 d->d_namlen, d->d_namlen, d->d_name);
2201 tprintf("/* %u entries */", dents);
2203 tprintf(", %lu", tcp->u_arg[2]);
2204 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2205 tprintf(", %#lx", tcp->u_arg[3]);
2207 tprintf(", [%lu]", basep);
2219 tprintf("%#lx", tcp->u_arg[0]);
2221 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2222 tprintf(", %lu", tcp->u_arg[1]);
2235 tprintf("%#lx", tcp->u_arg[0]);
2237 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2238 tprintf(", %lu", tcp->u_arg[1]);
2244 #ifdef HAVE_SYS_ASYNCH_H
2250 struct aio_result_t res;
2252 if (entering(tcp)) {
2253 tprintf("%lu, ", tcp->u_arg[0]);
2256 tprintf("%#lx", tcp->u_arg[1]);
2258 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2259 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2260 printxval(whence, tcp->u_arg[4], "L_???");
2261 if (syserror(tcp) || tcp->u_arg[5] == 0
2262 || umove(tcp, tcp->u_arg[5], &res) < 0)
2263 tprintf(", %#lx", tcp->u_arg[5]);
2265 tprintf(", {aio_return %d aio_errno %d}",
2266 res.aio_return, res.aio_errno);
2275 struct aio_result_t res;
2277 if (entering(tcp)) {
2278 tprintf("%lu, ", tcp->u_arg[0]);
2279 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2280 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2281 printxval(whence, tcp->u_arg[4], "L_???");
2284 if (tcp->u_arg[5] == 0)
2286 else if (syserror(tcp)
2287 || umove(tcp, tcp->u_arg[5], &res) < 0)
2288 tprintf(", %#lx", tcp->u_arg[5]);
2290 tprintf(", {aio_return %d aio_errno %d}",
2291 res.aio_return, res.aio_errno);
2301 printtv(tcp, tcp->u_arg[0]);
2309 struct aio_result_t res;
2312 if (tcp->u_arg[0] == 0)
2314 else if (syserror(tcp)
2315 || umove(tcp, tcp->u_arg[0], &res) < 0)
2316 tprintf("%#lx", tcp->u_arg[0]);
2318 tprintf("{aio_return %d aio_errno %d}",
2319 res.aio_return, res.aio_errno);
2324 #endif /* HAVE_SYS_ASYNCH_H */
2326 const struct xlat xattrflags[] = {
2328 { XATTR_CREATE, "XATTR_CREATE" },
2329 { XATTR_REPLACE, "XATTR_REPLACE" },
2335 print_xattr_val(tcp, failed, arg, insize, size)
2341 unsigned char buf[4 * size + 1];
2342 if (!failed && umoven(tcp, arg, size, &buf[3 * size]) >= 0) {
2343 unsigned char *out = buf;
2344 unsigned char *in = &buf[3 * size];
2346 for (i = 0; i < size; ++i)
2350 #define tohex(n) "0123456789abcdef"[n]
2353 *out++ = tohex(in[i] / 16);
2354 *out++ = tohex(in[i] % 16);
2356 /* Don't print terminating NUL if there is one. */
2357 if (in[i - 1] == '\0')
2360 tprintf(", \"%s\", %zd", buf, insize);
2362 tprintf(", 0x%lx, %zd", arg, insize);
2369 if (entering(tcp)) {
2370 printpath(tcp, tcp->u_arg[0]);
2372 printstr(tcp, tcp->u_arg[1], -1);
2373 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2375 printflags(xattrflags, tcp->u_arg[4]);
2384 if (entering(tcp)) {
2385 tprintf("%ld, ", tcp->u_arg[0]);
2386 printstr(tcp, tcp->u_arg[1], -1);
2387 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2389 printflags(xattrflags, tcp->u_arg[4]);
2398 if (entering(tcp)) {
2399 printpath(tcp, tcp->u_arg[0]);
2401 printstr(tcp, tcp->u_arg[1], -1);
2403 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2413 if (entering(tcp)) {
2414 tprintf("%ld, ", tcp->u_arg[0]);
2415 printstr(tcp, tcp->u_arg[1], -1);
2417 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2427 if (entering(tcp)) {
2428 printpath(tcp, tcp->u_arg[0]);
2430 /* XXX Print value in format */
2431 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2440 if (entering(tcp)) {
2441 tprintf("%ld", tcp->u_arg[0]);
2443 /* XXX Print value in format */
2444 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2450 sys_removexattr(tcp)
2453 if (entering(tcp)) {
2454 printpath(tcp, tcp->u_arg[0]);
2456 printstr(tcp, tcp->u_arg[1], -1);
2462 sys_fremovexattr(tcp)
2465 if (entering(tcp)) {
2466 tprintf("%ld, ", tcp->u_arg[0]);
2467 printstr(tcp, tcp->u_arg[1], -1);
2473 static const struct xlat advise[] = {
2474 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2475 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2476 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2477 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2478 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2479 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2484 #if defined LINUX && (defined I386 || defined X86_64)
2489 if (entering(tcp)) {
2490 tprintf("%ld, %lld, %ld, ",
2492 # if defined IA64 || defined X86_64 || defined ALPHA
2493 (long long int) tcp->u_arg[1], tcp->u_arg[2]);
2494 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2496 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]);
2497 printxval(advise, tcp->u_arg[4], "POSIX_FADV_???");
2506 sys_fadvise64_64(tcp)
2509 if (entering(tcp)) {
2510 tprintf("%ld, %lld, %lld, ",
2512 # if defined IA64 || defined X86_64 || defined ALPHA
2513 (long long int) tcp->u_arg[1], (long long int) tcp->u_arg[2]);
2514 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2516 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]),
2517 LONG_LONG(tcp->u_arg[3], tcp->u_arg[4]));
2518 printxval(advise, tcp->u_arg[5], "POSIX_FADV_???");