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" },
259 { O_NOATIME, "O_NOATIME" },
263 { FNDELAY, "FNDELAY" },
266 { FAPPEND, "FAPPEND" },
272 { FDEFER, "FDEFER" },
275 { FASYNC, "FASYNC" },
278 { FSHLOCK, "FSHLOCK" },
281 { FEXLOCK, "FEXLOCK" },
284 { FCREAT, "FCREAT" },
287 { FTRUNC, "FTRUNC" },
299 { FNOCTTY, "FNOCTTY" },
302 { O_SHLOCK, "O_SHLOCK" },
305 { O_EXLOCK, "O_EXLOCK" },
315 printpath(tcp, tcp->u_arg[0]);
318 printflags(openmodes, tcp->u_arg[1] + 1, "O_???");
319 if (tcp->u_arg[1] & O_CREAT) {
321 tprintf(", %#lo", tcp->u_arg[2]);
328 const struct xlat openmodessol[] = {
332 { 0x80, "O_NONBLOCK" },
334 { 0x100, "O_CREAT" },
335 { 0x200, "O_TRUNC" },
337 { 0x800, "O_NOCTTY" },
340 { 0x8000, "O_RSYNC" },
342 { 0x1000, "O_PRIV" },
351 printpath(tcp, tcp->u_arg[0]);
354 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
355 if (tcp->u_arg[1] & 0x100) {
357 tprintf(", %#lo", tcp->u_arg[2]);
370 printpath(tcp, tcp->u_arg[0]);
371 tprintf(", %#lo", tcp->u_arg[1]);
376 static const struct xlat access_flags[] = {
382 { EFF_ONLY_OK, "EFF_ONLY_OK" },
395 printpath(tcp, tcp->u_arg[0]);
397 printflags(access_flags, tcp->u_arg[1], "?_OK");
407 tprintf("%#lo", tcp->u_arg[0]);
412 static const struct xlat whence[] = {
413 { SEEK_SET, "SEEK_SET" },
414 { SEEK_CUR, "SEEK_CUR" },
415 { SEEK_END, "SEEK_END" },
419 #ifndef HAVE_LONG_LONG_OFF_T
428 tprintf("%ld, ", tcp->u_arg[0]);
429 offset = tcp->u_arg[1];
430 _whence = tcp->u_arg[2];
431 if (_whence == SEEK_SET)
432 tprintf("%lu, ", offset);
434 tprintf("%ld, ", offset);
435 printxval(whence, _whence, "SEEK_???");
437 return RVAL_UDECIMAL;
448 * This one call takes explicitly two 32-bit arguments hi, lo,
449 * rather than one 64-bit argument for which LONG_LONG works
450 * appropriate for the native byte order.
452 if (tcp->u_arg[4] == SEEK_SET)
453 tprintf("%ld, %llu, ", tcp->u_arg[0],
454 (((long long int) tcp->u_arg[1]) << 32
455 | (unsigned long long) (unsigned) tcp->u_arg[2]));
457 tprintf("%ld, %lld, ", tcp->u_arg[0],
458 (((long long int) tcp->u_arg[1]) << 32
459 | (unsigned long long) (unsigned) tcp->u_arg[2]));
463 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
464 tprintf("%#lx, ", tcp->u_arg[3]);
466 tprintf("[%llu], ", off);
467 printxval(whence, tcp->u_arg[4], "SEEK_???");
477 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
478 # if defined IA64 || defined X86_64 || defined ALPHA
479 (long long int) tcp->u_arg[1], tcp->u_arg[2]
481 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]
489 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
496 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
497 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
498 if (tcp->u_arg[3] == SEEK_SET)
499 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
501 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
502 printxval(whence, tcp->u_arg[3], "SEEK_???");
504 return RVAL_LUDECIMAL;
508 #ifndef HAVE_LONG_LONG_OFF_T
514 printpath(tcp, tcp->u_arg[0]);
515 tprintf(", %lu", tcp->u_arg[1]);
521 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
528 printpath(tcp, tcp->u_arg[0]);
529 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
535 #ifndef HAVE_LONG_LONG_OFF_T
541 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
547 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
554 tprintf("%ld, %llu", tcp->u_arg[0],
555 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
563 static const struct xlat modetypes[] = {
564 { S_IFREG, "S_IFREG" },
565 { S_IFSOCK, "S_IFSOCK" },
566 { S_IFIFO, "S_IFIFO" },
567 { S_IFLNK, "S_IFLNK" },
568 { S_IFDIR, "S_IFDIR" },
569 { S_IFBLK, "S_IFBLK" },
570 { S_IFCHR, "S_IFCHR" },
581 if ((mode & S_IFMT) == 0)
583 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
584 sprintf(buf, "%#o", mode);
587 sprintf(buf, "%s%s%s%s", s,
588 (mode & S_ISUID) ? "|S_ISUID" : "",
589 (mode & S_ISGID) ? "|S_ISGID" : "",
590 (mode & S_ISVTX) ? "|S_ISVTX" : "");
591 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
593 sprintf(buf + strlen(buf), "|%#o", mode);
594 s = (*buf == '|') ? buf + 1 : buf;
610 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
611 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
612 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
624 int st_pad1[3]; /* network id */
633 int st_pad3; /* st_size, off_t expansion */
634 timestruct_t st_atime;
635 timestruct_t st_mtime;
636 timestruct_t st_ctime;
640 int st_pad4[8]; /* expansion area */
644 printstatsol(tcp, addr)
648 struct solstat statbuf;
654 if (syserror(tcp) || !verbose(tcp)) {
655 tprintf("%#lx", addr);
658 if (umove(tcp, addr, &statbuf) < 0) {
663 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
664 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
665 (unsigned long) (statbuf.st_dev & 0x3ffff),
666 (unsigned long) statbuf.st_ino,
667 sprintmode(statbuf.st_mode));
668 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
669 (unsigned long) statbuf.st_nlink,
670 (unsigned long) statbuf.st_uid,
671 (unsigned long) statbuf.st_gid);
672 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
673 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
676 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
677 switch (statbuf.st_mode & S_IFMT) {
678 case S_IFCHR: case S_IFBLK:
679 tprintf("st_rdev=makedev(%lu, %lu), ",
680 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
681 (unsigned long) (statbuf.st_rdev & 0x3ffff));
684 tprintf("st_size=%u, ", statbuf.st_size);
688 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
689 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
690 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
696 #if defined (SPARC64)
698 printstat_sparc64(tcp, addr)
702 struct stat_sparc64 statbuf;
708 if (syserror(tcp) || !verbose(tcp)) {
709 tprintf("%#lx", addr);
712 if (umove(tcp, addr, &statbuf) < 0) {
718 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
719 (unsigned long) major(statbuf.st_dev),
720 (unsigned long) minor(statbuf.st_dev),
721 (unsigned long) statbuf.st_ino,
722 sprintmode(statbuf.st_mode));
723 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
724 (unsigned long) statbuf.st_nlink,
725 (unsigned long) statbuf.st_uid,
726 (unsigned long) statbuf.st_gid);
727 tprintf("st_blksize=%lu, ",
728 (unsigned long) statbuf.st_blksize);
729 tprintf("st_blocks=%lu, ",
730 (unsigned long) statbuf.st_blocks);
733 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
734 switch (statbuf.st_mode & S_IFMT) {
735 case S_IFCHR: case S_IFBLK:
736 tprintf("st_rdev=makedev(%lu, %lu), ",
737 (unsigned long) major(statbuf.st_rdev),
738 (unsigned long) minor(statbuf.st_rdev));
741 tprintf("st_size=%lu, ", statbuf.st_size);
745 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
746 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
747 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
754 #endif /* LINUXSPARC */
756 const struct xlat fileflags[] = {
758 { UF_NODUMP, "UF_NODUMP" },
759 { UF_IMMUTABLE, "UF_IMMUTABLE" },
760 { UF_APPEND, "UF_APPEND" },
761 { UF_OPAQUE, "UF_OPAQUE" },
762 { UF_NOUNLINK, "UF_NOUNLINK" },
763 { SF_ARCHIVED, "SF_ARCHIVED" },
764 { SF_IMMUTABLE, "SF_IMMUTABLE" },
765 { SF_APPEND, "SF_APPEND" },
766 { SF_NOUNLINK, "SF_NOUNLINK" },
769 { _S_ISMLD, "_S_ISMLD" },
772 { _S_ISMOUNTED, "_S_ISMOUNTED" },
784 printpath(tcp, tcp->u_arg[0]);
786 printflags(fileflags, tcp->u_arg[1], "UF_???");
796 tprintf("%ld, ", tcp->u_arg[0]);
797 printflags(fileflags, tcp->u_arg[1], "UF_???");
803 #ifndef HAVE_LONG_LONG_OFF_T
805 realprintstat(tcp, statbuf)
807 struct stat *statbuf;
810 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
811 (unsigned long) major(statbuf->st_dev),
812 (unsigned long) minor(statbuf->st_dev),
813 (unsigned long) statbuf->st_ino,
814 sprintmode(statbuf->st_mode));
815 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
816 (unsigned long) statbuf->st_nlink,
817 (unsigned long) statbuf->st_uid,
818 (unsigned long) statbuf->st_gid);
819 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
820 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
821 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
822 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
823 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
824 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
827 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
828 switch (statbuf->st_mode & S_IFMT) {
829 case S_IFCHR: case S_IFBLK:
830 #ifdef HAVE_STRUCT_STAT_ST_RDEV
831 tprintf("st_rdev=makedev(%lu, %lu), ",
832 (unsigned long) major(statbuf->st_rdev),
833 (unsigned long) minor(statbuf->st_rdev));
834 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
835 tprintf("st_size=makedev(%lu, %lu), ",
836 (unsigned long) major(statbuf->st_size),
837 (unsigned long) minor(statbuf->st_size));
838 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
841 tprintf("st_size=%lu, ", statbuf->st_size);
845 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
846 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
847 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
848 #if HAVE_STRUCT_STAT_ST_FLAGS
849 tprintf(", st_flags=");
850 printflags(fileflags, statbuf->st_flags, "UF_???");
852 #if HAVE_STRUCT_STAT_ST_ACLCNT
853 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
855 #if HAVE_STRUCT_STAT_ST_LEVEL
856 tprintf(", st_level=%ld", statbuf->st_level);
858 #if HAVE_STRUCT_STAT_ST_FSTYPE
859 tprintf(", st_fstype=%.*s",
860 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
862 #if HAVE_STRUCT_STAT_ST_GEN
863 tprintf(", st_gen=%u", statbuf->st_gen);
880 if (current_personality == 1) {
881 printstatsol(tcp, addr);
885 else if (current_personality == 2) {
886 printstat_sparc64(tcp, addr);
890 #endif /* LINUXSPARC */
896 if (syserror(tcp) || !verbose(tcp)) {
897 tprintf("%#lx", addr);
900 if (umove(tcp, addr, &statbuf) < 0) {
905 realprintstat(tcp, &statbuf);
907 #endif /* !HAVE_LONG_LONG_OFF_T */
911 printstat64(tcp, addr)
915 struct stat64 statbuf;
918 if (current_personality == 1) {
919 printstatsol(tcp, addr);
923 else if (current_personality == 2) {
924 printstat_sparc64(tcp, addr);
928 #endif /* LINUXSPARC */
934 if (syserror(tcp) || !verbose(tcp)) {
935 tprintf("%#lx", addr);
938 if (umove(tcp, addr, &statbuf) < 0) {
944 #ifdef HAVE_LONG_LONG
945 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
947 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
949 (unsigned long) major(statbuf.st_dev),
950 (unsigned long) minor(statbuf.st_dev),
951 #ifdef HAVE_LONG_LONG
952 (unsigned long long) statbuf.st_ino,
954 (unsigned long) statbuf.st_ino,
956 sprintmode(statbuf.st_mode));
957 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
958 (unsigned long) statbuf.st_nlink,
959 (unsigned long) statbuf.st_uid,
960 (unsigned long) statbuf.st_gid);
961 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
962 tprintf("st_blksize=%lu, ",
963 (unsigned long) statbuf.st_blksize);
964 #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
965 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
966 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
967 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
970 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
971 switch (statbuf.st_mode & S_IFMT) {
972 case S_IFCHR: case S_IFBLK:
973 #ifdef HAVE_STRUCT_STAT_ST_RDEV
974 tprintf("st_rdev=makedev(%lu, %lu), ",
975 (unsigned long) major(statbuf.st_rdev),
976 (unsigned long) minor(statbuf.st_rdev));
977 #else /* !HAVE_STRUCT_STAT_ST_RDEV */
978 tprintf("st_size=makedev(%lu, %lu), ",
979 (unsigned long) major(statbuf.st_size),
980 (unsigned long) minor(statbuf.st_size));
981 #endif /* !HAVE_STRUCT_STAT_ST_RDEV */
984 tprintf("st_size=%llu, ", statbuf.st_size);
988 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
989 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
990 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
991 #if HAVE_STRUCT_STAT_ST_FLAGS
992 tprintf(", st_flags=");
993 printflags(fileflags, statbuf.st_flags, "UF_???");
995 #if HAVE_STRUCT_STAT_ST_ACLCNT
996 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
998 #if HAVE_STRUCT_STAT_ST_LEVEL
999 tprintf(", st_level=%ld", statbuf.st_level);
1001 #if HAVE_STRUCT_STAT_ST_FSTYPE
1002 tprintf(", st_fstype=%.*s",
1003 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1005 #if HAVE_STRUCT_STAT_ST_GEN
1006 tprintf(", st_gen=%u", statbuf.st_gen);
1013 #endif /* HAVE_STAT64 */
1015 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1017 convertoldstat(oldbuf, newbuf)
1018 const struct __old_kernel_stat *oldbuf;
1019 struct stat *newbuf;
1021 newbuf->st_dev=oldbuf->st_dev;
1022 newbuf->st_ino=oldbuf->st_ino;
1023 newbuf->st_mode=oldbuf->st_mode;
1024 newbuf->st_nlink=oldbuf->st_nlink;
1025 newbuf->st_uid=oldbuf->st_uid;
1026 newbuf->st_gid=oldbuf->st_gid;
1027 newbuf->st_rdev=oldbuf->st_rdev;
1028 newbuf->st_size=oldbuf->st_size;
1029 newbuf->st_atime=oldbuf->st_atime;
1030 newbuf->st_mtime=oldbuf->st_mtime;
1031 newbuf->st_ctime=oldbuf->st_ctime;
1032 newbuf->st_blksize=0; /* not supported in old_stat */
1033 newbuf->st_blocks=0; /* not supported in old_stat */
1038 printoldstat(tcp, addr)
1042 struct __old_kernel_stat statbuf;
1043 struct stat newstatbuf;
1046 if (current_personality == 1) {
1047 printstatsol(tcp, addr);
1050 #endif /* LINUXSPARC */
1056 if (syserror(tcp) || !verbose(tcp)) {
1057 tprintf("%#lx", addr);
1060 if (umove(tcp, addr, &statbuf) < 0) {
1065 convertoldstat(&statbuf, &newstatbuf);
1066 realprintstat(tcp, &newstatbuf);
1068 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1070 #ifndef HAVE_LONG_LONG_OFF_T
1075 if (entering(tcp)) {
1076 printpath(tcp, tcp->u_arg[0]);
1079 printstat(tcp, tcp->u_arg[1]);
1090 if (entering(tcp)) {
1091 printpath(tcp, tcp->u_arg[0]);
1094 printstat64(tcp, tcp->u_arg[1]);
1098 return printargs(tcp);
1102 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1107 if (entering(tcp)) {
1108 printpath(tcp, tcp->u_arg[0]);
1111 printoldstat(tcp, tcp->u_arg[1]);
1115 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1117 #ifndef HAVE_LONG_LONG_OFF_T
1123 tprintf("%ld, ", tcp->u_arg[0]);
1125 printstat(tcp, tcp->u_arg[1]);
1137 tprintf("%ld, ", tcp->u_arg[0]);
1139 printstat64(tcp, tcp->u_arg[1]);
1143 return printargs(tcp);
1147 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1153 tprintf("%ld, ", tcp->u_arg[0]);
1155 printoldstat(tcp, tcp->u_arg[1]);
1159 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1161 #ifndef HAVE_LONG_LONG_OFF_T
1166 if (entering(tcp)) {
1167 printpath(tcp, tcp->u_arg[0]);
1170 printstat(tcp, tcp->u_arg[1]);
1181 if (entering(tcp)) {
1182 printpath(tcp, tcp->u_arg[0]);
1185 printstat64(tcp, tcp->u_arg[1]);
1189 return printargs(tcp);
1193 #if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
1198 if (entering(tcp)) {
1199 printpath(tcp, tcp->u_arg[0]);
1202 printoldstat(tcp, tcp->u_arg[1]);
1206 #endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
1209 #if defined(SVR4) || defined(LINUXSPARC)
1215 if (entering(tcp)) {
1216 tprintf("%ld, ", tcp->u_arg[0]);
1217 printpath(tcp, tcp->u_arg[1]);
1221 if (tcp->u_arg[0] == _STAT64_VER)
1222 printstat64 (tcp, tcp->u_arg[2]);
1225 printstat(tcp, tcp->u_arg[2]);
1235 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1238 if (tcp->u_arg[0] == _STAT64_VER)
1239 printstat64 (tcp, tcp->u_arg[2]);
1242 printstat(tcp, tcp->u_arg[2]);
1251 if (entering(tcp)) {
1252 tprintf("%ld, ", tcp->u_arg[0]);
1253 printpath(tcp, tcp->u_arg[1]);
1257 if (tcp->u_arg[0] == _STAT64_VER)
1258 printstat64 (tcp, tcp->u_arg[2]);
1261 printstat(tcp, tcp->u_arg[2]);
1270 int mode = tcp->u_arg[2];
1272 if (entering(tcp)) {
1273 tprintf("%ld, ", tcp->u_arg[0]);
1274 printpath(tcp, tcp->u_arg[1]);
1275 tprintf(", %s", sprintmode(mode));
1276 switch (mode & S_IFMT) {
1277 case S_IFCHR: case S_IFBLK:
1279 tprintf(", makedev(%lu, %lu)",
1280 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1281 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1283 tprintf(", makedev(%lu, %lu)",
1284 (unsigned long) major(tcp->u_arg[3]),
1285 (unsigned long) minor(tcp->u_arg[3]));
1295 #ifdef HAVE_SYS_ACL_H
1297 #include <sys/acl.h>
1299 const struct xlat aclcmds[] = {
1301 { SETACL, "SETACL" },
1304 { GETACL, "GETACL" },
1307 { GETACLCNT, "GETACLCNT" },
1310 { ACL_GET, "ACL_GET" },
1313 { ACL_SET, "ACL_SET" },
1316 { ACL_CNT, "ACL_CNT" },
1325 if (entering(tcp)) {
1326 printpath(tcp, tcp->u_arg[0]);
1328 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1329 tprintf(", %ld", tcp->u_arg[2]);
1331 * FIXME - dump out the list of aclent_t's pointed to
1332 * by "tcp->u_arg[3]" if it's not NULL.
1335 tprintf(", %#lx", tcp->u_arg[3]);
1347 if (entering(tcp)) {
1348 tprintf("%ld, ", tcp->u_arg[0]);
1349 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1350 tprintf(", %ld", tcp->u_arg[2]);
1352 * FIXME - dump out the list of aclent_t's pointed to
1353 * by "tcp->u_arg[3]" if it's not NULL.
1356 tprintf(", %#lx", tcp->u_arg[3]);
1364 const struct xlat aclipc[] = {
1366 { IPC_SHM, "IPC_SHM" },
1369 { IPC_SEM, "IPC_SEM" },
1372 { IPC_MSG, "IPC_MSG" },
1382 if (entering(tcp)) {
1383 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1384 tprintf(", %#lx, ", tcp->u_arg[1]);
1385 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1386 tprintf(", %ld", tcp->u_arg[3]);
1388 * FIXME - dump out the list of aclent_t's pointed to
1389 * by "tcp->u_arg[4]" if it's not NULL.
1392 tprintf(", %#lx", tcp->u_arg[4]);
1401 #endif /* HAVE_SYS_ACL_H */
1403 #endif /* SVR4 || LINUXSPARC */
1407 static const struct xlat fsmagic[] = {
1408 { 0x73757245, "CODA_SUPER_MAGIC" },
1409 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1410 { 0x1373, "DEVFS_SUPER_MAGIC" },
1411 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1412 { 0x414A53, "EFS_SUPER_MAGIC" },
1413 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1414 { 0xef53, "EXT2_SUPER_MAGIC" },
1415 { 0x137d, "EXT_SUPER_MAGIC" },
1416 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1417 { 0x9660, "ISOFS_SUPER_MAGIC" },
1418 { 0x137f, "MINIX_SUPER_MAGIC" },
1419 { 0x138f, "MINIX_SUPER_MAGIC2" },
1420 { 0x2468, "MINIX2_SUPER_MAGIC" },
1421 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1422 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1423 { 0x564c, "NCP_SUPER_MAGIC" },
1424 { 0x6969, "NFS_SUPER_MAGIC" },
1425 { 0x9fa0, "PROC_SUPER_MAGIC" },
1426 { 0x002f, "QNX4_SUPER_MAGIC" },
1427 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1428 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1429 { 0x517b, "SMB_SUPER_MAGIC" },
1430 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1431 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1432 { 0x00011954, "UFS_MAGIC" },
1433 { 0x54190100, "UFS_CIGAM" },
1434 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1435 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1436 { 0x62656572, "SYSFS_MAGIC" },
1448 static char buf[32];
1452 s = xlookup(fsmagic, magic);
1454 sprintf(buf, "\"%s\"", s);
1458 sprintf(buf, "%#x", magic);
1463 printstatfs(tcp, addr)
1467 struct statfs statbuf;
1469 if (syserror(tcp) || !verbose(tcp)) {
1470 tprintf("%#lx", addr);
1473 if (umove(tcp, addr, &statbuf) < 0) {
1479 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1480 sprintfstype(statbuf.f_type),
1481 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1482 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1483 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1484 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1487 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1488 sprintfstype(statbuf.f_type),
1489 (unsigned long)statbuf.f_bsize,
1490 (unsigned long)statbuf.f_blocks,
1491 (unsigned long)statbuf.f_bfree);
1492 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1493 (unsigned long)statbuf.f_bavail,
1494 (unsigned long)statbuf.f_files,
1495 (unsigned long)statbuf.f_ffree,
1496 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1498 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1501 #ifdef _STATFS_F_FRSIZE
1502 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1511 if (entering(tcp)) {
1512 printpath(tcp, tcp->u_arg[0]);
1515 printstatfs(tcp, tcp->u_arg[1]);
1524 if (entering(tcp)) {
1525 tprintf("%lu, ", tcp->u_arg[0]);
1527 printstatfs(tcp, tcp->u_arg[1]);
1534 printstatfs64(tcp, addr)
1538 struct statfs64 statbuf;
1540 if (syserror(tcp) || !verbose(tcp)) {
1541 tprintf("%#lx", addr);
1544 if (umove(tcp, addr, &statbuf) < 0) {
1550 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1551 sprintfstype(statbuf.f_type),
1552 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1553 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1554 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1555 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1558 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1559 sprintfstype(statbuf.f_type),
1560 (unsigned long)statbuf.f_bsize,
1561 (unsigned long)statbuf.f_blocks,
1562 (unsigned long)statbuf.f_bfree);
1563 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1564 (unsigned long)statbuf.f_bavail,
1565 (unsigned long)statbuf.f_files,
1566 (unsigned long)statbuf.f_ffree,
1567 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1568 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1570 #ifdef _STATFS_F_FRSIZE
1571 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1580 if (entering(tcp)) {
1581 printpath(tcp, tcp->u_arg[0]);
1582 tprintf(", %lu, ", tcp->u_arg[1]);
1584 if (tcp->u_arg[1] == sizeof (struct statfs64))
1585 printstatfs64(tcp, tcp->u_arg[2]);
1596 if (entering(tcp)) {
1597 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1599 if (tcp->u_arg[1] == sizeof (struct statfs64))
1600 printstatfs64(tcp, tcp->u_arg[2]);
1608 #if defined(LINUX) && defined(__alpha)
1614 if (entering(tcp)) {
1615 printpath(tcp, tcp->u_arg[0]);
1618 printstatfs(tcp, tcp->u_arg[1]);
1619 tprintf(", %lu", tcp->u_arg[2]);
1628 if (entering(tcp)) {
1629 tprintf("%lu, ", tcp->u_arg[0]);
1631 printstatfs(tcp, tcp->u_arg[1]);
1632 tprintf(", %lu", tcp->u_arg[2]);
1636 #endif /* LINUX && __alpha */
1646 struct ustat statbuf;
1648 if (entering(tcp)) {
1649 tprintf("makedev(%lu, %lu), ",
1650 (long) major(tcp->u_arg[0]),
1651 (long) minor(tcp->u_arg[0]));
1654 if (syserror(tcp) || !verbose(tcp))
1655 tprintf("%#lx", tcp->u_arg[1]);
1656 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1659 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1660 statbuf.f_tfree, statbuf.f_tinode);
1661 tprintf("f_fname=\"%.*s\", ",
1662 (int) sizeof(statbuf.f_fname),
1664 tprintf("f_fpack=\"%.*s\"}",
1665 (int) sizeof(statbuf.f_fpack),
1678 if (entering(tcp)) {
1679 printpath(tcp, tcp->u_arg[0]);
1681 printpath(tcp, tcp->u_arg[1]);
1692 if (entering(tcp)) {
1693 printpath(tcp, tcp->u_arg[0]);
1702 if (entering(tcp)) {
1703 printpath(tcp, tcp->u_arg[0]);
1704 tprintf(", %#lo", tcp->u_arg[1]);
1713 if (entering(tcp)) {
1714 printpath(tcp, tcp->u_arg[0]);
1723 if (entering(tcp)) {
1724 tprintf("%ld", tcp->u_arg[0]);
1733 if (entering(tcp)) {
1734 printpath(tcp, tcp->u_arg[0]);
1743 if (entering(tcp)) {
1744 tprintf("%ld", tcp->u_arg[0]);
1753 if (entering(tcp)) {
1754 printpath(tcp, tcp->u_arg[0]);
1756 printpath(tcp, tcp->u_arg[1]);
1765 if (entering(tcp)) {
1766 printpath(tcp, tcp->u_arg[0]);
1775 if (entering(tcp)) {
1776 printpath(tcp, tcp->u_arg[0]);
1778 printpath(tcp, tcp->u_arg[1]);
1787 if (entering(tcp)) {
1788 printpath(tcp, tcp->u_arg[0]);
1792 tprintf("%#lx", tcp->u_arg[1]);
1794 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1795 tprintf(", %lu", tcp->u_arg[2]);
1804 if (entering(tcp)) {
1805 printpath(tcp, tcp->u_arg[0]);
1807 printpath(tcp, tcp->u_arg[1]);
1816 if (entering(tcp)) {
1817 printpath(tcp, tcp->u_arg[0]);
1818 printuid(", ", tcp->u_arg[1]);
1819 printuid(", ", tcp->u_arg[2]);
1828 if (entering(tcp)) {
1829 tprintf("%ld", tcp->u_arg[0]);
1830 printuid(", ", tcp->u_arg[1]);
1831 printuid(", ", tcp->u_arg[2]);
1840 if (entering(tcp)) {
1841 printpath(tcp, tcp->u_arg[0]);
1842 tprintf(", %#lo", tcp->u_arg[1]);
1851 if (entering(tcp)) {
1852 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1862 if (entering(tcp)) {
1863 printpath(tcp, tcp->u_arg[0]);
1865 printtv32(tcp, tcp->u_arg[1]);
1875 if (entering(tcp)) {
1876 printpath(tcp, tcp->u_arg[0]);
1878 printtv(tcp, tcp->u_arg[1]);
1889 if (entering(tcp)) {
1890 printpath(tcp, tcp->u_arg[0]);
1894 else if (!verbose(tcp))
1895 tprintf("%#lx", tcp->u_arg[1]);
1896 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1900 tprintf("[%s,", sprinttime(ut[0]));
1901 tprintf(" %s]", sprinttime(ut[1]));
1911 int mode = tcp->u_arg[1];
1913 if (entering(tcp)) {
1914 printpath(tcp, tcp->u_arg[0]);
1915 tprintf(", %s", sprintmode(mode));
1916 switch (mode & S_IFMT) {
1917 case S_IFCHR: case S_IFBLK:
1919 if (current_personality == 1)
1920 tprintf(", makedev(%lu, %lu)",
1921 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1922 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1925 tprintf(", makedev(%lu, %lu)",
1926 (unsigned long) major(tcp->u_arg[2]),
1927 (unsigned long) minor(tcp->u_arg[2]));
1940 if (entering(tcp)) {
1941 printpath(tcp, tcp->u_arg[0]);
1942 tprintf(", %#lo", tcp->u_arg[1]);
1951 if (entering(tcp)) {
1952 tprintf("%ld", tcp->u_arg[0]);
1966 if (!verbose(tcp)) {
1967 tprintf("%#lx", addr);
1970 if (umove(tcp, addr, &d) < 0) {
1974 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1976 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1984 if (entering(tcp)) {
1985 tprintf("%lu, ", tcp->u_arg[0]);
1987 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1988 tprintf("%#lx", tcp->u_arg[1]);
1990 printdir(tcp, tcp->u_arg[1]);
1991 /* Not much point in printing this out, it is always 1. */
1992 if (tcp->u_arg[2] != 1)
1993 tprintf(", %lu", tcp->u_arg[2]);
2000 #if defined FREEBSD || defined LINUX
2001 const struct xlat direnttypes[] = {
2002 { DT_UNKNOWN, "DT_UNKNOWN" },
2003 { DT_FIFO, "DT_FIFO" },
2004 { DT_CHR, "DT_CHR" },
2005 { DT_DIR, "DT_DIR" },
2006 { DT_BLK, "DT_BLK" },
2007 { DT_REG, "DT_REG" },
2008 { DT_LNK, "DT_LNK" },
2009 { DT_SOCK, "DT_SOCK" },
2010 { DT_WHT, "DT_WHT" },
2020 int i, len, dents = 0;
2023 if (entering(tcp)) {
2024 tprintf("%lu, ", tcp->u_arg[0]);
2027 if (syserror(tcp) || !verbose(tcp)) {
2028 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2032 if ((buf = malloc(len)) == NULL) {
2033 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2034 fprintf(stderr, "out of memory\n");
2037 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2038 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2044 for (i = 0; i < len;) {
2045 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2048 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2049 i ? " " : "", d->d_ino, d->d_off);
2050 tprintf("d_reclen=%u, d_name=\"%s\"}",
2051 d->d_reclen, d->d_name);
2056 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2058 (unsigned long) d->d_ino,
2059 (unsigned long) d->d_off);
2060 tprintf("d_reclen=%u, d_name=\"%s\"}",
2061 d->d_reclen, d->d_name);
2066 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2067 i ? " " : "", d->d_off, d->d_fileno,
2069 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2070 d->d_namlen, d->d_namlen, d->d_name);
2075 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2076 i ? " " : "", d->d_fileno, d->d_reclen);
2077 printxval(direnttypes, d->d_type, "DT_???");
2078 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2079 d->d_namlen, d->d_namlen, d->d_name);
2081 #endif /* FREEBSD */
2083 tprintf("/* d_reclen == 0, problem here */");
2092 tprintf("/* %u entries */", dents);
2093 tprintf(", %lu", tcp->u_arg[2]);
2099 #if _LFS64_LARGEFILE
2104 int i, len, dents = 0;
2107 if (entering(tcp)) {
2108 tprintf("%lu, ", tcp->u_arg[0]);
2111 if (syserror(tcp) || !verbose(tcp)) {
2112 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2116 if ((buf = malloc(len)) == NULL) {
2117 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2118 fprintf(stderr, "out of memory\n");
2121 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2122 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2128 for (i = 0; i < len;) {
2129 struct dirent64 *d = (struct dirent64 *) &buf[i];
2130 #if defined(LINUX) || defined(SVR4)
2132 tprintf("%s{d_ino=%llu, d_off=%llu, ",
2138 printxval(direnttypes, d->d_type, "DT_???");
2141 tprintf("d_reclen=%u, d_name=\"%s\"}",
2142 d->d_reclen, d->d_name);
2144 #endif /* LINUX || SVR4 */
2147 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2148 i ? " " : "", d->d_off, d->d_fileno,
2150 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2151 d->d_namlen, d->d_namlen, d->d_name);
2160 tprintf("/* %u entries */", dents);
2161 tprintf(", %lu", tcp->u_arg[2]);
2169 sys_getdirentries(tcp)
2172 int i, len, dents = 0;
2176 if (entering(tcp)) {
2177 tprintf("%lu, ", tcp->u_arg[0]);
2180 if (syserror(tcp) || !verbose(tcp)) {
2181 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2185 if ((buf = malloc(len)) == NULL) {
2186 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2187 fprintf(stderr, "out of memory\n");
2190 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2191 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2197 for (i = 0; i < len;) {
2198 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2200 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2201 i ? " " : "", d->d_fileno, d->d_reclen);
2202 printxval(direnttypes, d->d_type, "DT_???");
2203 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2204 d->d_namlen, d->d_namlen, d->d_name);
2212 tprintf("/* %u entries */", dents);
2214 tprintf(", %lu", tcp->u_arg[2]);
2215 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2216 tprintf(", %#lx", tcp->u_arg[3]);
2218 tprintf(", [%lu]", basep);
2230 tprintf("%#lx", tcp->u_arg[0]);
2232 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2233 tprintf(", %lu", tcp->u_arg[1]);
2246 tprintf("%#lx", tcp->u_arg[0]);
2248 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2249 tprintf(", %lu", tcp->u_arg[1]);
2255 #ifdef HAVE_SYS_ASYNCH_H
2261 struct aio_result_t res;
2263 if (entering(tcp)) {
2264 tprintf("%lu, ", tcp->u_arg[0]);
2267 tprintf("%#lx", tcp->u_arg[1]);
2269 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2270 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2271 printxval(whence, tcp->u_arg[4], "L_???");
2272 if (syserror(tcp) || tcp->u_arg[5] == 0
2273 || umove(tcp, tcp->u_arg[5], &res) < 0)
2274 tprintf(", %#lx", tcp->u_arg[5]);
2276 tprintf(", {aio_return %d aio_errno %d}",
2277 res.aio_return, res.aio_errno);
2286 struct aio_result_t res;
2288 if (entering(tcp)) {
2289 tprintf("%lu, ", tcp->u_arg[0]);
2290 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2291 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2292 printxval(whence, tcp->u_arg[4], "L_???");
2295 if (tcp->u_arg[5] == 0)
2297 else if (syserror(tcp)
2298 || umove(tcp, tcp->u_arg[5], &res) < 0)
2299 tprintf(", %#lx", tcp->u_arg[5]);
2301 tprintf(", {aio_return %d aio_errno %d}",
2302 res.aio_return, res.aio_errno);
2312 printtv(tcp, tcp->u_arg[0]);
2320 struct aio_result_t res;
2323 if (tcp->u_arg[0] == 0)
2325 else if (syserror(tcp)
2326 || umove(tcp, tcp->u_arg[0], &res) < 0)
2327 tprintf("%#lx", tcp->u_arg[0]);
2329 tprintf("{aio_return %d aio_errno %d}",
2330 res.aio_return, res.aio_errno);
2335 #endif /* HAVE_SYS_ASYNCH_H */
2337 const struct xlat xattrflags[] = {
2339 { XATTR_CREATE, "XATTR_CREATE" },
2340 { XATTR_REPLACE, "XATTR_REPLACE" },
2346 print_xattr_val(tcp, failed, arg, insize, size)
2350 unsigned long insize, size;
2353 unsigned long capacity = 4 * size + 1;
2354 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
2355 if (buf == NULL || /* probably a bogus size argument */
2356 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2360 unsigned char *out = buf;
2361 unsigned char *in = &buf[3 * size];
2363 for (i = 0; i < size; ++i)
2367 #define tohex(n) "0123456789abcdef"[n]
2370 *out++ = tohex(in[i] / 16);
2371 *out++ = tohex(in[i] % 16);
2373 /* Don't print terminating NUL if there is one. */
2374 if (in[i - 1] == '\0')
2377 tprintf(", \"%s\", %ld", buf, insize);
2382 tprintf(", 0x%lx, %ld", arg, insize);
2389 if (entering(tcp)) {
2390 printpath(tcp, tcp->u_arg[0]);
2392 printstr(tcp, tcp->u_arg[1], -1);
2393 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2395 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2404 if (entering(tcp)) {
2405 tprintf("%ld, ", tcp->u_arg[0]);
2406 printstr(tcp, tcp->u_arg[1], -1);
2407 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2409 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2418 if (entering(tcp)) {
2419 printpath(tcp, tcp->u_arg[0]);
2421 printstr(tcp, tcp->u_arg[1], -1);
2423 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2433 if (entering(tcp)) {
2434 tprintf("%ld, ", tcp->u_arg[0]);
2435 printstr(tcp, tcp->u_arg[1], -1);
2437 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2447 if (entering(tcp)) {
2448 printpath(tcp, tcp->u_arg[0]);
2450 /* XXX Print value in format */
2451 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2460 if (entering(tcp)) {
2461 tprintf("%ld", tcp->u_arg[0]);
2463 /* XXX Print value in format */
2464 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2470 sys_removexattr(tcp)
2473 if (entering(tcp)) {
2474 printpath(tcp, tcp->u_arg[0]);
2476 printstr(tcp, tcp->u_arg[1], -1);
2482 sys_fremovexattr(tcp)
2485 if (entering(tcp)) {
2486 tprintf("%ld, ", tcp->u_arg[0]);
2487 printstr(tcp, tcp->u_arg[1], -1);
2493 static const struct xlat advise[] = {
2494 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2495 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2496 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2497 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2498 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2499 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2509 if (entering(tcp)) {
2510 tprintf("%ld, %lld, %ld, ",
2512 # if defined IA64 || defined X86_64 || defined ALPHA
2513 (long long int) tcp->u_arg[1], tcp->u_arg[2]);
2514 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2516 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]);
2517 printxval(advise, tcp->u_arg[4], "POSIX_FADV_???");
2526 sys_fadvise64_64(tcp)
2529 if (entering(tcp)) {
2530 tprintf("%ld, %lld, %lld, ",
2532 # if defined IA64 || defined X86_64 || defined ALPHA
2533 (long long int) tcp->u_arg[1], (long long int) tcp->u_arg[2]);
2534 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2536 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]),
2537 LONG_LONG(tcp->u_arg[3], tcp->u_arg[4]));
2538 printxval(advise, tcp->u_arg[5], "POSIX_FADV_???");