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" },
361 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);
370 offset = ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2];
371 _whence = tcp->u_arg[4];
372 if (_whence == SEEK_SET)
373 tprintf("%llu, ", offset);
375 tprintf("%lld, ", offset);
377 printxval(whence, _whence, "SEEK_???");
382 return RVAL_LUDECIMAL;
384 return RVAL_UDECIMAL;
393 if (tcp->u_arg[4] == SEEK_SET)
394 tprintf("%ld, %llu, ", tcp->u_arg[0],
395 (((long long int) tcp->u_arg[1]) << 32
396 | (unsigned long long) tcp->u_arg[2]));
398 tprintf("%ld, %lld, ", tcp->u_arg[0],
399 (((long long int) tcp->u_arg[1]) << 32
400 | (unsigned long long) tcp->u_arg[2]));
404 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
405 tprintf("%#lx, ", tcp->u_arg[3]);
407 tprintf("[%llu], ", off);
408 printxval(whence, tcp->u_arg[4], "SEEK_???");
419 printpath(tcp, tcp->u_arg[0]);
421 tprintf(", %lu", tcp->u_arg[1]);
423 tprintf(", %llu", ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2]);
435 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
437 tprintf("%ld, %llu", tcp->u_arg[0],
438 ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2]);
446 static struct xlat modetypes[] = {
447 { S_IFREG, "S_IFREG" },
448 { S_IFSOCK, "S_IFSOCK" },
449 { S_IFIFO, "S_IFIFO" },
450 { S_IFLNK, "S_IFLNK" },
451 { S_IFDIR, "S_IFDIR" },
452 { S_IFBLK, "S_IFBLK" },
453 { S_IFCHR, "S_IFCHR" },
464 if ((mode & S_IFMT) == 0)
466 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
467 sprintf(buf, "%#o", mode);
470 sprintf(buf, "%s%s%s%s", s,
471 (mode & S_ISUID) ? "|S_ISUID" : "",
472 (mode & S_ISGID) ? "|S_ISGID" : "",
473 (mode & S_ISVTX) ? "|S_ISVTX" : "");
474 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
476 sprintf(buf + strlen(buf), "|%#o", mode);
477 s = (*buf == '|') ? buf + 1 : buf;
493 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
494 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
495 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
507 int st_pad1[3]; /* network id */
516 int st_pad3; /* st_size, off_t expansion */
517 timestruct_t st_atime;
518 timestruct_t st_mtime;
519 timestruct_t st_ctime;
523 int st_pad4[8]; /* expansion area */
527 printstatsol(tcp, addr)
531 struct solstat statbuf;
537 if (syserror(tcp) || !verbose(tcp)) {
538 tprintf("%#lx", addr);
541 if (umove(tcp, addr, &statbuf) < 0) {
546 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
547 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
548 (unsigned long) (statbuf.st_dev & 0x3ffff),
549 (unsigned long) statbuf.st_ino,
550 sprintmode(statbuf.st_mode));
551 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
552 (unsigned long) statbuf.st_nlink,
553 (unsigned long) statbuf.st_uid,
554 (unsigned long) statbuf.st_gid);
555 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
556 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
559 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
560 switch (statbuf.st_mode & S_IFMT) {
561 case S_IFCHR: case S_IFBLK:
562 tprintf("st_rdev=makedev(%lu, %lu), ",
563 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
564 (unsigned long) (statbuf.st_rdev & 0x3ffff));
567 tprintf("st_size=%u, ", statbuf.st_size);
571 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
572 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
573 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
578 #endif /* LINUXSPARC */
581 static struct xlat fileflags[] = {
582 { UF_NODUMP, "UF_NODUMP" },
583 { UF_IMMUTABLE, "UF_IMMUTABLE" },
584 { UF_APPEND, "UF_APPEND" },
585 { UF_OPAQUE, "UF_OPAQUE" },
586 { UF_NOUNLINK, "UF_NOUNLINK" },
587 { SF_ARCHIVED, "SF_ARCHIVED" },
588 { SF_IMMUTABLE, "SF_IMMUTABLE" },
589 { SF_APPEND, "SF_APPEND" },
590 { SF_NOUNLINK, "SF_NOUNLINK" },
599 printpath(tcp, tcp->u_arg[0]);
602 printflags(fileflags, tcp->u_arg[1]);
614 tprintf("%ld, ", tcp->u_arg[0]);
616 printflags(fileflags, tcp->u_arg[1]);
625 realprintstat(tcp, statbuf)
627 struct stat *statbuf;
630 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
631 (unsigned long) major(statbuf->st_dev),
632 (unsigned long) minor(statbuf->st_dev),
633 (unsigned long) statbuf->st_ino,
634 sprintmode(statbuf->st_mode));
635 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
636 (unsigned long) statbuf->st_nlink,
637 (unsigned long) statbuf->st_uid,
638 (unsigned long) statbuf->st_gid);
639 #ifdef HAVE_ST_BLKSIZE
640 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
641 #endif /* HAVE_ST_BLKSIZE */
642 #ifdef HAVE_ST_BLOCKS
643 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
644 #endif /* HAVE_ST_BLOCKS */
647 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
648 switch (statbuf->st_mode & S_IFMT) {
649 case S_IFCHR: case S_IFBLK:
651 tprintf("st_rdev=makedev(%lu, %lu), ",
652 (unsigned long) major(statbuf->st_rdev),
653 (unsigned long) minor(statbuf->st_rdev));
654 #else /* !HAVE_ST_RDEV */
655 tprintf("st_size=makedev(%lu, %lu), ",
656 (unsigned long) major(statbuf->st_size),
657 (unsigned long) minor(statbuf->st_size));
658 #endif /* !HAVE_ST_RDEV */
661 tprintf("st_size=%lu, ", statbuf->st_size);
665 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
666 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
668 tprintf("st_ctime=%s}", sprinttime(statbuf->st_ctime));
670 tprintf("st_ctime=%s, ", sprinttime(statbuf->st_ctime));
671 tprintf("st_flags=");
672 if (statbuf->st_flags) {
673 printflags(fileflags, statbuf->st_flags);
676 tprintf(", st_gen=%u}", statbuf->st_gen);
692 if (current_personality == 1) {
693 printstatsol(tcp, addr);
696 #endif /* LINUXSPARC */
702 if (syserror(tcp) || !verbose(tcp)) {
703 tprintf("%#lx", addr);
706 if (umove(tcp, addr, &statbuf) < 0) {
711 realprintstat(tcp, &statbuf);
716 printstat64(tcp, addr)
720 struct stat64 statbuf;
723 if (current_personality == 1) {
724 printstatsol(tcp, addr);
727 #endif /* LINUXSPARC */
733 if (syserror(tcp) || !verbose(tcp)) {
734 tprintf("%#lx", addr);
737 if (umove(tcp, addr, &statbuf) < 0) {
743 #ifdef HAVE_LONG_LONG
744 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
746 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
748 (unsigned long) major(statbuf.st_dev),
749 (unsigned long) minor(statbuf.st_dev),
750 #ifdef HAVE_LONG_LONG
751 (unsigned long long) statbuf.st_ino,
753 (unsigned long) statbuf.st_ino,
755 sprintmode(statbuf.st_mode));
756 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
757 (unsigned long) statbuf.st_nlink,
758 (unsigned long) statbuf.st_uid,
759 (unsigned long) statbuf.st_gid);
760 #ifdef HAVE_ST_BLKSIZE
761 tprintf("st_blksize=%lu, ",
762 (unsigned long) statbuf.st_blksize);
763 #endif /* HAVE_ST_BLKSIZE */
764 #ifdef HAVE_ST_BLOCKS
765 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
766 #endif /* HAVE_ST_BLOCKS */
769 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
770 switch (statbuf.st_mode & S_IFMT) {
771 case S_IFCHR: case S_IFBLK:
773 tprintf("st_rdev=makedev(%lu, %lu), ",
774 (unsigned long) major(statbuf.st_rdev),
775 (unsigned long) minor(statbuf.st_rdev));
776 #else /* !HAVE_ST_RDEV */
777 tprintf("st_size=makedev(%lu, %lu), ",
778 (unsigned long) major(statbuf.st_size),
779 (unsigned long) minor(statbuf.st_size));
780 #endif /* !HAVE_ST_RDEV */
783 tprintf("st_size=%llu, ", statbuf.st_size);
787 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
788 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
789 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
794 #endif /* HAVE_STAT64 */
796 #if defined(linux) && !defined(IA64)
798 convertoldstat(oldbuf, newbuf)
799 const struct __old_kernel_stat *oldbuf;
802 newbuf->st_dev=oldbuf->st_dev;
803 newbuf->st_ino=oldbuf->st_ino;
804 newbuf->st_mode=oldbuf->st_mode;
805 newbuf->st_nlink=oldbuf->st_nlink;
806 newbuf->st_uid=oldbuf->st_uid;
807 newbuf->st_gid=oldbuf->st_gid;
808 newbuf->st_rdev=oldbuf->st_rdev;
809 newbuf->st_size=oldbuf->st_size;
810 newbuf->st_atime=oldbuf->st_atime;
811 newbuf->st_mtime=oldbuf->st_mtime;
812 newbuf->st_ctime=oldbuf->st_ctime;
813 newbuf->st_blksize=0; /* not supported in old_stat */
814 newbuf->st_blocks=0; /* not supported in old_stat */
819 printoldstat(tcp, addr)
823 struct __old_kernel_stat statbuf;
824 struct stat newstatbuf;
827 if (current_personality == 1) {
828 printstatsol(tcp, addr);
831 #endif /* LINUXSPARC */
837 if (syserror(tcp) || !verbose(tcp)) {
838 tprintf("%#lx", addr);
841 if (umove(tcp, addr, &statbuf) < 0) {
846 convertoldstat(&statbuf, &newstatbuf);
847 realprintstat(tcp, &newstatbuf);
849 #endif /* linux && !IA64 */
857 printpath(tcp, tcp->u_arg[0]);
860 printstat(tcp, tcp->u_arg[1]);
872 printpath(tcp, tcp->u_arg[0]);
875 printstat64(tcp, tcp->u_arg[1]);
879 return printargs(tcp);
889 printpath(tcp, tcp->u_arg[0]);
892 printoldstat(tcp, tcp->u_arg[1]);
904 tprintf("%ld, ", tcp->u_arg[0]);
906 printstat(tcp, tcp->u_arg[1]);
918 tprintf("%ld, ", tcp->u_arg[0]);
920 printstat64(tcp, tcp->u_arg[1]);
924 return printargs(tcp);
934 tprintf("%ld, ", tcp->u_arg[0]);
936 printoldstat(tcp, tcp->u_arg[1]);
948 printpath(tcp, tcp->u_arg[0]);
951 printstat(tcp, tcp->u_arg[1]);
963 printpath(tcp, tcp->u_arg[0]);
966 printstat64(tcp, tcp->u_arg[1]);
970 return printargs(tcp);
980 printpath(tcp, tcp->u_arg[0]);
983 printoldstat(tcp, tcp->u_arg[1]);
991 #if defined(SVR4) || defined(LINUXSPARC)
998 tprintf("%ld, ", tcp->u_arg[0]);
999 printpath(tcp, tcp->u_arg[1]);
1003 if (tcp->u_arg[0] == _STAT64_VER)
1004 printstat64 (tcp, tcp->u_arg[2]);
1007 printstat(tcp, tcp->u_arg[2]);
1017 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1020 if (tcp->u_arg[0] == _STAT64_VER)
1021 printstat64 (tcp, tcp->u_arg[2]);
1024 printstat(tcp, tcp->u_arg[2]);
1033 if (entering(tcp)) {
1034 tprintf("%ld, ", tcp->u_arg[0]);
1035 printpath(tcp, tcp->u_arg[1]);
1039 if (tcp->u_arg[0] == _STAT64_VER)
1040 printstat64 (tcp, tcp->u_arg[2]);
1043 printstat(tcp, tcp->u_arg[2]);
1052 int mode = tcp->u_arg[2];
1054 if (entering(tcp)) {
1055 tprintf("%ld, ", tcp->u_arg[0]);
1056 printpath(tcp, tcp->u_arg[1]);
1057 tprintf(", %s", sprintmode(mode));
1058 switch (mode & S_IFMT) {
1059 case S_IFCHR: case S_IFBLK:
1061 tprintf(", makedev(%lu, %lu)",
1062 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1063 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1065 tprintf(", makedev(%lu, %lu)",
1066 (unsigned long) major(tcp->u_arg[3]),
1067 (unsigned long) minor(tcp->u_arg[3]));
1077 #ifdef HAVE_SYS_ACL_H
1079 #include <sys/acl.h>
1081 struct xlat aclcmds[] = {
1083 { SETACL, "SETACL" },
1086 { GETACL, "GETACL" },
1089 { GETACLCNT, "GETACLCNT" },
1092 { ACL_GET, "ACL_GET" },
1095 { ACL_SET, "ACL_SET" },
1098 { ACL_CNT, "ACL_CNT" },
1107 if (entering(tcp)) {
1108 printpath(tcp, tcp->u_arg[0]);
1110 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1111 tprintf(", %ld", tcp->u_arg[2]);
1113 * FIXME - dump out the list of aclent_t's pointed to
1114 * by "tcp->u_arg[3]" if it's not NULL.
1117 tprintf(", %#lx", tcp->u_arg[3]);
1129 if (entering(tcp)) {
1130 tprintf("%ld, ", tcp->u_arg[0]);
1131 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1132 tprintf(", %ld", tcp->u_arg[2]);
1134 * FIXME - dump out the list of aclent_t's pointed to
1135 * by "tcp->u_arg[3]" if it's not NULL.
1138 tprintf(", %#lx", tcp->u_arg[3]);
1146 struct xlat aclipc[] = {
1148 { IPC_SHM, "IPC_SHM" },
1151 { IPC_SEM, "IPC_SEM" },
1154 { IPC_MSG, "IPC_MSG" },
1164 if (entering(tcp)) {
1165 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1166 tprintf(", %#lx, ", tcp->u_arg[1]);
1167 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1168 tprintf(", %ld", tcp->u_arg[3]);
1170 * FIXME - dump out the list of aclent_t's pointed to
1171 * by "tcp->u_arg[4]" if it's not NULL.
1174 tprintf(", %#lx", tcp->u_arg[4]);
1183 #endif /* HAVE_SYS_ACL_H */
1185 #endif /* SVR4 || LINUXSPARC */
1189 static struct xlat fsmagic[] = {
1190 { 0x73757245, "CODA_SUPER_MAGIC" },
1191 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1192 { 0x1373, "DEVFS_SUPER_MAGIC" },
1193 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1194 { 0x414A53, "EFS_SUPER_MAGIC" },
1195 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1196 { 0xef53, "EXT2_SUPER_MAGIC" },
1197 { 0x137d, "EXT_SUPER_MAGIC" },
1198 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1199 { 0x9660, "ISOFS_SUPER_MAGIC" },
1200 { 0x137f, "MINIX_SUPER_MAGIC" },
1201 { 0x138f, "MINIX_SUPER_MAGIC2" },
1202 { 0x2468, "MINIX2_SUPER_MAGIC" },
1203 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1204 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1205 { 0x564c, "NCP_SUPER_MAGIC" },
1206 { 0x6969, "NFS_SUPER_MAGIC" },
1207 { 0x9fa0, "PROC_SUPER_MAGIC" },
1208 { 0x002f, "QNX4_SUPER_MAGIC" },
1209 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1210 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1211 { 0x517b, "SMB_SUPER_MAGIC" },
1212 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1213 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1214 { 0x00011954, "UFS_MAGIC" },
1215 { 0x54190100, "UFS_CIGAM" },
1216 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1217 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1229 static char buf[32];
1233 s = xlookup(fsmagic, magic);
1235 sprintf(buf, "\"%s\"", s);
1239 sprintf(buf, "%#x", magic);
1244 printstatfs(tcp, addr)
1248 struct statfs statbuf;
1250 if (syserror(tcp) || !verbose(tcp)) {
1251 tprintf("%#lx", addr);
1254 if (umove(tcp, addr, &statbuf) < 0) {
1260 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1261 sprintfstype(statbuf.f_type),
1262 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1263 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
1264 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1266 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1267 sprintfstype(statbuf.f_type),
1268 (unsigned long)statbuf.f_bsize,
1269 (unsigned long)statbuf.f_blocks,
1270 (unsigned long)statbuf.f_bfree);
1271 tprintf("f_files=%lu, f_ffree=%lu",
1272 (unsigned long)statbuf.f_files,
1273 (unsigned long)statbuf.f_ffree);
1275 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1285 if (entering(tcp)) {
1286 printpath(tcp, tcp->u_arg[0]);
1289 printstatfs(tcp, tcp->u_arg[1]);
1298 if (entering(tcp)) {
1299 tprintf("%lu, ", tcp->u_arg[0]);
1301 printstatfs(tcp, tcp->u_arg[1]);
1306 #if defined(linux) && defined(__alpha)
1312 if (entering(tcp)) {
1313 printpath(tcp, tcp->u_arg[0]);
1316 printstatfs(tcp, tcp->u_arg[1]);
1317 tprintf(", %lu", tcp->u_arg[2]);
1326 if (entering(tcp)) {
1327 tprintf("%lu, ", tcp->u_arg[0]);
1329 printstatfs(tcp, tcp->u_arg[1]);
1330 tprintf(", %lu", tcp->u_arg[2]);
1334 #endif /* linux && __alpha */
1344 struct ustat statbuf;
1346 if (entering(tcp)) {
1347 tprintf("makedev(%lu, %lu), ",
1348 (long) major(tcp->u_arg[0]),
1349 (long) minor(tcp->u_arg[0]));
1352 if (syserror(tcp) || !verbose(tcp))
1353 tprintf("%#lx", tcp->u_arg[1]);
1354 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1357 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1358 statbuf.f_tfree, statbuf.f_tinode);
1359 tprintf("f_fname=\"%.*s\", ",
1360 (int) sizeof(statbuf.f_fname),
1362 tprintf("f_fpack=\"%.*s\"}",
1363 (int) sizeof(statbuf.f_fpack),
1376 if (entering(tcp)) {
1377 printpath(tcp, tcp->u_arg[0]);
1379 printpath(tcp, tcp->u_arg[1]);
1390 if (entering(tcp)) {
1391 printpath(tcp, tcp->u_arg[0]);
1400 if (entering(tcp)) {
1401 printpath(tcp, tcp->u_arg[0]);
1402 tprintf(", %#lo", tcp->u_arg[1]);
1411 if (entering(tcp)) {
1412 printpath(tcp, tcp->u_arg[0]);
1421 if (entering(tcp)) {
1422 tprintf("%ld", tcp->u_arg[0]);
1431 if (entering(tcp)) {
1432 printpath(tcp, tcp->u_arg[0]);
1441 if (entering(tcp)) {
1442 tprintf("%ld", tcp->u_arg[0]);
1451 if (entering(tcp)) {
1452 printpath(tcp, tcp->u_arg[0]);
1454 printpath(tcp, tcp->u_arg[1]);
1463 if (entering(tcp)) {
1464 printpath(tcp, tcp->u_arg[0]);
1473 if (entering(tcp)) {
1474 printpath(tcp, tcp->u_arg[0]);
1476 printpath(tcp, tcp->u_arg[1]);
1485 if (entering(tcp)) {
1486 printpath(tcp, tcp->u_arg[0]);
1490 tprintf("%#lx", tcp->u_arg[1]);
1492 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1493 tprintf(", %lu", tcp->u_arg[2]);
1502 if (entering(tcp)) {
1503 printpath(tcp, tcp->u_arg[0]);
1505 printpath(tcp, tcp->u_arg[1]);
1514 if (entering(tcp)) {
1515 printpath(tcp, tcp->u_arg[0]);
1516 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1525 if (entering(tcp)) {
1526 tprintf("%ld, %lu, %lu",
1527 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1536 if (entering(tcp)) {
1537 printpath(tcp, tcp->u_arg[0]);
1538 tprintf(", %#lo", tcp->u_arg[1]);
1547 if (entering(tcp)) {
1548 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1558 if (entering(tcp)) {
1559 printpath(tcp, tcp->u_arg[0]);
1561 printtv32(tcp, tcp->u_arg[1]);
1571 if (entering(tcp)) {
1572 printpath(tcp, tcp->u_arg[0]);
1574 printtv(tcp, tcp->u_arg[1]);
1585 if (entering(tcp)) {
1586 printpath(tcp, tcp->u_arg[0]);
1590 else if (!verbose(tcp))
1591 tprintf("%#lx", tcp->u_arg[1]);
1592 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1596 tprintf("[%s,", sprinttime(ut[0]));
1597 tprintf(" %s]", sprinttime(ut[1]));
1607 int mode = tcp->u_arg[1];
1609 if (entering(tcp)) {
1610 printpath(tcp, tcp->u_arg[0]);
1611 tprintf(", %s", sprintmode(mode));
1612 switch (mode & S_IFMT) {
1613 case S_IFCHR: case S_IFBLK:
1615 if (current_personality == 1)
1616 tprintf(", makedev(%lu, %lu)",
1617 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1618 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1621 tprintf(", makedev(%lu, %lu)",
1622 (unsigned long) major(tcp->u_arg[2]),
1623 (unsigned long) minor(tcp->u_arg[2]));
1636 if (entering(tcp)) {
1637 printpath(tcp, tcp->u_arg[0]);
1638 tprintf(", %#lo", tcp->u_arg[1]);
1647 if (entering(tcp)) {
1648 tprintf("%ld", tcp->u_arg[0]);
1662 if (!verbose(tcp)) {
1663 tprintf("%#lx", addr);
1666 if (umove(tcp, addr, &d) < 0) {
1670 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1672 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1680 if (entering(tcp)) {
1681 tprintf("%lu, ", tcp->u_arg[0]);
1683 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1684 tprintf("%#lx", tcp->u_arg[1]);
1686 printdir(tcp, tcp->u_arg[1]);
1687 /* Not much point in printing this out, it is always 1. */
1688 if (tcp->u_arg[2] != 1)
1689 tprintf(", %lu", tcp->u_arg[2]);
1697 struct xlat direnttypes[] = {
1698 { DT_FIFO, "DT_FIFO" },
1699 { DT_CHR, "DT_CHR" },
1700 { DT_DIR, "DT_DIR" },
1701 { DT_BLK, "DT_BLK" },
1702 { DT_REG, "DT_REG" },
1703 { DT_LNK, "DT_LNK" },
1704 { DT_SOCK, "DT_SOCK" },
1705 { DT_WHT, "DT_WHT" },
1715 int i, len, dents = 0;
1718 if (entering(tcp)) {
1719 tprintf("%lu, ", tcp->u_arg[0]);
1722 if (syserror(tcp) || !verbose(tcp)) {
1723 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1727 if ((buf = malloc(len)) == NULL) {
1728 tprintf("out of memory\n");
1731 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1732 tprintf("{...}, %lu", tcp->u_arg[2]);
1738 for (i = 0; i < len;) {
1739 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1742 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1743 i ? " " : "", d->d_ino, d->d_off);
1744 tprintf("d_reclen=%u, d_name=\"%s\"}",
1745 d->d_reclen, d->d_name);
1750 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1751 i ? " " : "", d->d_ino, d->d_off);
1752 tprintf("d_reclen=%u, d_name=\"%s\"}",
1753 d->d_reclen, d->d_name);
1758 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1759 i ? " " : "", d->d_off, d->d_fileno,
1761 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1762 d->d_namlen, d->d_namlen, d->d_name);
1767 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1768 i ? " " : "", d->d_fileno, d->d_reclen);
1769 printxval(direnttypes, d->d_type, "DT_???");
1770 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1771 d->d_namlen, d->d_namlen, d->d_name);
1773 #endif /* FREEBSD */
1775 tprintf("/* d_reclen == 0, problem here */");
1784 tprintf("/* %u entries */", dents);
1785 tprintf(", %lu", tcp->u_arg[2]);
1792 sys_getdirentries(tcp)
1795 int i, len, dents = 0;
1799 if (entering(tcp)) {
1800 tprintf("%lu, ", tcp->u_arg[0]);
1803 if (syserror(tcp) || !verbose(tcp)) {
1804 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1808 if ((buf = malloc(len)) == NULL) {
1809 tprintf("out of memory\n");
1812 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1813 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
1819 for (i = 0; i < len;) {
1820 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1822 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1823 i ? " " : "", d->d_fileno, d->d_reclen);
1824 printxval(direnttypes, d->d_type, "DT_???");
1825 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1826 d->d_namlen, d->d_namlen, d->d_name);
1834 tprintf("/* %u entries */", dents);
1836 tprintf(", %lu", tcp->u_arg[2]);
1837 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
1838 tprintf(", %#lx", tcp->u_arg[3]);
1840 tprintf(", [%lu]", basep);
1852 tprintf("%#lx", tcp->u_arg[0]);
1854 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
1855 tprintf(", %lu", tcp->u_arg[1]);
1868 tprintf("%#lx", tcp->u_arg[0]);
1870 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
1871 tprintf(", %lu", tcp->u_arg[1]);
1877 #ifdef HAVE_SYS_ASYNCH_H
1883 struct aio_result_t res;
1885 if (entering(tcp)) {
1886 tprintf("%lu, ", tcp->u_arg[0]);
1889 tprintf("%#lx", tcp->u_arg[1]);
1891 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1892 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
1893 printxval(whence, tcp->u_arg[4], "L_???");
1894 if (syserror(tcp) || tcp->u_arg[5] == 0
1895 || umove(tcp, tcp->u_arg[5], &res) < 0)
1896 tprintf(", %#lx", tcp->u_arg[5]);
1898 tprintf(", {aio_return %d aio_errno %d}",
1899 res.aio_return, res.aio_errno);
1908 struct aio_result_t res;
1910 if (entering(tcp)) {
1911 tprintf("%lu, ", tcp->u_arg[0]);
1912 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1913 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
1914 printxval(whence, tcp->u_arg[4], "L_???");
1917 if (tcp->u_arg[5] == 0)
1919 else if (syserror(tcp)
1920 || umove(tcp, tcp->u_arg[5], &res) < 0)
1921 tprintf(", %#lx", tcp->u_arg[5]);
1923 tprintf(", {aio_return %d aio_errno %d}",
1924 res.aio_return, res.aio_errno);
1934 printtv(tcp, tcp->u_arg[0]);
1942 struct aio_result_t res;
1945 if (tcp->u_arg[0] == 0)
1947 else if (syserror(tcp)
1948 || umove(tcp, tcp->u_arg[0], &res) < 0)
1949 tprintf("%#lx", tcp->u_arg[0]);
1951 tprintf("{aio_return %d aio_errno %d}",
1952 res.aio_return, res.aio_errno);
1957 #endif /* HAVE_SYS_ASYNCH_H */
1964 if (entering(tcp)) {
1965 long long offset = * (long long *) & tcp->u_arg [1];
1966 if (tcp->u_arg[3] == SEEK_SET)
1967 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
1969 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
1970 printxval(whence, tcp->u_arg[3], "SEEK_???");
1972 return RVAL_LDECIMAL;