3 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
4 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
5 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
6 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #define dirent kernel_dirent
39 #define dirent64 kernel_dirent64
40 #include <linux/types.h>
41 #include <linux/dirent.h>
44 #define kernel_dirent dirent
50 unsigned short st_dev;
52 unsigned short st_mode;
54 unsigned short st_uid;
55 unsigned short st_gid;
56 unsigned short st_rdev;
59 unsigned int __unused1;
61 unsigned int __unused2;
63 unsigned int __unused3;
66 unsigned int __unused4[2];
68 # define stat kernel_stat
69 # include <asm/stat.h>
81 # define dev_t __kernel_dev_t
82 # define ino_t __kernel_ino_t
83 # define mode_t __kernel_mode_t
84 # define nlink_t __kernel_nlink_t
85 # define uid_t __kernel_uid_t
86 # define gid_t __kernel_gid_t
87 # define off_t __kernel_off_t
88 # define loff_t __kernel_loff_t
90 # include <asm/stat.h>
103 # define mode_t mode_t
104 # define nlink_t nlink_t
108 # define loff_t loff_t
110 # define stat libc_stat
111 # define stat64 libc_stat64
112 # include <sys/stat.h>
116 # include <sys/stat.h>
122 # include <sys/cred.h>
125 #ifdef HAVE_SYS_VFS_H
130 #include <sys/param.h>
131 #include <sys/mount.h>
132 #include <sys/stat.h>
135 #if HAVE_LONG_LONG_OFF_T
137 * Ugly hacks for systems that have typedef long long off_t
141 #define HAVE_STAT64 1 /* Ugly hack */
143 #define sys_stat64 sys_stat
144 #define sys_fstat64 sys_fstat
145 #define sys_lstat64 sys_lstat
146 #define sys_lseek64 sys_lseek
147 #define sys_truncate64 sys_truncate
148 #define sys_ftruncate64 sys_ftruncate
151 #ifdef MAJOR_IN_SYSMACROS
152 #include <sys/sysmacros.h>
155 #ifdef MAJOR_IN_MKDEV
156 #include <sys/mkdev.h>
159 #ifdef HAVE_SYS_ASYNCH_H
160 #include <sys/asynch.h>
168 * This is a really dirty trick but it should always work. Traditional
169 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
170 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
172 struct xlat openmodes[] = {
173 { O_RDWR+1, "O_RDWR" },
174 { O_RDONLY+1, "O_RDONLY" },
175 { O_WRONLY+1, "O_WRONLY" },
176 { O_NONBLOCK, "O_NONBLOCK" },
177 { O_APPEND, "O_APPEND" },
178 { O_CREAT, "O_CREAT" },
179 { O_TRUNC, "O_TRUNC" },
180 { O_EXCL, "O_EXCL" },
181 { O_NOCTTY, "O_NOCTTY" },
183 { O_SYNC, "O_SYNC" },
186 { O_ASYNC, "O_ASYNC" },
189 { O_DSYNC, "O_DSYNC" },
192 { O_RSYNC, "O_RSYNC" },
195 { O_NDELAY, "O_NDELAY" },
198 { O_PRIV, "O_PRIV" },
201 { O_DIRECT, "O_DIRECT" },
204 { O_LARGEFILE, "O_LARGEFILE" },
207 { O_DIRECTORY, "O_DIRECTORY" },
210 { O_NOFOLLOW, "O_NOFOLLOW" },
214 { FNDELAY, "FNDELAY" },
217 { FAPPEND, "FAPPEND" },
223 { FDEFER, "FDEFER" },
226 { FASYNC, "FASYNC" },
229 { FSHLOCK, "FSHLOCK" },
232 { FEXLOCK, "FEXLOCK" },
235 { FCREAT, "FCREAT" },
238 { FTRUNC, "FTRUNC" },
250 { FNOCTTY, "FNOCTTY" },
253 { O_SHLOCK, "O_SHLOCK" },
256 { O_EXLOCK, "O_EXLOCK" },
266 printpath(tcp, tcp->u_arg[0]);
269 printflags(openmodes, tcp->u_arg[1] + 1);
270 if (tcp->u_arg[1] & O_CREAT) {
272 tprintf(", %#lo", tcp->u_arg[2]);
279 struct xlat openmodessol[] = {
283 { 0x80, "O_NONBLOCK" },
285 { 0x100, "O_CREAT" },
286 { 0x200, "O_TRUNC" },
288 { 0x800, "O_NOCTTY" },
291 { 0x8000, "O_RSYNC" },
293 { 0x1000, "O_PRIV" },
302 printpath(tcp, tcp->u_arg[0]);
305 printflags(openmodessol, tcp->u_arg[1] + 1);
306 if (tcp->u_arg[1] & 0x100) {
308 tprintf(", %#lo", tcp->u_arg[2]);
321 printpath(tcp, tcp->u_arg[0]);
322 tprintf(", %#lo", tcp->u_arg[1]);
327 static struct xlat access_flags[] = {
333 { EFF_ONLY_OK, "EFF_ONLY_OK" },
346 printpath(tcp, tcp->u_arg[0]);
348 printflags(access_flags, tcp->u_arg[1]);
358 tprintf("%#lo", tcp->u_arg[0]);
363 static struct xlat whence[] = {
364 { SEEK_SET, "SEEK_SET" },
365 { SEEK_CUR, "SEEK_CUR" },
366 { SEEK_END, "SEEK_END" },
370 #ifndef HAVE_LONG_LONG_OFF_T
379 tprintf("%ld, ", tcp->u_arg[0]);
380 offset = tcp->u_arg[1];
381 _whence = tcp->u_arg[2];
382 if (_whence == SEEK_SET)
383 tprintf("%lu, ", offset);
385 tprintf("%ld, ", offset);
386 printxval(whence, _whence, "SEEK_???");
388 return RVAL_UDECIMAL;
398 if (tcp->u_arg[4] == SEEK_SET)
399 tprintf("%ld, %llu, ", tcp->u_arg[0],
400 (((long long int) tcp->u_arg[1]) << 32
401 | (unsigned long long) tcp->u_arg[2]));
403 tprintf("%ld, %lld, ", tcp->u_arg[0],
404 (((long long int) tcp->u_arg[1]) << 32
405 | (unsigned long long) tcp->u_arg[2]));
409 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
410 tprintf("%#lx, ", tcp->u_arg[3]);
412 tprintf("[%llu], ", off);
413 printxval(whence, tcp->u_arg[4], "SEEK_???");
419 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
426 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
427 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
428 if (tcp->u_arg[3] == SEEK_SET)
429 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
431 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
432 printxval(whence, tcp->u_arg[3], "SEEK_???");
434 return RVAL_LUDECIMAL;
438 #ifndef HAVE_LONG_LONG_OFF_T
444 printpath(tcp, tcp->u_arg[0]);
445 tprintf(", %lu", tcp->u_arg[1]);
451 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
458 printpath(tcp, tcp->u_arg[0]);
459 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
465 #ifndef HAVE_LONG_LONG_OFF_T
471 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
477 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
484 tprintf("%ld, %llu", tcp->u_arg[0],
485 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
493 static struct xlat modetypes[] = {
494 { S_IFREG, "S_IFREG" },
495 { S_IFSOCK, "S_IFSOCK" },
496 { S_IFIFO, "S_IFIFO" },
497 { S_IFLNK, "S_IFLNK" },
498 { S_IFDIR, "S_IFDIR" },
499 { S_IFBLK, "S_IFBLK" },
500 { S_IFCHR, "S_IFCHR" },
511 if ((mode & S_IFMT) == 0)
513 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
514 sprintf(buf, "%#o", mode);
517 sprintf(buf, "%s%s%s%s", s,
518 (mode & S_ISUID) ? "|S_ISUID" : "",
519 (mode & S_ISGID) ? "|S_ISGID" : "",
520 (mode & S_ISVTX) ? "|S_ISVTX" : "");
521 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
523 sprintf(buf + strlen(buf), "|%#o", mode);
524 s = (*buf == '|') ? buf + 1 : buf;
540 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
541 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
542 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
554 int st_pad1[3]; /* network id */
563 int st_pad3; /* st_size, off_t expansion */
564 timestruct_t st_atime;
565 timestruct_t st_mtime;
566 timestruct_t st_ctime;
570 int st_pad4[8]; /* expansion area */
574 printstatsol(tcp, addr)
578 struct solstat statbuf;
584 if (syserror(tcp) || !verbose(tcp)) {
585 tprintf("%#lx", addr);
588 if (umove(tcp, addr, &statbuf) < 0) {
593 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
594 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
595 (unsigned long) (statbuf.st_dev & 0x3ffff),
596 (unsigned long) statbuf.st_ino,
597 sprintmode(statbuf.st_mode));
598 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
599 (unsigned long) statbuf.st_nlink,
600 (unsigned long) statbuf.st_uid,
601 (unsigned long) statbuf.st_gid);
602 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
603 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
606 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
607 switch (statbuf.st_mode & S_IFMT) {
608 case S_IFCHR: case S_IFBLK:
609 tprintf("st_rdev=makedev(%lu, %lu), ",
610 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
611 (unsigned long) (statbuf.st_rdev & 0x3ffff));
614 tprintf("st_size=%u, ", statbuf.st_size);
618 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
619 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
620 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
625 #endif /* LINUXSPARC */
627 static struct xlat fileflags[] = {
629 { UF_NODUMP, "UF_NODUMP" },
630 { UF_IMMUTABLE, "UF_IMMUTABLE" },
631 { UF_APPEND, "UF_APPEND" },
632 { UF_OPAQUE, "UF_OPAQUE" },
633 { UF_NOUNLINK, "UF_NOUNLINK" },
634 { SF_ARCHIVED, "SF_ARCHIVED" },
635 { SF_IMMUTABLE, "SF_IMMUTABLE" },
636 { SF_APPEND, "SF_APPEND" },
637 { SF_NOUNLINK, "SF_NOUNLINK" },
640 { _S_ISMLD, "_S_ISMLD" },
643 { _S_ISMOUNTED, "_S_ISMOUNTED" },
655 printpath(tcp, tcp->u_arg[0]);
658 printflags(fileflags, tcp->u_arg[1]);
670 tprintf("%ld, ", tcp->u_arg[0]);
672 printflags(fileflags, tcp->u_arg[1]);
680 #ifndef HAVE_LONG_LONG_OFF_T
682 realprintstat(tcp, statbuf)
684 struct stat *statbuf;
687 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
688 (unsigned long) major(statbuf->st_dev),
689 (unsigned long) minor(statbuf->st_dev),
690 (unsigned long) statbuf->st_ino,
691 sprintmode(statbuf->st_mode));
692 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
693 (unsigned long) statbuf->st_nlink,
694 (unsigned long) statbuf->st_uid,
695 (unsigned long) statbuf->st_gid);
696 #ifdef HAVE_ST_BLKSIZE
697 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
698 #endif /* HAVE_ST_BLKSIZE */
699 #ifdef HAVE_ST_BLOCKS
700 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
701 #endif /* HAVE_ST_BLOCKS */
704 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
705 switch (statbuf->st_mode & S_IFMT) {
706 case S_IFCHR: case S_IFBLK:
708 tprintf("st_rdev=makedev(%lu, %lu), ",
709 (unsigned long) major(statbuf->st_rdev),
710 (unsigned long) minor(statbuf->st_rdev));
711 #else /* !HAVE_ST_RDEV */
712 tprintf("st_size=makedev(%lu, %lu), ",
713 (unsigned long) major(statbuf->st_size),
714 (unsigned long) minor(statbuf->st_size));
715 #endif /* !HAVE_ST_RDEV */
718 tprintf("st_size=%lu, ", statbuf->st_size);
722 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
723 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
724 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
726 tprintf(", st_flags=");
727 if (statbuf->st_flags) {
728 printflags(fileflags, statbuf->st_flags);
733 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
736 tprintf(", st_level=%ld", statbuf->st_level);
739 tprintf(", st_fstype=%.*s",
740 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
743 tprintf(", st_gen=%u", statbuf->st_gen);
760 if (current_personality == 1) {
761 printstatsol(tcp, addr);
764 #endif /* LINUXSPARC */
770 if (syserror(tcp) || !verbose(tcp)) {
771 tprintf("%#lx", addr);
774 if (umove(tcp, addr, &statbuf) < 0) {
779 realprintstat(tcp, &statbuf);
781 #endif /* !HAVE_LONG_LONG_OFF_T */
785 printstat64(tcp, addr)
789 struct stat64 statbuf;
792 if (current_personality == 1) {
793 printstatsol(tcp, addr);
796 #endif /* LINUXSPARC */
802 if (syserror(tcp) || !verbose(tcp)) {
803 tprintf("%#lx", addr);
806 if (umove(tcp, addr, &statbuf) < 0) {
812 #ifdef HAVE_LONG_LONG
813 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
815 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
817 (unsigned long) major(statbuf.st_dev),
818 (unsigned long) minor(statbuf.st_dev),
819 #ifdef HAVE_LONG_LONG
820 (unsigned long long) statbuf.st_ino,
822 (unsigned long) statbuf.st_ino,
824 sprintmode(statbuf.st_mode));
825 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
826 (unsigned long) statbuf.st_nlink,
827 (unsigned long) statbuf.st_uid,
828 (unsigned long) statbuf.st_gid);
829 #ifdef HAVE_ST_BLKSIZE
830 tprintf("st_blksize=%lu, ",
831 (unsigned long) statbuf.st_blksize);
832 #endif /* HAVE_ST_BLKSIZE */
833 #ifdef HAVE_ST_BLOCKS
834 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
835 #endif /* HAVE_ST_BLOCKS */
838 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
839 switch (statbuf.st_mode & S_IFMT) {
840 case S_IFCHR: case S_IFBLK:
842 tprintf("st_rdev=makedev(%lu, %lu), ",
843 (unsigned long) major(statbuf.st_rdev),
844 (unsigned long) minor(statbuf.st_rdev));
845 #else /* !HAVE_ST_RDEV */
846 tprintf("st_size=makedev(%lu, %lu), ",
847 (unsigned long) major(statbuf.st_size),
848 (unsigned long) minor(statbuf.st_size));
849 #endif /* !HAVE_ST_RDEV */
852 tprintf("st_size=%llu, ", statbuf.st_size);
856 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
857 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
858 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
860 tprintf(", st_flags=");
861 if (statbuf.st_flags) {
862 printflags(fileflags, statbuf.st_flags);
867 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
870 tprintf(", st_level=%ld", statbuf.st_level);
873 tprintf(", st_fstype=%.*s",
874 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
877 tprintf(", st_gen=%u", statbuf.st_gen);
884 #endif /* HAVE_STAT64 */
886 #if defined(linux) && !defined(IA64)
888 convertoldstat(oldbuf, newbuf)
889 const struct __old_kernel_stat *oldbuf;
892 newbuf->st_dev=oldbuf->st_dev;
893 newbuf->st_ino=oldbuf->st_ino;
894 newbuf->st_mode=oldbuf->st_mode;
895 newbuf->st_nlink=oldbuf->st_nlink;
896 newbuf->st_uid=oldbuf->st_uid;
897 newbuf->st_gid=oldbuf->st_gid;
898 newbuf->st_rdev=oldbuf->st_rdev;
899 newbuf->st_size=oldbuf->st_size;
900 newbuf->st_atime=oldbuf->st_atime;
901 newbuf->st_mtime=oldbuf->st_mtime;
902 newbuf->st_ctime=oldbuf->st_ctime;
903 newbuf->st_blksize=0; /* not supported in old_stat */
904 newbuf->st_blocks=0; /* not supported in old_stat */
909 printoldstat(tcp, addr)
913 struct __old_kernel_stat statbuf;
914 struct stat newstatbuf;
917 if (current_personality == 1) {
918 printstatsol(tcp, addr);
921 #endif /* LINUXSPARC */
927 if (syserror(tcp) || !verbose(tcp)) {
928 tprintf("%#lx", addr);
931 if (umove(tcp, addr, &statbuf) < 0) {
936 convertoldstat(&statbuf, &newstatbuf);
937 realprintstat(tcp, &newstatbuf);
939 #endif /* linux && !IA64 */
941 #ifndef HAVE_LONG_LONG_OFF_T
947 printpath(tcp, tcp->u_arg[0]);
950 printstat(tcp, tcp->u_arg[1]);
962 printpath(tcp, tcp->u_arg[0]);
965 printstat64(tcp, tcp->u_arg[1]);
969 return printargs(tcp);
980 printpath(tcp, tcp->u_arg[0]);
983 printoldstat(tcp, tcp->u_arg[1]);
990 #ifndef HAVE_LONG_LONG_OFF_T
996 tprintf("%ld, ", tcp->u_arg[0]);
998 printstat(tcp, tcp->u_arg[1]);
1010 tprintf("%ld, ", tcp->u_arg[0]);
1012 printstat64(tcp, tcp->u_arg[1]);
1016 return printargs(tcp);
1027 tprintf("%ld, ", tcp->u_arg[0]);
1029 printoldstat(tcp, tcp->u_arg[1]);
1036 #ifndef HAVE_LONG_LONG_OFF_T
1041 if (entering(tcp)) {
1042 printpath(tcp, tcp->u_arg[0]);
1045 printstat(tcp, tcp->u_arg[1]);
1056 if (entering(tcp)) {
1057 printpath(tcp, tcp->u_arg[0]);
1060 printstat64(tcp, tcp->u_arg[1]);
1064 return printargs(tcp);
1074 if (entering(tcp)) {
1075 printpath(tcp, tcp->u_arg[0]);
1078 printoldstat(tcp, tcp->u_arg[1]);
1086 #if defined(SVR4) || defined(LINUXSPARC)
1092 if (entering(tcp)) {
1093 tprintf("%ld, ", tcp->u_arg[0]);
1094 printpath(tcp, tcp->u_arg[1]);
1098 if (tcp->u_arg[0] == _STAT64_VER)
1099 printstat64 (tcp, tcp->u_arg[2]);
1102 printstat(tcp, tcp->u_arg[2]);
1112 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1115 if (tcp->u_arg[0] == _STAT64_VER)
1116 printstat64 (tcp, tcp->u_arg[2]);
1119 printstat(tcp, tcp->u_arg[2]);
1128 if (entering(tcp)) {
1129 tprintf("%ld, ", tcp->u_arg[0]);
1130 printpath(tcp, tcp->u_arg[1]);
1134 if (tcp->u_arg[0] == _STAT64_VER)
1135 printstat64 (tcp, tcp->u_arg[2]);
1138 printstat(tcp, tcp->u_arg[2]);
1147 int mode = tcp->u_arg[2];
1149 if (entering(tcp)) {
1150 tprintf("%ld, ", tcp->u_arg[0]);
1151 printpath(tcp, tcp->u_arg[1]);
1152 tprintf(", %s", sprintmode(mode));
1153 switch (mode & S_IFMT) {
1154 case S_IFCHR: case S_IFBLK:
1156 tprintf(", makedev(%lu, %lu)",
1157 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1158 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1160 tprintf(", makedev(%lu, %lu)",
1161 (unsigned long) major(tcp->u_arg[3]),
1162 (unsigned long) minor(tcp->u_arg[3]));
1172 #ifdef HAVE_SYS_ACL_H
1174 #include <sys/acl.h>
1176 struct xlat aclcmds[] = {
1178 { SETACL, "SETACL" },
1181 { GETACL, "GETACL" },
1184 { GETACLCNT, "GETACLCNT" },
1187 { ACL_GET, "ACL_GET" },
1190 { ACL_SET, "ACL_SET" },
1193 { ACL_CNT, "ACL_CNT" },
1202 if (entering(tcp)) {
1203 printpath(tcp, tcp->u_arg[0]);
1205 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1206 tprintf(", %ld", tcp->u_arg[2]);
1208 * FIXME - dump out the list of aclent_t's pointed to
1209 * by "tcp->u_arg[3]" if it's not NULL.
1212 tprintf(", %#lx", tcp->u_arg[3]);
1224 if (entering(tcp)) {
1225 tprintf("%ld, ", tcp->u_arg[0]);
1226 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1227 tprintf(", %ld", tcp->u_arg[2]);
1229 * FIXME - dump out the list of aclent_t's pointed to
1230 * by "tcp->u_arg[3]" if it's not NULL.
1233 tprintf(", %#lx", tcp->u_arg[3]);
1241 struct xlat aclipc[] = {
1243 { IPC_SHM, "IPC_SHM" },
1246 { IPC_SEM, "IPC_SEM" },
1249 { IPC_MSG, "IPC_MSG" },
1259 if (entering(tcp)) {
1260 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1261 tprintf(", %#lx, ", tcp->u_arg[1]);
1262 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1263 tprintf(", %ld", tcp->u_arg[3]);
1265 * FIXME - dump out the list of aclent_t's pointed to
1266 * by "tcp->u_arg[4]" if it's not NULL.
1269 tprintf(", %#lx", tcp->u_arg[4]);
1278 #endif /* HAVE_SYS_ACL_H */
1280 #endif /* SVR4 || LINUXSPARC */
1284 static struct xlat fsmagic[] = {
1285 { 0x73757245, "CODA_SUPER_MAGIC" },
1286 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1287 { 0x1373, "DEVFS_SUPER_MAGIC" },
1288 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1289 { 0x414A53, "EFS_SUPER_MAGIC" },
1290 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1291 { 0xef53, "EXT2_SUPER_MAGIC" },
1292 { 0x137d, "EXT_SUPER_MAGIC" },
1293 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1294 { 0x9660, "ISOFS_SUPER_MAGIC" },
1295 { 0x137f, "MINIX_SUPER_MAGIC" },
1296 { 0x138f, "MINIX_SUPER_MAGIC2" },
1297 { 0x2468, "MINIX2_SUPER_MAGIC" },
1298 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1299 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1300 { 0x564c, "NCP_SUPER_MAGIC" },
1301 { 0x6969, "NFS_SUPER_MAGIC" },
1302 { 0x9fa0, "PROC_SUPER_MAGIC" },
1303 { 0x002f, "QNX4_SUPER_MAGIC" },
1304 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1305 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1306 { 0x517b, "SMB_SUPER_MAGIC" },
1307 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1308 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1309 { 0x00011954, "UFS_MAGIC" },
1310 { 0x54190100, "UFS_CIGAM" },
1311 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1312 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1324 static char buf[32];
1328 s = xlookup(fsmagic, magic);
1330 sprintf(buf, "\"%s\"", s);
1334 sprintf(buf, "%#x", magic);
1339 printstatfs(tcp, addr)
1343 struct statfs statbuf;
1345 if (syserror(tcp) || !verbose(tcp)) {
1346 tprintf("%#lx", addr);
1349 if (umove(tcp, addr, &statbuf) < 0) {
1355 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1356 sprintfstype(statbuf.f_type),
1357 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1358 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
1359 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1361 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1362 sprintfstype(statbuf.f_type),
1363 (unsigned long)statbuf.f_bsize,
1364 (unsigned long)statbuf.f_blocks,
1365 (unsigned long)statbuf.f_bfree);
1366 tprintf("f_files=%lu, f_ffree=%lu",
1367 (unsigned long)statbuf.f_files,
1368 (unsigned long)statbuf.f_ffree);
1370 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1380 if (entering(tcp)) {
1381 printpath(tcp, tcp->u_arg[0]);
1384 printstatfs(tcp, tcp->u_arg[1]);
1393 if (entering(tcp)) {
1394 tprintf("%lu, ", tcp->u_arg[0]);
1396 printstatfs(tcp, tcp->u_arg[1]);
1401 #if defined(linux) && defined(__alpha)
1407 if (entering(tcp)) {
1408 printpath(tcp, tcp->u_arg[0]);
1411 printstatfs(tcp, tcp->u_arg[1]);
1412 tprintf(", %lu", tcp->u_arg[2]);
1421 if (entering(tcp)) {
1422 tprintf("%lu, ", tcp->u_arg[0]);
1424 printstatfs(tcp, tcp->u_arg[1]);
1425 tprintf(", %lu", tcp->u_arg[2]);
1429 #endif /* linux && __alpha */
1439 struct ustat statbuf;
1441 if (entering(tcp)) {
1442 tprintf("makedev(%lu, %lu), ",
1443 (long) major(tcp->u_arg[0]),
1444 (long) minor(tcp->u_arg[0]));
1447 if (syserror(tcp) || !verbose(tcp))
1448 tprintf("%#lx", tcp->u_arg[1]);
1449 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1452 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1453 statbuf.f_tfree, statbuf.f_tinode);
1454 tprintf("f_fname=\"%.*s\", ",
1455 (int) sizeof(statbuf.f_fname),
1457 tprintf("f_fpack=\"%.*s\"}",
1458 (int) sizeof(statbuf.f_fpack),
1471 if (entering(tcp)) {
1472 printpath(tcp, tcp->u_arg[0]);
1474 printpath(tcp, tcp->u_arg[1]);
1485 if (entering(tcp)) {
1486 printpath(tcp, tcp->u_arg[0]);
1495 if (entering(tcp)) {
1496 printpath(tcp, tcp->u_arg[0]);
1497 tprintf(", %#lo", tcp->u_arg[1]);
1506 if (entering(tcp)) {
1507 printpath(tcp, tcp->u_arg[0]);
1516 if (entering(tcp)) {
1517 tprintf("%ld", tcp->u_arg[0]);
1526 if (entering(tcp)) {
1527 printpath(tcp, tcp->u_arg[0]);
1536 if (entering(tcp)) {
1537 tprintf("%ld", tcp->u_arg[0]);
1546 if (entering(tcp)) {
1547 printpath(tcp, tcp->u_arg[0]);
1549 printpath(tcp, tcp->u_arg[1]);
1558 if (entering(tcp)) {
1559 printpath(tcp, tcp->u_arg[0]);
1568 if (entering(tcp)) {
1569 printpath(tcp, tcp->u_arg[0]);
1571 printpath(tcp, tcp->u_arg[1]);
1580 if (entering(tcp)) {
1581 printpath(tcp, tcp->u_arg[0]);
1585 tprintf("%#lx", tcp->u_arg[1]);
1587 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1588 tprintf(", %lu", tcp->u_arg[2]);
1597 if (entering(tcp)) {
1598 printpath(tcp, tcp->u_arg[0]);
1600 printpath(tcp, tcp->u_arg[1]);
1609 if (entering(tcp)) {
1610 printpath(tcp, tcp->u_arg[0]);
1611 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1620 if (entering(tcp)) {
1621 tprintf("%ld, %lu, %lu",
1622 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1631 if (entering(tcp)) {
1632 printpath(tcp, tcp->u_arg[0]);
1633 tprintf(", %#lo", tcp->u_arg[1]);
1642 if (entering(tcp)) {
1643 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1653 if (entering(tcp)) {
1654 printpath(tcp, tcp->u_arg[0]);
1656 printtv32(tcp, tcp->u_arg[1]);
1666 if (entering(tcp)) {
1667 printpath(tcp, tcp->u_arg[0]);
1669 printtv(tcp, tcp->u_arg[1]);
1680 if (entering(tcp)) {
1681 printpath(tcp, tcp->u_arg[0]);
1685 else if (!verbose(tcp))
1686 tprintf("%#lx", tcp->u_arg[1]);
1687 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1691 tprintf("[%s,", sprinttime(ut[0]));
1692 tprintf(" %s]", sprinttime(ut[1]));
1702 int mode = tcp->u_arg[1];
1704 if (entering(tcp)) {
1705 printpath(tcp, tcp->u_arg[0]);
1706 tprintf(", %s", sprintmode(mode));
1707 switch (mode & S_IFMT) {
1708 case S_IFCHR: case S_IFBLK:
1710 if (current_personality == 1)
1711 tprintf(", makedev(%lu, %lu)",
1712 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1713 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1716 tprintf(", makedev(%lu, %lu)",
1717 (unsigned long) major(tcp->u_arg[2]),
1718 (unsigned long) minor(tcp->u_arg[2]));
1731 if (entering(tcp)) {
1732 printpath(tcp, tcp->u_arg[0]);
1733 tprintf(", %#lo", tcp->u_arg[1]);
1742 if (entering(tcp)) {
1743 tprintf("%ld", tcp->u_arg[0]);
1757 if (!verbose(tcp)) {
1758 tprintf("%#lx", addr);
1761 if (umove(tcp, addr, &d) < 0) {
1765 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1767 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1775 if (entering(tcp)) {
1776 tprintf("%lu, ", tcp->u_arg[0]);
1778 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1779 tprintf("%#lx", tcp->u_arg[1]);
1781 printdir(tcp, tcp->u_arg[1]);
1782 /* Not much point in printing this out, it is always 1. */
1783 if (tcp->u_arg[2] != 1)
1784 tprintf(", %lu", tcp->u_arg[2]);
1792 struct xlat direnttypes[] = {
1793 { DT_FIFO, "DT_FIFO" },
1794 { DT_CHR, "DT_CHR" },
1795 { DT_DIR, "DT_DIR" },
1796 { DT_BLK, "DT_BLK" },
1797 { DT_REG, "DT_REG" },
1798 { DT_LNK, "DT_LNK" },
1799 { DT_SOCK, "DT_SOCK" },
1800 { DT_WHT, "DT_WHT" },
1810 int i, len, dents = 0;
1813 if (entering(tcp)) {
1814 tprintf("%lu, ", tcp->u_arg[0]);
1817 if (syserror(tcp) || !verbose(tcp)) {
1818 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1822 if ((buf = malloc(len)) == NULL) {
1823 tprintf("out of memory\n");
1826 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1827 tprintf("{...}, %lu", tcp->u_arg[2]);
1833 for (i = 0; i < len;) {
1834 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1837 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1838 i ? " " : "", d->d_ino, d->d_off);
1839 tprintf("d_reclen=%u, d_name=\"%s\"}",
1840 d->d_reclen, d->d_name);
1845 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1846 i ? " " : "", d->d_ino, d->d_off);
1847 tprintf("d_reclen=%u, d_name=\"%s\"}",
1848 d->d_reclen, d->d_name);
1853 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1854 i ? " " : "", d->d_off, d->d_fileno,
1856 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1857 d->d_namlen, d->d_namlen, d->d_name);
1862 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1863 i ? " " : "", d->d_fileno, d->d_reclen);
1864 printxval(direnttypes, d->d_type, "DT_???");
1865 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1866 d->d_namlen, d->d_namlen, d->d_name);
1868 #endif /* FREEBSD */
1870 tprintf("/* d_reclen == 0, problem here */");
1879 tprintf("/* %u entries */", dents);
1880 tprintf(", %lu", tcp->u_arg[2]);
1886 #if _LFS64_LARGEFILE
1891 int i, len, dents = 0;
1894 if (entering(tcp)) {
1895 tprintf("%lu, ", tcp->u_arg[0]);
1898 if (syserror(tcp) || !verbose(tcp)) {
1899 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1903 if ((buf = malloc(len)) == NULL) {
1904 tprintf("out of memory\n");
1907 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1908 tprintf("{...}, %lu", tcp->u_arg[2]);
1914 for (i = 0; i < len;) {
1915 struct dirent64 *d = (struct dirent64 *) &buf[i];
1918 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1919 i ? " " : "", d->d_ino, d->d_off);
1920 tprintf("d_reclen=%u, d_name=\"%s\"}",
1921 d->d_reclen, d->d_name);
1926 tprintf("%s{d_ino=%llu, d_off=%llu, ",
1927 i ? " " : "", d->d_ino, d->d_off);
1928 tprintf("d_reclen=%u, d_name=\"%s\"}",
1929 d->d_reclen, d->d_name);
1934 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1935 i ? " " : "", d->d_off, d->d_fileno,
1937 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1938 d->d_namlen, d->d_namlen, d->d_name);
1947 tprintf("/* %u entries */", dents);
1948 tprintf(", %lu", tcp->u_arg[2]);
1956 sys_getdirentries(tcp)
1959 int i, len, dents = 0;
1963 if (entering(tcp)) {
1964 tprintf("%lu, ", tcp->u_arg[0]);
1967 if (syserror(tcp) || !verbose(tcp)) {
1968 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1972 if ((buf = malloc(len)) == NULL) {
1973 tprintf("out of memory\n");
1976 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1977 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
1983 for (i = 0; i < len;) {
1984 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1986 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1987 i ? " " : "", d->d_fileno, d->d_reclen);
1988 printxval(direnttypes, d->d_type, "DT_???");
1989 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1990 d->d_namlen, d->d_namlen, d->d_name);
1998 tprintf("/* %u entries */", dents);
2000 tprintf(", %lu", tcp->u_arg[2]);
2001 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2002 tprintf(", %#lx", tcp->u_arg[3]);
2004 tprintf(", [%lu]", basep);
2016 tprintf("%#lx", tcp->u_arg[0]);
2018 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2019 tprintf(", %lu", tcp->u_arg[1]);
2032 tprintf("%#lx", tcp->u_arg[0]);
2034 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2035 tprintf(", %lu", tcp->u_arg[1]);
2041 #ifdef HAVE_SYS_ASYNCH_H
2047 struct aio_result_t res;
2049 if (entering(tcp)) {
2050 tprintf("%lu, ", tcp->u_arg[0]);
2053 tprintf("%#lx", tcp->u_arg[1]);
2055 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2056 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2057 printxval(whence, tcp->u_arg[4], "L_???");
2058 if (syserror(tcp) || tcp->u_arg[5] == 0
2059 || umove(tcp, tcp->u_arg[5], &res) < 0)
2060 tprintf(", %#lx", tcp->u_arg[5]);
2062 tprintf(", {aio_return %d aio_errno %d}",
2063 res.aio_return, res.aio_errno);
2072 struct aio_result_t res;
2074 if (entering(tcp)) {
2075 tprintf("%lu, ", tcp->u_arg[0]);
2076 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2077 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2078 printxval(whence, tcp->u_arg[4], "L_???");
2081 if (tcp->u_arg[5] == 0)
2083 else if (syserror(tcp)
2084 || umove(tcp, tcp->u_arg[5], &res) < 0)
2085 tprintf(", %#lx", tcp->u_arg[5]);
2087 tprintf(", {aio_return %d aio_errno %d}",
2088 res.aio_return, res.aio_errno);
2098 printtv(tcp, tcp->u_arg[0]);
2106 struct aio_result_t res;
2109 if (tcp->u_arg[0] == 0)
2111 else if (syserror(tcp)
2112 || umove(tcp, tcp->u_arg[0], &res) < 0)
2113 tprintf("%#lx", tcp->u_arg[0]);
2115 tprintf("{aio_return %d aio_errno %d}",
2116 res.aio_return, res.aio_errno);
2121 #endif /* HAVE_SYS_ASYNCH_H */