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
249 { O_LARGEFILE, "O_LARGEFILE" },
253 { O_DIRECTORY, "O_DIRECTORY" },
256 { O_NOFOLLOW, "O_NOFOLLOW" },
260 { FNDELAY, "FNDELAY" },
263 { FAPPEND, "FAPPEND" },
269 { FDEFER, "FDEFER" },
272 { FASYNC, "FASYNC" },
275 { FSHLOCK, "FSHLOCK" },
278 { FEXLOCK, "FEXLOCK" },
281 { FCREAT, "FCREAT" },
284 { FTRUNC, "FTRUNC" },
296 { FNOCTTY, "FNOCTTY" },
299 { O_SHLOCK, "O_SHLOCK" },
302 { O_EXLOCK, "O_EXLOCK" },
312 printpath(tcp, tcp->u_arg[0]);
315 printflags(openmodes, tcp->u_arg[1] + 1);
316 if (tcp->u_arg[1] & O_CREAT) {
318 tprintf(", %#lo", tcp->u_arg[2]);
325 const struct xlat openmodessol[] = {
329 { 0x80, "O_NONBLOCK" },
331 { 0x100, "O_CREAT" },
332 { 0x200, "O_TRUNC" },
334 { 0x800, "O_NOCTTY" },
337 { 0x8000, "O_RSYNC" },
339 { 0x1000, "O_PRIV" },
348 printpath(tcp, tcp->u_arg[0]);
351 printflags(openmodessol, tcp->u_arg[1] + 1);
352 if (tcp->u_arg[1] & 0x100) {
354 tprintf(", %#lo", tcp->u_arg[2]);
367 printpath(tcp, tcp->u_arg[0]);
368 tprintf(", %#lo", tcp->u_arg[1]);
373 static const struct xlat access_flags[] = {
379 { EFF_ONLY_OK, "EFF_ONLY_OK" },
392 printpath(tcp, tcp->u_arg[0]);
394 printflags(access_flags, tcp->u_arg[1]);
404 tprintf("%#lo", tcp->u_arg[0]);
409 static const struct xlat whence[] = {
410 { SEEK_SET, "SEEK_SET" },
411 { SEEK_CUR, "SEEK_CUR" },
412 { SEEK_END, "SEEK_END" },
416 #ifndef HAVE_LONG_LONG_OFF_T
425 tprintf("%ld, ", tcp->u_arg[0]);
426 offset = tcp->u_arg[1];
427 _whence = tcp->u_arg[2];
428 if (_whence == SEEK_SET)
429 tprintf("%lu, ", offset);
431 tprintf("%ld, ", offset);
432 printxval(whence, _whence, "SEEK_???");
434 return RVAL_UDECIMAL;
445 * This one call takes explicitly two 32-bit arguments hi, lo,
446 * rather than one 64-bit argument for which LONG_LONG works
447 * appropriate for the native byte order.
449 if (tcp->u_arg[4] == SEEK_SET)
450 tprintf("%ld, %llu, ", tcp->u_arg[0],
451 (((long long int) tcp->u_arg[1]) << 32
452 | (unsigned long long) (unsigned) tcp->u_arg[2]));
454 tprintf("%ld, %lld, ", tcp->u_arg[0],
455 (((long long int) tcp->u_arg[1]) << 32
456 | (unsigned long long) (unsigned) tcp->u_arg[2]));
460 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
461 tprintf("%#lx, ", tcp->u_arg[3]);
463 tprintf("[%llu], ", off);
464 printxval(whence, tcp->u_arg[4], "SEEK_???");
474 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
475 # if defined IA64 || defined X86_64 || defined ALPHA
476 (long long int) tcp->u_arg[1], tcp->u_arg[2]
478 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]
486 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
493 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
494 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
495 if (tcp->u_arg[3] == SEEK_SET)
496 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
498 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
499 printxval(whence, tcp->u_arg[3], "SEEK_???");
501 return RVAL_LUDECIMAL;
505 #ifndef HAVE_LONG_LONG_OFF_T
511 printpath(tcp, tcp->u_arg[0]);
512 tprintf(", %lu", tcp->u_arg[1]);
518 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
525 printpath(tcp, tcp->u_arg[0]);
526 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
532 #ifndef HAVE_LONG_LONG_OFF_T
538 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
544 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
551 tprintf("%ld, %llu", tcp->u_arg[0],
552 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
560 static const struct xlat modetypes[] = {
561 { S_IFREG, "S_IFREG" },
562 { S_IFSOCK, "S_IFSOCK" },
563 { S_IFIFO, "S_IFIFO" },
564 { S_IFLNK, "S_IFLNK" },
565 { S_IFDIR, "S_IFDIR" },
566 { S_IFBLK, "S_IFBLK" },
567 { S_IFCHR, "S_IFCHR" },
578 if ((mode & S_IFMT) == 0)
580 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
581 sprintf(buf, "%#o", mode);
584 sprintf(buf, "%s%s%s%s", s,
585 (mode & S_ISUID) ? "|S_ISUID" : "",
586 (mode & S_ISGID) ? "|S_ISGID" : "",
587 (mode & S_ISVTX) ? "|S_ISVTX" : "");
588 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
590 sprintf(buf + strlen(buf), "|%#o", mode);
591 s = (*buf == '|') ? buf + 1 : buf;
607 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
608 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
609 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
621 int st_pad1[3]; /* network id */
630 int st_pad3; /* st_size, off_t expansion */
631 timestruct_t st_atime;
632 timestruct_t st_mtime;
633 timestruct_t st_ctime;
637 int st_pad4[8]; /* expansion area */
641 printstatsol(tcp, addr)
645 struct solstat statbuf;
651 if (syserror(tcp) || !verbose(tcp)) {
652 tprintf("%#lx", addr);
655 if (umove(tcp, addr, &statbuf) < 0) {
660 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
661 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
662 (unsigned long) (statbuf.st_dev & 0x3ffff),
663 (unsigned long) statbuf.st_ino,
664 sprintmode(statbuf.st_mode));
665 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
666 (unsigned long) statbuf.st_nlink,
667 (unsigned long) statbuf.st_uid,
668 (unsigned long) statbuf.st_gid);
669 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
670 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
673 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
674 switch (statbuf.st_mode & S_IFMT) {
675 case S_IFCHR: case S_IFBLK:
676 tprintf("st_rdev=makedev(%lu, %lu), ",
677 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
678 (unsigned long) (statbuf.st_rdev & 0x3ffff));
681 tprintf("st_size=%u, ", statbuf.st_size);
685 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
686 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
687 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
693 #if defined (SPARC64)
695 printstat_sparc64(tcp, addr)
699 struct stat_sparc64 statbuf;
705 if (syserror(tcp) || !verbose(tcp)) {
706 tprintf("%#lx", addr);
709 if (umove(tcp, addr, &statbuf) < 0) {
715 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
716 (unsigned long) major(statbuf.st_dev),
717 (unsigned long) minor(statbuf.st_dev),
718 (unsigned long) statbuf.st_ino,
719 sprintmode(statbuf.st_mode));
720 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
721 (unsigned long) statbuf.st_nlink,
722 (unsigned long) statbuf.st_uid,
723 (unsigned long) statbuf.st_gid);
724 tprintf("st_blksize=%lu, ",
725 (unsigned long) statbuf.st_blksize);
726 tprintf("st_blocks=%lu, ",
727 (unsigned long) statbuf.st_blocks);
730 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
731 switch (statbuf.st_mode & S_IFMT) {
732 case S_IFCHR: case S_IFBLK:
733 tprintf("st_rdev=makedev(%lu, %lu), ",
734 (unsigned long) major(statbuf.st_rdev),
735 (unsigned long) minor(statbuf.st_rdev));
738 tprintf("st_size=%lu, ", statbuf.st_size);
742 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
743 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
744 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
751 #endif /* LINUXSPARC */
753 const struct xlat fileflags[] = {
755 { UF_NODUMP, "UF_NODUMP" },
756 { UF_IMMUTABLE, "UF_IMMUTABLE" },
757 { UF_APPEND, "UF_APPEND" },
758 { UF_OPAQUE, "UF_OPAQUE" },
759 { UF_NOUNLINK, "UF_NOUNLINK" },
760 { SF_ARCHIVED, "SF_ARCHIVED" },
761 { SF_IMMUTABLE, "SF_IMMUTABLE" },
762 { SF_APPEND, "SF_APPEND" },
763 { SF_NOUNLINK, "SF_NOUNLINK" },
766 { _S_ISMLD, "_S_ISMLD" },
769 { _S_ISMOUNTED, "_S_ISMOUNTED" },
781 printpath(tcp, tcp->u_arg[0]);
784 printflags(fileflags, tcp->u_arg[1]);
796 tprintf("%ld, ", tcp->u_arg[0]);
798 printflags(fileflags, tcp->u_arg[1]);
806 #ifndef HAVE_LONG_LONG_OFF_T
808 realprintstat(tcp, statbuf)
810 struct stat *statbuf;
813 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
814 (unsigned long) major(statbuf->st_dev),
815 (unsigned long) minor(statbuf->st_dev),
816 (unsigned long) statbuf->st_ino,
817 sprintmode(statbuf->st_mode));
818 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
819 (unsigned long) statbuf->st_nlink,
820 (unsigned long) statbuf->st_uid,
821 (unsigned long) statbuf->st_gid);
822 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
823 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
824 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
825 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
826 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
827 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
830 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
831 switch (statbuf->st_mode & S_IFMT) {
832 case S_IFCHR: case S_IFBLK:
833 #ifdef HAVE_STRUCT_STAT_ST_RDEV
834 tprintf("st_rdev=makedev(%lu, %lu), ",
835 (unsigned long) major(statbuf->st_rdev),
836 (unsigned long) minor(statbuf->st_rdev));
837 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
838 tprintf("st_size=makedev(%lu, %lu), ",
839 (unsigned long) major(statbuf->st_size),
840 (unsigned long) minor(statbuf->st_size));
841 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
844 tprintf("st_size=%lu, ", statbuf->st_size);
848 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
849 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
850 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
851 #if HAVE_STRUCT_STAT_ST_FLAGS
852 tprintf(", st_flags=");
853 if (statbuf->st_flags) {
854 printflags(fileflags, statbuf->st_flags);
858 #if HAVE_STRUCT_STAT_ST_ACLCNT
859 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
861 #if HAVE_STRUCT_STAT_ST_LEVEL
862 tprintf(", st_level=%ld", statbuf->st_level);
864 #if HAVE_STRUCT_STAT_ST_FSTYPE
865 tprintf(", st_fstype=%.*s",
866 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
868 #if HAVE_STRUCT_STAT_ST_GEN
869 tprintf(", st_gen=%u", statbuf->st_gen);
886 if (current_personality == 1) {
887 printstatsol(tcp, addr);
891 else if (current_personality == 2) {
892 printstat_sparc64(tcp, addr);
896 #endif /* LINUXSPARC */
902 if (syserror(tcp) || !verbose(tcp)) {
903 tprintf("%#lx", addr);
906 if (umove(tcp, addr, &statbuf) < 0) {
911 realprintstat(tcp, &statbuf);
913 #endif /* !HAVE_LONG_LONG_OFF_T */
917 printstat64(tcp, addr)
921 struct stat64 statbuf;
924 if (current_personality == 1) {
925 printstatsol(tcp, addr);
929 else if (current_personality == 2) {
930 printstat_sparc64(tcp, addr);
934 #endif /* LINUXSPARC */
940 if (syserror(tcp) || !verbose(tcp)) {
941 tprintf("%#lx", addr);
944 if (umove(tcp, addr, &statbuf) < 0) {
950 #ifdef HAVE_LONG_LONG
951 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
953 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
955 (unsigned long) major(statbuf.st_dev),
956 (unsigned long) minor(statbuf.st_dev),
957 #ifdef HAVE_LONG_LONG
958 (unsigned long long) statbuf.st_ino,
960 (unsigned long) statbuf.st_ino,
962 sprintmode(statbuf.st_mode));
963 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
964 (unsigned long) statbuf.st_nlink,
965 (unsigned long) statbuf.st_uid,
966 (unsigned long) statbuf.st_gid);
967 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
968 tprintf("st_blksize=%lu, ",
969 (unsigned long) statbuf.st_blksize);
970 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
971 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
972 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
973 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
976 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
977 switch (statbuf.st_mode & S_IFMT) {
978 case S_IFCHR: case S_IFBLK:
979 #ifdef HAVE_STRUCT_STAT_ST_RDEV
980 tprintf("st_rdev=makedev(%lu, %lu), ",
981 (unsigned long) major(statbuf.st_rdev),
982 (unsigned long) minor(statbuf.st_rdev));
983 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
984 tprintf("st_size=makedev(%lu, %lu), ",
985 (unsigned long) major(statbuf.st_size),
986 (unsigned long) minor(statbuf.st_size));
987 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
990 tprintf("st_size=%llu, ", statbuf.st_size);
994 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
995 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
996 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
997 #if HAVE_STRUCT_STAT_ST_FLAGS
998 tprintf(", st_flags=");
999 if (statbuf.st_flags) {
1000 printflags(fileflags, statbuf.st_flags);
1004 #if HAVE_STRUCT_STAT_ST_ACLCNT
1005 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1007 #if HAVE_STRUCT_STAT_ST_LEVEL
1008 tprintf(", st_level=%ld", statbuf.st_level);
1010 #if HAVE_STRUCT_STAT_ST_FSTYPE
1011 tprintf(", st_fstype=%.*s",
1012 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1014 #if HAVE_STRUCT_STAT_ST_GEN
1015 tprintf(", st_gen=%u", statbuf.st_gen);
1022 #endif /* HAVE_STAT64 */
1024 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1026 convertoldstat(oldbuf, newbuf)
1027 const struct __old_kernel_stat *oldbuf;
1028 struct stat *newbuf;
1030 newbuf->st_dev=oldbuf->st_dev;
1031 newbuf->st_ino=oldbuf->st_ino;
1032 newbuf->st_mode=oldbuf->st_mode;
1033 newbuf->st_nlink=oldbuf->st_nlink;
1034 newbuf->st_uid=oldbuf->st_uid;
1035 newbuf->st_gid=oldbuf->st_gid;
1036 newbuf->st_rdev=oldbuf->st_rdev;
1037 newbuf->st_size=oldbuf->st_size;
1038 newbuf->st_atime=oldbuf->st_atime;
1039 newbuf->st_mtime=oldbuf->st_mtime;
1040 newbuf->st_ctime=oldbuf->st_ctime;
1041 newbuf->st_blksize=0; /* not supported in old_stat */
1042 newbuf->st_blocks=0; /* not supported in old_stat */
1047 printoldstat(tcp, addr)
1051 struct __old_kernel_stat statbuf;
1052 struct stat newstatbuf;
1055 if (current_personality == 1) {
1056 printstatsol(tcp, addr);
1059 #endif /* LINUXSPARC */
1065 if (syserror(tcp) || !verbose(tcp)) {
1066 tprintf("%#lx", addr);
1069 if (umove(tcp, addr, &statbuf) < 0) {
1074 convertoldstat(&statbuf, &newstatbuf);
1075 realprintstat(tcp, &newstatbuf);
1077 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1079 #ifndef HAVE_LONG_LONG_OFF_T
1084 if (entering(tcp)) {
1085 printpath(tcp, tcp->u_arg[0]);
1088 printstat(tcp, tcp->u_arg[1]);
1099 if (entering(tcp)) {
1100 printpath(tcp, tcp->u_arg[0]);
1103 printstat64(tcp, tcp->u_arg[1]);
1107 return printargs(tcp);
1111 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1116 if (entering(tcp)) {
1117 printpath(tcp, tcp->u_arg[0]);
1120 printoldstat(tcp, tcp->u_arg[1]);
1124 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1126 #ifndef HAVE_LONG_LONG_OFF_T
1132 tprintf("%ld, ", tcp->u_arg[0]);
1134 printstat(tcp, tcp->u_arg[1]);
1146 tprintf("%ld, ", tcp->u_arg[0]);
1148 printstat64(tcp, tcp->u_arg[1]);
1152 return printargs(tcp);
1156 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1162 tprintf("%ld, ", tcp->u_arg[0]);
1164 printoldstat(tcp, tcp->u_arg[1]);
1168 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1170 #ifndef HAVE_LONG_LONG_OFF_T
1175 if (entering(tcp)) {
1176 printpath(tcp, tcp->u_arg[0]);
1179 printstat(tcp, tcp->u_arg[1]);
1190 if (entering(tcp)) {
1191 printpath(tcp, tcp->u_arg[0]);
1194 printstat64(tcp, tcp->u_arg[1]);
1198 return printargs(tcp);
1202 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1207 if (entering(tcp)) {
1208 printpath(tcp, tcp->u_arg[0]);
1211 printoldstat(tcp, tcp->u_arg[1]);
1215 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1218 #if defined(SVR4) || defined(LINUXSPARC)
1224 if (entering(tcp)) {
1225 tprintf("%ld, ", tcp->u_arg[0]);
1226 printpath(tcp, 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]);
1244 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1247 if (tcp->u_arg[0] == _STAT64_VER)
1248 printstat64 (tcp, tcp->u_arg[2]);
1251 printstat(tcp, tcp->u_arg[2]);
1260 if (entering(tcp)) {
1261 tprintf("%ld, ", tcp->u_arg[0]);
1262 printpath(tcp, tcp->u_arg[1]);
1266 if (tcp->u_arg[0] == _STAT64_VER)
1267 printstat64 (tcp, tcp->u_arg[2]);
1270 printstat(tcp, tcp->u_arg[2]);
1279 int mode = tcp->u_arg[2];
1281 if (entering(tcp)) {
1282 tprintf("%ld, ", tcp->u_arg[0]);
1283 printpath(tcp, tcp->u_arg[1]);
1284 tprintf(", %s", sprintmode(mode));
1285 switch (mode & S_IFMT) {
1286 case S_IFCHR: case S_IFBLK:
1288 tprintf(", makedev(%lu, %lu)",
1289 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1290 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1292 tprintf(", makedev(%lu, %lu)",
1293 (unsigned long) major(tcp->u_arg[3]),
1294 (unsigned long) minor(tcp->u_arg[3]));
1304 #ifdef HAVE_SYS_ACL_H
1306 #include <sys/acl.h>
1308 const struct xlat aclcmds[] = {
1310 { SETACL, "SETACL" },
1313 { GETACL, "GETACL" },
1316 { GETACLCNT, "GETACLCNT" },
1319 { ACL_GET, "ACL_GET" },
1322 { ACL_SET, "ACL_SET" },
1325 { ACL_CNT, "ACL_CNT" },
1334 if (entering(tcp)) {
1335 printpath(tcp, tcp->u_arg[0]);
1337 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1338 tprintf(", %ld", tcp->u_arg[2]);
1340 * FIXME - dump out the list of aclent_t's pointed to
1341 * by "tcp->u_arg[3]" if it's not NULL.
1344 tprintf(", %#lx", tcp->u_arg[3]);
1356 if (entering(tcp)) {
1357 tprintf("%ld, ", tcp->u_arg[0]);
1358 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1359 tprintf(", %ld", tcp->u_arg[2]);
1361 * FIXME - dump out the list of aclent_t's pointed to
1362 * by "tcp->u_arg[3]" if it's not NULL.
1365 tprintf(", %#lx", tcp->u_arg[3]);
1373 const struct xlat aclipc[] = {
1375 { IPC_SHM, "IPC_SHM" },
1378 { IPC_SEM, "IPC_SEM" },
1381 { IPC_MSG, "IPC_MSG" },
1391 if (entering(tcp)) {
1392 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1393 tprintf(", %#lx, ", tcp->u_arg[1]);
1394 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1395 tprintf(", %ld", tcp->u_arg[3]);
1397 * FIXME - dump out the list of aclent_t's pointed to
1398 * by "tcp->u_arg[4]" if it's not NULL.
1401 tprintf(", %#lx", tcp->u_arg[4]);
1410 #endif /* HAVE_SYS_ACL_H */
1412 #endif /* SVR4 || LINUXSPARC */
1416 static const struct xlat fsmagic[] = {
1417 { 0x73757245, "CODA_SUPER_MAGIC" },
1418 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1419 { 0x1373, "DEVFS_SUPER_MAGIC" },
1420 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1421 { 0x414A53, "EFS_SUPER_MAGIC" },
1422 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1423 { 0xef53, "EXT2_SUPER_MAGIC" },
1424 { 0x137d, "EXT_SUPER_MAGIC" },
1425 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1426 { 0x9660, "ISOFS_SUPER_MAGIC" },
1427 { 0x137f, "MINIX_SUPER_MAGIC" },
1428 { 0x138f, "MINIX_SUPER_MAGIC2" },
1429 { 0x2468, "MINIX2_SUPER_MAGIC" },
1430 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1431 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1432 { 0x564c, "NCP_SUPER_MAGIC" },
1433 { 0x6969, "NFS_SUPER_MAGIC" },
1434 { 0x9fa0, "PROC_SUPER_MAGIC" },
1435 { 0x002f, "QNX4_SUPER_MAGIC" },
1436 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1437 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1438 { 0x517b, "SMB_SUPER_MAGIC" },
1439 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1440 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1441 { 0x00011954, "UFS_MAGIC" },
1442 { 0x54190100, "UFS_CIGAM" },
1443 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1444 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1445 { 0x62656572, "SYSFS_MAGIC" },
1457 static char buf[32];
1461 s = xlookup(fsmagic, magic);
1463 sprintf(buf, "\"%s\"", s);
1467 sprintf(buf, "%#x", magic);
1472 printstatfs(tcp, addr)
1476 struct statfs statbuf;
1478 if (syserror(tcp) || !verbose(tcp)) {
1479 tprintf("%#lx", addr);
1482 if (umove(tcp, addr, &statbuf) < 0) {
1488 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1489 sprintfstype(statbuf.f_type),
1490 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1491 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1492 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1493 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1496 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1497 sprintfstype(statbuf.f_type),
1498 (unsigned long)statbuf.f_bsize,
1499 (unsigned long)statbuf.f_blocks,
1500 (unsigned long)statbuf.f_bfree);
1501 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1502 (unsigned long)statbuf.f_bavail,
1503 (unsigned long)statbuf.f_files,
1504 (unsigned long)statbuf.f_ffree,
1505 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1507 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1510 #ifdef _STATFS_F_FRSIZE
1511 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1520 if (entering(tcp)) {
1521 printpath(tcp, tcp->u_arg[0]);
1524 printstatfs(tcp, tcp->u_arg[1]);
1533 if (entering(tcp)) {
1534 tprintf("%lu, ", tcp->u_arg[0]);
1536 printstatfs(tcp, tcp->u_arg[1]);
1543 printstatfs64(tcp, addr)
1547 struct statfs64 statbuf;
1549 if (syserror(tcp) || !verbose(tcp)) {
1550 tprintf("%#lx", addr);
1553 if (umove(tcp, addr, &statbuf) < 0) {
1559 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1560 sprintfstype(statbuf.f_type),
1561 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1562 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1563 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1564 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1567 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1568 sprintfstype(statbuf.f_type),
1569 (unsigned long)statbuf.f_bsize,
1570 (unsigned long)statbuf.f_blocks,
1571 (unsigned long)statbuf.f_bfree);
1572 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1573 (unsigned long)statbuf.f_bavail,
1574 (unsigned long)statbuf.f_files,
1575 (unsigned long)statbuf.f_ffree,
1576 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1577 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1579 #ifdef _STATFS_F_FRSIZE
1580 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1589 if (entering(tcp)) {
1590 printpath(tcp, tcp->u_arg[0]);
1591 tprintf(", %lu, ", tcp->u_arg[1]);
1593 if (tcp->u_arg[1] == sizeof (struct statfs64))
1594 printstatfs64(tcp, tcp->u_arg[2]);
1605 if (entering(tcp)) {
1606 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1608 if (tcp->u_arg[1] == sizeof (struct statfs64))
1609 printstatfs64(tcp, tcp->u_arg[2]);
1617 #if defined(LINUX) && defined(__alpha)
1623 if (entering(tcp)) {
1624 printpath(tcp, tcp->u_arg[0]);
1627 printstatfs(tcp, tcp->u_arg[1]);
1628 tprintf(", %lu", tcp->u_arg[2]);
1637 if (entering(tcp)) {
1638 tprintf("%lu, ", tcp->u_arg[0]);
1640 printstatfs(tcp, tcp->u_arg[1]);
1641 tprintf(", %lu", tcp->u_arg[2]);
1645 #endif /* LINUX && __alpha */
1655 struct ustat statbuf;
1657 if (entering(tcp)) {
1658 tprintf("makedev(%lu, %lu), ",
1659 (long) major(tcp->u_arg[0]),
1660 (long) minor(tcp->u_arg[0]));
1663 if (syserror(tcp) || !verbose(tcp))
1664 tprintf("%#lx", tcp->u_arg[1]);
1665 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1668 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1669 statbuf.f_tfree, statbuf.f_tinode);
1670 tprintf("f_fname=\"%.*s\", ",
1671 (int) sizeof(statbuf.f_fname),
1673 tprintf("f_fpack=\"%.*s\"}",
1674 (int) sizeof(statbuf.f_fpack),
1687 if (entering(tcp)) {
1688 printpath(tcp, tcp->u_arg[0]);
1690 printpath(tcp, tcp->u_arg[1]);
1701 if (entering(tcp)) {
1702 printpath(tcp, tcp->u_arg[0]);
1711 if (entering(tcp)) {
1712 printpath(tcp, tcp->u_arg[0]);
1713 tprintf(", %#lo", tcp->u_arg[1]);
1722 if (entering(tcp)) {
1723 printpath(tcp, tcp->u_arg[0]);
1732 if (entering(tcp)) {
1733 tprintf("%ld", tcp->u_arg[0]);
1742 if (entering(tcp)) {
1743 printpath(tcp, tcp->u_arg[0]);
1752 if (entering(tcp)) {
1753 tprintf("%ld", tcp->u_arg[0]);
1762 if (entering(tcp)) {
1763 printpath(tcp, tcp->u_arg[0]);
1765 printpath(tcp, tcp->u_arg[1]);
1774 if (entering(tcp)) {
1775 printpath(tcp, tcp->u_arg[0]);
1784 if (entering(tcp)) {
1785 printpath(tcp, tcp->u_arg[0]);
1787 printpath(tcp, tcp->u_arg[1]);
1796 if (entering(tcp)) {
1797 printpath(tcp, tcp->u_arg[0]);
1801 tprintf("%#lx", tcp->u_arg[1]);
1803 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1804 tprintf(", %lu", tcp->u_arg[2]);
1813 if (entering(tcp)) {
1814 printpath(tcp, tcp->u_arg[0]);
1816 printpath(tcp, tcp->u_arg[1]);
1825 if (entering(tcp)) {
1826 printpath(tcp, tcp->u_arg[0]);
1827 printuid(", ", tcp->u_arg[1]);
1828 printuid(", ", tcp->u_arg[2]);
1837 if (entering(tcp)) {
1838 tprintf("%ld", tcp->u_arg[0]);
1839 printuid(", ", tcp->u_arg[1]);
1840 printuid(", ", tcp->u_arg[2]);
1849 if (entering(tcp)) {
1850 printpath(tcp, tcp->u_arg[0]);
1851 tprintf(", %#lo", tcp->u_arg[1]);
1860 if (entering(tcp)) {
1861 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1871 if (entering(tcp)) {
1872 printpath(tcp, tcp->u_arg[0]);
1874 printtv32(tcp, tcp->u_arg[1]);
1884 if (entering(tcp)) {
1885 printpath(tcp, tcp->u_arg[0]);
1887 printtv(tcp, tcp->u_arg[1]);
1898 if (entering(tcp)) {
1899 printpath(tcp, tcp->u_arg[0]);
1903 else if (!verbose(tcp))
1904 tprintf("%#lx", tcp->u_arg[1]);
1905 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1909 tprintf("[%s,", sprinttime(ut[0]));
1910 tprintf(" %s]", sprinttime(ut[1]));
1920 int mode = tcp->u_arg[1];
1922 if (entering(tcp)) {
1923 printpath(tcp, tcp->u_arg[0]);
1924 tprintf(", %s", sprintmode(mode));
1925 switch (mode & S_IFMT) {
1926 case S_IFCHR: case S_IFBLK:
1928 if (current_personality == 1)
1929 tprintf(", makedev(%lu, %lu)",
1930 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1931 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1934 tprintf(", makedev(%lu, %lu)",
1935 (unsigned long) major(tcp->u_arg[2]),
1936 (unsigned long) minor(tcp->u_arg[2]));
1949 if (entering(tcp)) {
1950 printpath(tcp, tcp->u_arg[0]);
1951 tprintf(", %#lo", tcp->u_arg[1]);
1960 if (entering(tcp)) {
1961 tprintf("%ld", tcp->u_arg[0]);
1975 if (!verbose(tcp)) {
1976 tprintf("%#lx", addr);
1979 if (umove(tcp, addr, &d) < 0) {
1983 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1985 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1993 if (entering(tcp)) {
1994 tprintf("%lu, ", tcp->u_arg[0]);
1996 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1997 tprintf("%#lx", tcp->u_arg[1]);
1999 printdir(tcp, tcp->u_arg[1]);
2000 /* Not much point in printing this out, it is always 1. */
2001 if (tcp->u_arg[2] != 1)
2002 tprintf(", %lu", tcp->u_arg[2]);
2009 #if defined FREEBSD || defined LINUX
2010 const struct xlat direnttypes[] = {
2011 { DT_UNKNOWN, "DT_UNKNOWN" },
2012 { DT_FIFO, "DT_FIFO" },
2013 { DT_CHR, "DT_CHR" },
2014 { DT_DIR, "DT_DIR" },
2015 { DT_BLK, "DT_BLK" },
2016 { DT_REG, "DT_REG" },
2017 { DT_LNK, "DT_LNK" },
2018 { DT_SOCK, "DT_SOCK" },
2019 { DT_WHT, "DT_WHT" },
2029 int i, len, dents = 0;
2032 if (entering(tcp)) {
2033 tprintf("%lu, ", tcp->u_arg[0]);
2036 if (syserror(tcp) || !verbose(tcp)) {
2037 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2041 if ((buf = malloc(len)) == NULL) {
2042 tprintf("out of memory\n");
2045 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2046 tprintf("{...}, %lu", tcp->u_arg[2]);
2052 for (i = 0; i < len;) {
2053 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2056 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2057 i ? " " : "", d->d_ino, d->d_off);
2058 tprintf("d_reclen=%u, d_name=\"%s\"}",
2059 d->d_reclen, d->d_name);
2064 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2066 (unsigned long) d->d_ino,
2067 (unsigned long) d->d_off);
2068 tprintf("d_reclen=%u, d_name=\"%s\"}",
2069 d->d_reclen, d->d_name);
2074 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2075 i ? " " : "", d->d_off, d->d_fileno,
2077 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2078 d->d_namlen, d->d_namlen, d->d_name);
2083 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2084 i ? " " : "", d->d_fileno, d->d_reclen);
2085 printxval(direnttypes, d->d_type, "DT_???");
2086 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2087 d->d_namlen, d->d_namlen, d->d_name);
2089 #endif /* FREEBSD */
2091 tprintf("/* d_reclen == 0, problem here */");
2100 tprintf("/* %u entries */", dents);
2101 tprintf(", %lu", tcp->u_arg[2]);
2107 #if _LFS64_LARGEFILE
2112 int i, len, dents = 0;
2115 if (entering(tcp)) {
2116 tprintf("%lu, ", tcp->u_arg[0]);
2119 if (syserror(tcp) || !verbose(tcp)) {
2120 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2124 if ((buf = malloc(len)) == NULL) {
2125 tprintf("out of memory\n");
2128 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2129 tprintf("{...}, %lu", tcp->u_arg[2]);
2135 for (i = 0; i < len;) {
2136 struct dirent64 *d = (struct dirent64 *) &buf[i];
2137 #if defined(LINUX) || defined(SVR4)
2139 tprintf("%s{d_ino=%llu, d_off=%llu, ",
2145 printxval(direnttypes, d->d_type, "DT_???");
2148 tprintf("d_reclen=%u, d_name=\"%s\"}",
2149 d->d_reclen, d->d_name);
2151 #endif /* LINUX || SVR4 */
2154 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2155 i ? " " : "", d->d_off, d->d_fileno,
2157 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2158 d->d_namlen, d->d_namlen, d->d_name);
2167 tprintf("/* %u entries */", dents);
2168 tprintf(", %lu", tcp->u_arg[2]);
2176 sys_getdirentries(tcp)
2179 int i, len, dents = 0;
2183 if (entering(tcp)) {
2184 tprintf("%lu, ", tcp->u_arg[0]);
2187 if (syserror(tcp) || !verbose(tcp)) {
2188 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2192 if ((buf = malloc(len)) == NULL) {
2193 tprintf("out of memory\n");
2196 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2197 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
2203 for (i = 0; i < len;) {
2204 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2206 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2207 i ? " " : "", d->d_fileno, d->d_reclen);
2208 printxval(direnttypes, d->d_type, "DT_???");
2209 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2210 d->d_namlen, d->d_namlen, d->d_name);
2218 tprintf("/* %u entries */", dents);
2220 tprintf(", %lu", tcp->u_arg[2]);
2221 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2222 tprintf(", %#lx", tcp->u_arg[3]);
2224 tprintf(", [%lu]", basep);
2236 tprintf("%#lx", tcp->u_arg[0]);
2238 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2239 tprintf(", %lu", tcp->u_arg[1]);
2252 tprintf("%#lx", tcp->u_arg[0]);
2254 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2255 tprintf(", %lu", tcp->u_arg[1]);
2261 #ifdef HAVE_SYS_ASYNCH_H
2267 struct aio_result_t res;
2269 if (entering(tcp)) {
2270 tprintf("%lu, ", tcp->u_arg[0]);
2273 tprintf("%#lx", tcp->u_arg[1]);
2275 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2276 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2277 printxval(whence, tcp->u_arg[4], "L_???");
2278 if (syserror(tcp) || tcp->u_arg[5] == 0
2279 || umove(tcp, tcp->u_arg[5], &res) < 0)
2280 tprintf(", %#lx", tcp->u_arg[5]);
2282 tprintf(", {aio_return %d aio_errno %d}",
2283 res.aio_return, res.aio_errno);
2292 struct aio_result_t res;
2294 if (entering(tcp)) {
2295 tprintf("%lu, ", tcp->u_arg[0]);
2296 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2297 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2298 printxval(whence, tcp->u_arg[4], "L_???");
2301 if (tcp->u_arg[5] == 0)
2303 else if (syserror(tcp)
2304 || umove(tcp, tcp->u_arg[5], &res) < 0)
2305 tprintf(", %#lx", tcp->u_arg[5]);
2307 tprintf(", {aio_return %d aio_errno %d}",
2308 res.aio_return, res.aio_errno);
2318 printtv(tcp, tcp->u_arg[0]);
2326 struct aio_result_t res;
2329 if (tcp->u_arg[0] == 0)
2331 else if (syserror(tcp)
2332 || umove(tcp, tcp->u_arg[0], &res) < 0)
2333 tprintf("%#lx", tcp->u_arg[0]);
2335 tprintf("{aio_return %d aio_errno %d}",
2336 res.aio_return, res.aio_errno);
2341 #endif /* HAVE_SYS_ASYNCH_H */
2343 const struct xlat xattrflags[] = {
2345 { XATTR_CREATE, "XATTR_CREATE" },
2346 { XATTR_REPLACE, "XATTR_REPLACE" },
2352 print_xattr_val(tcp, failed, arg, insize, size)
2359 unsigned char *buf = malloc(4 * size + 1);
2360 if (buf == NULL || /* probably a bogus size argument */
2361 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2365 unsigned char *out = buf;
2366 unsigned char *in = &buf[3 * size];
2368 for (i = 0; i < size; ++i)
2372 #define tohex(n) "0123456789abcdef"[n]
2375 *out++ = tohex(in[i] / 16);
2376 *out++ = tohex(in[i] % 16);
2378 /* Don't print terminating NUL if there is one. */
2379 if (in[i - 1] == '\0')
2382 tprintf(", \"%s\", %ld", buf, insize);
2387 tprintf(", 0x%lx, %ld", arg, insize);
2394 if (entering(tcp)) {
2395 printpath(tcp, tcp->u_arg[0]);
2397 printstr(tcp, tcp->u_arg[1], -1);
2398 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2400 printflags(xattrflags, tcp->u_arg[4]);
2409 if (entering(tcp)) {
2410 tprintf("%ld, ", tcp->u_arg[0]);
2411 printstr(tcp, tcp->u_arg[1], -1);
2412 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2414 printflags(xattrflags, tcp->u_arg[4]);
2423 if (entering(tcp)) {
2424 printpath(tcp, tcp->u_arg[0]);
2426 printstr(tcp, tcp->u_arg[1], -1);
2428 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2438 if (entering(tcp)) {
2439 tprintf("%ld, ", tcp->u_arg[0]);
2440 printstr(tcp, tcp->u_arg[1], -1);
2442 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2452 if (entering(tcp)) {
2453 printpath(tcp, tcp->u_arg[0]);
2455 /* XXX Print value in format */
2456 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2465 if (entering(tcp)) {
2466 tprintf("%ld", tcp->u_arg[0]);
2468 /* XXX Print value in format */
2469 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2475 sys_removexattr(tcp)
2478 if (entering(tcp)) {
2479 printpath(tcp, tcp->u_arg[0]);
2481 printstr(tcp, tcp->u_arg[1], -1);
2487 sys_fremovexattr(tcp)
2490 if (entering(tcp)) {
2491 tprintf("%ld, ", tcp->u_arg[0]);
2492 printstr(tcp, tcp->u_arg[1], -1);
2498 static const struct xlat advise[] = {
2499 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2500 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2501 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2502 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2503 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2504 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2514 if (entering(tcp)) {
2515 tprintf("%ld, %lld, %ld, ",
2517 # if defined IA64 || defined X86_64 || defined ALPHA
2518 (long long int) tcp->u_arg[1], tcp->u_arg[2]);
2519 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2521 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]);
2522 printxval(advise, tcp->u_arg[4], "POSIX_FADV_???");
2531 sys_fadvise64_64(tcp)
2534 if (entering(tcp)) {
2535 tprintf("%ld, %lld, %lld, ",
2537 # if defined IA64 || defined X86_64 || defined ALPHA
2538 (long long int) tcp->u_arg[1], (long long int) tcp->u_arg[2]);
2539 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2541 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]),
2542 LONG_LONG(tcp->u_arg[3], tcp->u_arg[4]));
2543 printxval(advise, tcp->u_arg[5], "POSIX_FADV_???");