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 # ifdef HPPA /* asm-parisc/stat.h defines stat64 */
113 # define stat libc_stat
114 # define stat64 libc_stat64
115 # include <sys/stat.h>
119 # define stat64 hpux_stat64
122 # include <sys/stat.h>
128 # include <sys/cred.h>
131 #ifdef HAVE_SYS_VFS_H
136 #include <sys/param.h>
137 #include <sys/mount.h>
138 #include <sys/stat.h>
141 #if HAVE_LONG_LONG_OFF_T
143 * Ugly hacks for systems that have typedef long long off_t
147 #define HAVE_STAT64 1 /* Ugly hack */
149 #define sys_stat64 sys_stat
150 #define sys_fstat64 sys_fstat
151 #define sys_lstat64 sys_lstat
152 #define sys_lseek64 sys_lseek
153 #define sys_truncate64 sys_truncate
154 #define sys_ftruncate64 sys_ftruncate
157 #ifdef MAJOR_IN_SYSMACROS
158 #include <sys/sysmacros.h>
161 #ifdef MAJOR_IN_MKDEV
162 #include <sys/mkdev.h>
165 #ifdef HAVE_SYS_ASYNCH_H
166 #include <sys/asynch.h>
174 * This is a really dirty trick but it should always work. Traditional
175 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
176 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
178 struct xlat openmodes[] = {
179 { O_RDWR+1, "O_RDWR" },
180 { O_RDONLY+1, "O_RDONLY" },
181 { O_WRONLY+1, "O_WRONLY" },
182 { O_NONBLOCK, "O_NONBLOCK" },
183 { O_APPEND, "O_APPEND" },
184 { O_CREAT, "O_CREAT" },
185 { O_TRUNC, "O_TRUNC" },
186 { O_EXCL, "O_EXCL" },
187 { O_NOCTTY, "O_NOCTTY" },
189 { O_SYNC, "O_SYNC" },
192 { O_ASYNC, "O_ASYNC" },
195 { O_DSYNC, "O_DSYNC" },
198 { O_RSYNC, "O_RSYNC" },
201 { O_NDELAY, "O_NDELAY" },
204 { O_PRIV, "O_PRIV" },
207 { O_DIRECT, "O_DIRECT" },
210 { O_LARGEFILE, "O_LARGEFILE" },
213 { O_DIRECTORY, "O_DIRECTORY" },
216 { O_NOFOLLOW, "O_NOFOLLOW" },
220 { FNDELAY, "FNDELAY" },
223 { FAPPEND, "FAPPEND" },
229 { FDEFER, "FDEFER" },
232 { FASYNC, "FASYNC" },
235 { FSHLOCK, "FSHLOCK" },
238 { FEXLOCK, "FEXLOCK" },
241 { FCREAT, "FCREAT" },
244 { FTRUNC, "FTRUNC" },
256 { FNOCTTY, "FNOCTTY" },
259 { O_SHLOCK, "O_SHLOCK" },
262 { O_EXLOCK, "O_EXLOCK" },
272 printpath(tcp, tcp->u_arg[0]);
275 printflags(openmodes, tcp->u_arg[1] + 1);
276 if (tcp->u_arg[1] & O_CREAT) {
278 tprintf(", %#lo", tcp->u_arg[2]);
285 struct xlat openmodessol[] = {
289 { 0x80, "O_NONBLOCK" },
291 { 0x100, "O_CREAT" },
292 { 0x200, "O_TRUNC" },
294 { 0x800, "O_NOCTTY" },
297 { 0x8000, "O_RSYNC" },
299 { 0x1000, "O_PRIV" },
308 printpath(tcp, tcp->u_arg[0]);
311 printflags(openmodessol, tcp->u_arg[1] + 1);
312 if (tcp->u_arg[1] & 0x100) {
314 tprintf(", %#lo", tcp->u_arg[2]);
327 printpath(tcp, tcp->u_arg[0]);
328 tprintf(", %#lo", tcp->u_arg[1]);
333 static struct xlat access_flags[] = {
339 { EFF_ONLY_OK, "EFF_ONLY_OK" },
352 printpath(tcp, tcp->u_arg[0]);
354 printflags(access_flags, tcp->u_arg[1]);
364 tprintf("%#lo", tcp->u_arg[0]);
369 static struct xlat whence[] = {
370 { SEEK_SET, "SEEK_SET" },
371 { SEEK_CUR, "SEEK_CUR" },
372 { SEEK_END, "SEEK_END" },
376 #ifndef HAVE_LONG_LONG_OFF_T
385 tprintf("%ld, ", tcp->u_arg[0]);
386 offset = tcp->u_arg[1];
387 _whence = tcp->u_arg[2];
388 if (_whence == SEEK_SET)
389 tprintf("%lu, ", offset);
391 tprintf("%ld, ", offset);
392 printxval(whence, _whence, "SEEK_???");
394 return RVAL_UDECIMAL;
404 if (tcp->u_arg[4] == SEEK_SET)
405 tprintf("%ld, %llu, ", tcp->u_arg[0],
406 (((long long int) tcp->u_arg[1]) << 32
407 | (unsigned long long) (unsigned) tcp->u_arg[2]));
409 tprintf("%ld, %lld, ", tcp->u_arg[0],
410 (((long long int) tcp->u_arg[1]) << 32
411 | (unsigned long long) (unsigned) tcp->u_arg[2]));
415 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
416 tprintf("%#lx, ", tcp->u_arg[3]);
418 tprintf("[%llu], ", off);
419 printxval(whence, tcp->u_arg[4], "SEEK_???");
425 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
432 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
433 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
434 if (tcp->u_arg[3] == SEEK_SET)
435 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
437 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
438 printxval(whence, tcp->u_arg[3], "SEEK_???");
440 return RVAL_LUDECIMAL;
444 #ifndef HAVE_LONG_LONG_OFF_T
450 printpath(tcp, tcp->u_arg[0]);
451 tprintf(", %lu", tcp->u_arg[1]);
457 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
464 printpath(tcp, tcp->u_arg[0]);
465 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
471 #ifndef HAVE_LONG_LONG_OFF_T
477 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
483 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
490 tprintf("%ld, %llu", tcp->u_arg[0],
491 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
499 static struct xlat modetypes[] = {
500 { S_IFREG, "S_IFREG" },
501 { S_IFSOCK, "S_IFSOCK" },
502 { S_IFIFO, "S_IFIFO" },
503 { S_IFLNK, "S_IFLNK" },
504 { S_IFDIR, "S_IFDIR" },
505 { S_IFBLK, "S_IFBLK" },
506 { S_IFCHR, "S_IFCHR" },
517 if ((mode & S_IFMT) == 0)
519 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
520 sprintf(buf, "%#o", mode);
523 sprintf(buf, "%s%s%s%s", s,
524 (mode & S_ISUID) ? "|S_ISUID" : "",
525 (mode & S_ISGID) ? "|S_ISGID" : "",
526 (mode & S_ISVTX) ? "|S_ISVTX" : "");
527 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
529 sprintf(buf + strlen(buf), "|%#o", mode);
530 s = (*buf == '|') ? buf + 1 : buf;
546 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
547 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
548 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
560 int st_pad1[3]; /* network id */
569 int st_pad3; /* st_size, off_t expansion */
570 timestruct_t st_atime;
571 timestruct_t st_mtime;
572 timestruct_t st_ctime;
576 int st_pad4[8]; /* expansion area */
580 printstatsol(tcp, addr)
584 struct solstat statbuf;
590 if (syserror(tcp) || !verbose(tcp)) {
591 tprintf("%#lx", addr);
594 if (umove(tcp, addr, &statbuf) < 0) {
599 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
600 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
601 (unsigned long) (statbuf.st_dev & 0x3ffff),
602 (unsigned long) statbuf.st_ino,
603 sprintmode(statbuf.st_mode));
604 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
605 (unsigned long) statbuf.st_nlink,
606 (unsigned long) statbuf.st_uid,
607 (unsigned long) statbuf.st_gid);
608 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
609 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
612 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
613 switch (statbuf.st_mode & S_IFMT) {
614 case S_IFCHR: case S_IFBLK:
615 tprintf("st_rdev=makedev(%lu, %lu), ",
616 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
617 (unsigned long) (statbuf.st_rdev & 0x3ffff));
620 tprintf("st_size=%u, ", statbuf.st_size);
624 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
625 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
626 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
631 #endif /* LINUXSPARC */
633 static struct xlat fileflags[] = {
635 { UF_NODUMP, "UF_NODUMP" },
636 { UF_IMMUTABLE, "UF_IMMUTABLE" },
637 { UF_APPEND, "UF_APPEND" },
638 { UF_OPAQUE, "UF_OPAQUE" },
639 { UF_NOUNLINK, "UF_NOUNLINK" },
640 { SF_ARCHIVED, "SF_ARCHIVED" },
641 { SF_IMMUTABLE, "SF_IMMUTABLE" },
642 { SF_APPEND, "SF_APPEND" },
643 { SF_NOUNLINK, "SF_NOUNLINK" },
646 { _S_ISMLD, "_S_ISMLD" },
649 { _S_ISMOUNTED, "_S_ISMOUNTED" },
661 printpath(tcp, tcp->u_arg[0]);
664 printflags(fileflags, tcp->u_arg[1]);
676 tprintf("%ld, ", tcp->u_arg[0]);
678 printflags(fileflags, tcp->u_arg[1]);
686 #ifndef HAVE_LONG_LONG_OFF_T
688 realprintstat(tcp, statbuf)
690 struct stat *statbuf;
693 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
694 (unsigned long) major(statbuf->st_dev),
695 (unsigned long) minor(statbuf->st_dev),
696 (unsigned long) statbuf->st_ino,
697 sprintmode(statbuf->st_mode));
698 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
699 (unsigned long) statbuf->st_nlink,
700 (unsigned long) statbuf->st_uid,
701 (unsigned long) statbuf->st_gid);
702 #ifdef HAVE_ST_BLKSIZE
703 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
704 #endif /* HAVE_ST_BLKSIZE */
705 #ifdef HAVE_ST_BLOCKS
706 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
707 #endif /* HAVE_ST_BLOCKS */
710 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
711 switch (statbuf->st_mode & S_IFMT) {
712 case S_IFCHR: case S_IFBLK:
714 tprintf("st_rdev=makedev(%lu, %lu), ",
715 (unsigned long) major(statbuf->st_rdev),
716 (unsigned long) minor(statbuf->st_rdev));
717 #else /* !HAVE_ST_RDEV */
718 tprintf("st_size=makedev(%lu, %lu), ",
719 (unsigned long) major(statbuf->st_size),
720 (unsigned long) minor(statbuf->st_size));
721 #endif /* !HAVE_ST_RDEV */
724 tprintf("st_size=%lu, ", statbuf->st_size);
728 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
729 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
730 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
732 tprintf(", st_flags=");
733 if (statbuf->st_flags) {
734 printflags(fileflags, statbuf->st_flags);
739 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
742 tprintf(", st_level=%ld", statbuf->st_level);
745 tprintf(", st_fstype=%.*s",
746 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
749 tprintf(", st_gen=%u", statbuf->st_gen);
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) {
785 realprintstat(tcp, &statbuf);
787 #endif /* !HAVE_LONG_LONG_OFF_T */
791 printstat64(tcp, addr)
795 struct stat64 statbuf;
798 if (current_personality == 1) {
799 printstatsol(tcp, addr);
802 #endif /* LINUXSPARC */
808 if (syserror(tcp) || !verbose(tcp)) {
809 tprintf("%#lx", addr);
812 if (umove(tcp, addr, &statbuf) < 0) {
818 #ifdef HAVE_LONG_LONG
819 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
821 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
823 (unsigned long) major(statbuf.st_dev),
824 (unsigned long) minor(statbuf.st_dev),
825 #ifdef HAVE_LONG_LONG
826 (unsigned long long) statbuf.st_ino,
828 (unsigned long) statbuf.st_ino,
830 sprintmode(statbuf.st_mode));
831 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
832 (unsigned long) statbuf.st_nlink,
833 (unsigned long) statbuf.st_uid,
834 (unsigned long) statbuf.st_gid);
835 #ifdef HAVE_ST_BLKSIZE
836 tprintf("st_blksize=%lu, ",
837 (unsigned long) statbuf.st_blksize);
838 #endif /* HAVE_ST_BLKSIZE */
839 #ifdef HAVE_ST_BLOCKS
840 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
841 #endif /* HAVE_ST_BLOCKS */
844 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
845 switch (statbuf.st_mode & S_IFMT) {
846 case S_IFCHR: case S_IFBLK:
848 tprintf("st_rdev=makedev(%lu, %lu), ",
849 (unsigned long) major(statbuf.st_rdev),
850 (unsigned long) minor(statbuf.st_rdev));
851 #else /* !HAVE_ST_RDEV */
852 tprintf("st_size=makedev(%lu, %lu), ",
853 (unsigned long) major(statbuf.st_size),
854 (unsigned long) minor(statbuf.st_size));
855 #endif /* !HAVE_ST_RDEV */
858 tprintf("st_size=%llu, ", statbuf.st_size);
862 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
863 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
864 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
866 tprintf(", st_flags=");
867 if (statbuf.st_flags) {
868 printflags(fileflags, statbuf.st_flags);
873 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
876 tprintf(", st_level=%ld", statbuf.st_level);
879 tprintf(", st_fstype=%.*s",
880 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
883 tprintf(", st_gen=%u", statbuf.st_gen);
890 #endif /* HAVE_STAT64 */
892 #if defined(linux) && !defined(IA64) && !defined(HPPA)
894 convertoldstat(oldbuf, newbuf)
895 const struct __old_kernel_stat *oldbuf;
898 newbuf->st_dev=oldbuf->st_dev;
899 newbuf->st_ino=oldbuf->st_ino;
900 newbuf->st_mode=oldbuf->st_mode;
901 newbuf->st_nlink=oldbuf->st_nlink;
902 newbuf->st_uid=oldbuf->st_uid;
903 newbuf->st_gid=oldbuf->st_gid;
904 newbuf->st_rdev=oldbuf->st_rdev;
905 newbuf->st_size=oldbuf->st_size;
906 newbuf->st_atime=oldbuf->st_atime;
907 newbuf->st_mtime=oldbuf->st_mtime;
908 newbuf->st_ctime=oldbuf->st_ctime;
909 newbuf->st_blksize=0; /* not supported in old_stat */
910 newbuf->st_blocks=0; /* not supported in old_stat */
915 printoldstat(tcp, addr)
919 struct __old_kernel_stat statbuf;
920 struct stat newstatbuf;
923 if (current_personality == 1) {
924 printstatsol(tcp, addr);
927 #endif /* LINUXSPARC */
933 if (syserror(tcp) || !verbose(tcp)) {
934 tprintf("%#lx", addr);
937 if (umove(tcp, addr, &statbuf) < 0) {
942 convertoldstat(&statbuf, &newstatbuf);
943 realprintstat(tcp, &newstatbuf);
945 #endif /* linux && !IA64 */
947 #ifndef HAVE_LONG_LONG_OFF_T
953 printpath(tcp, tcp->u_arg[0]);
956 printstat(tcp, tcp->u_arg[1]);
968 printpath(tcp, tcp->u_arg[0]);
971 printstat64(tcp, tcp->u_arg[1]);
975 return printargs(tcp);
980 # if !defined(IA64) && !defined(HPPA)
986 printpath(tcp, tcp->u_arg[0]);
989 printoldstat(tcp, tcp->u_arg[1]);
993 # endif /* !IA64 && !HPPA*/
996 #ifndef HAVE_LONG_LONG_OFF_T
1002 tprintf("%ld, ", tcp->u_arg[0]);
1004 printstat(tcp, tcp->u_arg[1]);
1016 tprintf("%ld, ", tcp->u_arg[0]);
1018 printstat64(tcp, tcp->u_arg[1]);
1022 return printargs(tcp);
1027 # if !defined(IA64) && !defined(HPPA)
1033 tprintf("%ld, ", tcp->u_arg[0]);
1035 printoldstat(tcp, tcp->u_arg[1]);
1039 # endif /* !IA64 && !HPPA*/
1042 #ifndef HAVE_LONG_LONG_OFF_T
1047 if (entering(tcp)) {
1048 printpath(tcp, tcp->u_arg[0]);
1051 printstat(tcp, tcp->u_arg[1]);
1062 if (entering(tcp)) {
1063 printpath(tcp, tcp->u_arg[0]);
1066 printstat64(tcp, tcp->u_arg[1]);
1070 return printargs(tcp);
1075 # if !defined(IA64) && !defined(HPPA)
1080 if (entering(tcp)) {
1081 printpath(tcp, tcp->u_arg[0]);
1084 printoldstat(tcp, tcp->u_arg[1]);
1088 # endif /* !IA64 && !HPPA */
1092 #if defined(SVR4) || defined(LINUXSPARC)
1098 if (entering(tcp)) {
1099 tprintf("%ld, ", tcp->u_arg[0]);
1100 printpath(tcp, tcp->u_arg[1]);
1104 if (tcp->u_arg[0] == _STAT64_VER)
1105 printstat64 (tcp, tcp->u_arg[2]);
1108 printstat(tcp, tcp->u_arg[2]);
1118 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1121 if (tcp->u_arg[0] == _STAT64_VER)
1122 printstat64 (tcp, tcp->u_arg[2]);
1125 printstat(tcp, tcp->u_arg[2]);
1134 if (entering(tcp)) {
1135 tprintf("%ld, ", tcp->u_arg[0]);
1136 printpath(tcp, tcp->u_arg[1]);
1140 if (tcp->u_arg[0] == _STAT64_VER)
1141 printstat64 (tcp, tcp->u_arg[2]);
1144 printstat(tcp, tcp->u_arg[2]);
1153 int mode = tcp->u_arg[2];
1155 if (entering(tcp)) {
1156 tprintf("%ld, ", tcp->u_arg[0]);
1157 printpath(tcp, tcp->u_arg[1]);
1158 tprintf(", %s", sprintmode(mode));
1159 switch (mode & S_IFMT) {
1160 case S_IFCHR: case S_IFBLK:
1162 tprintf(", makedev(%lu, %lu)",
1163 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1164 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1166 tprintf(", makedev(%lu, %lu)",
1167 (unsigned long) major(tcp->u_arg[3]),
1168 (unsigned long) minor(tcp->u_arg[3]));
1178 #ifdef HAVE_SYS_ACL_H
1180 #include <sys/acl.h>
1182 struct xlat aclcmds[] = {
1184 { SETACL, "SETACL" },
1187 { GETACL, "GETACL" },
1190 { GETACLCNT, "GETACLCNT" },
1193 { ACL_GET, "ACL_GET" },
1196 { ACL_SET, "ACL_SET" },
1199 { ACL_CNT, "ACL_CNT" },
1208 if (entering(tcp)) {
1209 printpath(tcp, tcp->u_arg[0]);
1211 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1212 tprintf(", %ld", tcp->u_arg[2]);
1214 * FIXME - dump out the list of aclent_t's pointed to
1215 * by "tcp->u_arg[3]" if it's not NULL.
1218 tprintf(", %#lx", tcp->u_arg[3]);
1230 if (entering(tcp)) {
1231 tprintf("%ld, ", tcp->u_arg[0]);
1232 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1233 tprintf(", %ld", tcp->u_arg[2]);
1235 * FIXME - dump out the list of aclent_t's pointed to
1236 * by "tcp->u_arg[3]" if it's not NULL.
1239 tprintf(", %#lx", tcp->u_arg[3]);
1247 struct xlat aclipc[] = {
1249 { IPC_SHM, "IPC_SHM" },
1252 { IPC_SEM, "IPC_SEM" },
1255 { IPC_MSG, "IPC_MSG" },
1265 if (entering(tcp)) {
1266 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1267 tprintf(", %#lx, ", tcp->u_arg[1]);
1268 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1269 tprintf(", %ld", tcp->u_arg[3]);
1271 * FIXME - dump out the list of aclent_t's pointed to
1272 * by "tcp->u_arg[4]" if it's not NULL.
1275 tprintf(", %#lx", tcp->u_arg[4]);
1284 #endif /* HAVE_SYS_ACL_H */
1286 #endif /* SVR4 || LINUXSPARC */
1290 static struct xlat fsmagic[] = {
1291 { 0x73757245, "CODA_SUPER_MAGIC" },
1292 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1293 { 0x1373, "DEVFS_SUPER_MAGIC" },
1294 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1295 { 0x414A53, "EFS_SUPER_MAGIC" },
1296 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1297 { 0xef53, "EXT2_SUPER_MAGIC" },
1298 { 0x137d, "EXT_SUPER_MAGIC" },
1299 { 0xf995e849, "HPFS_SUPER_MAGIC" },
1300 { 0x9660, "ISOFS_SUPER_MAGIC" },
1301 { 0x137f, "MINIX_SUPER_MAGIC" },
1302 { 0x138f, "MINIX_SUPER_MAGIC2" },
1303 { 0x2468, "MINIX2_SUPER_MAGIC" },
1304 { 0x2478, "MINIX2_SUPER_MAGIC2" },
1305 { 0x4d44, "MSDOS_SUPER_MAGIC" },
1306 { 0x564c, "NCP_SUPER_MAGIC" },
1307 { 0x6969, "NFS_SUPER_MAGIC" },
1308 { 0x9fa0, "PROC_SUPER_MAGIC" },
1309 { 0x002f, "QNX4_SUPER_MAGIC" },
1310 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1311 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1312 { 0x517b, "SMB_SUPER_MAGIC" },
1313 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1314 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1315 { 0x00011954, "UFS_MAGIC" },
1316 { 0x54190100, "UFS_CIGAM" },
1317 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
1318 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1330 static char buf[32];
1334 s = xlookup(fsmagic, magic);
1336 sprintf(buf, "\"%s\"", s);
1340 sprintf(buf, "%#x", magic);
1345 printstatfs(tcp, addr)
1349 struct statfs statbuf;
1351 if (syserror(tcp) || !verbose(tcp)) {
1352 tprintf("%#lx", addr);
1355 if (umove(tcp, addr, &statbuf) < 0) {
1361 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1362 sprintfstype(statbuf.f_type),
1363 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1364 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
1365 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1367 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1368 sprintfstype(statbuf.f_type),
1369 (unsigned long)statbuf.f_bsize,
1370 (unsigned long)statbuf.f_blocks,
1371 (unsigned long)statbuf.f_bfree);
1372 tprintf("f_files=%lu, f_ffree=%lu",
1373 (unsigned long)statbuf.f_files,
1374 (unsigned long)statbuf.f_ffree);
1376 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1386 if (entering(tcp)) {
1387 printpath(tcp, tcp->u_arg[0]);
1390 printstatfs(tcp, tcp->u_arg[1]);
1399 if (entering(tcp)) {
1400 tprintf("%lu, ", tcp->u_arg[0]);
1402 printstatfs(tcp, tcp->u_arg[1]);
1407 #if defined(linux) && defined(__alpha)
1413 if (entering(tcp)) {
1414 printpath(tcp, tcp->u_arg[0]);
1417 printstatfs(tcp, tcp->u_arg[1]);
1418 tprintf(", %lu", tcp->u_arg[2]);
1427 if (entering(tcp)) {
1428 tprintf("%lu, ", tcp->u_arg[0]);
1430 printstatfs(tcp, tcp->u_arg[1]);
1431 tprintf(", %lu", tcp->u_arg[2]);
1435 #endif /* linux && __alpha */
1445 struct ustat statbuf;
1447 if (entering(tcp)) {
1448 tprintf("makedev(%lu, %lu), ",
1449 (long) major(tcp->u_arg[0]),
1450 (long) minor(tcp->u_arg[0]));
1453 if (syserror(tcp) || !verbose(tcp))
1454 tprintf("%#lx", tcp->u_arg[1]);
1455 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1458 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1459 statbuf.f_tfree, statbuf.f_tinode);
1460 tprintf("f_fname=\"%.*s\", ",
1461 (int) sizeof(statbuf.f_fname),
1463 tprintf("f_fpack=\"%.*s\"}",
1464 (int) sizeof(statbuf.f_fpack),
1477 if (entering(tcp)) {
1478 printpath(tcp, tcp->u_arg[0]);
1480 printpath(tcp, tcp->u_arg[1]);
1491 if (entering(tcp)) {
1492 printpath(tcp, tcp->u_arg[0]);
1501 if (entering(tcp)) {
1502 printpath(tcp, tcp->u_arg[0]);
1503 tprintf(", %#lo", tcp->u_arg[1]);
1512 if (entering(tcp)) {
1513 printpath(tcp, tcp->u_arg[0]);
1522 if (entering(tcp)) {
1523 tprintf("%ld", tcp->u_arg[0]);
1532 if (entering(tcp)) {
1533 printpath(tcp, tcp->u_arg[0]);
1542 if (entering(tcp)) {
1543 tprintf("%ld", tcp->u_arg[0]);
1552 if (entering(tcp)) {
1553 printpath(tcp, tcp->u_arg[0]);
1555 printpath(tcp, tcp->u_arg[1]);
1564 if (entering(tcp)) {
1565 printpath(tcp, tcp->u_arg[0]);
1574 if (entering(tcp)) {
1575 printpath(tcp, tcp->u_arg[0]);
1577 printpath(tcp, tcp->u_arg[1]);
1586 if (entering(tcp)) {
1587 printpath(tcp, tcp->u_arg[0]);
1591 tprintf("%#lx", tcp->u_arg[1]);
1593 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1594 tprintf(", %lu", tcp->u_arg[2]);
1603 if (entering(tcp)) {
1604 printpath(tcp, tcp->u_arg[0]);
1606 printpath(tcp, tcp->u_arg[1]);
1615 if (entering(tcp)) {
1616 printpath(tcp, tcp->u_arg[0]);
1617 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1626 if (entering(tcp)) {
1627 tprintf("%ld, %lu, %lu",
1628 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1637 if (entering(tcp)) {
1638 printpath(tcp, tcp->u_arg[0]);
1639 tprintf(", %#lo", tcp->u_arg[1]);
1648 if (entering(tcp)) {
1649 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1659 if (entering(tcp)) {
1660 printpath(tcp, tcp->u_arg[0]);
1662 printtv32(tcp, tcp->u_arg[1]);
1672 if (entering(tcp)) {
1673 printpath(tcp, tcp->u_arg[0]);
1675 printtv(tcp, tcp->u_arg[1]);
1686 if (entering(tcp)) {
1687 printpath(tcp, tcp->u_arg[0]);
1691 else if (!verbose(tcp))
1692 tprintf("%#lx", tcp->u_arg[1]);
1693 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1697 tprintf("[%s,", sprinttime(ut[0]));
1698 tprintf(" %s]", sprinttime(ut[1]));
1708 int mode = tcp->u_arg[1];
1710 if (entering(tcp)) {
1711 printpath(tcp, tcp->u_arg[0]);
1712 tprintf(", %s", sprintmode(mode));
1713 switch (mode & S_IFMT) {
1714 case S_IFCHR: case S_IFBLK:
1716 if (current_personality == 1)
1717 tprintf(", makedev(%lu, %lu)",
1718 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1719 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1722 tprintf(", makedev(%lu, %lu)",
1723 (unsigned long) major(tcp->u_arg[2]),
1724 (unsigned long) minor(tcp->u_arg[2]));
1737 if (entering(tcp)) {
1738 printpath(tcp, tcp->u_arg[0]);
1739 tprintf(", %#lo", tcp->u_arg[1]);
1748 if (entering(tcp)) {
1749 tprintf("%ld", tcp->u_arg[0]);
1763 if (!verbose(tcp)) {
1764 tprintf("%#lx", addr);
1767 if (umove(tcp, addr, &d) < 0) {
1771 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1773 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1781 if (entering(tcp)) {
1782 tprintf("%lu, ", tcp->u_arg[0]);
1784 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1785 tprintf("%#lx", tcp->u_arg[1]);
1787 printdir(tcp, tcp->u_arg[1]);
1788 /* Not much point in printing this out, it is always 1. */
1789 if (tcp->u_arg[2] != 1)
1790 tprintf(", %lu", tcp->u_arg[2]);
1798 struct xlat direnttypes[] = {
1799 { DT_FIFO, "DT_FIFO" },
1800 { DT_CHR, "DT_CHR" },
1801 { DT_DIR, "DT_DIR" },
1802 { DT_BLK, "DT_BLK" },
1803 { DT_REG, "DT_REG" },
1804 { DT_LNK, "DT_LNK" },
1805 { DT_SOCK, "DT_SOCK" },
1806 { DT_WHT, "DT_WHT" },
1816 int i, len, dents = 0;
1819 if (entering(tcp)) {
1820 tprintf("%lu, ", tcp->u_arg[0]);
1823 if (syserror(tcp) || !verbose(tcp)) {
1824 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1828 if ((buf = malloc(len)) == NULL) {
1829 tprintf("out of memory\n");
1832 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1833 tprintf("{...}, %lu", tcp->u_arg[2]);
1839 for (i = 0; i < len;) {
1840 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1843 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1844 i ? " " : "", d->d_ino, d->d_off);
1845 tprintf("d_reclen=%u, d_name=\"%s\"}",
1846 d->d_reclen, d->d_name);
1851 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1852 i ? " " : "", d->d_ino, d->d_off);
1853 tprintf("d_reclen=%u, d_name=\"%s\"}",
1854 d->d_reclen, d->d_name);
1859 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1860 i ? " " : "", d->d_off, d->d_fileno,
1862 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1863 d->d_namlen, d->d_namlen, d->d_name);
1868 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1869 i ? " " : "", d->d_fileno, d->d_reclen);
1870 printxval(direnttypes, d->d_type, "DT_???");
1871 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1872 d->d_namlen, d->d_namlen, d->d_name);
1874 #endif /* FREEBSD */
1876 tprintf("/* d_reclen == 0, problem here */");
1885 tprintf("/* %u entries */", dents);
1886 tprintf(", %lu", tcp->u_arg[2]);
1892 #if _LFS64_LARGEFILE
1897 int i, len, dents = 0;
1900 if (entering(tcp)) {
1901 tprintf("%lu, ", tcp->u_arg[0]);
1904 if (syserror(tcp) || !verbose(tcp)) {
1905 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1909 if ((buf = malloc(len)) == NULL) {
1910 tprintf("out of memory\n");
1913 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1914 tprintf("{...}, %lu", tcp->u_arg[2]);
1920 for (i = 0; i < len;) {
1921 struct dirent64 *d = (struct dirent64 *) &buf[i];
1924 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1925 i ? " " : "", d->d_ino, d->d_off);
1926 tprintf("d_reclen=%u, d_name=\"%s\"}",
1927 d->d_reclen, d->d_name);
1932 tprintf("%s{d_ino=%llu, d_off=%llu, ",
1933 i ? " " : "", d->d_ino, d->d_off);
1934 tprintf("d_reclen=%u, d_name=\"%s\"}",
1935 d->d_reclen, d->d_name);
1940 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1941 i ? " " : "", d->d_off, d->d_fileno,
1943 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1944 d->d_namlen, d->d_namlen, d->d_name);
1953 tprintf("/* %u entries */", dents);
1954 tprintf(", %lu", tcp->u_arg[2]);
1962 sys_getdirentries(tcp)
1965 int i, len, dents = 0;
1969 if (entering(tcp)) {
1970 tprintf("%lu, ", tcp->u_arg[0]);
1973 if (syserror(tcp) || !verbose(tcp)) {
1974 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1978 if ((buf = malloc(len)) == NULL) {
1979 tprintf("out of memory\n");
1982 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1983 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
1989 for (i = 0; i < len;) {
1990 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1992 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1993 i ? " " : "", d->d_fileno, d->d_reclen);
1994 printxval(direnttypes, d->d_type, "DT_???");
1995 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1996 d->d_namlen, d->d_namlen, d->d_name);
2004 tprintf("/* %u entries */", dents);
2006 tprintf(", %lu", tcp->u_arg[2]);
2007 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2008 tprintf(", %#lx", tcp->u_arg[3]);
2010 tprintf(", [%lu]", basep);
2022 tprintf("%#lx", tcp->u_arg[0]);
2024 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2025 tprintf(", %lu", tcp->u_arg[1]);
2038 tprintf("%#lx", tcp->u_arg[0]);
2040 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2041 tprintf(", %lu", tcp->u_arg[1]);
2047 #ifdef HAVE_SYS_ASYNCH_H
2053 struct aio_result_t res;
2055 if (entering(tcp)) {
2056 tprintf("%lu, ", tcp->u_arg[0]);
2059 tprintf("%#lx", tcp->u_arg[1]);
2061 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2062 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2063 printxval(whence, tcp->u_arg[4], "L_???");
2064 if (syserror(tcp) || tcp->u_arg[5] == 0
2065 || umove(tcp, tcp->u_arg[5], &res) < 0)
2066 tprintf(", %#lx", tcp->u_arg[5]);
2068 tprintf(", {aio_return %d aio_errno %d}",
2069 res.aio_return, res.aio_errno);
2078 struct aio_result_t res;
2080 if (entering(tcp)) {
2081 tprintf("%lu, ", tcp->u_arg[0]);
2082 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2083 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2084 printxval(whence, tcp->u_arg[4], "L_???");
2087 if (tcp->u_arg[5] == 0)
2089 else if (syserror(tcp)
2090 || umove(tcp, tcp->u_arg[5], &res) < 0)
2091 tprintf(", %#lx", tcp->u_arg[5]);
2093 tprintf(", {aio_return %d aio_errno %d}",
2094 res.aio_return, res.aio_errno);
2104 printtv(tcp, tcp->u_arg[0]);
2112 struct aio_result_t res;
2115 if (tcp->u_arg[0] == 0)
2117 else if (syserror(tcp)
2118 || umove(tcp, tcp->u_arg[0], &res) < 0)
2119 tprintf("%#lx", tcp->u_arg[0]);
2121 tprintf("{aio_return %d aio_errno %d}",
2122 res.aio_return, res.aio_errno);
2127 #endif /* HAVE_SYS_ASYNCH_H */