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
137 #include <sys/param.h>
138 #include <sys/mount.h>
139 #include <sys/stat.h>
142 #if HAVE_LONG_LONG_OFF_T
144 * Ugly hacks for systems that have typedef long long off_t
148 #define HAVE_STAT64 1 /* Ugly hack */
150 #define sys_stat64 sys_stat
151 #define sys_fstat64 sys_fstat
152 #define sys_lstat64 sys_lstat
153 #define sys_lseek64 sys_lseek
154 #define sys_truncate64 sys_truncate
155 #define sys_ftruncate64 sys_ftruncate
158 #ifdef MAJOR_IN_SYSMACROS
159 #include <sys/sysmacros.h>
162 #ifdef MAJOR_IN_MKDEV
163 #include <sys/mkdev.h>
166 #ifdef HAVE_SYS_ASYNCH_H
167 #include <sys/asynch.h>
175 * This is a really dirty trick but it should always work. Traditional
176 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
177 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
179 struct xlat openmodes[] = {
180 { O_RDWR+1, "O_RDWR" },
181 { O_RDONLY+1, "O_RDONLY" },
182 { O_WRONLY+1, "O_WRONLY" },
183 { O_NONBLOCK, "O_NONBLOCK" },
184 { O_APPEND, "O_APPEND" },
185 { O_CREAT, "O_CREAT" },
186 { O_TRUNC, "O_TRUNC" },
187 { O_EXCL, "O_EXCL" },
188 { O_NOCTTY, "O_NOCTTY" },
190 { O_SYNC, "O_SYNC" },
193 { O_ASYNC, "O_ASYNC" },
196 { O_DSYNC, "O_DSYNC" },
199 { O_RSYNC, "O_RSYNC" },
202 { O_NDELAY, "O_NDELAY" },
205 { O_PRIV, "O_PRIV" },
208 { O_DIRECT, "O_DIRECT" },
211 { O_LARGEFILE, "O_LARGEFILE" },
214 { O_DIRECTORY, "O_DIRECTORY" },
217 { O_NOFOLLOW, "O_NOFOLLOW" },
221 { FNDELAY, "FNDELAY" },
224 { FAPPEND, "FAPPEND" },
230 { FDEFER, "FDEFER" },
233 { FASYNC, "FASYNC" },
236 { FSHLOCK, "FSHLOCK" },
239 { FEXLOCK, "FEXLOCK" },
242 { FCREAT, "FCREAT" },
245 { FTRUNC, "FTRUNC" },
257 { FNOCTTY, "FNOCTTY" },
260 { O_SHLOCK, "O_SHLOCK" },
263 { O_EXLOCK, "O_EXLOCK" },
273 printpath(tcp, tcp->u_arg[0]);
276 printflags(openmodes, tcp->u_arg[1] + 1);
277 if (tcp->u_arg[1] & O_CREAT) {
279 tprintf(", %#lo", tcp->u_arg[2]);
286 struct xlat openmodessol[] = {
290 { 0x80, "O_NONBLOCK" },
292 { 0x100, "O_CREAT" },
293 { 0x200, "O_TRUNC" },
295 { 0x800, "O_NOCTTY" },
298 { 0x8000, "O_RSYNC" },
300 { 0x1000, "O_PRIV" },
309 printpath(tcp, tcp->u_arg[0]);
312 printflags(openmodessol, tcp->u_arg[1] + 1);
313 if (tcp->u_arg[1] & 0x100) {
315 tprintf(", %#lo", tcp->u_arg[2]);
328 printpath(tcp, tcp->u_arg[0]);
329 tprintf(", %#lo", tcp->u_arg[1]);
334 static struct xlat access_flags[] = {
340 { EFF_ONLY_OK, "EFF_ONLY_OK" },
353 printpath(tcp, tcp->u_arg[0]);
355 printflags(access_flags, tcp->u_arg[1]);
365 tprintf("%#lo", tcp->u_arg[0]);
370 static struct xlat whence[] = {
371 { SEEK_SET, "SEEK_SET" },
372 { SEEK_CUR, "SEEK_CUR" },
373 { SEEK_END, "SEEK_END" },
377 #ifndef HAVE_LONG_LONG_OFF_T
386 tprintf("%ld, ", tcp->u_arg[0]);
387 offset = tcp->u_arg[1];
388 _whence = tcp->u_arg[2];
389 if (_whence == SEEK_SET)
390 tprintf("%lu, ", offset);
392 tprintf("%ld, ", offset);
393 printxval(whence, _whence, "SEEK_???");
395 return RVAL_UDECIMAL;
405 if (tcp->u_arg[4] == SEEK_SET)
406 tprintf("%ld, %llu, ", tcp->u_arg[0],
407 (((long long int) tcp->u_arg[1]) << 32
408 | (unsigned long long) (unsigned) tcp->u_arg[2]));
410 tprintf("%ld, %lld, ", tcp->u_arg[0],
411 (((long long int) tcp->u_arg[1]) << 32
412 | (unsigned long long) (unsigned) tcp->u_arg[2]));
416 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
417 tprintf("%#lx, ", tcp->u_arg[3]);
419 tprintf("[%llu], ", off);
420 printxval(whence, tcp->u_arg[4], "SEEK_???");
426 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
433 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
434 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
435 if (tcp->u_arg[3] == SEEK_SET)
436 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
438 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
439 printxval(whence, tcp->u_arg[3], "SEEK_???");
441 return RVAL_LUDECIMAL;
445 #ifndef HAVE_LONG_LONG_OFF_T
451 printpath(tcp, tcp->u_arg[0]);
452 tprintf(", %lu", tcp->u_arg[1]);
458 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
465 printpath(tcp, tcp->u_arg[0]);
466 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
472 #ifndef HAVE_LONG_LONG_OFF_T
478 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
484 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
491 tprintf("%ld, %llu", tcp->u_arg[0],
492 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
500 static struct xlat modetypes[] = {
501 { S_IFREG, "S_IFREG" },
502 { S_IFSOCK, "S_IFSOCK" },
503 { S_IFIFO, "S_IFIFO" },
504 { S_IFLNK, "S_IFLNK" },
505 { S_IFDIR, "S_IFDIR" },
506 { S_IFBLK, "S_IFBLK" },
507 { S_IFCHR, "S_IFCHR" },
518 if ((mode & S_IFMT) == 0)
520 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
521 sprintf(buf, "%#o", mode);
524 sprintf(buf, "%s%s%s%s", s,
525 (mode & S_ISUID) ? "|S_ISUID" : "",
526 (mode & S_ISGID) ? "|S_ISGID" : "",
527 (mode & S_ISVTX) ? "|S_ISVTX" : "");
528 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
530 sprintf(buf + strlen(buf), "|%#o", mode);
531 s = (*buf == '|') ? buf + 1 : buf;
547 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
548 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
549 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
561 int st_pad1[3]; /* network id */
570 int st_pad3; /* st_size, off_t expansion */
571 timestruct_t st_atime;
572 timestruct_t st_mtime;
573 timestruct_t st_ctime;
577 int st_pad4[8]; /* expansion area */
581 printstatsol(tcp, addr)
585 struct solstat statbuf;
591 if (syserror(tcp) || !verbose(tcp)) {
592 tprintf("%#lx", addr);
595 if (umove(tcp, addr, &statbuf) < 0) {
600 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
601 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
602 (unsigned long) (statbuf.st_dev & 0x3ffff),
603 (unsigned long) statbuf.st_ino,
604 sprintmode(statbuf.st_mode));
605 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
606 (unsigned long) statbuf.st_nlink,
607 (unsigned long) statbuf.st_uid,
608 (unsigned long) statbuf.st_gid);
609 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
610 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
613 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
614 switch (statbuf.st_mode & S_IFMT) {
615 case S_IFCHR: case S_IFBLK:
616 tprintf("st_rdev=makedev(%lu, %lu), ",
617 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
618 (unsigned long) (statbuf.st_rdev & 0x3ffff));
621 tprintf("st_size=%u, ", statbuf.st_size);
625 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
626 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
627 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
632 #endif /* LINUXSPARC */
634 struct xlat fileflags[] = {
636 { UF_NODUMP, "UF_NODUMP" },
637 { UF_IMMUTABLE, "UF_IMMUTABLE" },
638 { UF_APPEND, "UF_APPEND" },
639 { UF_OPAQUE, "UF_OPAQUE" },
640 { UF_NOUNLINK, "UF_NOUNLINK" },
641 { SF_ARCHIVED, "SF_ARCHIVED" },
642 { SF_IMMUTABLE, "SF_IMMUTABLE" },
643 { SF_APPEND, "SF_APPEND" },
644 { SF_NOUNLINK, "SF_NOUNLINK" },
647 { _S_ISMLD, "_S_ISMLD" },
650 { _S_ISMOUNTED, "_S_ISMOUNTED" },
662 printpath(tcp, tcp->u_arg[0]);
665 printflags(fileflags, tcp->u_arg[1]);
677 tprintf("%ld, ", tcp->u_arg[0]);
679 printflags(fileflags, tcp->u_arg[1]);
687 #ifndef HAVE_LONG_LONG_OFF_T
689 realprintstat(tcp, statbuf)
691 struct stat *statbuf;
694 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
695 (unsigned long) major(statbuf->st_dev),
696 (unsigned long) minor(statbuf->st_dev),
697 (unsigned long) statbuf->st_ino,
698 sprintmode(statbuf->st_mode));
699 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
700 (unsigned long) statbuf->st_nlink,
701 (unsigned long) statbuf->st_uid,
702 (unsigned long) statbuf->st_gid);
703 #ifdef HAVE_ST_BLKSIZE
704 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
705 #endif /* HAVE_ST_BLKSIZE */
706 #ifdef HAVE_ST_BLOCKS
707 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
708 #endif /* HAVE_ST_BLOCKS */
711 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
712 switch (statbuf->st_mode & S_IFMT) {
713 case S_IFCHR: case S_IFBLK:
715 tprintf("st_rdev=makedev(%lu, %lu), ",
716 (unsigned long) major(statbuf->st_rdev),
717 (unsigned long) minor(statbuf->st_rdev));
718 #else /* !HAVE_ST_RDEV */
719 tprintf("st_size=makedev(%lu, %lu), ",
720 (unsigned long) major(statbuf->st_size),
721 (unsigned long) minor(statbuf->st_size));
722 #endif /* !HAVE_ST_RDEV */
725 tprintf("st_size=%lu, ", statbuf->st_size);
729 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
730 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
731 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
733 tprintf(", st_flags=");
734 if (statbuf->st_flags) {
735 printflags(fileflags, statbuf->st_flags);
740 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
743 tprintf(", st_level=%ld", statbuf->st_level);
746 tprintf(", st_fstype=%.*s",
747 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
750 tprintf(", st_gen=%u", statbuf->st_gen);
767 if (current_personality == 1) {
768 printstatsol(tcp, addr);
771 #endif /* LINUXSPARC */
777 if (syserror(tcp) || !verbose(tcp)) {
778 tprintf("%#lx", addr);
781 if (umove(tcp, addr, &statbuf) < 0) {
786 realprintstat(tcp, &statbuf);
788 #endif /* !HAVE_LONG_LONG_OFF_T */
792 printstat64(tcp, addr)
796 struct stat64 statbuf;
799 if (current_personality == 1) {
800 printstatsol(tcp, addr);
803 #endif /* LINUXSPARC */
809 if (syserror(tcp) || !verbose(tcp)) {
810 tprintf("%#lx", addr);
813 if (umove(tcp, addr, &statbuf) < 0) {
819 #ifdef HAVE_LONG_LONG
820 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
822 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
824 (unsigned long) major(statbuf.st_dev),
825 (unsigned long) minor(statbuf.st_dev),
826 #ifdef HAVE_LONG_LONG
827 (unsigned long long) statbuf.st_ino,
829 (unsigned long) statbuf.st_ino,
831 sprintmode(statbuf.st_mode));
832 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
833 (unsigned long) statbuf.st_nlink,
834 (unsigned long) statbuf.st_uid,
835 (unsigned long) statbuf.st_gid);
836 #ifdef HAVE_ST_BLKSIZE
837 tprintf("st_blksize=%lu, ",
838 (unsigned long) statbuf.st_blksize);
839 #endif /* HAVE_ST_BLKSIZE */
840 #ifdef HAVE_ST_BLOCKS
841 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
842 #endif /* HAVE_ST_BLOCKS */
845 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
846 switch (statbuf.st_mode & S_IFMT) {
847 case S_IFCHR: case S_IFBLK:
849 tprintf("st_rdev=makedev(%lu, %lu), ",
850 (unsigned long) major(statbuf.st_rdev),
851 (unsigned long) minor(statbuf.st_rdev));
852 #else /* !HAVE_ST_RDEV */
853 tprintf("st_size=makedev(%lu, %lu), ",
854 (unsigned long) major(statbuf.st_size),
855 (unsigned long) minor(statbuf.st_size));
856 #endif /* !HAVE_ST_RDEV */
859 tprintf("st_size=%llu, ", statbuf.st_size);
863 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
864 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
865 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
867 tprintf(", st_flags=");
868 if (statbuf.st_flags) {
869 printflags(fileflags, statbuf.st_flags);
874 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
877 tprintf(", st_level=%ld", statbuf.st_level);
880 tprintf(", st_fstype=%.*s",
881 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
884 tprintf(", st_gen=%u", statbuf.st_gen);
891 #endif /* HAVE_STAT64 */
893 #if defined(LINUX) && !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
894 && !defined(S390) && !defined(S390X)
896 convertoldstat(oldbuf, newbuf)
897 const struct __old_kernel_stat *oldbuf;
900 newbuf->st_dev=oldbuf->st_dev;
901 newbuf->st_ino=oldbuf->st_ino;
902 newbuf->st_mode=oldbuf->st_mode;
903 newbuf->st_nlink=oldbuf->st_nlink;
904 newbuf->st_uid=oldbuf->st_uid;
905 newbuf->st_gid=oldbuf->st_gid;
906 newbuf->st_rdev=oldbuf->st_rdev;
907 newbuf->st_size=oldbuf->st_size;
908 newbuf->st_atime=oldbuf->st_atime;
909 newbuf->st_mtime=oldbuf->st_mtime;
910 newbuf->st_ctime=oldbuf->st_ctime;
911 newbuf->st_blksize=0; /* not supported in old_stat */
912 newbuf->st_blocks=0; /* not supported in old_stat */
917 printoldstat(tcp, addr)
921 struct __old_kernel_stat statbuf;
922 struct stat newstatbuf;
925 if (current_personality == 1) {
926 printstatsol(tcp, addr);
929 #endif /* LINUXSPARC */
935 if (syserror(tcp) || !verbose(tcp)) {
936 tprintf("%#lx", addr);
939 if (umove(tcp, addr, &statbuf) < 0) {
944 convertoldstat(&statbuf, &newstatbuf);
945 realprintstat(tcp, &newstatbuf);
947 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
949 #ifndef HAVE_LONG_LONG_OFF_T
955 printpath(tcp, tcp->u_arg[0]);
958 printstat(tcp, tcp->u_arg[1]);
970 printpath(tcp, tcp->u_arg[0]);
973 printstat64(tcp, tcp->u_arg[1]);
977 return printargs(tcp);
982 # if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
983 && !defined(S390) && !defined(S390X)
989 printpath(tcp, tcp->u_arg[0]);
992 printoldstat(tcp, tcp->u_arg[1]);
996 # endif /* !IA64 && !HPPA*/
999 #ifndef HAVE_LONG_LONG_OFF_T
1005 tprintf("%ld, ", tcp->u_arg[0]);
1007 printstat(tcp, tcp->u_arg[1]);
1019 tprintf("%ld, ", tcp->u_arg[0]);
1021 printstat64(tcp, tcp->u_arg[1]);
1025 return printargs(tcp);
1030 # if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
1031 && !defined(S390) && !defined(S390X)
1037 tprintf("%ld, ", tcp->u_arg[0]);
1039 printoldstat(tcp, tcp->u_arg[1]);
1043 # endif /* !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1046 #ifndef HAVE_LONG_LONG_OFF_T
1051 if (entering(tcp)) {
1052 printpath(tcp, tcp->u_arg[0]);
1055 printstat(tcp, tcp->u_arg[1]);
1066 if (entering(tcp)) {
1067 printpath(tcp, tcp->u_arg[0]);
1070 printstat64(tcp, tcp->u_arg[1]);
1074 return printargs(tcp);
1079 # if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
1080 && !defined(S390) && !defined(S390X)
1085 if (entering(tcp)) {
1086 printpath(tcp, tcp->u_arg[0]);
1089 printoldstat(tcp, tcp->u_arg[1]);
1093 # endif /* !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1097 #if defined(SVR4) || defined(LINUXSPARC)
1103 if (entering(tcp)) {
1104 tprintf("%ld, ", tcp->u_arg[0]);
1105 printpath(tcp, tcp->u_arg[1]);
1109 if (tcp->u_arg[0] == _STAT64_VER)
1110 printstat64 (tcp, tcp->u_arg[2]);
1113 printstat(tcp, tcp->u_arg[2]);
1123 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1126 if (tcp->u_arg[0] == _STAT64_VER)
1127 printstat64 (tcp, tcp->u_arg[2]);
1130 printstat(tcp, tcp->u_arg[2]);
1139 if (entering(tcp)) {
1140 tprintf("%ld, ", tcp->u_arg[0]);
1141 printpath(tcp, tcp->u_arg[1]);
1145 if (tcp->u_arg[0] == _STAT64_VER)
1146 printstat64 (tcp, tcp->u_arg[2]);
1149 printstat(tcp, tcp->u_arg[2]);
1158 int mode = tcp->u_arg[2];
1160 if (entering(tcp)) {
1161 tprintf("%ld, ", tcp->u_arg[0]);
1162 printpath(tcp, tcp->u_arg[1]);
1163 tprintf(", %s", sprintmode(mode));
1164 switch (mode & S_IFMT) {
1165 case S_IFCHR: case S_IFBLK:
1167 tprintf(", makedev(%lu, %lu)",
1168 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1169 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1171 tprintf(", makedev(%lu, %lu)",
1172 (unsigned long) major(tcp->u_arg[3]),
1173 (unsigned long) minor(tcp->u_arg[3]));
1183 #ifdef HAVE_SYS_ACL_H
1185 #include <sys/acl.h>
1187 struct xlat aclcmds[] = {
1189 { SETACL, "SETACL" },
1192 { GETACL, "GETACL" },
1195 { GETACLCNT, "GETACLCNT" },
1198 { ACL_GET, "ACL_GET" },
1201 { ACL_SET, "ACL_SET" },
1204 { ACL_CNT, "ACL_CNT" },
1213 if (entering(tcp)) {
1214 printpath(tcp, tcp->u_arg[0]);
1216 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1217 tprintf(", %ld", tcp->u_arg[2]);
1219 * FIXME - dump out the list of aclent_t's pointed to
1220 * by "tcp->u_arg[3]" if it's not NULL.
1223 tprintf(", %#lx", tcp->u_arg[3]);
1235 if (entering(tcp)) {
1236 tprintf("%ld, ", tcp->u_arg[0]);
1237 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1238 tprintf(", %ld", tcp->u_arg[2]);
1240 * FIXME - dump out the list of aclent_t's pointed to
1241 * by "tcp->u_arg[3]" if it's not NULL.
1244 tprintf(", %#lx", tcp->u_arg[3]);
1252 struct xlat aclipc[] = {
1254 { IPC_SHM, "IPC_SHM" },
1257 { IPC_SEM, "IPC_SEM" },
1260 { IPC_MSG, "IPC_MSG" },
1270 if (entering(tcp)) {
1271 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1272 tprintf(", %#lx, ", tcp->u_arg[1]);
1273 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1274 tprintf(", %ld", tcp->u_arg[3]);
1276 * FIXME - dump out the list of aclent_t's pointed to
1277 * by "tcp->u_arg[4]" if it's not NULL.
1280 tprintf(", %#lx", tcp->u_arg[4]);
1289 #endif /* HAVE_SYS_ACL_H */
1291 #endif /* SVR4 || LINUXSPARC */
1295 static struct xlat fsmagic[] = {
1296 { 0x73757245, "CODA_SUPER_MAGIC" },
1297 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1298 { 0x1373, "DEVFS_SUPER_MAGIC" },
1299 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1300 { 0x414A53, "EFS_SUPER_MAGIC" },
1301 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1302 { 0xef53, "EXT2_SUPER_MAGIC" },
1303 { 0x137d, "EXT_SUPER_MAGIC" },
1304 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1305 { 0x9660, "ISOFS_SUPER_MAGIC" },
1306 { 0x137f, "MINIX_SUPER_MAGIC" },
1307 { 0x138f, "MINIX_SUPER_MAGIC2" },
1308 { 0x2468, "MINIX2_SUPER_MAGIC" },
1309 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1310 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1311 { 0x564c, "NCP_SUPER_MAGIC" },
1312 { 0x6969, "NFS_SUPER_MAGIC" },
1313 { 0x9fa0, "PROC_SUPER_MAGIC" },
1314 { 0x002f, "QNX4_SUPER_MAGIC" },
1315 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1316 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1317 { 0x517b, "SMB_SUPER_MAGIC" },
1318 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1319 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1320 { 0x00011954, "UFS_MAGIC" },
1321 { 0x54190100, "UFS_CIGAM" },
1322 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1323 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1335 static char buf[32];
1339 s = xlookup(fsmagic, magic);
1341 sprintf(buf, "\"%s\"", s);
1345 sprintf(buf, "%#x", magic);
1350 printstatfs(tcp, addr)
1354 struct statfs statbuf;
1356 if (syserror(tcp) || !verbose(tcp)) {
1357 tprintf("%#lx", addr);
1360 if (umove(tcp, addr, &statbuf) < 0) {
1366 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1367 sprintfstype(statbuf.f_type),
1368 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1369 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
1370 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1372 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1373 sprintfstype(statbuf.f_type),
1374 (unsigned long)statbuf.f_bsize,
1375 (unsigned long)statbuf.f_blocks,
1376 (unsigned long)statbuf.f_bfree);
1377 tprintf("f_files=%lu, f_ffree=%lu",
1378 (unsigned long)statbuf.f_files,
1379 (unsigned long)statbuf.f_ffree);
1381 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1391 if (entering(tcp)) {
1392 printpath(tcp, tcp->u_arg[0]);
1395 printstatfs(tcp, tcp->u_arg[1]);
1404 if (entering(tcp)) {
1405 tprintf("%lu, ", tcp->u_arg[0]);
1407 printstatfs(tcp, tcp->u_arg[1]);
1412 #if defined(LINUX) && defined(__alpha)
1418 if (entering(tcp)) {
1419 printpath(tcp, tcp->u_arg[0]);
1422 printstatfs(tcp, tcp->u_arg[1]);
1423 tprintf(", %lu", tcp->u_arg[2]);
1432 if (entering(tcp)) {
1433 tprintf("%lu, ", tcp->u_arg[0]);
1435 printstatfs(tcp, tcp->u_arg[1]);
1436 tprintf(", %lu", tcp->u_arg[2]);
1440 #endif /* LINUX && __alpha */
1450 struct ustat statbuf;
1452 if (entering(tcp)) {
1453 tprintf("makedev(%lu, %lu), ",
1454 (long) major(tcp->u_arg[0]),
1455 (long) minor(tcp->u_arg[0]));
1458 if (syserror(tcp) || !verbose(tcp))
1459 tprintf("%#lx", tcp->u_arg[1]);
1460 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1463 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1464 statbuf.f_tfree, statbuf.f_tinode);
1465 tprintf("f_fname=\"%.*s\", ",
1466 (int) sizeof(statbuf.f_fname),
1468 tprintf("f_fpack=\"%.*s\"}",
1469 (int) sizeof(statbuf.f_fpack),
1482 if (entering(tcp)) {
1483 printpath(tcp, tcp->u_arg[0]);
1485 printpath(tcp, tcp->u_arg[1]);
1496 if (entering(tcp)) {
1497 printpath(tcp, tcp->u_arg[0]);
1506 if (entering(tcp)) {
1507 printpath(tcp, tcp->u_arg[0]);
1508 tprintf(", %#lo", tcp->u_arg[1]);
1517 if (entering(tcp)) {
1518 printpath(tcp, tcp->u_arg[0]);
1527 if (entering(tcp)) {
1528 tprintf("%ld", tcp->u_arg[0]);
1537 if (entering(tcp)) {
1538 printpath(tcp, tcp->u_arg[0]);
1547 if (entering(tcp)) {
1548 tprintf("%ld", tcp->u_arg[0]);
1557 if (entering(tcp)) {
1558 printpath(tcp, tcp->u_arg[0]);
1560 printpath(tcp, tcp->u_arg[1]);
1569 if (entering(tcp)) {
1570 printpath(tcp, tcp->u_arg[0]);
1579 if (entering(tcp)) {
1580 printpath(tcp, tcp->u_arg[0]);
1582 printpath(tcp, tcp->u_arg[1]);
1591 if (entering(tcp)) {
1592 printpath(tcp, tcp->u_arg[0]);
1596 tprintf("%#lx", tcp->u_arg[1]);
1598 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1599 tprintf(", %lu", tcp->u_arg[2]);
1608 if (entering(tcp)) {
1609 printpath(tcp, tcp->u_arg[0]);
1611 printpath(tcp, tcp->u_arg[1]);
1620 if (entering(tcp)) {
1621 printpath(tcp, tcp->u_arg[0]);
1622 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1631 if (entering(tcp)) {
1632 tprintf("%ld, %lu, %lu",
1633 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1642 if (entering(tcp)) {
1643 printpath(tcp, tcp->u_arg[0]);
1644 tprintf(", %#lo", tcp->u_arg[1]);
1653 if (entering(tcp)) {
1654 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1664 if (entering(tcp)) {
1665 printpath(tcp, tcp->u_arg[0]);
1667 printtv32(tcp, tcp->u_arg[1]);
1677 if (entering(tcp)) {
1678 printpath(tcp, tcp->u_arg[0]);
1680 printtv(tcp, tcp->u_arg[1]);
1691 if (entering(tcp)) {
1692 printpath(tcp, tcp->u_arg[0]);
1696 else if (!verbose(tcp))
1697 tprintf("%#lx", tcp->u_arg[1]);
1698 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1702 tprintf("[%s,", sprinttime(ut[0]));
1703 tprintf(" %s]", sprinttime(ut[1]));
1713 int mode = tcp->u_arg[1];
1715 if (entering(tcp)) {
1716 printpath(tcp, tcp->u_arg[0]);
1717 tprintf(", %s", sprintmode(mode));
1718 switch (mode & S_IFMT) {
1719 case S_IFCHR: case S_IFBLK:
1721 if (current_personality == 1)
1722 tprintf(", makedev(%lu, %lu)",
1723 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1724 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1727 tprintf(", makedev(%lu, %lu)",
1728 (unsigned long) major(tcp->u_arg[2]),
1729 (unsigned long) minor(tcp->u_arg[2]));
1742 if (entering(tcp)) {
1743 printpath(tcp, tcp->u_arg[0]);
1744 tprintf(", %#lo", tcp->u_arg[1]);
1753 if (entering(tcp)) {
1754 tprintf("%ld", tcp->u_arg[0]);
1768 if (!verbose(tcp)) {
1769 tprintf("%#lx", addr);
1772 if (umove(tcp, addr, &d) < 0) {
1776 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1778 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1786 if (entering(tcp)) {
1787 tprintf("%lu, ", tcp->u_arg[0]);
1789 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1790 tprintf("%#lx", tcp->u_arg[1]);
1792 printdir(tcp, tcp->u_arg[1]);
1793 /* Not much point in printing this out, it is always 1. */
1794 if (tcp->u_arg[2] != 1)
1795 tprintf(", %lu", tcp->u_arg[2]);
1803 struct xlat direnttypes[] = {
1804 { DT_FIFO, "DT_FIFO" },
1805 { DT_CHR, "DT_CHR" },
1806 { DT_DIR, "DT_DIR" },
1807 { DT_BLK, "DT_BLK" },
1808 { DT_REG, "DT_REG" },
1809 { DT_LNK, "DT_LNK" },
1810 { DT_SOCK, "DT_SOCK" },
1811 { DT_WHT, "DT_WHT" },
1821 int i, len, dents = 0;
1824 if (entering(tcp)) {
1825 tprintf("%lu, ", tcp->u_arg[0]);
1828 if (syserror(tcp) || !verbose(tcp)) {
1829 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1833 if ((buf = malloc(len)) == NULL) {
1834 tprintf("out of memory\n");
1837 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1838 tprintf("{...}, %lu", tcp->u_arg[2]);
1844 for (i = 0; i < len;) {
1845 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1848 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1849 i ? " " : "", d->d_ino, d->d_off);
1850 tprintf("d_reclen=%u, d_name=\"%s\"}",
1851 d->d_reclen, d->d_name);
1856 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1857 i ? " " : "", d->d_ino, d->d_off);
1858 tprintf("d_reclen=%u, d_name=\"%s\"}",
1859 d->d_reclen, d->d_name);
1864 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1865 i ? " " : "", d->d_off, d->d_fileno,
1867 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1868 d->d_namlen, d->d_namlen, d->d_name);
1873 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1874 i ? " " : "", d->d_fileno, d->d_reclen);
1875 printxval(direnttypes, d->d_type, "DT_???");
1876 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1877 d->d_namlen, d->d_namlen, d->d_name);
1879 #endif /* FREEBSD */
1881 tprintf("/* d_reclen == 0, problem here */");
1890 tprintf("/* %u entries */", dents);
1891 tprintf(", %lu", tcp->u_arg[2]);
1897 #if _LFS64_LARGEFILE
1902 int i, len, dents = 0;
1905 if (entering(tcp)) {
1906 tprintf("%lu, ", tcp->u_arg[0]);
1909 if (syserror(tcp) || !verbose(tcp)) {
1910 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1914 if ((buf = malloc(len)) == NULL) {
1915 tprintf("out of memory\n");
1918 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1919 tprintf("{...}, %lu", tcp->u_arg[2]);
1925 for (i = 0; i < len;) {
1926 struct dirent64 *d = (struct dirent64 *) &buf[i];
1927 #if defined(LINUX) || defined(SVR4)
1929 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1931 (unsigned long)d->d_ino,
1932 (unsigned long)d->d_off);
1933 tprintf("d_reclen=%u, d_name=\"%s\"}",
1934 d->d_reclen, d->d_name);
1936 #endif /* LINUX || SVR4 */
1939 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1940 i ? " " : "", d->d_off, d->d_fileno,
1942 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1943 d->d_namlen, d->d_namlen, d->d_name);
1952 tprintf("/* %u entries */", dents);
1953 tprintf(", %lu", tcp->u_arg[2]);
1961 sys_getdirentries(tcp)
1964 int i, len, dents = 0;
1968 if (entering(tcp)) {
1969 tprintf("%lu, ", tcp->u_arg[0]);
1972 if (syserror(tcp) || !verbose(tcp)) {
1973 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1977 if ((buf = malloc(len)) == NULL) {
1978 tprintf("out of memory\n");
1981 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1982 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
1988 for (i = 0; i < len;) {
1989 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1991 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1992 i ? " " : "", d->d_fileno, d->d_reclen);
1993 printxval(direnttypes, d->d_type, "DT_???");
1994 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1995 d->d_namlen, d->d_namlen, d->d_name);
2003 tprintf("/* %u entries */", dents);
2005 tprintf(", %lu", tcp->u_arg[2]);
2006 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2007 tprintf(", %#lx", tcp->u_arg[3]);
2009 tprintf(", [%lu]", basep);
2021 tprintf("%#lx", tcp->u_arg[0]);
2023 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2024 tprintf(", %lu", tcp->u_arg[1]);
2037 tprintf("%#lx", tcp->u_arg[0]);
2039 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2040 tprintf(", %lu", tcp->u_arg[1]);
2046 #ifdef HAVE_SYS_ASYNCH_H
2052 struct aio_result_t res;
2054 if (entering(tcp)) {
2055 tprintf("%lu, ", tcp->u_arg[0]);
2058 tprintf("%#lx", tcp->u_arg[1]);
2060 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2061 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2062 printxval(whence, tcp->u_arg[4], "L_???");
2063 if (syserror(tcp) || tcp->u_arg[5] == 0
2064 || umove(tcp, tcp->u_arg[5], &res) < 0)
2065 tprintf(", %#lx", tcp->u_arg[5]);
2067 tprintf(", {aio_return %d aio_errno %d}",
2068 res.aio_return, res.aio_errno);
2077 struct aio_result_t res;
2079 if (entering(tcp)) {
2080 tprintf("%lu, ", tcp->u_arg[0]);
2081 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2082 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2083 printxval(whence, tcp->u_arg[4], "L_???");
2086 if (tcp->u_arg[5] == 0)
2088 else if (syserror(tcp)
2089 || umove(tcp, tcp->u_arg[5], &res) < 0)
2090 tprintf(", %#lx", tcp->u_arg[5]);
2092 tprintf(", {aio_return %d aio_errno %d}",
2093 res.aio_return, res.aio_errno);
2103 printtv(tcp, tcp->u_arg[0]);
2111 struct aio_result_t res;
2114 if (tcp->u_arg[0] == 0)
2116 else if (syserror(tcp)
2117 || umove(tcp, tcp->u_arg[0], &res) < 0)
2118 tprintf("%#lx", tcp->u_arg[0]);
2120 tprintf("{aio_return %d aio_errno %d}",
2121 res.aio_return, res.aio_errno);
2126 #endif /* HAVE_SYS_ASYNCH_H */