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 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 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 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 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 int) tcp->u_arg[1]) << 32
437 | (unsigned long long) (unsigned) tcp->u_arg[2]));
439 tprintf("%ld, %lld, ", tcp->u_arg[0],
440 (((long long int) tcp->u_arg[1]) << 32
441 | (unsigned long long) (unsigned) tcp->u_arg[2]));
445 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
446 tprintf("%#lx, ", tcp->u_arg[3]);
448 tprintf("[%llu], ", off);
449 printxval(whence, tcp->u_arg[4], "SEEK_???");
459 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
460 # if defined IA64 || defined X86_64 || defined ALPHA
461 (long long int) tcp->u_arg[1], tcp->u_arg[2]
463 (((long long int) tcp->u_arg[1]) << 32
464 | ((unsigned long *) tcp->u_arg)[2]),
473 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
480 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
481 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
482 if (tcp->u_arg[3] == SEEK_SET)
483 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
485 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
486 printxval(whence, tcp->u_arg[3], "SEEK_???");
488 return RVAL_LUDECIMAL;
492 #ifndef HAVE_LONG_LONG_OFF_T
498 printpath(tcp, tcp->u_arg[0]);
499 tprintf(", %lu", tcp->u_arg[1]);
505 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
512 printpath(tcp, tcp->u_arg[0]);
513 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
519 #ifndef HAVE_LONG_LONG_OFF_T
525 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
531 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
538 tprintf("%ld, %llu", tcp->u_arg[0],
539 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
547 static struct xlat modetypes[] = {
548 { S_IFREG, "S_IFREG" },
549 { S_IFSOCK, "S_IFSOCK" },
550 { S_IFIFO, "S_IFIFO" },
551 { S_IFLNK, "S_IFLNK" },
552 { S_IFDIR, "S_IFDIR" },
553 { S_IFBLK, "S_IFBLK" },
554 { S_IFCHR, "S_IFCHR" },
565 if ((mode & S_IFMT) == 0)
567 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
568 sprintf(buf, "%#o", mode);
571 sprintf(buf, "%s%s%s%s", s,
572 (mode & S_ISUID) ? "|S_ISUID" : "",
573 (mode & S_ISGID) ? "|S_ISGID" : "",
574 (mode & S_ISVTX) ? "|S_ISVTX" : "");
575 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
577 sprintf(buf + strlen(buf), "|%#o", mode);
578 s = (*buf == '|') ? buf + 1 : buf;
594 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
595 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
596 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
608 int st_pad1[3]; /* network id */
617 int st_pad3; /* st_size, off_t expansion */
618 timestruct_t st_atime;
619 timestruct_t st_mtime;
620 timestruct_t st_ctime;
624 int st_pad4[8]; /* expansion area */
628 printstatsol(tcp, addr)
632 struct solstat statbuf;
638 if (syserror(tcp) || !verbose(tcp)) {
639 tprintf("%#lx", addr);
642 if (umove(tcp, addr, &statbuf) < 0) {
647 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
648 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
649 (unsigned long) (statbuf.st_dev & 0x3ffff),
650 (unsigned long) statbuf.st_ino,
651 sprintmode(statbuf.st_mode));
652 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
653 (unsigned long) statbuf.st_nlink,
654 (unsigned long) statbuf.st_uid,
655 (unsigned long) statbuf.st_gid);
656 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
657 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
660 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
661 switch (statbuf.st_mode & S_IFMT) {
662 case S_IFCHR: case S_IFBLK:
663 tprintf("st_rdev=makedev(%lu, %lu), ",
664 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
665 (unsigned long) (statbuf.st_rdev & 0x3ffff));
668 tprintf("st_size=%u, ", statbuf.st_size);
672 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
673 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
674 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
680 #if defined (SPARC64)
682 printstat_sparc64(tcp, addr)
686 struct stat_sparc64 statbuf;
692 if (syserror(tcp) || !verbose(tcp)) {
693 tprintf("%#lx", addr);
696 if (umove(tcp, addr, &statbuf) < 0) {
702 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
703 (unsigned long) major(statbuf.st_dev),
704 (unsigned long) minor(statbuf.st_dev),
705 (unsigned long) statbuf.st_ino,
706 sprintmode(statbuf.st_mode));
707 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
708 (unsigned long) statbuf.st_nlink,
709 (unsigned long) statbuf.st_uid,
710 (unsigned long) statbuf.st_gid);
711 tprintf("st_blksize=%lu, ",
712 (unsigned long) statbuf.st_blksize);
713 tprintf("st_blocks=%lu, ",
714 (unsigned long) statbuf.st_blocks);
717 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
718 switch (statbuf.st_mode & S_IFMT) {
719 case S_IFCHR: case S_IFBLK:
720 tprintf("st_rdev=makedev(%lu, %lu), ",
721 (unsigned long) major(statbuf.st_rdev),
722 (unsigned long) minor(statbuf.st_rdev));
725 tprintf("st_size=%lu, ", statbuf.st_size);
729 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
730 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
731 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
738 #endif /* LINUXSPARC */
740 struct xlat fileflags[] = {
742 { UF_NODUMP, "UF_NODUMP" },
743 { UF_IMMUTABLE, "UF_IMMUTABLE" },
744 { UF_APPEND, "UF_APPEND" },
745 { UF_OPAQUE, "UF_OPAQUE" },
746 { UF_NOUNLINK, "UF_NOUNLINK" },
747 { SF_ARCHIVED, "SF_ARCHIVED" },
748 { SF_IMMUTABLE, "SF_IMMUTABLE" },
749 { SF_APPEND, "SF_APPEND" },
750 { SF_NOUNLINK, "SF_NOUNLINK" },
753 { _S_ISMLD, "_S_ISMLD" },
756 { _S_ISMOUNTED, "_S_ISMOUNTED" },
768 printpath(tcp, tcp->u_arg[0]);
771 printflags(fileflags, tcp->u_arg[1]);
783 tprintf("%ld, ", tcp->u_arg[0]);
785 printflags(fileflags, tcp->u_arg[1]);
793 #ifndef HAVE_LONG_LONG_OFF_T
795 realprintstat(tcp, statbuf)
797 struct stat *statbuf;
800 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
801 (unsigned long) major(statbuf->st_dev),
802 (unsigned long) minor(statbuf->st_dev),
803 (unsigned long) statbuf->st_ino,
804 sprintmode(statbuf->st_mode));
805 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
806 (unsigned long) statbuf->st_nlink,
807 (unsigned long) statbuf->st_uid,
808 (unsigned long) statbuf->st_gid);
809 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
810 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
811 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
812 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
813 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
814 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
817 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
818 switch (statbuf->st_mode & S_IFMT) {
819 case S_IFCHR: case S_IFBLK:
820 #ifdef HAVE_STRUCT_STAT_ST_RDEV
821 tprintf("st_rdev=makedev(%lu, %lu), ",
822 (unsigned long) major(statbuf->st_rdev),
823 (unsigned long) minor(statbuf->st_rdev));
824 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
825 tprintf("st_size=makedev(%lu, %lu), ",
826 (unsigned long) major(statbuf->st_size),
827 (unsigned long) minor(statbuf->st_size));
828 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
831 tprintf("st_size=%lu, ", statbuf->st_size);
835 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
836 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
837 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
838 #if HAVE_STRUCT_STAT_ST_FLAGS
839 tprintf(", st_flags=");
840 if (statbuf->st_flags) {
841 printflags(fileflags, statbuf->st_flags);
845 #if HAVE_STRUCT_STAT_ST_ACLCNT
846 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
848 #if HAVE_STRUCT_STAT_ST_LEVEL
849 tprintf(", st_level=%ld", statbuf->st_level);
851 #if HAVE_STRUCT_STAT_ST_FSTYPE
852 tprintf(", st_fstype=%.*s",
853 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
855 #if HAVE_STRUCT_STAT_ST_GEN
856 tprintf(", st_gen=%u", statbuf->st_gen);
873 if (current_personality == 1) {
874 printstatsol(tcp, addr);
878 else if (current_personality == 2) {
879 printstat_sparc64(tcp, addr);
883 #endif /* LINUXSPARC */
889 if (syserror(tcp) || !verbose(tcp)) {
890 tprintf("%#lx", addr);
893 if (umove(tcp, addr, &statbuf) < 0) {
898 realprintstat(tcp, &statbuf);
900 #endif /* !HAVE_LONG_LONG_OFF_T */
904 printstat64(tcp, addr)
908 struct stat64 statbuf;
911 if (current_personality == 1) {
912 printstatsol(tcp, addr);
916 else if (current_personality == 2) {
917 printstat_sparc64(tcp, addr);
921 #endif /* LINUXSPARC */
927 if (syserror(tcp) || !verbose(tcp)) {
928 tprintf("%#lx", addr);
931 if (umove(tcp, addr, &statbuf) < 0) {
937 #ifdef HAVE_LONG_LONG
938 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
940 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
942 (unsigned long) major(statbuf.st_dev),
943 (unsigned long) minor(statbuf.st_dev),
944 #ifdef HAVE_LONG_LONG
945 (unsigned long long) statbuf.st_ino,
947 (unsigned long) statbuf.st_ino,
949 sprintmode(statbuf.st_mode));
950 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
951 (unsigned long) statbuf.st_nlink,
952 (unsigned long) statbuf.st_uid,
953 (unsigned long) statbuf.st_gid);
954 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
955 tprintf("st_blksize=%lu, ",
956 (unsigned long) statbuf.st_blksize);
957 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
958 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
959 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
960 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
963 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
964 switch (statbuf.st_mode & S_IFMT) {
965 case S_IFCHR: case S_IFBLK:
966 #ifdef HAVE_STRUCT_STAT_ST_RDEV
967 tprintf("st_rdev=makedev(%lu, %lu), ",
968 (unsigned long) major(statbuf.st_rdev),
969 (unsigned long) minor(statbuf.st_rdev));
970 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
971 tprintf("st_size=makedev(%lu, %lu), ",
972 (unsigned long) major(statbuf.st_size),
973 (unsigned long) minor(statbuf.st_size));
974 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
977 tprintf("st_size=%llu, ", statbuf.st_size);
981 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
982 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
983 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
984 #if HAVE_STRUCT_STAT_ST_FLAGS
985 tprintf(", st_flags=");
986 if (statbuf.st_flags) {
987 printflags(fileflags, statbuf.st_flags);
991 #if HAVE_STRUCT_STAT_ST_ACLCNT
992 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
994 #if HAVE_STRUCT_STAT_ST_LEVEL
995 tprintf(", st_level=%ld", statbuf.st_level);
997 #if HAVE_STRUCT_STAT_ST_FSTYPE
998 tprintf(", st_fstype=%.*s",
999 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1001 #if HAVE_STRUCT_STAT_ST_GEN
1002 tprintf(", st_gen=%u", statbuf.st_gen);
1009 #endif /* HAVE_STAT64 */
1011 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1013 convertoldstat(oldbuf, newbuf)
1014 const struct __old_kernel_stat *oldbuf;
1015 struct stat *newbuf;
1017 newbuf->st_dev=oldbuf->st_dev;
1018 newbuf->st_ino=oldbuf->st_ino;
1019 newbuf->st_mode=oldbuf->st_mode;
1020 newbuf->st_nlink=oldbuf->st_nlink;
1021 newbuf->st_uid=oldbuf->st_uid;
1022 newbuf->st_gid=oldbuf->st_gid;
1023 newbuf->st_rdev=oldbuf->st_rdev;
1024 newbuf->st_size=oldbuf->st_size;
1025 newbuf->st_atime=oldbuf->st_atime;
1026 newbuf->st_mtime=oldbuf->st_mtime;
1027 newbuf->st_ctime=oldbuf->st_ctime;
1028 newbuf->st_blksize=0; /* not supported in old_stat */
1029 newbuf->st_blocks=0; /* not supported in old_stat */
1034 printoldstat(tcp, addr)
1038 struct __old_kernel_stat statbuf;
1039 struct stat newstatbuf;
1042 if (current_personality == 1) {
1043 printstatsol(tcp, addr);
1046 #endif /* LINUXSPARC */
1052 if (syserror(tcp) || !verbose(tcp)) {
1053 tprintf("%#lx", addr);
1056 if (umove(tcp, addr, &statbuf) < 0) {
1061 convertoldstat(&statbuf, &newstatbuf);
1062 realprintstat(tcp, &newstatbuf);
1064 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1066 #ifndef HAVE_LONG_LONG_OFF_T
1071 if (entering(tcp)) {
1072 printpath(tcp, tcp->u_arg[0]);
1075 printstat(tcp, tcp->u_arg[1]);
1086 if (entering(tcp)) {
1087 printpath(tcp, tcp->u_arg[0]);
1090 printstat64(tcp, tcp->u_arg[1]);
1094 return printargs(tcp);
1098 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1103 if (entering(tcp)) {
1104 printpath(tcp, tcp->u_arg[0]);
1107 printoldstat(tcp, tcp->u_arg[1]);
1111 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1113 #ifndef HAVE_LONG_LONG_OFF_T
1119 tprintf("%ld, ", tcp->u_arg[0]);
1121 printstat(tcp, tcp->u_arg[1]);
1133 tprintf("%ld, ", tcp->u_arg[0]);
1135 printstat64(tcp, tcp->u_arg[1]);
1139 return printargs(tcp);
1143 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1149 tprintf("%ld, ", tcp->u_arg[0]);
1151 printoldstat(tcp, tcp->u_arg[1]);
1155 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1157 #ifndef HAVE_LONG_LONG_OFF_T
1162 if (entering(tcp)) {
1163 printpath(tcp, tcp->u_arg[0]);
1166 printstat(tcp, tcp->u_arg[1]);
1177 if (entering(tcp)) {
1178 printpath(tcp, tcp->u_arg[0]);
1181 printstat64(tcp, tcp->u_arg[1]);
1185 return printargs(tcp);
1189 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1194 if (entering(tcp)) {
1195 printpath(tcp, tcp->u_arg[0]);
1198 printoldstat(tcp, tcp->u_arg[1]);
1202 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1205 #if defined(SVR4) || defined(LINUXSPARC)
1211 if (entering(tcp)) {
1212 tprintf("%ld, ", tcp->u_arg[0]);
1213 printpath(tcp, tcp->u_arg[1]);
1217 if (tcp->u_arg[0] == _STAT64_VER)
1218 printstat64 (tcp, tcp->u_arg[2]);
1221 printstat(tcp, tcp->u_arg[2]);
1231 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1234 if (tcp->u_arg[0] == _STAT64_VER)
1235 printstat64 (tcp, tcp->u_arg[2]);
1238 printstat(tcp, tcp->u_arg[2]);
1247 if (entering(tcp)) {
1248 tprintf("%ld, ", tcp->u_arg[0]);
1249 printpath(tcp, tcp->u_arg[1]);
1253 if (tcp->u_arg[0] == _STAT64_VER)
1254 printstat64 (tcp, tcp->u_arg[2]);
1257 printstat(tcp, tcp->u_arg[2]);
1266 int mode = tcp->u_arg[2];
1268 if (entering(tcp)) {
1269 tprintf("%ld, ", tcp->u_arg[0]);
1270 printpath(tcp, tcp->u_arg[1]);
1271 tprintf(", %s", sprintmode(mode));
1272 switch (mode & S_IFMT) {
1273 case S_IFCHR: case S_IFBLK:
1275 tprintf(", makedev(%lu, %lu)",
1276 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1277 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1279 tprintf(", makedev(%lu, %lu)",
1280 (unsigned long) major(tcp->u_arg[3]),
1281 (unsigned long) minor(tcp->u_arg[3]));
1291 #ifdef HAVE_SYS_ACL_H
1293 #include <sys/acl.h>
1295 struct xlat aclcmds[] = {
1297 { SETACL, "SETACL" },
1300 { GETACL, "GETACL" },
1303 { GETACLCNT, "GETACLCNT" },
1306 { ACL_GET, "ACL_GET" },
1309 { ACL_SET, "ACL_SET" },
1312 { ACL_CNT, "ACL_CNT" },
1321 if (entering(tcp)) {
1322 printpath(tcp, tcp->u_arg[0]);
1324 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1325 tprintf(", %ld", tcp->u_arg[2]);
1327 * FIXME - dump out the list of aclent_t's pointed to
1328 * by "tcp->u_arg[3]" if it's not NULL.
1331 tprintf(", %#lx", tcp->u_arg[3]);
1343 if (entering(tcp)) {
1344 tprintf("%ld, ", tcp->u_arg[0]);
1345 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1346 tprintf(", %ld", tcp->u_arg[2]);
1348 * FIXME - dump out the list of aclent_t's pointed to
1349 * by "tcp->u_arg[3]" if it's not NULL.
1352 tprintf(", %#lx", tcp->u_arg[3]);
1360 struct xlat aclipc[] = {
1362 { IPC_SHM, "IPC_SHM" },
1365 { IPC_SEM, "IPC_SEM" },
1368 { IPC_MSG, "IPC_MSG" },
1378 if (entering(tcp)) {
1379 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1380 tprintf(", %#lx, ", tcp->u_arg[1]);
1381 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1382 tprintf(", %ld", tcp->u_arg[3]);
1384 * FIXME - dump out the list of aclent_t's pointed to
1385 * by "tcp->u_arg[4]" if it's not NULL.
1388 tprintf(", %#lx", tcp->u_arg[4]);
1397 #endif /* HAVE_SYS_ACL_H */
1399 #endif /* SVR4 || LINUXSPARC */
1403 static struct xlat fsmagic[] = {
1404 { 0x73757245, "CODA_SUPER_MAGIC" },
1405 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1406 { 0x1373, "DEVFS_SUPER_MAGIC" },
1407 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1408 { 0x414A53, "EFS_SUPER_MAGIC" },
1409 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1410 { 0xef53, "EXT2_SUPER_MAGIC" },
1411 { 0x137d, "EXT_SUPER_MAGIC" },
1412 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1413 { 0x9660, "ISOFS_SUPER_MAGIC" },
1414 { 0x137f, "MINIX_SUPER_MAGIC" },
1415 { 0x138f, "MINIX_SUPER_MAGIC2" },
1416 { 0x2468, "MINIX2_SUPER_MAGIC" },
1417 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1418 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1419 { 0x564c, "NCP_SUPER_MAGIC" },
1420 { 0x6969, "NFS_SUPER_MAGIC" },
1421 { 0x9fa0, "PROC_SUPER_MAGIC" },
1422 { 0x002f, "QNX4_SUPER_MAGIC" },
1423 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1424 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1425 { 0x517b, "SMB_SUPER_MAGIC" },
1426 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1427 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1428 { 0x00011954, "UFS_MAGIC" },
1429 { 0x54190100, "UFS_CIGAM" },
1430 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1431 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1432 { 0x62656572, "SYSFS_MAGIC" },
1444 static char buf[32];
1448 s = xlookup(fsmagic, magic);
1450 sprintf(buf, "\"%s\"", s);
1454 sprintf(buf, "%#x", magic);
1459 printstatfs(tcp, addr)
1463 struct statfs statbuf;
1465 if (syserror(tcp) || !verbose(tcp)) {
1466 tprintf("%#lx", addr);
1469 if (umove(tcp, addr, &statbuf) < 0) {
1475 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1476 sprintfstype(statbuf.f_type),
1477 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1478 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1479 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1480 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1483 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1484 sprintfstype(statbuf.f_type),
1485 (unsigned long)statbuf.f_bsize,
1486 (unsigned long)statbuf.f_blocks,
1487 (unsigned long)statbuf.f_bfree);
1488 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1489 (unsigned long)statbuf.f_bavail,
1490 (unsigned long)statbuf.f_files,
1491 (unsigned long)statbuf.f_ffree,
1492 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1494 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1497 #ifdef _STATFS_F_FRSIZE
1498 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1507 if (entering(tcp)) {
1508 printpath(tcp, tcp->u_arg[0]);
1511 printstatfs(tcp, tcp->u_arg[1]);
1520 if (entering(tcp)) {
1521 tprintf("%lu, ", tcp->u_arg[0]);
1523 printstatfs(tcp, tcp->u_arg[1]);
1530 printstatfs64(tcp, addr)
1534 struct statfs64 statbuf;
1536 if (syserror(tcp) || !verbose(tcp)) {
1537 tprintf("%#lx", addr);
1540 if (umove(tcp, addr, &statbuf) < 0) {
1546 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1547 sprintfstype(statbuf.f_type),
1548 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1549 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1550 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1551 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1554 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1555 sprintfstype(statbuf.f_type),
1556 (unsigned long)statbuf.f_bsize,
1557 (unsigned long)statbuf.f_blocks,
1558 (unsigned long)statbuf.f_bfree);
1559 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1560 (unsigned long)statbuf.f_bavail,
1561 (unsigned long)statbuf.f_files,
1562 (unsigned long)statbuf.f_ffree,
1563 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1564 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1566 #ifdef _STATFS_F_FRSIZE
1567 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1576 if (entering(tcp)) {
1577 printpath(tcp, tcp->u_arg[0]);
1578 tprintf(", %lu, ", tcp->u_arg[1]);
1580 if (tcp->u_arg[1] == sizeof (struct statfs64))
1581 printstatfs64(tcp, tcp->u_arg[2]);
1592 if (entering(tcp)) {
1593 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1595 if (tcp->u_arg[1] == sizeof (struct statfs64))
1596 printstatfs64(tcp, tcp->u_arg[2]);
1604 #if defined(LINUX) && defined(__alpha)
1610 if (entering(tcp)) {
1611 printpath(tcp, tcp->u_arg[0]);
1614 printstatfs(tcp, tcp->u_arg[1]);
1615 tprintf(", %lu", tcp->u_arg[2]);
1624 if (entering(tcp)) {
1625 tprintf("%lu, ", tcp->u_arg[0]);
1627 printstatfs(tcp, tcp->u_arg[1]);
1628 tprintf(", %lu", tcp->u_arg[2]);
1632 #endif /* LINUX && __alpha */
1642 struct ustat statbuf;
1644 if (entering(tcp)) {
1645 tprintf("makedev(%lu, %lu), ",
1646 (long) major(tcp->u_arg[0]),
1647 (long) minor(tcp->u_arg[0]));
1650 if (syserror(tcp) || !verbose(tcp))
1651 tprintf("%#lx", tcp->u_arg[1]);
1652 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1655 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1656 statbuf.f_tfree, statbuf.f_tinode);
1657 tprintf("f_fname=\"%.*s\", ",
1658 (int) sizeof(statbuf.f_fname),
1660 tprintf("f_fpack=\"%.*s\"}",
1661 (int) sizeof(statbuf.f_fpack),
1674 if (entering(tcp)) {
1675 printpath(tcp, tcp->u_arg[0]);
1677 printpath(tcp, tcp->u_arg[1]);
1688 if (entering(tcp)) {
1689 printpath(tcp, tcp->u_arg[0]);
1698 if (entering(tcp)) {
1699 printpath(tcp, tcp->u_arg[0]);
1700 tprintf(", %#lo", tcp->u_arg[1]);
1709 if (entering(tcp)) {
1710 printpath(tcp, tcp->u_arg[0]);
1719 if (entering(tcp)) {
1720 tprintf("%ld", tcp->u_arg[0]);
1729 if (entering(tcp)) {
1730 printpath(tcp, tcp->u_arg[0]);
1739 if (entering(tcp)) {
1740 tprintf("%ld", tcp->u_arg[0]);
1749 if (entering(tcp)) {
1750 printpath(tcp, tcp->u_arg[0]);
1752 printpath(tcp, tcp->u_arg[1]);
1761 if (entering(tcp)) {
1762 printpath(tcp, tcp->u_arg[0]);
1771 if (entering(tcp)) {
1772 printpath(tcp, tcp->u_arg[0]);
1774 printpath(tcp, tcp->u_arg[1]);
1783 if (entering(tcp)) {
1784 printpath(tcp, tcp->u_arg[0]);
1788 tprintf("%#lx", tcp->u_arg[1]);
1790 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1791 tprintf(", %lu", tcp->u_arg[2]);
1800 if (entering(tcp)) {
1801 printpath(tcp, tcp->u_arg[0]);
1803 printpath(tcp, tcp->u_arg[1]);
1812 if (entering(tcp)) {
1813 printpath(tcp, tcp->u_arg[0]);
1814 printuid(", ", tcp->u_arg[1]);
1815 printuid(", ", tcp->u_arg[2]);
1824 if (entering(tcp)) {
1825 tprintf("%ld", tcp->u_arg[0]);
1826 printuid(", ", tcp->u_arg[1]);
1827 printuid(", ", tcp->u_arg[2]);
1836 if (entering(tcp)) {
1837 printpath(tcp, tcp->u_arg[0]);
1838 tprintf(", %#lo", tcp->u_arg[1]);
1847 if (entering(tcp)) {
1848 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1858 if (entering(tcp)) {
1859 printpath(tcp, tcp->u_arg[0]);
1861 printtv32(tcp, tcp->u_arg[1]);
1871 if (entering(tcp)) {
1872 printpath(tcp, tcp->u_arg[0]);
1874 printtv(tcp, tcp->u_arg[1]);
1885 if (entering(tcp)) {
1886 printpath(tcp, tcp->u_arg[0]);
1890 else if (!verbose(tcp))
1891 tprintf("%#lx", tcp->u_arg[1]);
1892 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1896 tprintf("[%s,", sprinttime(ut[0]));
1897 tprintf(" %s]", sprinttime(ut[1]));
1907 int mode = tcp->u_arg[1];
1909 if (entering(tcp)) {
1910 printpath(tcp, tcp->u_arg[0]);
1911 tprintf(", %s", sprintmode(mode));
1912 switch (mode & S_IFMT) {
1913 case S_IFCHR: case S_IFBLK:
1915 if (current_personality == 1)
1916 tprintf(", makedev(%lu, %lu)",
1917 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1918 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1921 tprintf(", makedev(%lu, %lu)",
1922 (unsigned long) major(tcp->u_arg[2]),
1923 (unsigned long) minor(tcp->u_arg[2]));
1936 if (entering(tcp)) {
1937 printpath(tcp, tcp->u_arg[0]);
1938 tprintf(", %#lo", tcp->u_arg[1]);
1947 if (entering(tcp)) {
1948 tprintf("%ld", tcp->u_arg[0]);
1962 if (!verbose(tcp)) {
1963 tprintf("%#lx", addr);
1966 if (umove(tcp, addr, &d) < 0) {
1970 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1972 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1980 if (entering(tcp)) {
1981 tprintf("%lu, ", tcp->u_arg[0]);
1983 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1984 tprintf("%#lx", tcp->u_arg[1]);
1986 printdir(tcp, tcp->u_arg[1]);
1987 /* Not much point in printing this out, it is always 1. */
1988 if (tcp->u_arg[2] != 1)
1989 tprintf(", %lu", tcp->u_arg[2]);
1996 #if defined FREEBSD || defined LINUX
1997 struct xlat direnttypes[] = {
1998 { DT_UNKNOWN, "DT_UNKNOWN" },
1999 { DT_FIFO, "DT_FIFO" },
2000 { DT_CHR, "DT_CHR" },
2001 { DT_DIR, "DT_DIR" },
2002 { DT_BLK, "DT_BLK" },
2003 { DT_REG, "DT_REG" },
2004 { DT_LNK, "DT_LNK" },
2005 { DT_SOCK, "DT_SOCK" },
2006 { DT_WHT, "DT_WHT" },
2016 int i, len, dents = 0;
2019 if (entering(tcp)) {
2020 tprintf("%lu, ", tcp->u_arg[0]);
2023 if (syserror(tcp) || !verbose(tcp)) {
2024 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2028 if ((buf = malloc(len)) == NULL) {
2029 tprintf("out of memory\n");
2032 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2033 tprintf("{...}, %lu", tcp->u_arg[2]);
2039 for (i = 0; i < len;) {
2040 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2043 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2044 i ? " " : "", d->d_ino, d->d_off);
2045 tprintf("d_reclen=%u, d_name=\"%s\"}",
2046 d->d_reclen, d->d_name);
2051 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2053 (unsigned long) d->d_ino,
2054 (unsigned long) d->d_off);
2055 tprintf("d_reclen=%u, d_name=\"%s\"}",
2056 d->d_reclen, d->d_name);
2061 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2062 i ? " " : "", d->d_off, d->d_fileno,
2064 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2065 d->d_namlen, d->d_namlen, d->d_name);
2070 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2071 i ? " " : "", d->d_fileno, d->d_reclen);
2072 printxval(direnttypes, d->d_type, "DT_???");
2073 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2074 d->d_namlen, d->d_namlen, d->d_name);
2076 #endif /* FREEBSD */
2078 tprintf("/* d_reclen == 0, problem here */");
2087 tprintf("/* %u entries */", dents);
2088 tprintf(", %lu", tcp->u_arg[2]);
2094 #if _LFS64_LARGEFILE
2099 int i, len, dents = 0;
2102 if (entering(tcp)) {
2103 tprintf("%lu, ", tcp->u_arg[0]);
2106 if (syserror(tcp) || !verbose(tcp)) {
2107 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2111 if ((buf = malloc(len)) == NULL) {
2112 tprintf("out of memory\n");
2115 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2116 tprintf("{...}, %lu", tcp->u_arg[2]);
2122 for (i = 0; i < len;) {
2123 struct dirent64 *d = (struct dirent64 *) &buf[i];
2124 #if defined(LINUX) || defined(SVR4)
2126 tprintf("%s{d_ino=%llu, d_off=%llu, ",
2132 printxval(direnttypes, d->d_type, "DT_???");
2135 tprintf("d_reclen=%u, d_name=\"%s\"}",
2136 d->d_reclen, d->d_name);
2138 #endif /* LINUX || SVR4 */
2141 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2142 i ? " " : "", d->d_off, d->d_fileno,
2144 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2145 d->d_namlen, d->d_namlen, d->d_name);
2154 tprintf("/* %u entries */", dents);
2155 tprintf(", %lu", tcp->u_arg[2]);
2163 sys_getdirentries(tcp)
2166 int i, len, dents = 0;
2170 if (entering(tcp)) {
2171 tprintf("%lu, ", tcp->u_arg[0]);
2174 if (syserror(tcp) || !verbose(tcp)) {
2175 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2179 if ((buf = malloc(len)) == NULL) {
2180 tprintf("out of memory\n");
2183 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2184 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
2190 for (i = 0; i < len;) {
2191 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2193 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2194 i ? " " : "", d->d_fileno, d->d_reclen);
2195 printxval(direnttypes, d->d_type, "DT_???");
2196 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2197 d->d_namlen, d->d_namlen, d->d_name);
2205 tprintf("/* %u entries */", dents);
2207 tprintf(", %lu", tcp->u_arg[2]);
2208 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2209 tprintf(", %#lx", tcp->u_arg[3]);
2211 tprintf(", [%lu]", basep);
2223 tprintf("%#lx", tcp->u_arg[0]);
2225 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2226 tprintf(", %lu", tcp->u_arg[1]);
2239 tprintf("%#lx", tcp->u_arg[0]);
2241 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2242 tprintf(", %lu", tcp->u_arg[1]);
2248 #ifdef HAVE_SYS_ASYNCH_H
2254 struct aio_result_t res;
2256 if (entering(tcp)) {
2257 tprintf("%lu, ", tcp->u_arg[0]);
2260 tprintf("%#lx", tcp->u_arg[1]);
2262 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2263 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2264 printxval(whence, tcp->u_arg[4], "L_???");
2265 if (syserror(tcp) || tcp->u_arg[5] == 0
2266 || umove(tcp, tcp->u_arg[5], &res) < 0)
2267 tprintf(", %#lx", tcp->u_arg[5]);
2269 tprintf(", {aio_return %d aio_errno %d}",
2270 res.aio_return, res.aio_errno);
2279 struct aio_result_t res;
2281 if (entering(tcp)) {
2282 tprintf("%lu, ", tcp->u_arg[0]);
2283 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2284 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2285 printxval(whence, tcp->u_arg[4], "L_???");
2288 if (tcp->u_arg[5] == 0)
2290 else if (syserror(tcp)
2291 || umove(tcp, tcp->u_arg[5], &res) < 0)
2292 tprintf(", %#lx", tcp->u_arg[5]);
2294 tprintf(", {aio_return %d aio_errno %d}",
2295 res.aio_return, res.aio_errno);
2305 printtv(tcp, tcp->u_arg[0]);
2313 struct aio_result_t res;
2316 if (tcp->u_arg[0] == 0)
2318 else if (syserror(tcp)
2319 || umove(tcp, tcp->u_arg[0], &res) < 0)
2320 tprintf("%#lx", tcp->u_arg[0]);
2322 tprintf("{aio_return %d aio_errno %d}",
2323 res.aio_return, res.aio_errno);
2328 #endif /* HAVE_SYS_ASYNCH_H */
2330 struct xlat xattrflags[] = {
2332 { XATTR_CREATE, "XATTR_CREATE" },
2333 { XATTR_REPLACE, "XATTR_REPLACE" },
2339 print_xattr_val(tcp, failed, arg, insize, size)
2345 unsigned char buf[4 * size + 1];
2346 if (!failed && umoven(tcp, arg, size, &buf[3 * size]) >= 0) {
2347 unsigned char *out = buf;
2348 unsigned char *in = &buf[3 * size];
2350 for (i = 0; i < size; ++i)
2354 #define tohex(n) "0123456789abcdef"[n]
2357 *out++ = tohex(in[i] / 16);
2358 *out++ = tohex(in[i] % 16);
2360 /* Don't print terminating NUL if there is one. */
2361 if (in[i - 1] == '\0')
2364 tprintf(", \"%s\", %zd", buf, insize);
2366 tprintf(", 0x%lx, %zd", arg, insize);
2373 if (entering(tcp)) {
2374 printpath(tcp, tcp->u_arg[0]);
2376 printstr(tcp, tcp->u_arg[1], -1);
2377 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2379 printflags(xattrflags, tcp->u_arg[4]);
2388 if (entering(tcp)) {
2389 tprintf("%ld, ", tcp->u_arg[0]);
2390 printstr(tcp, tcp->u_arg[1], -1);
2391 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2393 printflags(xattrflags, tcp->u_arg[4]);
2402 if (entering(tcp)) {
2403 printpath(tcp, tcp->u_arg[0]);
2405 printstr(tcp, tcp->u_arg[1], -1);
2407 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2417 if (entering(tcp)) {
2418 tprintf("%ld, ", tcp->u_arg[0]);
2419 printstr(tcp, tcp->u_arg[1], -1);
2421 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2431 if (entering(tcp)) {
2432 printpath(tcp, tcp->u_arg[0]);
2434 /* XXX Print value in format */
2435 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2444 if (entering(tcp)) {
2445 tprintf("%ld", tcp->u_arg[0]);
2447 /* XXX Print value in format */
2448 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2454 sys_removexattr(tcp)
2457 if (entering(tcp)) {
2458 printpath(tcp, tcp->u_arg[0]);
2460 printstr(tcp, tcp->u_arg[1], -1);
2466 sys_fremovexattr(tcp)
2469 if (entering(tcp)) {
2470 tprintf("%ld, ", tcp->u_arg[0]);
2471 printstr(tcp, tcp->u_arg[1], -1);