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];
69 # define stat kernel_stat
70 # include <asm/stat.h>
82 # define dev_t __kernel_dev_t
83 # define ino_t __kernel_ino_t
84 # define mode_t __kernel_mode_t
85 # define nlink_t __kernel_nlink_t
86 # define uid_t __kernel_uid_t
87 # define gid_t __kernel_gid_t
88 # define off_t __kernel_off_t
89 # define loff_t __kernel_loff_t
91 # include <asm/stat.h>
104 # define mode_t mode_t
105 # define nlink_t nlink_t
109 # define loff_t loff_t
111 # ifdef HPPA /* asm-parisc/stat.h defines stat64 */
114 # define stat libc_stat
115 # define stat64 libc_stat64
116 # include <sys/stat.h>
120 # define stat64 hpux_stat64
123 # include <sys/stat.h>
129 # include <sys/cred.h>
132 #ifdef HAVE_SYS_VFS_H
136 #ifdef HAVE_LINUX_XATTR_H
137 #include <linux/xattr.h>
139 #define XATTR_CREATE 1
140 #define XATTR_REPLACE 2
144 #include <sys/param.h>
145 #include <sys/mount.h>
146 #include <sys/stat.h>
149 #if HAVE_LONG_LONG_OFF_T
151 * Ugly hacks for systems that have typedef long long off_t
155 #define HAVE_STAT64 1 /* Ugly hack */
157 #define sys_stat64 sys_stat
158 #define sys_fstat64 sys_fstat
159 #define sys_lstat64 sys_lstat
160 #define sys_lseek64 sys_lseek
161 #define sys_truncate64 sys_truncate
162 #define sys_ftruncate64 sys_ftruncate
165 #ifdef MAJOR_IN_SYSMACROS
166 #include <sys/sysmacros.h>
169 #ifdef MAJOR_IN_MKDEV
170 #include <sys/mkdev.h>
173 #ifdef HAVE_SYS_ASYNCH_H
174 #include <sys/asynch.h>
182 * This is a really dirty trick but it should always work. Traditional
183 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
184 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
186 struct xlat openmodes[] = {
187 { O_RDWR+1, "O_RDWR" },
188 { O_RDONLY+1, "O_RDONLY" },
189 { O_WRONLY+1, "O_WRONLY" },
190 { O_NONBLOCK, "O_NONBLOCK" },
191 { O_APPEND, "O_APPEND" },
192 { O_CREAT, "O_CREAT" },
193 { O_TRUNC, "O_TRUNC" },
194 { O_EXCL, "O_EXCL" },
195 { O_NOCTTY, "O_NOCTTY" },
197 { O_SYNC, "O_SYNC" },
200 { O_ASYNC, "O_ASYNC" },
203 { O_DSYNC, "O_DSYNC" },
206 { O_RSYNC, "O_RSYNC" },
209 { O_NDELAY, "O_NDELAY" },
212 { O_PRIV, "O_PRIV" },
215 { O_DIRECT, "O_DIRECT" },
218 { O_LARGEFILE, "O_LARGEFILE" },
221 { O_DIRECTORY, "O_DIRECTORY" },
224 { O_NOFOLLOW, "O_NOFOLLOW" },
228 { FNDELAY, "FNDELAY" },
231 { FAPPEND, "FAPPEND" },
237 { FDEFER, "FDEFER" },
240 { FASYNC, "FASYNC" },
243 { FSHLOCK, "FSHLOCK" },
246 { FEXLOCK, "FEXLOCK" },
249 { FCREAT, "FCREAT" },
252 { FTRUNC, "FTRUNC" },
264 { FNOCTTY, "FNOCTTY" },
267 { O_SHLOCK, "O_SHLOCK" },
270 { O_EXLOCK, "O_EXLOCK" },
280 printpath(tcp, tcp->u_arg[0]);
283 printflags(openmodes, tcp->u_arg[1] + 1);
284 if (tcp->u_arg[1] & O_CREAT) {
286 tprintf(", %#lo", tcp->u_arg[2]);
293 struct xlat openmodessol[] = {
297 { 0x80, "O_NONBLOCK" },
299 { 0x100, "O_CREAT" },
300 { 0x200, "O_TRUNC" },
302 { 0x800, "O_NOCTTY" },
305 { 0x8000, "O_RSYNC" },
307 { 0x1000, "O_PRIV" },
316 printpath(tcp, tcp->u_arg[0]);
319 printflags(openmodessol, tcp->u_arg[1] + 1);
320 if (tcp->u_arg[1] & 0x100) {
322 tprintf(", %#lo", tcp->u_arg[2]);
335 printpath(tcp, tcp->u_arg[0]);
336 tprintf(", %#lo", tcp->u_arg[1]);
341 static struct xlat access_flags[] = {
347 { EFF_ONLY_OK, "EFF_ONLY_OK" },
360 printpath(tcp, tcp->u_arg[0]);
362 printflags(access_flags, tcp->u_arg[1]);
372 tprintf("%#lo", tcp->u_arg[0]);
377 static struct xlat whence[] = {
378 { SEEK_SET, "SEEK_SET" },
379 { SEEK_CUR, "SEEK_CUR" },
380 { SEEK_END, "SEEK_END" },
384 #ifndef HAVE_LONG_LONG_OFF_T
393 tprintf("%ld, ", tcp->u_arg[0]);
394 offset = tcp->u_arg[1];
395 _whence = tcp->u_arg[2];
396 if (_whence == SEEK_SET)
397 tprintf("%lu, ", offset);
399 tprintf("%ld, ", offset);
400 printxval(whence, _whence, "SEEK_???");
402 return RVAL_UDECIMAL;
412 if (tcp->u_arg[4] == SEEK_SET)
413 tprintf("%ld, %llu, ", tcp->u_arg[0],
414 (((long long int) tcp->u_arg[1]) << 32
415 | (unsigned long long) (unsigned) tcp->u_arg[2]));
417 tprintf("%ld, %lld, ", tcp->u_arg[0],
418 (((long long int) tcp->u_arg[1]) << 32
419 | (unsigned long long) (unsigned) tcp->u_arg[2]));
423 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
424 tprintf("%#lx, ", tcp->u_arg[3]);
426 tprintf("[%llu], ", off);
427 printxval(whence, tcp->u_arg[4], "SEEK_???");
437 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
438 # if defined IA64 || defined X86_64 || defined ALPHA
439 (long long int) tcp->u_arg[1], tcp->u_arg[2]
441 (((long long int) tcp->u_arg[1]) << 32
442 | ((unsigned long *) tcp->u_arg)[2]),
451 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
458 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
459 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
460 if (tcp->u_arg[3] == SEEK_SET)
461 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
463 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
464 printxval(whence, tcp->u_arg[3], "SEEK_???");
466 return RVAL_LUDECIMAL;
470 #ifndef HAVE_LONG_LONG_OFF_T
476 printpath(tcp, tcp->u_arg[0]);
477 tprintf(", %lu", tcp->u_arg[1]);
483 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
490 printpath(tcp, tcp->u_arg[0]);
491 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
497 #ifndef HAVE_LONG_LONG_OFF_T
503 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
509 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
516 tprintf("%ld, %llu", tcp->u_arg[0],
517 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
525 static struct xlat modetypes[] = {
526 { S_IFREG, "S_IFREG" },
527 { S_IFSOCK, "S_IFSOCK" },
528 { S_IFIFO, "S_IFIFO" },
529 { S_IFLNK, "S_IFLNK" },
530 { S_IFDIR, "S_IFDIR" },
531 { S_IFBLK, "S_IFBLK" },
532 { S_IFCHR, "S_IFCHR" },
543 if ((mode & S_IFMT) == 0)
545 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
546 sprintf(buf, "%#o", mode);
549 sprintf(buf, "%s%s%s%s", s,
550 (mode & S_ISUID) ? "|S_ISUID" : "",
551 (mode & S_ISGID) ? "|S_ISGID" : "",
552 (mode & S_ISVTX) ? "|S_ISVTX" : "");
553 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
555 sprintf(buf + strlen(buf), "|%#o", mode);
556 s = (*buf == '|') ? buf + 1 : buf;
572 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
573 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
574 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
586 int st_pad1[3]; /* network id */
595 int st_pad3; /* st_size, off_t expansion */
596 timestruct_t st_atime;
597 timestruct_t st_mtime;
598 timestruct_t st_ctime;
602 int st_pad4[8]; /* expansion area */
606 printstatsol(tcp, addr)
610 struct solstat statbuf;
616 if (syserror(tcp) || !verbose(tcp)) {
617 tprintf("%#lx", addr);
620 if (umove(tcp, addr, &statbuf) < 0) {
625 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
626 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
627 (unsigned long) (statbuf.st_dev & 0x3ffff),
628 (unsigned long) statbuf.st_ino,
629 sprintmode(statbuf.st_mode));
630 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
631 (unsigned long) statbuf.st_nlink,
632 (unsigned long) statbuf.st_uid,
633 (unsigned long) statbuf.st_gid);
634 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
635 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
638 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
639 switch (statbuf.st_mode & S_IFMT) {
640 case S_IFCHR: case S_IFBLK:
641 tprintf("st_rdev=makedev(%lu, %lu), ",
642 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
643 (unsigned long) (statbuf.st_rdev & 0x3ffff));
646 tprintf("st_size=%u, ", statbuf.st_size);
650 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
651 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
652 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
657 #endif /* LINUXSPARC */
659 struct xlat fileflags[] = {
661 { UF_NODUMP, "UF_NODUMP" },
662 { UF_IMMUTABLE, "UF_IMMUTABLE" },
663 { UF_APPEND, "UF_APPEND" },
664 { UF_OPAQUE, "UF_OPAQUE" },
665 { UF_NOUNLINK, "UF_NOUNLINK" },
666 { SF_ARCHIVED, "SF_ARCHIVED" },
667 { SF_IMMUTABLE, "SF_IMMUTABLE" },
668 { SF_APPEND, "SF_APPEND" },
669 { SF_NOUNLINK, "SF_NOUNLINK" },
672 { _S_ISMLD, "_S_ISMLD" },
675 { _S_ISMOUNTED, "_S_ISMOUNTED" },
687 printpath(tcp, tcp->u_arg[0]);
690 printflags(fileflags, tcp->u_arg[1]);
702 tprintf("%ld, ", tcp->u_arg[0]);
704 printflags(fileflags, tcp->u_arg[1]);
712 #ifndef HAVE_LONG_LONG_OFF_T
714 realprintstat(tcp, statbuf)
716 struct stat *statbuf;
719 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
720 (unsigned long) major(statbuf->st_dev),
721 (unsigned long) minor(statbuf->st_dev),
722 (unsigned long) statbuf->st_ino,
723 sprintmode(statbuf->st_mode));
724 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
725 (unsigned long) statbuf->st_nlink,
726 (unsigned long) statbuf->st_uid,
727 (unsigned long) statbuf->st_gid);
728 #ifdef HAVE_ST_BLKSIZE
729 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
730 #endif /* HAVE_ST_BLKSIZE */
731 #ifdef HAVE_ST_BLOCKS
732 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
733 #endif /* HAVE_ST_BLOCKS */
736 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
737 switch (statbuf->st_mode & S_IFMT) {
738 case S_IFCHR: case S_IFBLK:
740 tprintf("st_rdev=makedev(%lu, %lu), ",
741 (unsigned long) major(statbuf->st_rdev),
742 (unsigned long) minor(statbuf->st_rdev));
743 #else /* !HAVE_ST_RDEV */
744 tprintf("st_size=makedev(%lu, %lu), ",
745 (unsigned long) major(statbuf->st_size),
746 (unsigned long) minor(statbuf->st_size));
747 #endif /* !HAVE_ST_RDEV */
750 tprintf("st_size=%lu, ", statbuf->st_size);
754 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
755 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
756 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
758 tprintf(", st_flags=");
759 if (statbuf->st_flags) {
760 printflags(fileflags, statbuf->st_flags);
765 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
768 tprintf(", st_level=%ld", statbuf->st_level);
771 tprintf(", st_fstype=%.*s",
772 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
775 tprintf(", st_gen=%u", statbuf->st_gen);
792 if (current_personality == 1) {
793 printstatsol(tcp, addr);
796 #endif /* LINUXSPARC */
802 if (syserror(tcp) || !verbose(tcp)) {
803 tprintf("%#lx", addr);
806 if (umove(tcp, addr, &statbuf) < 0) {
811 realprintstat(tcp, &statbuf);
813 #endif /* !HAVE_LONG_LONG_OFF_T */
817 printstat64(tcp, addr)
821 struct stat64 statbuf;
824 if (current_personality == 1) {
825 printstatsol(tcp, addr);
828 #endif /* LINUXSPARC */
834 if (syserror(tcp) || !verbose(tcp)) {
835 tprintf("%#lx", addr);
838 if (umove(tcp, addr, &statbuf) < 0) {
844 #ifdef HAVE_LONG_LONG
845 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
847 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
849 (unsigned long) major(statbuf.st_dev),
850 (unsigned long) minor(statbuf.st_dev),
851 #ifdef HAVE_LONG_LONG
852 (unsigned long long) statbuf.st_ino,
854 (unsigned long) statbuf.st_ino,
856 sprintmode(statbuf.st_mode));
857 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
858 (unsigned long) statbuf.st_nlink,
859 (unsigned long) statbuf.st_uid,
860 (unsigned long) statbuf.st_gid);
861 #ifdef HAVE_ST_BLKSIZE
862 tprintf("st_blksize=%lu, ",
863 (unsigned long) statbuf.st_blksize);
864 #endif /* HAVE_ST_BLKSIZE */
865 #ifdef HAVE_ST_BLOCKS
866 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
867 #endif /* HAVE_ST_BLOCKS */
870 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
871 switch (statbuf.st_mode & S_IFMT) {
872 case S_IFCHR: case S_IFBLK:
874 tprintf("st_rdev=makedev(%lu, %lu), ",
875 (unsigned long) major(statbuf.st_rdev),
876 (unsigned long) minor(statbuf.st_rdev));
877 #else /* !HAVE_ST_RDEV */
878 tprintf("st_size=makedev(%lu, %lu), ",
879 (unsigned long) major(statbuf.st_size),
880 (unsigned long) minor(statbuf.st_size));
881 #endif /* !HAVE_ST_RDEV */
884 tprintf("st_size=%llu, ", statbuf.st_size);
888 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
889 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
890 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
892 tprintf(", st_flags=");
893 if (statbuf.st_flags) {
894 printflags(fileflags, statbuf.st_flags);
899 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
902 tprintf(", st_level=%ld", statbuf.st_level);
905 tprintf(", st_fstype=%.*s",
906 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
909 tprintf(", st_gen=%u", statbuf.st_gen);
916 #endif /* HAVE_STAT64 */
918 #if defined(LINUX) && !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
919 && !defined(S390) && !defined(S390X)
921 convertoldstat(oldbuf, newbuf)
922 const struct __old_kernel_stat *oldbuf;
925 newbuf->st_dev=oldbuf->st_dev;
926 newbuf->st_ino=oldbuf->st_ino;
927 newbuf->st_mode=oldbuf->st_mode;
928 newbuf->st_nlink=oldbuf->st_nlink;
929 newbuf->st_uid=oldbuf->st_uid;
930 newbuf->st_gid=oldbuf->st_gid;
931 newbuf->st_rdev=oldbuf->st_rdev;
932 newbuf->st_size=oldbuf->st_size;
933 newbuf->st_atime=oldbuf->st_atime;
934 newbuf->st_mtime=oldbuf->st_mtime;
935 newbuf->st_ctime=oldbuf->st_ctime;
936 newbuf->st_blksize=0; /* not supported in old_stat */
937 newbuf->st_blocks=0; /* not supported in old_stat */
942 printoldstat(tcp, addr)
946 struct __old_kernel_stat statbuf;
947 struct stat newstatbuf;
950 if (current_personality == 1) {
951 printstatsol(tcp, addr);
954 #endif /* LINUXSPARC */
960 if (syserror(tcp) || !verbose(tcp)) {
961 tprintf("%#lx", addr);
964 if (umove(tcp, addr, &statbuf) < 0) {
969 convertoldstat(&statbuf, &newstatbuf);
970 realprintstat(tcp, &newstatbuf);
972 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
974 #ifndef HAVE_LONG_LONG_OFF_T
980 printpath(tcp, tcp->u_arg[0]);
983 printstat(tcp, tcp->u_arg[1]);
995 printpath(tcp, tcp->u_arg[0]);
998 printstat64(tcp, tcp->u_arg[1]);
1002 return printargs(tcp);
1007 # if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
1008 && !defined(S390) && !defined(S390X)
1013 if (entering(tcp)) {
1014 printpath(tcp, tcp->u_arg[0]);
1017 printoldstat(tcp, tcp->u_arg[1]);
1021 # endif /* !IA64 && !HPPA*/
1024 #ifndef HAVE_LONG_LONG_OFF_T
1030 tprintf("%ld, ", tcp->u_arg[0]);
1032 printstat(tcp, tcp->u_arg[1]);
1044 tprintf("%ld, ", tcp->u_arg[0]);
1046 printstat64(tcp, tcp->u_arg[1]);
1050 return printargs(tcp);
1055 # if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
1056 && !defined(S390) && !defined(S390X)
1062 tprintf("%ld, ", tcp->u_arg[0]);
1064 printoldstat(tcp, tcp->u_arg[1]);
1068 # endif /* !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1071 #ifndef HAVE_LONG_LONG_OFF_T
1076 if (entering(tcp)) {
1077 printpath(tcp, tcp->u_arg[0]);
1080 printstat(tcp, tcp->u_arg[1]);
1091 if (entering(tcp)) {
1092 printpath(tcp, tcp->u_arg[0]);
1095 printstat64(tcp, tcp->u_arg[1]);
1099 return printargs(tcp);
1104 # if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
1105 && !defined(S390) && !defined(S390X)
1110 if (entering(tcp)) {
1111 printpath(tcp, tcp->u_arg[0]);
1114 printoldstat(tcp, tcp->u_arg[1]);
1118 # endif /* !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1122 #if defined(SVR4) || defined(LINUXSPARC)
1128 if (entering(tcp)) {
1129 tprintf("%ld, ", tcp->u_arg[0]);
1130 printpath(tcp, tcp->u_arg[1]);
1134 if (tcp->u_arg[0] == _STAT64_VER)
1135 printstat64 (tcp, tcp->u_arg[2]);
1138 printstat(tcp, tcp->u_arg[2]);
1148 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1151 if (tcp->u_arg[0] == _STAT64_VER)
1152 printstat64 (tcp, tcp->u_arg[2]);
1155 printstat(tcp, tcp->u_arg[2]);
1164 if (entering(tcp)) {
1165 tprintf("%ld, ", tcp->u_arg[0]);
1166 printpath(tcp, tcp->u_arg[1]);
1170 if (tcp->u_arg[0] == _STAT64_VER)
1171 printstat64 (tcp, tcp->u_arg[2]);
1174 printstat(tcp, tcp->u_arg[2]);
1183 int mode = tcp->u_arg[2];
1185 if (entering(tcp)) {
1186 tprintf("%ld, ", tcp->u_arg[0]);
1187 printpath(tcp, tcp->u_arg[1]);
1188 tprintf(", %s", sprintmode(mode));
1189 switch (mode & S_IFMT) {
1190 case S_IFCHR: case S_IFBLK:
1192 tprintf(", makedev(%lu, %lu)",
1193 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1194 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1196 tprintf(", makedev(%lu, %lu)",
1197 (unsigned long) major(tcp->u_arg[3]),
1198 (unsigned long) minor(tcp->u_arg[3]));
1208 #ifdef HAVE_SYS_ACL_H
1210 #include <sys/acl.h>
1212 struct xlat aclcmds[] = {
1214 { SETACL, "SETACL" },
1217 { GETACL, "GETACL" },
1220 { GETACLCNT, "GETACLCNT" },
1223 { ACL_GET, "ACL_GET" },
1226 { ACL_SET, "ACL_SET" },
1229 { ACL_CNT, "ACL_CNT" },
1238 if (entering(tcp)) {
1239 printpath(tcp, tcp->u_arg[0]);
1241 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1242 tprintf(", %ld", tcp->u_arg[2]);
1244 * FIXME - dump out the list of aclent_t's pointed to
1245 * by "tcp->u_arg[3]" if it's not NULL.
1248 tprintf(", %#lx", tcp->u_arg[3]);
1260 if (entering(tcp)) {
1261 tprintf("%ld, ", tcp->u_arg[0]);
1262 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1263 tprintf(", %ld", tcp->u_arg[2]);
1265 * FIXME - dump out the list of aclent_t's pointed to
1266 * by "tcp->u_arg[3]" if it's not NULL.
1269 tprintf(", %#lx", tcp->u_arg[3]);
1277 struct xlat aclipc[] = {
1279 { IPC_SHM, "IPC_SHM" },
1282 { IPC_SEM, "IPC_SEM" },
1285 { IPC_MSG, "IPC_MSG" },
1295 if (entering(tcp)) {
1296 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1297 tprintf(", %#lx, ", tcp->u_arg[1]);
1298 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1299 tprintf(", %ld", tcp->u_arg[3]);
1301 * FIXME - dump out the list of aclent_t's pointed to
1302 * by "tcp->u_arg[4]" if it's not NULL.
1305 tprintf(", %#lx", tcp->u_arg[4]);
1314 #endif /* HAVE_SYS_ACL_H */
1316 #endif /* SVR4 || LINUXSPARC */
1320 static struct xlat fsmagic[] = {
1321 { 0x73757245, "CODA_SUPER_MAGIC" },
1322 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1323 { 0x1373, "DEVFS_SUPER_MAGIC" },
1324 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1325 { 0x414A53, "EFS_SUPER_MAGIC" },
1326 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1327 { 0xef53, "EXT2_SUPER_MAGIC" },
1328 { 0x137d, "EXT_SUPER_MAGIC" },
1329 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1330 { 0x9660, "ISOFS_SUPER_MAGIC" },
1331 { 0x137f, "MINIX_SUPER_MAGIC" },
1332 { 0x138f, "MINIX_SUPER_MAGIC2" },
1333 { 0x2468, "MINIX2_SUPER_MAGIC" },
1334 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1335 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1336 { 0x564c, "NCP_SUPER_MAGIC" },
1337 { 0x6969, "NFS_SUPER_MAGIC" },
1338 { 0x9fa0, "PROC_SUPER_MAGIC" },
1339 { 0x002f, "QNX4_SUPER_MAGIC" },
1340 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1341 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1342 { 0x517b, "SMB_SUPER_MAGIC" },
1343 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1344 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1345 { 0x00011954, "UFS_MAGIC" },
1346 { 0x54190100, "UFS_CIGAM" },
1347 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1348 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1360 static char buf[32];
1364 s = xlookup(fsmagic, magic);
1366 sprintf(buf, "\"%s\"", s);
1370 sprintf(buf, "%#x", magic);
1375 printstatfs(tcp, addr)
1379 struct statfs statbuf;
1381 if (syserror(tcp) || !verbose(tcp)) {
1382 tprintf("%#lx", addr);
1385 if (umove(tcp, addr, &statbuf) < 0) {
1391 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1392 sprintfstype(statbuf.f_type),
1393 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1394 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
1395 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1397 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1398 sprintfstype(statbuf.f_type),
1399 (unsigned long)statbuf.f_bsize,
1400 (unsigned long)statbuf.f_blocks,
1401 (unsigned long)statbuf.f_bfree);
1402 tprintf("f_files=%lu, f_ffree=%lu",
1403 (unsigned long)statbuf.f_files,
1404 (unsigned long)statbuf.f_ffree);
1406 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1416 if (entering(tcp)) {
1417 printpath(tcp, tcp->u_arg[0]);
1420 printstatfs(tcp, tcp->u_arg[1]);
1429 if (entering(tcp)) {
1430 tprintf("%lu, ", tcp->u_arg[0]);
1432 printstatfs(tcp, tcp->u_arg[1]);
1437 #if defined(LINUX) && defined(__alpha)
1443 if (entering(tcp)) {
1444 printpath(tcp, tcp->u_arg[0]);
1447 printstatfs(tcp, tcp->u_arg[1]);
1448 tprintf(", %lu", tcp->u_arg[2]);
1457 if (entering(tcp)) {
1458 tprintf("%lu, ", tcp->u_arg[0]);
1460 printstatfs(tcp, tcp->u_arg[1]);
1461 tprintf(", %lu", tcp->u_arg[2]);
1465 #endif /* LINUX && __alpha */
1475 struct ustat statbuf;
1477 if (entering(tcp)) {
1478 tprintf("makedev(%lu, %lu), ",
1479 (long) major(tcp->u_arg[0]),
1480 (long) minor(tcp->u_arg[0]));
1483 if (syserror(tcp) || !verbose(tcp))
1484 tprintf("%#lx", tcp->u_arg[1]);
1485 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1488 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1489 statbuf.f_tfree, statbuf.f_tinode);
1490 tprintf("f_fname=\"%.*s\", ",
1491 (int) sizeof(statbuf.f_fname),
1493 tprintf("f_fpack=\"%.*s\"}",
1494 (int) sizeof(statbuf.f_fpack),
1507 if (entering(tcp)) {
1508 printpath(tcp, tcp->u_arg[0]);
1510 printpath(tcp, tcp->u_arg[1]);
1521 if (entering(tcp)) {
1522 printpath(tcp, tcp->u_arg[0]);
1531 if (entering(tcp)) {
1532 printpath(tcp, tcp->u_arg[0]);
1533 tprintf(", %#lo", tcp->u_arg[1]);
1542 if (entering(tcp)) {
1543 printpath(tcp, tcp->u_arg[0]);
1552 if (entering(tcp)) {
1553 tprintf("%ld", tcp->u_arg[0]);
1562 if (entering(tcp)) {
1563 printpath(tcp, tcp->u_arg[0]);
1572 if (entering(tcp)) {
1573 tprintf("%ld", tcp->u_arg[0]);
1582 if (entering(tcp)) {
1583 printpath(tcp, tcp->u_arg[0]);
1585 printpath(tcp, tcp->u_arg[1]);
1594 if (entering(tcp)) {
1595 printpath(tcp, tcp->u_arg[0]);
1604 if (entering(tcp)) {
1605 printpath(tcp, tcp->u_arg[0]);
1607 printpath(tcp, tcp->u_arg[1]);
1616 if (entering(tcp)) {
1617 printpath(tcp, tcp->u_arg[0]);
1621 tprintf("%#lx", tcp->u_arg[1]);
1623 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1624 tprintf(", %lu", tcp->u_arg[2]);
1633 if (entering(tcp)) {
1634 printpath(tcp, tcp->u_arg[0]);
1636 printpath(tcp, tcp->u_arg[1]);
1645 if (entering(tcp)) {
1646 printpath(tcp, tcp->u_arg[0]);
1647 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1656 if (entering(tcp)) {
1657 tprintf("%ld, %lu, %lu",
1658 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1667 if (entering(tcp)) {
1668 printpath(tcp, tcp->u_arg[0]);
1669 tprintf(", %#lo", tcp->u_arg[1]);
1678 if (entering(tcp)) {
1679 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1689 if (entering(tcp)) {
1690 printpath(tcp, tcp->u_arg[0]);
1692 printtv32(tcp, tcp->u_arg[1]);
1702 if (entering(tcp)) {
1703 printpath(tcp, tcp->u_arg[0]);
1705 printtv(tcp, tcp->u_arg[1]);
1716 if (entering(tcp)) {
1717 printpath(tcp, tcp->u_arg[0]);
1721 else if (!verbose(tcp))
1722 tprintf("%#lx", tcp->u_arg[1]);
1723 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1727 tprintf("[%s,", sprinttime(ut[0]));
1728 tprintf(" %s]", sprinttime(ut[1]));
1738 int mode = tcp->u_arg[1];
1740 if (entering(tcp)) {
1741 printpath(tcp, tcp->u_arg[0]);
1742 tprintf(", %s", sprintmode(mode));
1743 switch (mode & S_IFMT) {
1744 case S_IFCHR: case S_IFBLK:
1746 if (current_personality == 1)
1747 tprintf(", makedev(%lu, %lu)",
1748 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1749 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1752 tprintf(", makedev(%lu, %lu)",
1753 (unsigned long) major(tcp->u_arg[2]),
1754 (unsigned long) minor(tcp->u_arg[2]));
1767 if (entering(tcp)) {
1768 printpath(tcp, tcp->u_arg[0]);
1769 tprintf(", %#lo", tcp->u_arg[1]);
1778 if (entering(tcp)) {
1779 tprintf("%ld", tcp->u_arg[0]);
1793 if (!verbose(tcp)) {
1794 tprintf("%#lx", addr);
1797 if (umove(tcp, addr, &d) < 0) {
1801 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1803 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1811 if (entering(tcp)) {
1812 tprintf("%lu, ", tcp->u_arg[0]);
1814 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1815 tprintf("%#lx", tcp->u_arg[1]);
1817 printdir(tcp, tcp->u_arg[1]);
1818 /* Not much point in printing this out, it is always 1. */
1819 if (tcp->u_arg[2] != 1)
1820 tprintf(", %lu", tcp->u_arg[2]);
1828 struct xlat direnttypes[] = {
1829 { DT_FIFO, "DT_FIFO" },
1830 { DT_CHR, "DT_CHR" },
1831 { DT_DIR, "DT_DIR" },
1832 { DT_BLK, "DT_BLK" },
1833 { DT_REG, "DT_REG" },
1834 { DT_LNK, "DT_LNK" },
1835 { DT_SOCK, "DT_SOCK" },
1836 { DT_WHT, "DT_WHT" },
1846 int i, len, dents = 0;
1849 if (entering(tcp)) {
1850 tprintf("%lu, ", tcp->u_arg[0]);
1853 if (syserror(tcp) || !verbose(tcp)) {
1854 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1858 if ((buf = malloc(len)) == NULL) {
1859 tprintf("out of memory\n");
1862 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1863 tprintf("{...}, %lu", tcp->u_arg[2]);
1869 for (i = 0; i < len;) {
1870 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1873 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1874 i ? " " : "", d->d_ino, d->d_off);
1875 tprintf("d_reclen=%u, d_name=\"%s\"}",
1876 d->d_reclen, d->d_name);
1881 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1883 (unsigned long) d->d_ino,
1884 (unsigned long) d->d_off);
1885 tprintf("d_reclen=%u, d_name=\"%s\"}",
1886 d->d_reclen, d->d_name);
1891 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1892 i ? " " : "", d->d_off, d->d_fileno,
1894 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1895 d->d_namlen, d->d_namlen, d->d_name);
1900 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1901 i ? " " : "", d->d_fileno, d->d_reclen);
1902 printxval(direnttypes, d->d_type, "DT_???");
1903 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1904 d->d_namlen, d->d_namlen, d->d_name);
1906 #endif /* FREEBSD */
1908 tprintf("/* d_reclen == 0, problem here */");
1917 tprintf("/* %u entries */", dents);
1918 tprintf(", %lu", tcp->u_arg[2]);
1924 #if _LFS64_LARGEFILE
1929 int i, len, dents = 0;
1932 if (entering(tcp)) {
1933 tprintf("%lu, ", tcp->u_arg[0]);
1936 if (syserror(tcp) || !verbose(tcp)) {
1937 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1941 if ((buf = malloc(len)) == NULL) {
1942 tprintf("out of memory\n");
1945 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1946 tprintf("{...}, %lu", tcp->u_arg[2]);
1952 for (i = 0; i < len;) {
1953 struct dirent64 *d = (struct dirent64 *) &buf[i];
1954 #if defined(LINUX) || defined(SVR4)
1956 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1958 (unsigned long)d->d_ino,
1959 (unsigned long)d->d_off);
1960 tprintf("d_reclen=%u, d_name=\"%s\"}",
1961 d->d_reclen, d->d_name);
1963 #endif /* LINUX || SVR4 */
1966 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1967 i ? " " : "", d->d_off, d->d_fileno,
1969 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1970 d->d_namlen, d->d_namlen, d->d_name);
1979 tprintf("/* %u entries */", dents);
1980 tprintf(", %lu", tcp->u_arg[2]);
1988 sys_getdirentries(tcp)
1991 int i, len, dents = 0;
1995 if (entering(tcp)) {
1996 tprintf("%lu, ", tcp->u_arg[0]);
1999 if (syserror(tcp) || !verbose(tcp)) {
2000 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2004 if ((buf = malloc(len)) == NULL) {
2005 tprintf("out of memory\n");
2008 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2009 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
2015 for (i = 0; i < len;) {
2016 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2018 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2019 i ? " " : "", d->d_fileno, d->d_reclen);
2020 printxval(direnttypes, d->d_type, "DT_???");
2021 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2022 d->d_namlen, d->d_namlen, d->d_name);
2030 tprintf("/* %u entries */", dents);
2032 tprintf(", %lu", tcp->u_arg[2]);
2033 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2034 tprintf(", %#lx", tcp->u_arg[3]);
2036 tprintf(", [%lu]", basep);
2048 tprintf("%#lx", tcp->u_arg[0]);
2050 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2051 tprintf(", %lu", tcp->u_arg[1]);
2064 tprintf("%#lx", tcp->u_arg[0]);
2066 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2067 tprintf(", %lu", tcp->u_arg[1]);
2073 #ifdef HAVE_SYS_ASYNCH_H
2079 struct aio_result_t res;
2081 if (entering(tcp)) {
2082 tprintf("%lu, ", tcp->u_arg[0]);
2085 tprintf("%#lx", tcp->u_arg[1]);
2087 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2088 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2089 printxval(whence, tcp->u_arg[4], "L_???");
2090 if (syserror(tcp) || tcp->u_arg[5] == 0
2091 || umove(tcp, tcp->u_arg[5], &res) < 0)
2092 tprintf(", %#lx", tcp->u_arg[5]);
2094 tprintf(", {aio_return %d aio_errno %d}",
2095 res.aio_return, res.aio_errno);
2104 struct aio_result_t res;
2106 if (entering(tcp)) {
2107 tprintf("%lu, ", tcp->u_arg[0]);
2108 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2109 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2110 printxval(whence, tcp->u_arg[4], "L_???");
2113 if (tcp->u_arg[5] == 0)
2115 else if (syserror(tcp)
2116 || umove(tcp, tcp->u_arg[5], &res) < 0)
2117 tprintf(", %#lx", tcp->u_arg[5]);
2119 tprintf(", {aio_return %d aio_errno %d}",
2120 res.aio_return, res.aio_errno);
2130 printtv(tcp, tcp->u_arg[0]);
2138 struct aio_result_t res;
2141 if (tcp->u_arg[0] == 0)
2143 else if (syserror(tcp)
2144 || umove(tcp, tcp->u_arg[0], &res) < 0)
2145 tprintf("%#lx", tcp->u_arg[0]);
2147 tprintf("{aio_return %d aio_errno %d}",
2148 res.aio_return, res.aio_errno);
2153 #endif /* HAVE_SYS_ASYNCH_H */
2157 struct xlat xattrflags[] = {
2158 { XATTR_CREATE, "XATTR_CREATE" },
2159 { XATTR_REPLACE, "XATTR_REPLACE" },
2167 if (entering(tcp)) {
2168 printpath(tcp, tcp->u_arg[0]);
2170 printstr(tcp, tcp->u_arg[1], -1);
2171 /* XXX Print value in format */
2172 tprintf(", %p, %ld, ", (void *) tcp->u_arg[2], tcp->u_arg[3]);
2173 printflags(xattrflags, tcp->u_arg[4]);
2182 if (entering(tcp)) {
2183 tprintf("%ld, ", tcp->u_arg[0]);
2184 printstr(tcp, tcp->u_arg[1], -1);
2185 /* XXX Print value in format */
2186 tprintf(", %p, %ld, ", (void *) tcp->u_arg[2], tcp->u_arg[3]);
2187 printflags(xattrflags, tcp->u_arg[4]);
2196 if (entering(tcp)) {
2197 printpath(tcp, tcp->u_arg[0]);
2199 printstr(tcp, tcp->u_arg[1], -1);
2201 /* XXX Print value in format */
2202 tprintf(", %p, %ld", (void *) tcp->u_arg[2], tcp->u_arg[3]);
2211 if (entering(tcp)) {
2212 tprintf("%ld, ", tcp->u_arg[0]);
2213 printstr(tcp, tcp->u_arg[1], -1);
2215 /* XXX Print value in format */
2216 tprintf(", %p, %ld", (void *) tcp->u_arg[2], tcp->u_arg[3]);
2225 if (entering(tcp)) {
2226 printpath(tcp, tcp->u_arg[0]);
2228 /* XXX Print value in format */
2229 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2238 if (entering(tcp)) {
2239 tprintf("%ld", tcp->u_arg[0]);
2241 /* XXX Print value in format */
2242 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2248 sys_removexattr(tcp)
2251 if (entering(tcp)) {
2252 printpath(tcp, tcp->u_arg[0]);
2254 printstr(tcp, tcp->u_arg[1], -1);
2260 sys_fremovexattr(tcp)
2263 if (entering(tcp)) {
2264 tprintf("%ld, ", tcp->u_arg[0]);
2265 printstr(tcp, tcp->u_arg[1], -1);