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_???");
420 long long offset = get64(tcp->u_arg [1], tcp->u_arg[2]);
421 if (tcp->u_arg[3] == SEEK_SET)
422 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
424 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
425 printxval(whence, tcp->u_arg[3], "SEEK_???");
427 return RVAL_LUDECIMAL;
436 printpath(tcp, tcp->u_arg[0]);
438 tprintf(", %lu", tcp->u_arg[1]);
440 tprintf(", %llu", ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2]);
452 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
454 tprintf("%ld, %llu", tcp->u_arg[0],
455 ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2]);
463 static struct xlat modetypes[] = {
464 { S_IFREG, "S_IFREG" },
465 { S_IFSOCK, "S_IFSOCK" },
466 { S_IFIFO, "S_IFIFO" },
467 { S_IFLNK, "S_IFLNK" },
468 { S_IFDIR, "S_IFDIR" },
469 { S_IFBLK, "S_IFBLK" },
470 { S_IFCHR, "S_IFCHR" },
481 if ((mode & S_IFMT) == 0)
483 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
484 sprintf(buf, "%#o", mode);
487 sprintf(buf, "%s%s%s%s", s,
488 (mode & S_ISUID) ? "|S_ISUID" : "",
489 (mode & S_ISGID) ? "|S_ISGID" : "",
490 (mode & S_ISVTX) ? "|S_ISVTX" : "");
491 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
493 sprintf(buf + strlen(buf), "|%#o", mode);
494 s = (*buf == '|') ? buf + 1 : buf;
510 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
511 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
512 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
524 int st_pad1[3]; /* network id */
533 int st_pad3; /* st_size, off_t expansion */
534 timestruct_t st_atime;
535 timestruct_t st_mtime;
536 timestruct_t st_ctime;
540 int st_pad4[8]; /* expansion area */
544 printstatsol(tcp, addr)
548 struct solstat statbuf;
554 if (syserror(tcp) || !verbose(tcp)) {
555 tprintf("%#lx", addr);
558 if (umove(tcp, addr, &statbuf) < 0) {
563 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
564 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
565 (unsigned long) (statbuf.st_dev & 0x3ffff),
566 (unsigned long) statbuf.st_ino,
567 sprintmode(statbuf.st_mode));
568 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
569 (unsigned long) statbuf.st_nlink,
570 (unsigned long) statbuf.st_uid,
571 (unsigned long) statbuf.st_gid);
572 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
573 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
576 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
577 switch (statbuf.st_mode & S_IFMT) {
578 case S_IFCHR: case S_IFBLK:
579 tprintf("st_rdev=makedev(%lu, %lu), ",
580 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
581 (unsigned long) (statbuf.st_rdev & 0x3ffff));
584 tprintf("st_size=%u, ", statbuf.st_size);
588 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
589 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
590 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
595 #endif /* LINUXSPARC */
598 static struct xlat fileflags[] = {
599 { UF_NODUMP, "UF_NODUMP" },
600 { UF_IMMUTABLE, "UF_IMMUTABLE" },
601 { UF_APPEND, "UF_APPEND" },
602 { UF_OPAQUE, "UF_OPAQUE" },
603 { UF_NOUNLINK, "UF_NOUNLINK" },
604 { SF_ARCHIVED, "SF_ARCHIVED" },
605 { SF_IMMUTABLE, "SF_IMMUTABLE" },
606 { SF_APPEND, "SF_APPEND" },
607 { SF_NOUNLINK, "SF_NOUNLINK" },
616 printpath(tcp, tcp->u_arg[0]);
619 printflags(fileflags, tcp->u_arg[1]);
631 tprintf("%ld, ", tcp->u_arg[0]);
633 printflags(fileflags, tcp->u_arg[1]);
642 realprintstat(tcp, statbuf)
644 struct stat *statbuf;
647 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
648 (unsigned long) major(statbuf->st_dev),
649 (unsigned long) minor(statbuf->st_dev),
650 (unsigned long) statbuf->st_ino,
651 sprintmode(statbuf->st_mode));
652 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
653 (unsigned long) statbuf->st_nlink,
654 (unsigned long) statbuf->st_uid,
655 (unsigned long) statbuf->st_gid);
656 #ifdef HAVE_ST_BLKSIZE
657 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
658 #endif /* HAVE_ST_BLKSIZE */
659 #ifdef HAVE_ST_BLOCKS
660 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
661 #endif /* HAVE_ST_BLOCKS */
664 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
665 switch (statbuf->st_mode & S_IFMT) {
666 case S_IFCHR: case S_IFBLK:
668 tprintf("st_rdev=makedev(%lu, %lu), ",
669 (unsigned long) major(statbuf->st_rdev),
670 (unsigned long) minor(statbuf->st_rdev));
671 #else /* !HAVE_ST_RDEV */
672 tprintf("st_size=makedev(%lu, %lu), ",
673 (unsigned long) major(statbuf->st_size),
674 (unsigned long) minor(statbuf->st_size));
675 #endif /* !HAVE_ST_RDEV */
678 tprintf("st_size=%lu, ", statbuf->st_size);
682 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
683 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
685 tprintf("st_ctime=%s}", sprinttime(statbuf->st_ctime));
687 tprintf("st_ctime=%s, ", sprinttime(statbuf->st_ctime));
688 tprintf("st_flags=");
689 if (statbuf->st_flags) {
690 printflags(fileflags, statbuf->st_flags);
693 tprintf(", st_gen=%u}", statbuf->st_gen);
709 if (current_personality == 1) {
710 printstatsol(tcp, addr);
713 #endif /* LINUXSPARC */
719 if (syserror(tcp) || !verbose(tcp)) {
720 tprintf("%#lx", addr);
723 if (umove(tcp, addr, &statbuf) < 0) {
728 realprintstat(tcp, &statbuf);
733 printstat64(tcp, addr)
737 struct stat64 statbuf;
740 if (current_personality == 1) {
741 printstatsol(tcp, addr);
744 #endif /* LINUXSPARC */
750 if (syserror(tcp) || !verbose(tcp)) {
751 tprintf("%#lx", addr);
754 if (umove(tcp, addr, &statbuf) < 0) {
760 #ifdef HAVE_LONG_LONG
761 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
763 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
765 (unsigned long) major(statbuf.st_dev),
766 (unsigned long) minor(statbuf.st_dev),
767 #ifdef HAVE_LONG_LONG
768 (unsigned long long) statbuf.st_ino,
770 (unsigned long) statbuf.st_ino,
772 sprintmode(statbuf.st_mode));
773 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
774 (unsigned long) statbuf.st_nlink,
775 (unsigned long) statbuf.st_uid,
776 (unsigned long) statbuf.st_gid);
777 #ifdef HAVE_ST_BLKSIZE
778 tprintf("st_blksize=%lu, ",
779 (unsigned long) statbuf.st_blksize);
780 #endif /* HAVE_ST_BLKSIZE */
781 #ifdef HAVE_ST_BLOCKS
782 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
783 #endif /* HAVE_ST_BLOCKS */
786 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
787 switch (statbuf.st_mode & S_IFMT) {
788 case S_IFCHR: case S_IFBLK:
790 tprintf("st_rdev=makedev(%lu, %lu), ",
791 (unsigned long) major(statbuf.st_rdev),
792 (unsigned long) minor(statbuf.st_rdev));
793 #else /* !HAVE_ST_RDEV */
794 tprintf("st_size=makedev(%lu, %lu), ",
795 (unsigned long) major(statbuf.st_size),
796 (unsigned long) minor(statbuf.st_size));
797 #endif /* !HAVE_ST_RDEV */
800 tprintf("st_size=%llu, ", statbuf.st_size);
804 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
805 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
806 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
811 #endif /* HAVE_STAT64 */
813 #if defined(linux) && !defined(IA64)
815 convertoldstat(oldbuf, newbuf)
816 const struct __old_kernel_stat *oldbuf;
819 newbuf->st_dev=oldbuf->st_dev;
820 newbuf->st_ino=oldbuf->st_ino;
821 newbuf->st_mode=oldbuf->st_mode;
822 newbuf->st_nlink=oldbuf->st_nlink;
823 newbuf->st_uid=oldbuf->st_uid;
824 newbuf->st_gid=oldbuf->st_gid;
825 newbuf->st_rdev=oldbuf->st_rdev;
826 newbuf->st_size=oldbuf->st_size;
827 newbuf->st_atime=oldbuf->st_atime;
828 newbuf->st_mtime=oldbuf->st_mtime;
829 newbuf->st_ctime=oldbuf->st_ctime;
830 newbuf->st_blksize=0; /* not supported in old_stat */
831 newbuf->st_blocks=0; /* not supported in old_stat */
836 printoldstat(tcp, addr)
840 struct __old_kernel_stat statbuf;
841 struct stat newstatbuf;
844 if (current_personality == 1) {
845 printstatsol(tcp, addr);
848 #endif /* LINUXSPARC */
854 if (syserror(tcp) || !verbose(tcp)) {
855 tprintf("%#lx", addr);
858 if (umove(tcp, addr, &statbuf) < 0) {
863 convertoldstat(&statbuf, &newstatbuf);
864 realprintstat(tcp, &newstatbuf);
866 #endif /* linux && !IA64 */
874 printpath(tcp, tcp->u_arg[0]);
877 printstat(tcp, tcp->u_arg[1]);
889 printpath(tcp, tcp->u_arg[0]);
892 printstat64(tcp, tcp->u_arg[1]);
896 return printargs(tcp);
906 printpath(tcp, tcp->u_arg[0]);
909 printoldstat(tcp, tcp->u_arg[1]);
921 tprintf("%ld, ", tcp->u_arg[0]);
923 printstat(tcp, tcp->u_arg[1]);
935 tprintf("%ld, ", tcp->u_arg[0]);
937 printstat64(tcp, tcp->u_arg[1]);
941 return printargs(tcp);
951 tprintf("%ld, ", tcp->u_arg[0]);
953 printoldstat(tcp, tcp->u_arg[1]);
965 printpath(tcp, tcp->u_arg[0]);
968 printstat(tcp, tcp->u_arg[1]);
980 printpath(tcp, tcp->u_arg[0]);
983 printstat64(tcp, tcp->u_arg[1]);
987 return printargs(tcp);
997 printpath(tcp, tcp->u_arg[0]);
1000 printoldstat(tcp, tcp->u_arg[1]);
1008 #if defined(SVR4) || defined(LINUXSPARC)
1014 if (entering(tcp)) {
1015 tprintf("%ld, ", tcp->u_arg[0]);
1016 printpath(tcp, 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]);
1034 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1037 if (tcp->u_arg[0] == _STAT64_VER)
1038 printstat64 (tcp, tcp->u_arg[2]);
1041 printstat(tcp, tcp->u_arg[2]);
1050 if (entering(tcp)) {
1051 tprintf("%ld, ", tcp->u_arg[0]);
1052 printpath(tcp, tcp->u_arg[1]);
1056 if (tcp->u_arg[0] == _STAT64_VER)
1057 printstat64 (tcp, tcp->u_arg[2]);
1060 printstat(tcp, tcp->u_arg[2]);
1069 int mode = tcp->u_arg[2];
1071 if (entering(tcp)) {
1072 tprintf("%ld, ", tcp->u_arg[0]);
1073 printpath(tcp, tcp->u_arg[1]);
1074 tprintf(", %s", sprintmode(mode));
1075 switch (mode & S_IFMT) {
1076 case S_IFCHR: case S_IFBLK:
1078 tprintf(", makedev(%lu, %lu)",
1079 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1080 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1082 tprintf(", makedev(%lu, %lu)",
1083 (unsigned long) major(tcp->u_arg[3]),
1084 (unsigned long) minor(tcp->u_arg[3]));
1094 #ifdef HAVE_SYS_ACL_H
1096 #include <sys/acl.h>
1098 struct xlat aclcmds[] = {
1100 { SETACL, "SETACL" },
1103 { GETACL, "GETACL" },
1106 { GETACLCNT, "GETACLCNT" },
1109 { ACL_GET, "ACL_GET" },
1112 { ACL_SET, "ACL_SET" },
1115 { ACL_CNT, "ACL_CNT" },
1124 if (entering(tcp)) {
1125 printpath(tcp, tcp->u_arg[0]);
1127 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1128 tprintf(", %ld", tcp->u_arg[2]);
1130 * FIXME - dump out the list of aclent_t's pointed to
1131 * by "tcp->u_arg[3]" if it's not NULL.
1134 tprintf(", %#lx", tcp->u_arg[3]);
1146 if (entering(tcp)) {
1147 tprintf("%ld, ", tcp->u_arg[0]);
1148 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1149 tprintf(", %ld", tcp->u_arg[2]);
1151 * FIXME - dump out the list of aclent_t's pointed to
1152 * by "tcp->u_arg[3]" if it's not NULL.
1155 tprintf(", %#lx", tcp->u_arg[3]);
1163 struct xlat aclipc[] = {
1165 { IPC_SHM, "IPC_SHM" },
1168 { IPC_SEM, "IPC_SEM" },
1171 { IPC_MSG, "IPC_MSG" },
1181 if (entering(tcp)) {
1182 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1183 tprintf(", %#lx, ", tcp->u_arg[1]);
1184 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1185 tprintf(", %ld", tcp->u_arg[3]);
1187 * FIXME - dump out the list of aclent_t's pointed to
1188 * by "tcp->u_arg[4]" if it's not NULL.
1191 tprintf(", %#lx", tcp->u_arg[4]);
1200 #endif /* HAVE_SYS_ACL_H */
1202 #endif /* SVR4 || LINUXSPARC */
1206 static struct xlat fsmagic[] = {
1207 { 0x73757245, "CODA_SUPER_MAGIC" },
1208 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1209 { 0x1373, "DEVFS_SUPER_MAGIC" },
1210 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1211 { 0x414A53, "EFS_SUPER_MAGIC" },
1212 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1213 { 0xef53, "EXT2_SUPER_MAGIC" },
1214 { 0x137d, "EXT_SUPER_MAGIC" },
1215 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1216 { 0x9660, "ISOFS_SUPER_MAGIC" },
1217 { 0x137f, "MINIX_SUPER_MAGIC" },
1218 { 0x138f, "MINIX_SUPER_MAGIC2" },
1219 { 0x2468, "MINIX2_SUPER_MAGIC" },
1220 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1221 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1222 { 0x564c, "NCP_SUPER_MAGIC" },
1223 { 0x6969, "NFS_SUPER_MAGIC" },
1224 { 0x9fa0, "PROC_SUPER_MAGIC" },
1225 { 0x002f, "QNX4_SUPER_MAGIC" },
1226 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1227 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1228 { 0x517b, "SMB_SUPER_MAGIC" },
1229 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1230 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1231 { 0x00011954, "UFS_MAGIC" },
1232 { 0x54190100, "UFS_CIGAM" },
1233 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1234 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1246 static char buf[32];
1250 s = xlookup(fsmagic, magic);
1252 sprintf(buf, "\"%s\"", s);
1256 sprintf(buf, "%#x", magic);
1261 printstatfs(tcp, addr)
1265 struct statfs statbuf;
1267 if (syserror(tcp) || !verbose(tcp)) {
1268 tprintf("%#lx", addr);
1271 if (umove(tcp, addr, &statbuf) < 0) {
1277 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1278 sprintfstype(statbuf.f_type),
1279 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1280 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
1281 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1283 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1284 sprintfstype(statbuf.f_type),
1285 (unsigned long)statbuf.f_bsize,
1286 (unsigned long)statbuf.f_blocks,
1287 (unsigned long)statbuf.f_bfree);
1288 tprintf("f_files=%lu, f_ffree=%lu",
1289 (unsigned long)statbuf.f_files,
1290 (unsigned long)statbuf.f_ffree);
1292 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1302 if (entering(tcp)) {
1303 printpath(tcp, tcp->u_arg[0]);
1306 printstatfs(tcp, tcp->u_arg[1]);
1315 if (entering(tcp)) {
1316 tprintf("%lu, ", tcp->u_arg[0]);
1318 printstatfs(tcp, tcp->u_arg[1]);
1323 #if defined(linux) && defined(__alpha)
1329 if (entering(tcp)) {
1330 printpath(tcp, tcp->u_arg[0]);
1333 printstatfs(tcp, tcp->u_arg[1]);
1334 tprintf(", %lu", tcp->u_arg[2]);
1343 if (entering(tcp)) {
1344 tprintf("%lu, ", tcp->u_arg[0]);
1346 printstatfs(tcp, tcp->u_arg[1]);
1347 tprintf(", %lu", tcp->u_arg[2]);
1351 #endif /* linux && __alpha */
1361 struct ustat statbuf;
1363 if (entering(tcp)) {
1364 tprintf("makedev(%lu, %lu), ",
1365 (long) major(tcp->u_arg[0]),
1366 (long) minor(tcp->u_arg[0]));
1369 if (syserror(tcp) || !verbose(tcp))
1370 tprintf("%#lx", tcp->u_arg[1]);
1371 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1374 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1375 statbuf.f_tfree, statbuf.f_tinode);
1376 tprintf("f_fname=\"%.*s\", ",
1377 (int) sizeof(statbuf.f_fname),
1379 tprintf("f_fpack=\"%.*s\"}",
1380 (int) sizeof(statbuf.f_fpack),
1393 if (entering(tcp)) {
1394 printpath(tcp, tcp->u_arg[0]);
1396 printpath(tcp, tcp->u_arg[1]);
1407 if (entering(tcp)) {
1408 printpath(tcp, tcp->u_arg[0]);
1417 if (entering(tcp)) {
1418 printpath(tcp, tcp->u_arg[0]);
1419 tprintf(", %#lo", tcp->u_arg[1]);
1428 if (entering(tcp)) {
1429 printpath(tcp, tcp->u_arg[0]);
1438 if (entering(tcp)) {
1439 tprintf("%ld", tcp->u_arg[0]);
1448 if (entering(tcp)) {
1449 printpath(tcp, tcp->u_arg[0]);
1458 if (entering(tcp)) {
1459 tprintf("%ld", tcp->u_arg[0]);
1468 if (entering(tcp)) {
1469 printpath(tcp, tcp->u_arg[0]);
1471 printpath(tcp, tcp->u_arg[1]);
1480 if (entering(tcp)) {
1481 printpath(tcp, tcp->u_arg[0]);
1490 if (entering(tcp)) {
1491 printpath(tcp, tcp->u_arg[0]);
1493 printpath(tcp, tcp->u_arg[1]);
1502 if (entering(tcp)) {
1503 printpath(tcp, tcp->u_arg[0]);
1507 tprintf("%#lx", tcp->u_arg[1]);
1509 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1510 tprintf(", %lu", tcp->u_arg[2]);
1519 if (entering(tcp)) {
1520 printpath(tcp, tcp->u_arg[0]);
1522 printpath(tcp, tcp->u_arg[1]);
1531 if (entering(tcp)) {
1532 printpath(tcp, tcp->u_arg[0]);
1533 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1542 if (entering(tcp)) {
1543 tprintf("%ld, %lu, %lu",
1544 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1553 if (entering(tcp)) {
1554 printpath(tcp, tcp->u_arg[0]);
1555 tprintf(", %#lo", tcp->u_arg[1]);
1564 if (entering(tcp)) {
1565 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1575 if (entering(tcp)) {
1576 printpath(tcp, tcp->u_arg[0]);
1578 printtv32(tcp, tcp->u_arg[1]);
1588 if (entering(tcp)) {
1589 printpath(tcp, tcp->u_arg[0]);
1591 printtv(tcp, tcp->u_arg[1]);
1602 if (entering(tcp)) {
1603 printpath(tcp, tcp->u_arg[0]);
1607 else if (!verbose(tcp))
1608 tprintf("%#lx", tcp->u_arg[1]);
1609 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1613 tprintf("[%s,", sprinttime(ut[0]));
1614 tprintf(" %s]", sprinttime(ut[1]));
1624 int mode = tcp->u_arg[1];
1626 if (entering(tcp)) {
1627 printpath(tcp, tcp->u_arg[0]);
1628 tprintf(", %s", sprintmode(mode));
1629 switch (mode & S_IFMT) {
1630 case S_IFCHR: case S_IFBLK:
1632 if (current_personality == 1)
1633 tprintf(", makedev(%lu, %lu)",
1634 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1635 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1638 tprintf(", makedev(%lu, %lu)",
1639 (unsigned long) major(tcp->u_arg[2]),
1640 (unsigned long) minor(tcp->u_arg[2]));
1653 if (entering(tcp)) {
1654 printpath(tcp, tcp->u_arg[0]);
1655 tprintf(", %#lo", tcp->u_arg[1]);
1664 if (entering(tcp)) {
1665 tprintf("%ld", tcp->u_arg[0]);
1679 if (!verbose(tcp)) {
1680 tprintf("%#lx", addr);
1683 if (umove(tcp, addr, &d) < 0) {
1687 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1689 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1697 if (entering(tcp)) {
1698 tprintf("%lu, ", tcp->u_arg[0]);
1700 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1701 tprintf("%#lx", tcp->u_arg[1]);
1703 printdir(tcp, tcp->u_arg[1]);
1704 /* Not much point in printing this out, it is always 1. */
1705 if (tcp->u_arg[2] != 1)
1706 tprintf(", %lu", tcp->u_arg[2]);
1714 struct xlat direnttypes[] = {
1715 { DT_FIFO, "DT_FIFO" },
1716 { DT_CHR, "DT_CHR" },
1717 { DT_DIR, "DT_DIR" },
1718 { DT_BLK, "DT_BLK" },
1719 { DT_REG, "DT_REG" },
1720 { DT_LNK, "DT_LNK" },
1721 { DT_SOCK, "DT_SOCK" },
1722 { DT_WHT, "DT_WHT" },
1732 int i, len, dents = 0;
1735 if (entering(tcp)) {
1736 tprintf("%lu, ", tcp->u_arg[0]);
1739 if (syserror(tcp) || !verbose(tcp)) {
1740 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1744 if ((buf = malloc(len)) == NULL) {
1745 tprintf("out of memory\n");
1748 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1749 tprintf("{...}, %lu", tcp->u_arg[2]);
1755 for (i = 0; i < len;) {
1756 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1759 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1760 i ? " " : "", d->d_ino, d->d_off);
1761 tprintf("d_reclen=%u, d_name=\"%s\"}",
1762 d->d_reclen, d->d_name);
1767 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1768 i ? " " : "", d->d_ino, d->d_off);
1769 tprintf("d_reclen=%u, d_name=\"%s\"}",
1770 d->d_reclen, d->d_name);
1775 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1776 i ? " " : "", d->d_off, d->d_fileno,
1778 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1779 d->d_namlen, d->d_namlen, d->d_name);
1784 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1785 i ? " " : "", d->d_fileno, d->d_reclen);
1786 printxval(direnttypes, d->d_type, "DT_???");
1787 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1788 d->d_namlen, d->d_namlen, d->d_name);
1790 #endif /* FREEBSD */
1792 tprintf("/* d_reclen == 0, problem here */");
1801 tprintf("/* %u entries */", dents);
1802 tprintf(", %lu", tcp->u_arg[2]);
1808 #if _LFS64_LARGEFILE
1813 int i, len, dents = 0;
1816 if (entering(tcp)) {
1817 tprintf("%lu, ", tcp->u_arg[0]);
1820 if (syserror(tcp) || !verbose(tcp)) {
1821 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1825 if ((buf = malloc(len)) == NULL) {
1826 tprintf("out of memory\n");
1829 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1830 tprintf("{...}, %lu", tcp->u_arg[2]);
1836 for (i = 0; i < len;) {
1837 struct dirent64 *d = (struct dirent64 *) &buf[i];
1840 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1841 i ? " " : "", d->d_ino, d->d_off);
1842 tprintf("d_reclen=%u, d_name=\"%s\"}",
1843 d->d_reclen, d->d_name);
1848 tprintf("%s{d_ino=%llu, d_off=%llu, ",
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_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1857 i ? " " : "", d->d_off, d->d_fileno,
1859 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1860 d->d_namlen, d->d_namlen, d->d_name);
1869 tprintf("/* %u entries */", dents);
1870 tprintf(", %lu", tcp->u_arg[2]);
1878 sys_getdirentries(tcp)
1881 int i, len, dents = 0;
1885 if (entering(tcp)) {
1886 tprintf("%lu, ", tcp->u_arg[0]);
1889 if (syserror(tcp) || !verbose(tcp)) {
1890 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1894 if ((buf = malloc(len)) == NULL) {
1895 tprintf("out of memory\n");
1898 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1899 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
1905 for (i = 0; i < len;) {
1906 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1908 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1909 i ? " " : "", d->d_fileno, d->d_reclen);
1910 printxval(direnttypes, d->d_type, "DT_???");
1911 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1912 d->d_namlen, d->d_namlen, d->d_name);
1920 tprintf("/* %u entries */", dents);
1922 tprintf(", %lu", tcp->u_arg[2]);
1923 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
1924 tprintf(", %#lx", tcp->u_arg[3]);
1926 tprintf(", [%lu]", basep);
1938 tprintf("%#lx", tcp->u_arg[0]);
1940 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
1941 tprintf(", %lu", tcp->u_arg[1]);
1954 tprintf("%#lx", tcp->u_arg[0]);
1956 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
1957 tprintf(", %lu", tcp->u_arg[1]);
1963 #ifdef HAVE_SYS_ASYNCH_H
1969 struct aio_result_t res;
1971 if (entering(tcp)) {
1972 tprintf("%lu, ", tcp->u_arg[0]);
1975 tprintf("%#lx", tcp->u_arg[1]);
1977 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1978 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
1979 printxval(whence, tcp->u_arg[4], "L_???");
1980 if (syserror(tcp) || tcp->u_arg[5] == 0
1981 || umove(tcp, tcp->u_arg[5], &res) < 0)
1982 tprintf(", %#lx", tcp->u_arg[5]);
1984 tprintf(", {aio_return %d aio_errno %d}",
1985 res.aio_return, res.aio_errno);
1994 struct aio_result_t res;
1996 if (entering(tcp)) {
1997 tprintf("%lu, ", tcp->u_arg[0]);
1998 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1999 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2000 printxval(whence, tcp->u_arg[4], "L_???");
2003 if (tcp->u_arg[5] == 0)
2005 else if (syserror(tcp)
2006 || umove(tcp, tcp->u_arg[5], &res) < 0)
2007 tprintf(", %#lx", tcp->u_arg[5]);
2009 tprintf(", {aio_return %d aio_errno %d}",
2010 res.aio_return, res.aio_errno);
2020 printtv(tcp, tcp->u_arg[0]);
2028 struct aio_result_t res;
2031 if (tcp->u_arg[0] == 0)
2033 else if (syserror(tcp)
2034 || umove(tcp, tcp->u_arg[0], &res) < 0)
2035 tprintf("%#lx", tcp->u_arg[0]);
2037 tprintf("{aio_return %d aio_errno %d}",
2038 res.aio_return, res.aio_errno);
2043 #endif /* HAVE_SYS_ASYNCH_H */