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 printpath(tcp, tcp->u_arg[0]);
453 tprintf(", %llu", get64(tcp->u_arg[1],tcp->u_arg[2]));
465 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
467 tprintf("%ld, %llu", tcp->u_arg[0],
468 ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2]);
480 tprintf("%ld, %llu", tcp->u_arg[0],
481 get64(tcp->u_arg[1] ,tcp->u_arg[2]));
489 static struct xlat modetypes[] = {
490 { S_IFREG, "S_IFREG" },
491 { S_IFSOCK, "S_IFSOCK" },
492 { S_IFIFO, "S_IFIFO" },
493 { S_IFLNK, "S_IFLNK" },
494 { S_IFDIR, "S_IFDIR" },
495 { S_IFBLK, "S_IFBLK" },
496 { S_IFCHR, "S_IFCHR" },
507 if ((mode & S_IFMT) == 0)
509 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
510 sprintf(buf, "%#o", mode);
513 sprintf(buf, "%s%s%s%s", s,
514 (mode & S_ISUID) ? "|S_ISUID" : "",
515 (mode & S_ISGID) ? "|S_ISGID" : "",
516 (mode & S_ISVTX) ? "|S_ISVTX" : "");
517 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
519 sprintf(buf + strlen(buf), "|%#o", mode);
520 s = (*buf == '|') ? buf + 1 : buf;
536 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
537 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
538 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
550 int st_pad1[3]; /* network id */
559 int st_pad3; /* st_size, off_t expansion */
560 timestruct_t st_atime;
561 timestruct_t st_mtime;
562 timestruct_t st_ctime;
566 int st_pad4[8]; /* expansion area */
570 printstatsol(tcp, addr)
574 struct solstat statbuf;
580 if (syserror(tcp) || !verbose(tcp)) {
581 tprintf("%#lx", addr);
584 if (umove(tcp, addr, &statbuf) < 0) {
589 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
590 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
591 (unsigned long) (statbuf.st_dev & 0x3ffff),
592 (unsigned long) statbuf.st_ino,
593 sprintmode(statbuf.st_mode));
594 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
595 (unsigned long) statbuf.st_nlink,
596 (unsigned long) statbuf.st_uid,
597 (unsigned long) statbuf.st_gid);
598 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
599 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
602 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
603 switch (statbuf.st_mode & S_IFMT) {
604 case S_IFCHR: case S_IFBLK:
605 tprintf("st_rdev=makedev(%lu, %lu), ",
606 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
607 (unsigned long) (statbuf.st_rdev & 0x3ffff));
610 tprintf("st_size=%u, ", statbuf.st_size);
614 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
615 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
616 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
621 #endif /* LINUXSPARC */
624 static struct xlat fileflags[] = {
625 { UF_NODUMP, "UF_NODUMP" },
626 { UF_IMMUTABLE, "UF_IMMUTABLE" },
627 { UF_APPEND, "UF_APPEND" },
628 { UF_OPAQUE, "UF_OPAQUE" },
629 { UF_NOUNLINK, "UF_NOUNLINK" },
630 { SF_ARCHIVED, "SF_ARCHIVED" },
631 { SF_IMMUTABLE, "SF_IMMUTABLE" },
632 { SF_APPEND, "SF_APPEND" },
633 { SF_NOUNLINK, "SF_NOUNLINK" },
642 printpath(tcp, tcp->u_arg[0]);
645 printflags(fileflags, tcp->u_arg[1]);
657 tprintf("%ld, ", tcp->u_arg[0]);
659 printflags(fileflags, tcp->u_arg[1]);
668 realprintstat(tcp, statbuf)
670 struct stat *statbuf;
673 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
674 (unsigned long) major(statbuf->st_dev),
675 (unsigned long) minor(statbuf->st_dev),
676 (unsigned long) statbuf->st_ino,
677 sprintmode(statbuf->st_mode));
678 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
679 (unsigned long) statbuf->st_nlink,
680 (unsigned long) statbuf->st_uid,
681 (unsigned long) statbuf->st_gid);
682 #ifdef HAVE_ST_BLKSIZE
683 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
684 #endif /* HAVE_ST_BLKSIZE */
685 #ifdef HAVE_ST_BLOCKS
686 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
687 #endif /* HAVE_ST_BLOCKS */
690 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
691 switch (statbuf->st_mode & S_IFMT) {
692 case S_IFCHR: case S_IFBLK:
694 tprintf("st_rdev=makedev(%lu, %lu), ",
695 (unsigned long) major(statbuf->st_rdev),
696 (unsigned long) minor(statbuf->st_rdev));
697 #else /* !HAVE_ST_RDEV */
698 tprintf("st_size=makedev(%lu, %lu), ",
699 (unsigned long) major(statbuf->st_size),
700 (unsigned long) minor(statbuf->st_size));
701 #endif /* !HAVE_ST_RDEV */
704 tprintf("st_size=%lu, ", statbuf->st_size);
708 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
709 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
711 tprintf("st_ctime=%s}", sprinttime(statbuf->st_ctime));
713 tprintf("st_ctime=%s, ", sprinttime(statbuf->st_ctime));
714 tprintf("st_flags=");
715 if (statbuf->st_flags) {
716 printflags(fileflags, statbuf->st_flags);
719 tprintf(", st_gen=%u}", statbuf->st_gen);
735 if (current_personality == 1) {
736 printstatsol(tcp, addr);
739 #endif /* LINUXSPARC */
745 if (syserror(tcp) || !verbose(tcp)) {
746 tprintf("%#lx", addr);
749 if (umove(tcp, addr, &statbuf) < 0) {
754 realprintstat(tcp, &statbuf);
759 printstat64(tcp, addr)
763 struct stat64 statbuf;
766 if (current_personality == 1) {
767 printstatsol(tcp, addr);
770 #endif /* LINUXSPARC */
776 if (syserror(tcp) || !verbose(tcp)) {
777 tprintf("%#lx", addr);
780 if (umove(tcp, addr, &statbuf) < 0) {
786 #ifdef HAVE_LONG_LONG
787 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
789 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
791 (unsigned long) major(statbuf.st_dev),
792 (unsigned long) minor(statbuf.st_dev),
793 #ifdef HAVE_LONG_LONG
794 (unsigned long long) statbuf.st_ino,
796 (unsigned long) statbuf.st_ino,
798 sprintmode(statbuf.st_mode));
799 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
800 (unsigned long) statbuf.st_nlink,
801 (unsigned long) statbuf.st_uid,
802 (unsigned long) statbuf.st_gid);
803 #ifdef HAVE_ST_BLKSIZE
804 tprintf("st_blksize=%lu, ",
805 (unsigned long) statbuf.st_blksize);
806 #endif /* HAVE_ST_BLKSIZE */
807 #ifdef HAVE_ST_BLOCKS
808 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
809 #endif /* HAVE_ST_BLOCKS */
812 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
813 switch (statbuf.st_mode & S_IFMT) {
814 case S_IFCHR: case S_IFBLK:
816 tprintf("st_rdev=makedev(%lu, %lu), ",
817 (unsigned long) major(statbuf.st_rdev),
818 (unsigned long) minor(statbuf.st_rdev));
819 #else /* !HAVE_ST_RDEV */
820 tprintf("st_size=makedev(%lu, %lu), ",
821 (unsigned long) major(statbuf.st_size),
822 (unsigned long) minor(statbuf.st_size));
823 #endif /* !HAVE_ST_RDEV */
826 tprintf("st_size=%llu, ", statbuf.st_size);
830 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
831 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
832 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
837 #endif /* HAVE_STAT64 */
839 #if defined(linux) && !defined(IA64)
841 convertoldstat(oldbuf, newbuf)
842 const struct __old_kernel_stat *oldbuf;
845 newbuf->st_dev=oldbuf->st_dev;
846 newbuf->st_ino=oldbuf->st_ino;
847 newbuf->st_mode=oldbuf->st_mode;
848 newbuf->st_nlink=oldbuf->st_nlink;
849 newbuf->st_uid=oldbuf->st_uid;
850 newbuf->st_gid=oldbuf->st_gid;
851 newbuf->st_rdev=oldbuf->st_rdev;
852 newbuf->st_size=oldbuf->st_size;
853 newbuf->st_atime=oldbuf->st_atime;
854 newbuf->st_mtime=oldbuf->st_mtime;
855 newbuf->st_ctime=oldbuf->st_ctime;
856 newbuf->st_blksize=0; /* not supported in old_stat */
857 newbuf->st_blocks=0; /* not supported in old_stat */
862 printoldstat(tcp, addr)
866 struct __old_kernel_stat statbuf;
867 struct stat newstatbuf;
870 if (current_personality == 1) {
871 printstatsol(tcp, addr);
874 #endif /* LINUXSPARC */
880 if (syserror(tcp) || !verbose(tcp)) {
881 tprintf("%#lx", addr);
884 if (umove(tcp, addr, &statbuf) < 0) {
889 convertoldstat(&statbuf, &newstatbuf);
890 realprintstat(tcp, &newstatbuf);
892 #endif /* linux && !IA64 */
900 printpath(tcp, tcp->u_arg[0]);
903 printstat(tcp, tcp->u_arg[1]);
915 printpath(tcp, tcp->u_arg[0]);
918 printstat64(tcp, tcp->u_arg[1]);
922 return printargs(tcp);
932 printpath(tcp, tcp->u_arg[0]);
935 printoldstat(tcp, tcp->u_arg[1]);
947 tprintf("%ld, ", tcp->u_arg[0]);
949 printstat(tcp, tcp->u_arg[1]);
961 tprintf("%ld, ", tcp->u_arg[0]);
963 printstat64(tcp, tcp->u_arg[1]);
967 return printargs(tcp);
977 tprintf("%ld, ", tcp->u_arg[0]);
979 printoldstat(tcp, tcp->u_arg[1]);
991 printpath(tcp, tcp->u_arg[0]);
994 printstat(tcp, tcp->u_arg[1]);
1005 if (entering(tcp)) {
1006 printpath(tcp, tcp->u_arg[0]);
1009 printstat64(tcp, tcp->u_arg[1]);
1013 return printargs(tcp);
1022 if (entering(tcp)) {
1023 printpath(tcp, tcp->u_arg[0]);
1026 printoldstat(tcp, tcp->u_arg[1]);
1034 #if defined(SVR4) || defined(LINUXSPARC)
1040 if (entering(tcp)) {
1041 tprintf("%ld, ", tcp->u_arg[0]);
1042 printpath(tcp, tcp->u_arg[1]);
1046 if (tcp->u_arg[0] == _STAT64_VER)
1047 printstat64 (tcp, tcp->u_arg[2]);
1050 printstat(tcp, tcp->u_arg[2]);
1060 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1063 if (tcp->u_arg[0] == _STAT64_VER)
1064 printstat64 (tcp, tcp->u_arg[2]);
1067 printstat(tcp, tcp->u_arg[2]);
1076 if (entering(tcp)) {
1077 tprintf("%ld, ", tcp->u_arg[0]);
1078 printpath(tcp, tcp->u_arg[1]);
1082 if (tcp->u_arg[0] == _STAT64_VER)
1083 printstat64 (tcp, tcp->u_arg[2]);
1086 printstat(tcp, tcp->u_arg[2]);
1095 int mode = tcp->u_arg[2];
1097 if (entering(tcp)) {
1098 tprintf("%ld, ", tcp->u_arg[0]);
1099 printpath(tcp, tcp->u_arg[1]);
1100 tprintf(", %s", sprintmode(mode));
1101 switch (mode & S_IFMT) {
1102 case S_IFCHR: case S_IFBLK:
1104 tprintf(", makedev(%lu, %lu)",
1105 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1106 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1108 tprintf(", makedev(%lu, %lu)",
1109 (unsigned long) major(tcp->u_arg[3]),
1110 (unsigned long) minor(tcp->u_arg[3]));
1120 #ifdef HAVE_SYS_ACL_H
1122 #include <sys/acl.h>
1124 struct xlat aclcmds[] = {
1126 { SETACL, "SETACL" },
1129 { GETACL, "GETACL" },
1132 { GETACLCNT, "GETACLCNT" },
1135 { ACL_GET, "ACL_GET" },
1138 { ACL_SET, "ACL_SET" },
1141 { ACL_CNT, "ACL_CNT" },
1150 if (entering(tcp)) {
1151 printpath(tcp, tcp->u_arg[0]);
1153 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1154 tprintf(", %ld", tcp->u_arg[2]);
1156 * FIXME - dump out the list of aclent_t's pointed to
1157 * by "tcp->u_arg[3]" if it's not NULL.
1160 tprintf(", %#lx", tcp->u_arg[3]);
1172 if (entering(tcp)) {
1173 tprintf("%ld, ", tcp->u_arg[0]);
1174 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1175 tprintf(", %ld", tcp->u_arg[2]);
1177 * FIXME - dump out the list of aclent_t's pointed to
1178 * by "tcp->u_arg[3]" if it's not NULL.
1181 tprintf(", %#lx", tcp->u_arg[3]);
1189 struct xlat aclipc[] = {
1191 { IPC_SHM, "IPC_SHM" },
1194 { IPC_SEM, "IPC_SEM" },
1197 { IPC_MSG, "IPC_MSG" },
1207 if (entering(tcp)) {
1208 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1209 tprintf(", %#lx, ", tcp->u_arg[1]);
1210 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1211 tprintf(", %ld", tcp->u_arg[3]);
1213 * FIXME - dump out the list of aclent_t's pointed to
1214 * by "tcp->u_arg[4]" if it's not NULL.
1217 tprintf(", %#lx", tcp->u_arg[4]);
1226 #endif /* HAVE_SYS_ACL_H */
1228 #endif /* SVR4 || LINUXSPARC */
1232 static struct xlat fsmagic[] = {
1233 { 0x73757245, "CODA_SUPER_MAGIC" },
1234 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1235 { 0x1373, "DEVFS_SUPER_MAGIC" },
1236 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1237 { 0x414A53, "EFS_SUPER_MAGIC" },
1238 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1239 { 0xef53, "EXT2_SUPER_MAGIC" },
1240 { 0x137d, "EXT_SUPER_MAGIC" },
1241 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1242 { 0x9660, "ISOFS_SUPER_MAGIC" },
1243 { 0x137f, "MINIX_SUPER_MAGIC" },
1244 { 0x138f, "MINIX_SUPER_MAGIC2" },
1245 { 0x2468, "MINIX2_SUPER_MAGIC" },
1246 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1247 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1248 { 0x564c, "NCP_SUPER_MAGIC" },
1249 { 0x6969, "NFS_SUPER_MAGIC" },
1250 { 0x9fa0, "PROC_SUPER_MAGIC" },
1251 { 0x002f, "QNX4_SUPER_MAGIC" },
1252 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1253 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1254 { 0x517b, "SMB_SUPER_MAGIC" },
1255 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1256 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1257 { 0x00011954, "UFS_MAGIC" },
1258 { 0x54190100, "UFS_CIGAM" },
1259 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1260 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1272 static char buf[32];
1276 s = xlookup(fsmagic, magic);
1278 sprintf(buf, "\"%s\"", s);
1282 sprintf(buf, "%#x", magic);
1287 printstatfs(tcp, addr)
1291 struct statfs statbuf;
1293 if (syserror(tcp) || !verbose(tcp)) {
1294 tprintf("%#lx", addr);
1297 if (umove(tcp, addr, &statbuf) < 0) {
1303 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1304 sprintfstype(statbuf.f_type),
1305 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1306 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
1307 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1309 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1310 sprintfstype(statbuf.f_type),
1311 (unsigned long)statbuf.f_bsize,
1312 (unsigned long)statbuf.f_blocks,
1313 (unsigned long)statbuf.f_bfree);
1314 tprintf("f_files=%lu, f_ffree=%lu",
1315 (unsigned long)statbuf.f_files,
1316 (unsigned long)statbuf.f_ffree);
1318 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1328 if (entering(tcp)) {
1329 printpath(tcp, tcp->u_arg[0]);
1332 printstatfs(tcp, tcp->u_arg[1]);
1341 if (entering(tcp)) {
1342 tprintf("%lu, ", tcp->u_arg[0]);
1344 printstatfs(tcp, tcp->u_arg[1]);
1349 #if defined(linux) && defined(__alpha)
1355 if (entering(tcp)) {
1356 printpath(tcp, tcp->u_arg[0]);
1359 printstatfs(tcp, tcp->u_arg[1]);
1360 tprintf(", %lu", tcp->u_arg[2]);
1369 if (entering(tcp)) {
1370 tprintf("%lu, ", tcp->u_arg[0]);
1372 printstatfs(tcp, tcp->u_arg[1]);
1373 tprintf(", %lu", tcp->u_arg[2]);
1377 #endif /* linux && __alpha */
1387 struct ustat statbuf;
1389 if (entering(tcp)) {
1390 tprintf("makedev(%lu, %lu), ",
1391 (long) major(tcp->u_arg[0]),
1392 (long) minor(tcp->u_arg[0]));
1395 if (syserror(tcp) || !verbose(tcp))
1396 tprintf("%#lx", tcp->u_arg[1]);
1397 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1400 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1401 statbuf.f_tfree, statbuf.f_tinode);
1402 tprintf("f_fname=\"%.*s\", ",
1403 (int) sizeof(statbuf.f_fname),
1405 tprintf("f_fpack=\"%.*s\"}",
1406 (int) sizeof(statbuf.f_fpack),
1419 if (entering(tcp)) {
1420 printpath(tcp, tcp->u_arg[0]);
1422 printpath(tcp, tcp->u_arg[1]);
1433 if (entering(tcp)) {
1434 printpath(tcp, tcp->u_arg[0]);
1443 if (entering(tcp)) {
1444 printpath(tcp, tcp->u_arg[0]);
1445 tprintf(", %#lo", tcp->u_arg[1]);
1454 if (entering(tcp)) {
1455 printpath(tcp, tcp->u_arg[0]);
1464 if (entering(tcp)) {
1465 tprintf("%ld", tcp->u_arg[0]);
1474 if (entering(tcp)) {
1475 printpath(tcp, tcp->u_arg[0]);
1484 if (entering(tcp)) {
1485 tprintf("%ld", tcp->u_arg[0]);
1494 if (entering(tcp)) {
1495 printpath(tcp, tcp->u_arg[0]);
1497 printpath(tcp, tcp->u_arg[1]);
1506 if (entering(tcp)) {
1507 printpath(tcp, tcp->u_arg[0]);
1516 if (entering(tcp)) {
1517 printpath(tcp, tcp->u_arg[0]);
1519 printpath(tcp, tcp->u_arg[1]);
1528 if (entering(tcp)) {
1529 printpath(tcp, tcp->u_arg[0]);
1533 tprintf("%#lx", tcp->u_arg[1]);
1535 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1536 tprintf(", %lu", tcp->u_arg[2]);
1545 if (entering(tcp)) {
1546 printpath(tcp, tcp->u_arg[0]);
1548 printpath(tcp, tcp->u_arg[1]);
1557 if (entering(tcp)) {
1558 printpath(tcp, tcp->u_arg[0]);
1559 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1568 if (entering(tcp)) {
1569 tprintf("%ld, %lu, %lu",
1570 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1579 if (entering(tcp)) {
1580 printpath(tcp, tcp->u_arg[0]);
1581 tprintf(", %#lo", tcp->u_arg[1]);
1590 if (entering(tcp)) {
1591 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1601 if (entering(tcp)) {
1602 printpath(tcp, tcp->u_arg[0]);
1604 printtv32(tcp, tcp->u_arg[1]);
1614 if (entering(tcp)) {
1615 printpath(tcp, tcp->u_arg[0]);
1617 printtv(tcp, tcp->u_arg[1]);
1628 if (entering(tcp)) {
1629 printpath(tcp, tcp->u_arg[0]);
1633 else if (!verbose(tcp))
1634 tprintf("%#lx", tcp->u_arg[1]);
1635 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1639 tprintf("[%s,", sprinttime(ut[0]));
1640 tprintf(" %s]", sprinttime(ut[1]));
1650 int mode = tcp->u_arg[1];
1652 if (entering(tcp)) {
1653 printpath(tcp, tcp->u_arg[0]);
1654 tprintf(", %s", sprintmode(mode));
1655 switch (mode & S_IFMT) {
1656 case S_IFCHR: case S_IFBLK:
1658 if (current_personality == 1)
1659 tprintf(", makedev(%lu, %lu)",
1660 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1661 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1664 tprintf(", makedev(%lu, %lu)",
1665 (unsigned long) major(tcp->u_arg[2]),
1666 (unsigned long) minor(tcp->u_arg[2]));
1679 if (entering(tcp)) {
1680 printpath(tcp, tcp->u_arg[0]);
1681 tprintf(", %#lo", tcp->u_arg[1]);
1690 if (entering(tcp)) {
1691 tprintf("%ld", tcp->u_arg[0]);
1705 if (!verbose(tcp)) {
1706 tprintf("%#lx", addr);
1709 if (umove(tcp, addr, &d) < 0) {
1713 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1715 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1723 if (entering(tcp)) {
1724 tprintf("%lu, ", tcp->u_arg[0]);
1726 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1727 tprintf("%#lx", tcp->u_arg[1]);
1729 printdir(tcp, tcp->u_arg[1]);
1730 /* Not much point in printing this out, it is always 1. */
1731 if (tcp->u_arg[2] != 1)
1732 tprintf(", %lu", tcp->u_arg[2]);
1740 struct xlat direnttypes[] = {
1741 { DT_FIFO, "DT_FIFO" },
1742 { DT_CHR, "DT_CHR" },
1743 { DT_DIR, "DT_DIR" },
1744 { DT_BLK, "DT_BLK" },
1745 { DT_REG, "DT_REG" },
1746 { DT_LNK, "DT_LNK" },
1747 { DT_SOCK, "DT_SOCK" },
1748 { DT_WHT, "DT_WHT" },
1758 int i, len, dents = 0;
1761 if (entering(tcp)) {
1762 tprintf("%lu, ", tcp->u_arg[0]);
1765 if (syserror(tcp) || !verbose(tcp)) {
1766 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1770 if ((buf = malloc(len)) == NULL) {
1771 tprintf("out of memory\n");
1774 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1775 tprintf("{...}, %lu", tcp->u_arg[2]);
1781 for (i = 0; i < len;) {
1782 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1785 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1786 i ? " " : "", d->d_ino, d->d_off);
1787 tprintf("d_reclen=%u, d_name=\"%s\"}",
1788 d->d_reclen, d->d_name);
1793 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1794 i ? " " : "", d->d_ino, d->d_off);
1795 tprintf("d_reclen=%u, d_name=\"%s\"}",
1796 d->d_reclen, d->d_name);
1801 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1802 i ? " " : "", d->d_off, d->d_fileno,
1804 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1805 d->d_namlen, d->d_namlen, d->d_name);
1810 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1811 i ? " " : "", d->d_fileno, d->d_reclen);
1812 printxval(direnttypes, d->d_type, "DT_???");
1813 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1814 d->d_namlen, d->d_namlen, d->d_name);
1816 #endif /* FREEBSD */
1818 tprintf("/* d_reclen == 0, problem here */");
1827 tprintf("/* %u entries */", dents);
1828 tprintf(", %lu", tcp->u_arg[2]);
1834 #if _LFS64_LARGEFILE
1839 int i, len, dents = 0;
1842 if (entering(tcp)) {
1843 tprintf("%lu, ", tcp->u_arg[0]);
1846 if (syserror(tcp) || !verbose(tcp)) {
1847 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1851 if ((buf = malloc(len)) == NULL) {
1852 tprintf("out of memory\n");
1855 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1856 tprintf("{...}, %lu", tcp->u_arg[2]);
1862 for (i = 0; i < len;) {
1863 struct dirent64 *d = (struct dirent64 *) &buf[i];
1866 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1867 i ? " " : "", d->d_ino, d->d_off);
1868 tprintf("d_reclen=%u, d_name=\"%s\"}",
1869 d->d_reclen, d->d_name);
1874 tprintf("%s{d_ino=%llu, d_off=%llu, ",
1875 i ? " " : "", d->d_ino, d->d_off);
1876 tprintf("d_reclen=%u, d_name=\"%s\"}",
1877 d->d_reclen, d->d_name);
1882 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1883 i ? " " : "", d->d_off, d->d_fileno,
1885 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1886 d->d_namlen, d->d_namlen, d->d_name);
1895 tprintf("/* %u entries */", dents);
1896 tprintf(", %lu", tcp->u_arg[2]);
1904 sys_getdirentries(tcp)
1907 int i, len, dents = 0;
1911 if (entering(tcp)) {
1912 tprintf("%lu, ", tcp->u_arg[0]);
1915 if (syserror(tcp) || !verbose(tcp)) {
1916 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1920 if ((buf = malloc(len)) == NULL) {
1921 tprintf("out of memory\n");
1924 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1925 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
1931 for (i = 0; i < len;) {
1932 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1934 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1935 i ? " " : "", d->d_fileno, d->d_reclen);
1936 printxval(direnttypes, d->d_type, "DT_???");
1937 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1938 d->d_namlen, d->d_namlen, d->d_name);
1946 tprintf("/* %u entries */", dents);
1948 tprintf(", %lu", tcp->u_arg[2]);
1949 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
1950 tprintf(", %#lx", tcp->u_arg[3]);
1952 tprintf(", [%lu]", basep);
1964 tprintf("%#lx", tcp->u_arg[0]);
1966 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
1967 tprintf(", %lu", tcp->u_arg[1]);
1980 tprintf("%#lx", tcp->u_arg[0]);
1982 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
1983 tprintf(", %lu", tcp->u_arg[1]);
1989 #ifdef HAVE_SYS_ASYNCH_H
1995 struct aio_result_t res;
1997 if (entering(tcp)) {
1998 tprintf("%lu, ", tcp->u_arg[0]);
2001 tprintf("%#lx", tcp->u_arg[1]);
2003 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2004 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2005 printxval(whence, tcp->u_arg[4], "L_???");
2006 if (syserror(tcp) || tcp->u_arg[5] == 0
2007 || umove(tcp, tcp->u_arg[5], &res) < 0)
2008 tprintf(", %#lx", tcp->u_arg[5]);
2010 tprintf(", {aio_return %d aio_errno %d}",
2011 res.aio_return, res.aio_errno);
2020 struct aio_result_t res;
2022 if (entering(tcp)) {
2023 tprintf("%lu, ", tcp->u_arg[0]);
2024 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2025 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2026 printxval(whence, tcp->u_arg[4], "L_???");
2029 if (tcp->u_arg[5] == 0)
2031 else if (syserror(tcp)
2032 || umove(tcp, tcp->u_arg[5], &res) < 0)
2033 tprintf(", %#lx", tcp->u_arg[5]);
2035 tprintf(", {aio_return %d aio_errno %d}",
2036 res.aio_return, res.aio_errno);
2046 printtv(tcp, tcp->u_arg[0]);
2054 struct aio_result_t res;
2057 if (tcp->u_arg[0] == 0)
2059 else if (syserror(tcp)
2060 || umove(tcp, tcp->u_arg[0], &res) < 0)
2061 tprintf("%#lx", tcp->u_arg[0]);
2063 tprintf("{aio_return %d aio_errno %d}",
2064 res.aio_return, res.aio_errno);
2069 #endif /* HAVE_SYS_ASYNCH_H */