2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #define dirent kernel_dirent
38 #define dirent64 kernel_dirent64
39 #include <linux/types.h>
40 #include <linux/dirent.h>
43 #define kernel_dirent dirent
49 unsigned short st_dev;
51 unsigned short st_mode;
53 unsigned short st_uid;
54 unsigned short st_gid;
55 unsigned short st_rdev;
58 unsigned int __unused1;
60 unsigned int __unused2;
62 unsigned int __unused3;
65 unsigned int __unused4[2];
67 # define stat kernel_stat
68 # include <asm/stat.h>
80 # define dev_t __kernel_dev_t
81 # define ino_t __kernel_ino_t
82 # define mode_t __kernel_mode_t
83 # define nlink_t __kernel_nlink_t
84 # define uid_t __kernel_uid_t
85 # define gid_t __kernel_gid_t
86 # define off_t __kernel_off_t
87 # define loff_t __kernel_loff_t
89 # include <asm/stat.h>
102 # define mode_t mode_t
103 # define nlink_t nlink_t
107 # define loff_t loff_t
109 # define stat libc_stat
110 # define stat64 libc_stat64
111 # include <sys/stat.h>
115 # include <sys/stat.h>
121 # include <sys/cred.h>
124 #ifdef HAVE_SYS_VFS_H
129 #include <sys/param.h>
130 #include <sys/mount.h>
131 #include <sys/stat.h>
134 #ifdef MAJOR_IN_SYSMACROS
135 #include <sys/sysmacros.h>
138 #ifdef MAJOR_IN_MKDEV
139 #include <sys/mkdev.h>
142 #ifdef HAVE_SYS_ASYNCH_H
143 #include <sys/asynch.h>
151 * This is a really dirty trick but it should always work. Traditional
152 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
153 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
155 struct xlat openmodes[] = {
156 { O_RDWR+1, "O_RDWR" },
157 { O_RDONLY+1, "O_RDONLY" },
158 { O_WRONLY+1, "O_WRONLY" },
159 { O_NONBLOCK, "O_NONBLOCK" },
160 { O_APPEND, "O_APPEND" },
161 { O_CREAT, "O_CREAT" },
162 { O_TRUNC, "O_TRUNC" },
163 { O_EXCL, "O_EXCL" },
164 { O_NOCTTY, "O_NOCTTY" },
166 { O_SYNC, "O_SYNC" },
169 { O_ASYNC, "O_ASYNC" },
172 { O_DSYNC, "O_DSYNC" },
175 { O_RSYNC, "O_RSYNC" },
178 { O_NDELAY, "O_NDELAY" },
181 { O_PRIV, "O_PRIV" },
184 { O_DIRECT, "O_DIRECT" },
187 { O_LARGEFILE, "O_LARGEFILE" },
190 { O_DIRECTORY, "O_DIRECTORY" },
193 { O_NOFOLLOW, "O_NOFOLLOW" },
197 { FNDELAY, "FNDELAY" },
200 { FAPPEND, "FAPPEND" },
206 { FDEFER, "FDEFER" },
209 { FASYNC, "FASYNC" },
212 { FSHLOCK, "FSHLOCK" },
215 { FEXLOCK, "FEXLOCK" },
218 { FCREAT, "FCREAT" },
221 { FTRUNC, "FTRUNC" },
233 { FNOCTTY, "FNOCTTY" },
236 { O_SHLOCK, "O_SHLOCK" },
239 { O_EXLOCK, "O_EXLOCK" },
249 printpath(tcp, tcp->u_arg[0]);
252 printflags(openmodes, tcp->u_arg[1] + 1);
253 if (tcp->u_arg[1] & O_CREAT) {
255 tprintf(", %#lo", tcp->u_arg[2]);
262 struct xlat openmodessol[] = {
266 { 0x80, "O_NONBLOCK" },
268 { 0x100, "O_CREAT" },
269 { 0x200, "O_TRUNC" },
271 { 0x800, "O_NOCTTY" },
274 { 0x8000, "O_RSYNC" },
276 { 0x1000, "O_PRIV" },
285 printpath(tcp, tcp->u_arg[0]);
288 printflags(openmodessol, tcp->u_arg[1] + 1);
289 if (tcp->u_arg[1] & 0x100) {
291 tprintf(", %#lo", tcp->u_arg[2]);
304 printpath(tcp, tcp->u_arg[0]);
305 tprintf(", %#lo", tcp->u_arg[1]);
310 static struct xlat access_flags[] = {
316 { EFF_ONLY_OK, "EFF_ONLY_OK" },
329 printpath(tcp, tcp->u_arg[0]);
331 printflags(access_flags, tcp->u_arg[1]);
341 tprintf("%#lo", tcp->u_arg[0]);
346 static struct xlat whence[] = {
347 { SEEK_SET, "SEEK_SET" },
348 { SEEK_CUR, "SEEK_CUR" },
349 { SEEK_END, "SEEK_END" },
362 tprintf("%ld, ", tcp->u_arg[0]);
363 offset = tcp->u_arg[1];
364 _whence = tcp->u_arg[2];
365 if (_whence == SEEK_SET)
366 tprintf("%lu, ", offset);
368 tprintf("%ld, ", offset);
369 printxval(whence, _whence, "SEEK_???");
371 return RVAL_UDECIMAL;
381 if (tcp->u_arg[4] == SEEK_SET)
382 tprintf("%ld, %llu, ", tcp->u_arg[0],
383 (((long long int) tcp->u_arg[1]) << 32
384 | (unsigned long long) tcp->u_arg[2]));
386 tprintf("%ld, %lld, ", tcp->u_arg[0],
387 (((long long int) tcp->u_arg[1]) << 32
388 | (unsigned long long) tcp->u_arg[2]));
392 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
393 tprintf("%#lx, ", tcp->u_arg[3]);
395 tprintf("[%llu], ", off);
396 printxval(whence, tcp->u_arg[4], "SEEK_???");
402 #if _LFS64_LARGEFILE || FREEBSD
409 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
410 offset = get64(tcp->u_arg [1], tcp->u_arg[2]);
411 if (tcp->u_arg[3] == SEEK_SET)
412 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
414 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
415 printxval(whence, tcp->u_arg[3], "SEEK_???");
417 return RVAL_LUDECIMAL;
427 printpath(tcp, tcp->u_arg[0]);
428 tprintf(", %lu", tcp->u_arg[1]);
434 #if _LFS64_LARGEFILE || FREEBSD
441 printpath(tcp, tcp->u_arg[0]);
442 tprintf(", %llu", get64(tcp->u_arg[1],tcp->u_arg[2]));
454 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
460 #if _LFS64_LARGEFILE || FREEBSD
467 tprintf("%ld, %llu", tcp->u_arg[0],
468 get64(tcp->u_arg[1] ,tcp->u_arg[2]));
476 static struct xlat modetypes[] = {
477 { S_IFREG, "S_IFREG" },
478 { S_IFSOCK, "S_IFSOCK" },
479 { S_IFIFO, "S_IFIFO" },
480 { S_IFLNK, "S_IFLNK" },
481 { S_IFDIR, "S_IFDIR" },
482 { S_IFBLK, "S_IFBLK" },
483 { S_IFCHR, "S_IFCHR" },
494 if ((mode & S_IFMT) == 0)
496 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
497 sprintf(buf, "%#o", mode);
500 sprintf(buf, "%s%s%s%s", s,
501 (mode & S_ISUID) ? "|S_ISUID" : "",
502 (mode & S_ISGID) ? "|S_ISGID" : "",
503 (mode & S_ISVTX) ? "|S_ISVTX" : "");
504 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
506 sprintf(buf + strlen(buf), "|%#o", mode);
507 s = (*buf == '|') ? buf + 1 : buf;
523 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
524 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
525 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
537 int st_pad1[3]; /* network id */
546 int st_pad3; /* st_size, off_t expansion */
547 timestruct_t st_atime;
548 timestruct_t st_mtime;
549 timestruct_t st_ctime;
553 int st_pad4[8]; /* expansion area */
557 printstatsol(tcp, addr)
561 struct solstat statbuf;
567 if (syserror(tcp) || !verbose(tcp)) {
568 tprintf("%#lx", addr);
571 if (umove(tcp, addr, &statbuf) < 0) {
576 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
577 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
578 (unsigned long) (statbuf.st_dev & 0x3ffff),
579 (unsigned long) statbuf.st_ino,
580 sprintmode(statbuf.st_mode));
581 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
582 (unsigned long) statbuf.st_nlink,
583 (unsigned long) statbuf.st_uid,
584 (unsigned long) statbuf.st_gid);
585 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
586 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
589 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
590 switch (statbuf.st_mode & S_IFMT) {
591 case S_IFCHR: case S_IFBLK:
592 tprintf("st_rdev=makedev(%lu, %lu), ",
593 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
594 (unsigned long) (statbuf.st_rdev & 0x3ffff));
597 tprintf("st_size=%u, ", statbuf.st_size);
601 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
602 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
603 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
608 #endif /* LINUXSPARC */
611 static struct xlat fileflags[] = {
612 { UF_NODUMP, "UF_NODUMP" },
613 { UF_IMMUTABLE, "UF_IMMUTABLE" },
614 { UF_APPEND, "UF_APPEND" },
615 { UF_OPAQUE, "UF_OPAQUE" },
616 { UF_NOUNLINK, "UF_NOUNLINK" },
617 { SF_ARCHIVED, "SF_ARCHIVED" },
618 { SF_IMMUTABLE, "SF_IMMUTABLE" },
619 { SF_APPEND, "SF_APPEND" },
620 { SF_NOUNLINK, "SF_NOUNLINK" },
629 printpath(tcp, tcp->u_arg[0]);
632 printflags(fileflags, tcp->u_arg[1]);
644 tprintf("%ld, ", tcp->u_arg[0]);
646 printflags(fileflags, tcp->u_arg[1]);
655 realprintstat(tcp, statbuf)
657 struct stat *statbuf;
660 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
661 (unsigned long) major(statbuf->st_dev),
662 (unsigned long) minor(statbuf->st_dev),
663 (unsigned long) statbuf->st_ino,
664 sprintmode(statbuf->st_mode));
665 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
666 (unsigned long) statbuf->st_nlink,
667 (unsigned long) statbuf->st_uid,
668 (unsigned long) statbuf->st_gid);
669 #ifdef HAVE_ST_BLKSIZE
670 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
671 #endif /* HAVE_ST_BLKSIZE */
672 #ifdef HAVE_ST_BLOCKS
673 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
674 #endif /* HAVE_ST_BLOCKS */
677 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
678 switch (statbuf->st_mode & S_IFMT) {
679 case S_IFCHR: case S_IFBLK:
681 tprintf("st_rdev=makedev(%lu, %lu), ",
682 (unsigned long) major(statbuf->st_rdev),
683 (unsigned long) minor(statbuf->st_rdev));
684 #else /* !HAVE_ST_RDEV */
685 tprintf("st_size=makedev(%lu, %lu), ",
686 (unsigned long) major(statbuf->st_size),
687 (unsigned long) minor(statbuf->st_size));
688 #endif /* !HAVE_ST_RDEV */
691 tprintf("st_size=%lu, ", statbuf->st_size);
695 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
696 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
698 tprintf("st_ctime=%s}", sprinttime(statbuf->st_ctime));
700 tprintf("st_ctime=%s, ", sprinttime(statbuf->st_ctime));
701 tprintf("st_flags=");
702 if (statbuf->st_flags) {
703 printflags(fileflags, statbuf->st_flags);
706 tprintf(", st_gen=%u}", statbuf->st_gen);
722 if (current_personality == 1) {
723 printstatsol(tcp, addr);
726 #endif /* LINUXSPARC */
732 if (syserror(tcp) || !verbose(tcp)) {
733 tprintf("%#lx", addr);
736 if (umove(tcp, addr, &statbuf) < 0) {
741 realprintstat(tcp, &statbuf);
746 printstat64(tcp, addr)
750 struct stat64 statbuf;
753 if (current_personality == 1) {
754 printstatsol(tcp, addr);
757 #endif /* LINUXSPARC */
763 if (syserror(tcp) || !verbose(tcp)) {
764 tprintf("%#lx", addr);
767 if (umove(tcp, addr, &statbuf) < 0) {
773 #ifdef HAVE_LONG_LONG
774 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
776 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
778 (unsigned long) major(statbuf.st_dev),
779 (unsigned long) minor(statbuf.st_dev),
780 #ifdef HAVE_LONG_LONG
781 (unsigned long long) statbuf.st_ino,
783 (unsigned long) statbuf.st_ino,
785 sprintmode(statbuf.st_mode));
786 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
787 (unsigned long) statbuf.st_nlink,
788 (unsigned long) statbuf.st_uid,
789 (unsigned long) statbuf.st_gid);
790 #ifdef HAVE_ST_BLKSIZE
791 tprintf("st_blksize=%lu, ",
792 (unsigned long) statbuf.st_blksize);
793 #endif /* HAVE_ST_BLKSIZE */
794 #ifdef HAVE_ST_BLOCKS
795 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
796 #endif /* HAVE_ST_BLOCKS */
799 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
800 switch (statbuf.st_mode & S_IFMT) {
801 case S_IFCHR: case S_IFBLK:
803 tprintf("st_rdev=makedev(%lu, %lu), ",
804 (unsigned long) major(statbuf.st_rdev),
805 (unsigned long) minor(statbuf.st_rdev));
806 #else /* !HAVE_ST_RDEV */
807 tprintf("st_size=makedev(%lu, %lu), ",
808 (unsigned long) major(statbuf.st_size),
809 (unsigned long) minor(statbuf.st_size));
810 #endif /* !HAVE_ST_RDEV */
813 tprintf("st_size=%llu, ", statbuf.st_size);
817 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
818 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
819 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
824 #endif /* HAVE_STAT64 */
826 #if defined(linux) && !defined(IA64)
828 convertoldstat(oldbuf, newbuf)
829 const struct __old_kernel_stat *oldbuf;
832 newbuf->st_dev=oldbuf->st_dev;
833 newbuf->st_ino=oldbuf->st_ino;
834 newbuf->st_mode=oldbuf->st_mode;
835 newbuf->st_nlink=oldbuf->st_nlink;
836 newbuf->st_uid=oldbuf->st_uid;
837 newbuf->st_gid=oldbuf->st_gid;
838 newbuf->st_rdev=oldbuf->st_rdev;
839 newbuf->st_size=oldbuf->st_size;
840 newbuf->st_atime=oldbuf->st_atime;
841 newbuf->st_mtime=oldbuf->st_mtime;
842 newbuf->st_ctime=oldbuf->st_ctime;
843 newbuf->st_blksize=0; /* not supported in old_stat */
844 newbuf->st_blocks=0; /* not supported in old_stat */
849 printoldstat(tcp, addr)
853 struct __old_kernel_stat statbuf;
854 struct stat newstatbuf;
857 if (current_personality == 1) {
858 printstatsol(tcp, addr);
861 #endif /* LINUXSPARC */
867 if (syserror(tcp) || !verbose(tcp)) {
868 tprintf("%#lx", addr);
871 if (umove(tcp, addr, &statbuf) < 0) {
876 convertoldstat(&statbuf, &newstatbuf);
877 realprintstat(tcp, &newstatbuf);
879 #endif /* linux && !IA64 */
887 printpath(tcp, tcp->u_arg[0]);
890 printstat(tcp, tcp->u_arg[1]);
902 printpath(tcp, tcp->u_arg[0]);
905 printstat64(tcp, tcp->u_arg[1]);
909 return printargs(tcp);
919 printpath(tcp, tcp->u_arg[0]);
922 printoldstat(tcp, tcp->u_arg[1]);
934 tprintf("%ld, ", tcp->u_arg[0]);
936 printstat(tcp, tcp->u_arg[1]);
948 tprintf("%ld, ", tcp->u_arg[0]);
950 printstat64(tcp, tcp->u_arg[1]);
954 return printargs(tcp);
964 tprintf("%ld, ", tcp->u_arg[0]);
966 printoldstat(tcp, tcp->u_arg[1]);
978 printpath(tcp, tcp->u_arg[0]);
981 printstat(tcp, tcp->u_arg[1]);
993 printpath(tcp, tcp->u_arg[0]);
996 printstat64(tcp, tcp->u_arg[1]);
1000 return printargs(tcp);
1009 if (entering(tcp)) {
1010 printpath(tcp, tcp->u_arg[0]);
1013 printoldstat(tcp, tcp->u_arg[1]);
1021 #if defined(SVR4) || defined(LINUXSPARC)
1027 if (entering(tcp)) {
1028 tprintf("%ld, ", tcp->u_arg[0]);
1029 printpath(tcp, tcp->u_arg[1]);
1033 if (tcp->u_arg[0] == _STAT64_VER)
1034 printstat64 (tcp, tcp->u_arg[2]);
1037 printstat(tcp, tcp->u_arg[2]);
1047 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1050 if (tcp->u_arg[0] == _STAT64_VER)
1051 printstat64 (tcp, tcp->u_arg[2]);
1054 printstat(tcp, tcp->u_arg[2]);
1063 if (entering(tcp)) {
1064 tprintf("%ld, ", tcp->u_arg[0]);
1065 printpath(tcp, tcp->u_arg[1]);
1069 if (tcp->u_arg[0] == _STAT64_VER)
1070 printstat64 (tcp, tcp->u_arg[2]);
1073 printstat(tcp, tcp->u_arg[2]);
1082 int mode = tcp->u_arg[2];
1084 if (entering(tcp)) {
1085 tprintf("%ld, ", tcp->u_arg[0]);
1086 printpath(tcp, tcp->u_arg[1]);
1087 tprintf(", %s", sprintmode(mode));
1088 switch (mode & S_IFMT) {
1089 case S_IFCHR: case S_IFBLK:
1091 tprintf(", makedev(%lu, %lu)",
1092 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1093 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1095 tprintf(", makedev(%lu, %lu)",
1096 (unsigned long) major(tcp->u_arg[3]),
1097 (unsigned long) minor(tcp->u_arg[3]));
1107 #ifdef HAVE_SYS_ACL_H
1109 #include <sys/acl.h>
1111 struct xlat aclcmds[] = {
1113 { SETACL, "SETACL" },
1116 { GETACL, "GETACL" },
1119 { GETACLCNT, "GETACLCNT" },
1122 { ACL_GET, "ACL_GET" },
1125 { ACL_SET, "ACL_SET" },
1128 { ACL_CNT, "ACL_CNT" },
1137 if (entering(tcp)) {
1138 printpath(tcp, tcp->u_arg[0]);
1140 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1141 tprintf(", %ld", tcp->u_arg[2]);
1143 * FIXME - dump out the list of aclent_t's pointed to
1144 * by "tcp->u_arg[3]" if it's not NULL.
1147 tprintf(", %#lx", tcp->u_arg[3]);
1159 if (entering(tcp)) {
1160 tprintf("%ld, ", tcp->u_arg[0]);
1161 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1162 tprintf(", %ld", tcp->u_arg[2]);
1164 * FIXME - dump out the list of aclent_t's pointed to
1165 * by "tcp->u_arg[3]" if it's not NULL.
1168 tprintf(", %#lx", tcp->u_arg[3]);
1176 struct xlat aclipc[] = {
1178 { IPC_SHM, "IPC_SHM" },
1181 { IPC_SEM, "IPC_SEM" },
1184 { IPC_MSG, "IPC_MSG" },
1194 if (entering(tcp)) {
1195 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1196 tprintf(", %#lx, ", tcp->u_arg[1]);
1197 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1198 tprintf(", %ld", tcp->u_arg[3]);
1200 * FIXME - dump out the list of aclent_t's pointed to
1201 * by "tcp->u_arg[4]" if it's not NULL.
1204 tprintf(", %#lx", tcp->u_arg[4]);
1213 #endif /* HAVE_SYS_ACL_H */
1215 #endif /* SVR4 || LINUXSPARC */
1219 static struct xlat fsmagic[] = {
1220 { 0x73757245, "CODA_SUPER_MAGIC" },
1221 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1222 { 0x1373, "DEVFS_SUPER_MAGIC" },
1223 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1224 { 0x414A53, "EFS_SUPER_MAGIC" },
1225 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1226 { 0xef53, "EXT2_SUPER_MAGIC" },
1227 { 0x137d, "EXT_SUPER_MAGIC" },
1228 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1229 { 0x9660, "ISOFS_SUPER_MAGIC" },
1230 { 0x137f, "MINIX_SUPER_MAGIC" },
1231 { 0x138f, "MINIX_SUPER_MAGIC2" },
1232 { 0x2468, "MINIX2_SUPER_MAGIC" },
1233 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1234 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1235 { 0x564c, "NCP_SUPER_MAGIC" },
1236 { 0x6969, "NFS_SUPER_MAGIC" },
1237 { 0x9fa0, "PROC_SUPER_MAGIC" },
1238 { 0x002f, "QNX4_SUPER_MAGIC" },
1239 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1240 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1241 { 0x517b, "SMB_SUPER_MAGIC" },
1242 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1243 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1244 { 0x00011954, "UFS_MAGIC" },
1245 { 0x54190100, "UFS_CIGAM" },
1246 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1247 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1259 static char buf[32];
1263 s = xlookup(fsmagic, magic);
1265 sprintf(buf, "\"%s\"", s);
1269 sprintf(buf, "%#x", magic);
1274 printstatfs(tcp, addr)
1278 struct statfs statbuf;
1280 if (syserror(tcp) || !verbose(tcp)) {
1281 tprintf("%#lx", addr);
1284 if (umove(tcp, addr, &statbuf) < 0) {
1290 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1291 sprintfstype(statbuf.f_type),
1292 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1293 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
1294 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1296 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1297 sprintfstype(statbuf.f_type),
1298 (unsigned long)statbuf.f_bsize,
1299 (unsigned long)statbuf.f_blocks,
1300 (unsigned long)statbuf.f_bfree);
1301 tprintf("f_files=%lu, f_ffree=%lu",
1302 (unsigned long)statbuf.f_files,
1303 (unsigned long)statbuf.f_ffree);
1305 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1315 if (entering(tcp)) {
1316 printpath(tcp, tcp->u_arg[0]);
1319 printstatfs(tcp, tcp->u_arg[1]);
1328 if (entering(tcp)) {
1329 tprintf("%lu, ", tcp->u_arg[0]);
1331 printstatfs(tcp, tcp->u_arg[1]);
1336 #if defined(linux) && defined(__alpha)
1342 if (entering(tcp)) {
1343 printpath(tcp, tcp->u_arg[0]);
1346 printstatfs(tcp, tcp->u_arg[1]);
1347 tprintf(", %lu", tcp->u_arg[2]);
1356 if (entering(tcp)) {
1357 tprintf("%lu, ", tcp->u_arg[0]);
1359 printstatfs(tcp, tcp->u_arg[1]);
1360 tprintf(", %lu", tcp->u_arg[2]);
1364 #endif /* linux && __alpha */
1374 struct ustat statbuf;
1376 if (entering(tcp)) {
1377 tprintf("makedev(%lu, %lu), ",
1378 (long) major(tcp->u_arg[0]),
1379 (long) minor(tcp->u_arg[0]));
1382 if (syserror(tcp) || !verbose(tcp))
1383 tprintf("%#lx", tcp->u_arg[1]);
1384 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1387 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1388 statbuf.f_tfree, statbuf.f_tinode);
1389 tprintf("f_fname=\"%.*s\", ",
1390 (int) sizeof(statbuf.f_fname),
1392 tprintf("f_fpack=\"%.*s\"}",
1393 (int) sizeof(statbuf.f_fpack),
1406 if (entering(tcp)) {
1407 printpath(tcp, tcp->u_arg[0]);
1409 printpath(tcp, tcp->u_arg[1]);
1420 if (entering(tcp)) {
1421 printpath(tcp, tcp->u_arg[0]);
1430 if (entering(tcp)) {
1431 printpath(tcp, tcp->u_arg[0]);
1432 tprintf(", %#lo", tcp->u_arg[1]);
1441 if (entering(tcp)) {
1442 printpath(tcp, tcp->u_arg[0]);
1451 if (entering(tcp)) {
1452 tprintf("%ld", tcp->u_arg[0]);
1461 if (entering(tcp)) {
1462 printpath(tcp, tcp->u_arg[0]);
1471 if (entering(tcp)) {
1472 tprintf("%ld", tcp->u_arg[0]);
1481 if (entering(tcp)) {
1482 printpath(tcp, tcp->u_arg[0]);
1484 printpath(tcp, tcp->u_arg[1]);
1493 if (entering(tcp)) {
1494 printpath(tcp, tcp->u_arg[0]);
1503 if (entering(tcp)) {
1504 printpath(tcp, tcp->u_arg[0]);
1506 printpath(tcp, tcp->u_arg[1]);
1515 if (entering(tcp)) {
1516 printpath(tcp, tcp->u_arg[0]);
1520 tprintf("%#lx", tcp->u_arg[1]);
1522 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1523 tprintf(", %lu", tcp->u_arg[2]);
1532 if (entering(tcp)) {
1533 printpath(tcp, tcp->u_arg[0]);
1535 printpath(tcp, tcp->u_arg[1]);
1544 if (entering(tcp)) {
1545 printpath(tcp, tcp->u_arg[0]);
1546 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1555 if (entering(tcp)) {
1556 tprintf("%ld, %lu, %lu",
1557 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1566 if (entering(tcp)) {
1567 printpath(tcp, tcp->u_arg[0]);
1568 tprintf(", %#lo", tcp->u_arg[1]);
1577 if (entering(tcp)) {
1578 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1588 if (entering(tcp)) {
1589 printpath(tcp, tcp->u_arg[0]);
1591 printtv32(tcp, tcp->u_arg[1]);
1601 if (entering(tcp)) {
1602 printpath(tcp, tcp->u_arg[0]);
1604 printtv(tcp, tcp->u_arg[1]);
1615 if (entering(tcp)) {
1616 printpath(tcp, tcp->u_arg[0]);
1620 else if (!verbose(tcp))
1621 tprintf("%#lx", tcp->u_arg[1]);
1622 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1626 tprintf("[%s,", sprinttime(ut[0]));
1627 tprintf(" %s]", sprinttime(ut[1]));
1637 int mode = tcp->u_arg[1];
1639 if (entering(tcp)) {
1640 printpath(tcp, tcp->u_arg[0]);
1641 tprintf(", %s", sprintmode(mode));
1642 switch (mode & S_IFMT) {
1643 case S_IFCHR: case S_IFBLK:
1645 if (current_personality == 1)
1646 tprintf(", makedev(%lu, %lu)",
1647 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1648 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1651 tprintf(", makedev(%lu, %lu)",
1652 (unsigned long) major(tcp->u_arg[2]),
1653 (unsigned long) minor(tcp->u_arg[2]));
1666 if (entering(tcp)) {
1667 printpath(tcp, tcp->u_arg[0]);
1668 tprintf(", %#lo", tcp->u_arg[1]);
1677 if (entering(tcp)) {
1678 tprintf("%ld", tcp->u_arg[0]);
1692 if (!verbose(tcp)) {
1693 tprintf("%#lx", addr);
1696 if (umove(tcp, addr, &d) < 0) {
1700 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1702 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1710 if (entering(tcp)) {
1711 tprintf("%lu, ", tcp->u_arg[0]);
1713 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1714 tprintf("%#lx", tcp->u_arg[1]);
1716 printdir(tcp, tcp->u_arg[1]);
1717 /* Not much point in printing this out, it is always 1. */
1718 if (tcp->u_arg[2] != 1)
1719 tprintf(", %lu", tcp->u_arg[2]);
1727 struct xlat direnttypes[] = {
1728 { DT_FIFO, "DT_FIFO" },
1729 { DT_CHR, "DT_CHR" },
1730 { DT_DIR, "DT_DIR" },
1731 { DT_BLK, "DT_BLK" },
1732 { DT_REG, "DT_REG" },
1733 { DT_LNK, "DT_LNK" },
1734 { DT_SOCK, "DT_SOCK" },
1735 { DT_WHT, "DT_WHT" },
1745 int i, len, dents = 0;
1748 if (entering(tcp)) {
1749 tprintf("%lu, ", tcp->u_arg[0]);
1752 if (syserror(tcp) || !verbose(tcp)) {
1753 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1757 if ((buf = malloc(len)) == NULL) {
1758 tprintf("out of memory\n");
1761 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1762 tprintf("{...}, %lu", tcp->u_arg[2]);
1768 for (i = 0; i < len;) {
1769 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1772 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1773 i ? " " : "", d->d_ino, d->d_off);
1774 tprintf("d_reclen=%u, d_name=\"%s\"}",
1775 d->d_reclen, d->d_name);
1780 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1781 i ? " " : "", d->d_ino, d->d_off);
1782 tprintf("d_reclen=%u, d_name=\"%s\"}",
1783 d->d_reclen, d->d_name);
1788 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1789 i ? " " : "", d->d_off, d->d_fileno,
1791 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1792 d->d_namlen, d->d_namlen, d->d_name);
1797 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1798 i ? " " : "", d->d_fileno, d->d_reclen);
1799 printxval(direnttypes, d->d_type, "DT_???");
1800 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1801 d->d_namlen, d->d_namlen, d->d_name);
1803 #endif /* FREEBSD */
1805 tprintf("/* d_reclen == 0, problem here */");
1814 tprintf("/* %u entries */", dents);
1815 tprintf(", %lu", tcp->u_arg[2]);
1821 #if _LFS64_LARGEFILE
1826 int i, len, dents = 0;
1829 if (entering(tcp)) {
1830 tprintf("%lu, ", tcp->u_arg[0]);
1833 if (syserror(tcp) || !verbose(tcp)) {
1834 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1838 if ((buf = malloc(len)) == NULL) {
1839 tprintf("out of memory\n");
1842 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1843 tprintf("{...}, %lu", tcp->u_arg[2]);
1849 for (i = 0; i < len;) {
1850 struct dirent64 *d = (struct dirent64 *) &buf[i];
1853 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1854 i ? " " : "", d->d_ino, d->d_off);
1855 tprintf("d_reclen=%u, d_name=\"%s\"}",
1856 d->d_reclen, d->d_name);
1861 tprintf("%s{d_ino=%llu, d_off=%llu, ",
1862 i ? " " : "", d->d_ino, d->d_off);
1863 tprintf("d_reclen=%u, d_name=\"%s\"}",
1864 d->d_reclen, d->d_name);
1869 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1870 i ? " " : "", d->d_off, d->d_fileno,
1872 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1873 d->d_namlen, d->d_namlen, d->d_name);
1882 tprintf("/* %u entries */", dents);
1883 tprintf(", %lu", tcp->u_arg[2]);
1891 sys_getdirentries(tcp)
1894 int i, len, dents = 0;
1898 if (entering(tcp)) {
1899 tprintf("%lu, ", tcp->u_arg[0]);
1902 if (syserror(tcp) || !verbose(tcp)) {
1903 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1907 if ((buf = malloc(len)) == NULL) {
1908 tprintf("out of memory\n");
1911 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1912 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
1918 for (i = 0; i < len;) {
1919 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1921 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1922 i ? " " : "", d->d_fileno, d->d_reclen);
1923 printxval(direnttypes, d->d_type, "DT_???");
1924 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1925 d->d_namlen, d->d_namlen, d->d_name);
1933 tprintf("/* %u entries */", dents);
1935 tprintf(", %lu", tcp->u_arg[2]);
1936 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
1937 tprintf(", %#lx", tcp->u_arg[3]);
1939 tprintf(", [%lu]", basep);
1951 tprintf("%#lx", tcp->u_arg[0]);
1953 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
1954 tprintf(", %lu", tcp->u_arg[1]);
1967 tprintf("%#lx", tcp->u_arg[0]);
1969 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
1970 tprintf(", %lu", tcp->u_arg[1]);
1976 #ifdef HAVE_SYS_ASYNCH_H
1982 struct aio_result_t res;
1984 if (entering(tcp)) {
1985 tprintf("%lu, ", tcp->u_arg[0]);
1988 tprintf("%#lx", tcp->u_arg[1]);
1990 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1991 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
1992 printxval(whence, tcp->u_arg[4], "L_???");
1993 if (syserror(tcp) || tcp->u_arg[5] == 0
1994 || umove(tcp, tcp->u_arg[5], &res) < 0)
1995 tprintf(", %#lx", tcp->u_arg[5]);
1997 tprintf(", {aio_return %d aio_errno %d}",
1998 res.aio_return, res.aio_errno);
2007 struct aio_result_t res;
2009 if (entering(tcp)) {
2010 tprintf("%lu, ", tcp->u_arg[0]);
2011 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2012 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2013 printxval(whence, tcp->u_arg[4], "L_???");
2016 if (tcp->u_arg[5] == 0)
2018 else if (syserror(tcp)
2019 || umove(tcp, tcp->u_arg[5], &res) < 0)
2020 tprintf(", %#lx", tcp->u_arg[5]);
2022 tprintf(", {aio_return %d aio_errno %d}",
2023 res.aio_return, res.aio_errno);
2033 printtv(tcp, tcp->u_arg[0]);
2041 struct aio_result_t res;
2044 if (tcp->u_arg[0] == 0)
2046 else if (syserror(tcp)
2047 || umove(tcp, tcp->u_arg[0], &res) < 0)
2048 tprintf("%#lx", tcp->u_arg[0]);
2050 tprintf("{aio_return %d aio_errno %d}",
2051 res.aio_return, res.aio_errno);
2056 #endif /* HAVE_SYS_ASYNCH_H */