]> granicus.if.org Git - strace/blob - file.c
5b30eba72d4b0568b4a40d2c9c992e6befa8d515
[strace] / file.c
1 /*
2 #ifdef LINUX
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>
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
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.
19  *
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.
30  *
31  *      $Id$
32  */
33
34 #include "defs.h"
35
36 #include <dirent.h>
37 #ifdef LINUX
38 #define dirent kernel_dirent
39 #define dirent64 kernel_dirent64
40 #include <linux/types.h>
41 #include <linux/dirent.h>
42 #undef dirent
43 #undef dirent64
44 #else
45 #define kernel_dirent dirent
46 #endif
47
48 #ifdef LINUX
49 #  ifdef LINUXSPARC
50 struct stat {
51         unsigned short  st_dev;
52         unsigned int    st_ino;
53         unsigned short  st_mode;
54         short           st_nlink;
55         unsigned short  st_uid;
56         unsigned short  st_gid;
57         unsigned short  st_rdev;
58         unsigned int    st_size;
59         int             st_atime;
60         unsigned int    __unused1;
61         int             st_mtime;
62         unsigned int    __unused2;
63         int             st_ctime;
64         unsigned int    __unused3;
65         int             st_blksize;
66         int             st_blocks;
67         unsigned int    __unused4[2];
68 };
69 #    define stat kernel_stat
70 #    include <asm/stat.h>
71 #    undef stat
72 #  else
73 #    undef dev_t
74 #    undef ino_t
75 #    undef mode_t
76 #    undef nlink_t
77 #    undef uid_t
78 #    undef gid_t
79 #    undef off_t
80 #    undef loff_t
81
82 #    define dev_t __kernel_dev_t
83 #    define ino_t __kernel_ino_t
84 #    define mode_t __kernel_mode_t
85 #    define nlink_t __kernel_nlink_t
86 #    define uid_t __kernel_uid_t
87 #    define gid_t __kernel_gid_t
88 #    define off_t __kernel_off_t
89 #    define loff_t __kernel_loff_t
90
91 #    include <asm/stat.h>
92
93 #    undef dev_t
94 #    undef ino_t
95 #    undef mode_t
96 #    undef nlink_t
97 #    undef uid_t
98 #    undef gid_t
99 #    undef off_t
100 #    undef loff_t
101
102 #    define dev_t dev_t
103 #    define ino_t ino_t
104 #    define mode_t mode_t
105 #    define nlink_t nlink_t
106 #    define uid_t uid_t
107 #    define gid_t gid_t
108 #    define off_t off_t
109 #    define loff_t loff_t
110 #  endif
111 #  ifdef HPPA   /* asm-parisc/stat.h defines stat64 */
112 #    undef stat64
113 #  endif
114 #  define stat libc_stat
115 #  define stat64 libc_stat64
116 #  include <sys/stat.h>
117 #  undef stat
118 #  undef stat64
119 #  ifdef HPPA
120 #    define stat64 hpux_stat64
121 #  endif
122 #else
123 #  include <sys/stat.h>
124 #endif
125
126 #include <fcntl.h>
127
128 #ifdef SVR4
129 #  include <sys/cred.h>
130 #endif /* SVR4 */
131
132 #ifdef HAVE_SYS_VFS_H
133 #include <sys/vfs.h>
134 #endif
135
136 #ifdef FREEBSD
137 #include <sys/param.h>
138 #include <sys/mount.h>
139 #include <sys/stat.h>
140 #endif
141
142 #if HAVE_LONG_LONG_OFF_T
143 /*
144  * Ugly hacks for systems that have typedef long long off_t
145  */
146
147 #define stat64 stat
148 #define HAVE_STAT64 1   /* Ugly hack */
149
150 #define sys_stat64      sys_stat
151 #define sys_fstat64     sys_fstat
152 #define sys_lstat64     sys_lstat
153 #define sys_lseek64     sys_lseek
154 #define sys_truncate64  sys_truncate
155 #define sys_ftruncate64 sys_ftruncate
156 #endif
157
158 #ifdef MAJOR_IN_SYSMACROS
159 #include <sys/sysmacros.h>
160 #endif
161
162 #ifdef MAJOR_IN_MKDEV
163 #include <sys/mkdev.h>
164 #endif
165
166 #ifdef HAVE_SYS_ASYNCH_H
167 #include <sys/asynch.h>
168 #endif
169
170 #ifdef SUNOS4
171 #include <ustat.h>
172 #endif
173
174 /*
175  * This is a really dirty trick but it should always work.  Traditional
176  * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
177  * adding 1.  Just remember to add 1 to any arg decoded with openmodes.
178  */
179 struct xlat openmodes[] = {
180         { O_RDWR+1,     "O_RDWR"        },
181         { O_RDONLY+1,   "O_RDONLY"      },
182         { O_WRONLY+1,   "O_WRONLY"      },
183         { O_NONBLOCK,   "O_NONBLOCK"    },
184         { O_APPEND,     "O_APPEND"      },
185         { O_CREAT,      "O_CREAT"       },
186         { O_TRUNC,      "O_TRUNC"       },
187         { O_EXCL,       "O_EXCL"        },
188         { O_NOCTTY,     "O_NOCTTY"      },
189 #ifdef O_SYNC
190         { O_SYNC,       "O_SYNC"        },
191 #endif
192 #ifdef O_ASYNC
193         { O_ASYNC,      "O_ASYNC"       },
194 #endif
195 #ifdef O_DSYNC
196         { O_DSYNC,      "O_DSYNC"       },
197 #endif
198 #ifdef O_RSYNC
199         { O_RSYNC,      "O_RSYNC"       },
200 #endif
201 #ifdef O_NDELAY
202         { O_NDELAY,     "O_NDELAY"      },
203 #endif
204 #ifdef O_PRIV
205         { O_PRIV,       "O_PRIV"        },
206 #endif
207 #ifdef O_DIRECT
208         { O_DIRECT,     "O_DIRECT"      },
209 #endif
210 #ifdef O_LARGEFILE
211         { O_LARGEFILE,  "O_LARGEFILE"   },
212 #endif
213 #ifdef O_DIRECTORY
214         { O_DIRECTORY,  "O_DIRECTORY"   },
215 #endif
216 #ifdef O_NOFOLLOW
217         { O_NOFOLLOW,   "O_NOFOLLOW"    },
218 #endif
219
220 #ifdef FNDELAY
221         { FNDELAY,      "FNDELAY"       },
222 #endif
223 #ifdef FAPPEND
224         { FAPPEND,      "FAPPEND"       },
225 #endif
226 #ifdef FMARK
227         { FMARK,        "FMARK"         },
228 #endif
229 #ifdef FDEFER
230         { FDEFER,       "FDEFER"        },
231 #endif
232 #ifdef FASYNC
233         { FASYNC,       "FASYNC"        },
234 #endif
235 #ifdef FSHLOCK
236         { FSHLOCK,      "FSHLOCK"       },
237 #endif
238 #ifdef FEXLOCK
239         { FEXLOCK,      "FEXLOCK"       },
240 #endif
241 #ifdef FCREAT
242         { FCREAT,       "FCREAT"        },
243 #endif
244 #ifdef FTRUNC
245         { FTRUNC,       "FTRUNC"        },
246 #endif
247 #ifdef FEXCL
248         { FEXCL,        "FEXCL"         },
249 #endif
250 #ifdef FNBIO
251         { FNBIO,        "FNBIO"         },
252 #endif
253 #ifdef FSYNC
254         { FSYNC,        "FSYNC"         },
255 #endif
256 #ifdef FNOCTTY
257         { FNOCTTY,      "FNOCTTY"       },
258 #endif  
259 #ifdef O_SHLOCK
260         { O_SHLOCK,     "O_SHLOCK"      },
261 #endif
262 #ifdef O_EXLOCK
263         { O_EXLOCK,     "O_EXLOCK"      },
264 #endif
265         { 0,            NULL            },
266 };
267
268 int
269 sys_open(tcp)
270 struct tcb *tcp;
271 {
272         if (entering(tcp)) {
273                 printpath(tcp, tcp->u_arg[0]);
274                 tprintf(", ");
275                 /* flags */
276                 printflags(openmodes, tcp->u_arg[1] + 1);
277                 if (tcp->u_arg[1] & O_CREAT) {
278                         /* mode */
279                         tprintf(", %#lo", tcp->u_arg[2]);
280                 }
281         }
282         return 0;
283 }
284
285 #ifdef LINUXSPARC
286 struct xlat openmodessol[] = {
287         { 0,            "O_RDWR"        },
288         { 1,            "O_RDONLY"      },
289         { 2,            "O_WRONLY"      },
290         { 0x80,         "O_NONBLOCK"    },
291         { 8,            "O_APPEND"      },
292         { 0x100,        "O_CREAT"       },
293         { 0x200,        "O_TRUNC"       },
294         { 0x400,        "O_EXCL"        },
295         { 0x800,        "O_NOCTTY"      },
296         { 0x10,         "O_SYNC"        },
297         { 0x40,         "O_DSYNC"       },
298         { 0x8000,       "O_RSYNC"       },
299         { 4,            "O_NDELAY"      },
300         { 0x1000,       "O_PRIV"        },
301         { 0,            NULL            },
302 };
303
304 int
305 solaris_open(tcp)
306 struct tcb *tcp;
307 {
308         if (entering(tcp)) {
309                 printpath(tcp, tcp->u_arg[0]);
310                 tprintf(", ");
311                 /* flags */
312                 printflags(openmodessol, tcp->u_arg[1] + 1);
313                 if (tcp->u_arg[1] & 0x100) {
314                         /* mode */
315                         tprintf(", %#lo", tcp->u_arg[2]);
316                 }
317         }
318         return 0;
319 }
320
321 #endif
322
323 int
324 sys_creat(tcp)
325 struct tcb *tcp;
326 {
327         if (entering(tcp)) {
328                 printpath(tcp, tcp->u_arg[0]);
329                 tprintf(", %#lo", tcp->u_arg[1]);
330         }
331         return 0;
332 }
333
334 static struct xlat access_flags[] = {
335         { F_OK,         "F_OK",         },
336         { R_OK,         "R_OK"          },
337         { W_OK,         "W_OK"          },
338         { X_OK,         "X_OK"          },
339 #ifdef EFF_ONLY_OK
340         { EFF_ONLY_OK,  "EFF_ONLY_OK"   },
341 #endif
342 #ifdef EX_OK
343         { EX_OK,        "EX_OK"         },
344 #endif
345         { 0,            NULL            },
346 };
347
348 int
349 sys_access(tcp)
350 struct tcb *tcp;
351 {
352         if (entering(tcp)) {
353                 printpath(tcp, tcp->u_arg[0]);
354                 tprintf(", ");
355                 printflags(access_flags, tcp->u_arg[1]);
356         }
357         return 0;
358 }
359
360 int
361 sys_umask(tcp)
362 struct tcb *tcp;
363 {
364         if (entering(tcp)) {
365                 tprintf("%#lo", tcp->u_arg[0]);
366         }
367         return RVAL_OCTAL;
368 }
369
370 static struct xlat whence[] = {
371         { SEEK_SET,     "SEEK_SET"      },
372         { SEEK_CUR,     "SEEK_CUR"      },
373         { SEEK_END,     "SEEK_END"      },
374         { 0,            NULL            },
375 };
376
377 #ifndef HAVE_LONG_LONG_OFF_T
378 int
379 sys_lseek(tcp)
380 struct tcb *tcp;
381 {
382         off_t offset;
383         int _whence;
384
385         if (entering(tcp)) {
386                 tprintf("%ld, ", tcp->u_arg[0]);
387                 offset = tcp->u_arg[1];
388                 _whence = tcp->u_arg[2];
389                 if (_whence == SEEK_SET)
390                         tprintf("%lu, ", offset);
391                 else
392                         tprintf("%ld, ", offset);               
393                 printxval(whence, _whence, "SEEK_???");
394         } 
395         return RVAL_UDECIMAL;
396 }
397 #endif
398
399 #ifdef LINUX
400 int
401 sys_llseek (tcp)
402 struct tcb *tcp;
403 {
404     if (entering(tcp)) {
405         if (tcp->u_arg[4] == SEEK_SET)
406             tprintf("%ld, %llu, ", tcp->u_arg[0],
407                     (((long long int) tcp->u_arg[1]) << 32
408                      | (unsigned long long) (unsigned) tcp->u_arg[2]));
409         else
410             tprintf("%ld, %lld, ", tcp->u_arg[0],
411                     (((long long int) tcp->u_arg[1]) << 32
412                      | (unsigned long long) (unsigned) tcp->u_arg[2]));
413     }
414     else {
415         long long int off;
416         if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
417             tprintf("%#lx, ", tcp->u_arg[3]);
418         else
419             tprintf("[%llu], ", off);
420         printxval(whence, tcp->u_arg[4], "SEEK_???");
421     }
422     return 0;
423 }
424 #endif
425
426 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
427 int
428 sys_lseek64 (tcp)
429 struct tcb *tcp;
430 {
431         if (entering(tcp)) {
432                 long long offset;
433                 ALIGN64 (tcp, 1);       /* FreeBSD aligns off_t args */
434                 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
435                 if (tcp->u_arg[3] == SEEK_SET)
436                         tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
437                 else
438                         tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
439                 printxval(whence, tcp->u_arg[3], "SEEK_???");
440         }
441         return RVAL_LUDECIMAL;
442 }
443 #endif
444
445 #ifndef HAVE_LONG_LONG_OFF_T
446 int
447 sys_truncate(tcp)
448 struct tcb *tcp;
449 {
450         if (entering(tcp)) {
451                 printpath(tcp, tcp->u_arg[0]);
452                 tprintf(", %lu", tcp->u_arg[1]);
453         }
454         return 0;
455 }
456 #endif
457
458 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
459 int
460 sys_truncate64(tcp)
461 struct tcb *tcp;
462 {
463         if (entering(tcp)) {
464                 ALIGN64 (tcp, 1);
465                 printpath(tcp, tcp->u_arg[0]);
466                 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
467         }
468         return 0;
469 }
470 #endif
471
472 #ifndef HAVE_LONG_LONG_OFF_T
473 int
474 sys_ftruncate(tcp)
475 struct tcb *tcp;
476 {
477         if (entering(tcp)) {
478                 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
479         }
480         return 0;
481 }
482 #endif
483
484 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
485 int
486 sys_ftruncate64(tcp)
487 struct tcb *tcp;
488 {
489         if (entering(tcp)) {
490                 ALIGN64 (tcp, 1);
491                 tprintf("%ld, %llu", tcp->u_arg[0],
492                         LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
493         }
494         return 0;
495 }
496 #endif
497
498 /* several stats */
499
500 static struct xlat modetypes[] = {
501         { S_IFREG,      "S_IFREG"       },
502         { S_IFSOCK,     "S_IFSOCK"      },
503         { S_IFIFO,      "S_IFIFO"       },
504         { S_IFLNK,      "S_IFLNK"       },
505         { S_IFDIR,      "S_IFDIR"       },
506         { S_IFBLK,      "S_IFBLK"       },
507         { S_IFCHR,      "S_IFCHR"       },
508         { 0,            NULL            },
509 };
510
511 static char *
512 sprintmode(mode)
513 int mode;
514 {
515         static char buf[64];
516         char *s;
517
518         if ((mode & S_IFMT) == 0)
519                 s = "";
520         else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
521                 sprintf(buf, "%#o", mode);
522                 return buf;
523         }
524         sprintf(buf, "%s%s%s%s", s,
525                 (mode & S_ISUID) ? "|S_ISUID" : "",
526                 (mode & S_ISGID) ? "|S_ISGID" : "",
527                 (mode & S_ISVTX) ? "|S_ISVTX" : "");
528         mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
529         if (mode)
530                 sprintf(buf + strlen(buf), "|%#o", mode);
531         s = (*buf == '|') ? buf + 1 : buf;
532         return *s ? s : "0";
533 }
534
535 static char *
536 sprinttime(t)
537 time_t t;
538 {
539         struct tm *tmp;
540         static char buf[32];
541
542         if (t == 0) {
543                 sprintf(buf, "0");
544                 return buf;
545         }
546         tmp = localtime(&t);
547         sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
548                 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
549                 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
550         return buf;
551 }
552
553 #ifdef LINUXSPARC
554 typedef struct {
555         int     tv_sec;
556         int     tv_nsec;
557 } timestruct_t;
558
559 struct solstat {
560         unsigned        st_dev;
561         int             st_pad1[3];     /* network id */
562         unsigned        st_ino;
563         unsigned        st_mode;
564         unsigned        st_nlink;
565         unsigned        st_uid;
566         unsigned        st_gid;
567         unsigned        st_rdev;
568         int             st_pad2[2];
569         int             st_size;
570         int             st_pad3;        /* st_size, off_t expansion */
571         timestruct_t    st_atime;
572         timestruct_t    st_mtime;
573         timestruct_t    st_ctime;
574         int             st_blksize;
575         int             st_blocks;
576         char            st_fstype[16];
577         int             st_pad4[8];     /* expansion area */
578 };
579
580 static void
581 printstatsol(tcp, addr)
582 struct tcb *tcp;
583 long addr;
584 {
585         struct solstat statbuf;
586
587         if (!addr) {
588                 tprintf("NULL");
589                 return;
590         }
591         if (syserror(tcp) || !verbose(tcp)) {
592                 tprintf("%#lx", addr);
593                 return;
594         }
595         if (umove(tcp, addr, &statbuf) < 0) {
596                 tprintf("{...}");
597                 return;
598         }
599         if (!abbrev(tcp)) {
600                 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
601                         (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
602                         (unsigned long) (statbuf.st_dev & 0x3ffff),
603                         (unsigned long) statbuf.st_ino,
604                         sprintmode(statbuf.st_mode));
605                 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
606                         (unsigned long) statbuf.st_nlink,
607                         (unsigned long) statbuf.st_uid,
608                         (unsigned long) statbuf.st_gid);
609                 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
610                 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
611         }
612         else
613                 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
614         switch (statbuf.st_mode & S_IFMT) {
615         case S_IFCHR: case S_IFBLK:
616                 tprintf("st_rdev=makedev(%lu, %lu), ",
617                         (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
618                         (unsigned long) (statbuf.st_rdev & 0x3ffff));
619                 break;
620         default:
621                 tprintf("st_size=%u, ", statbuf.st_size);
622                 break;
623         }
624         if (!abbrev(tcp)) {
625                 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
626                 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
627                 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
628         }
629         else
630                 tprintf("...}");
631 }
632 #endif /* LINUXSPARC */
633
634 struct xlat fileflags[] = {
635 #ifdef FREEBSD
636         { UF_NODUMP,    "UF_NODUMP"     },
637         { UF_IMMUTABLE, "UF_IMMUTABLE"  },
638         { UF_APPEND,    "UF_APPEND"     },
639         { UF_OPAQUE,    "UF_OPAQUE"     },
640         { UF_NOUNLINK,  "UF_NOUNLINK"   },
641         { SF_ARCHIVED,  "SF_ARCHIVED"   },
642         { SF_IMMUTABLE, "SF_IMMUTABLE"  },
643         { SF_APPEND,    "SF_APPEND"     },
644         { SF_NOUNLINK,  "SF_NOUNLINK"   },
645 #elif UNIXWARE >= 2
646 #ifdef  _S_ISMLD
647         { _S_ISMLD,     "_S_ISMLD"      },
648 #endif
649 #ifdef  _S_ISMOUNTED
650         { _S_ISMOUNTED, "_S_ISMOUNTED"  },
651 #endif
652 #endif
653         { 0,            NULL            },
654 };
655
656 #ifdef FREEBSD
657 int
658 sys_chflags(tcp)
659 struct tcb *tcp;
660 {
661         if (entering(tcp)) {
662                 printpath(tcp, tcp->u_arg[0]);
663                 tprintf(", ");
664                 if (tcp->u_arg[1])
665                         printflags(fileflags, tcp->u_arg[1]);
666                 else
667                         tprintf("0");
668         }
669         return 0;
670 }
671
672 int
673 sys_fchflags(tcp)
674 struct tcb *tcp;
675 {
676         if (entering(tcp)) {
677                 tprintf("%ld, ", tcp->u_arg[0]);
678                 if (tcp->u_arg[1])
679                         printflags(fileflags, tcp->u_arg[1]);
680                 else
681                         tprintf("0");
682         }
683         return 0;
684 }
685 #endif
686
687 #ifndef HAVE_LONG_LONG_OFF_T
688 static void
689 realprintstat(tcp, statbuf)
690 struct tcb *tcp;
691 struct stat *statbuf;
692 {
693     if (!abbrev(tcp)) {
694             tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
695                     (unsigned long) major(statbuf->st_dev),
696                     (unsigned long) minor(statbuf->st_dev),
697                     (unsigned long) statbuf->st_ino,
698                     sprintmode(statbuf->st_mode));
699             tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
700                     (unsigned long) statbuf->st_nlink,
701                     (unsigned long) statbuf->st_uid,
702                     (unsigned long) statbuf->st_gid);
703 #ifdef HAVE_ST_BLKSIZE
704             tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
705 #endif /* HAVE_ST_BLKSIZE */
706 #ifdef HAVE_ST_BLOCKS
707             tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
708 #endif /* HAVE_ST_BLOCKS */
709     }
710     else
711             tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
712     switch (statbuf->st_mode & S_IFMT) {
713     case S_IFCHR: case S_IFBLK:
714 #ifdef HAVE_ST_RDEV
715             tprintf("st_rdev=makedev(%lu, %lu), ",
716                     (unsigned long) major(statbuf->st_rdev),
717                     (unsigned long) minor(statbuf->st_rdev));
718 #else /* !HAVE_ST_RDEV */
719             tprintf("st_size=makedev(%lu, %lu), ",
720                     (unsigned long) major(statbuf->st_size),
721                     (unsigned long) minor(statbuf->st_size));
722 #endif /* !HAVE_ST_RDEV */
723             break;
724     default:
725             tprintf("st_size=%lu, ", statbuf->st_size);
726             break;
727     }
728     if (!abbrev(tcp)) {
729             tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
730             tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
731             tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
732 #if HAVE_ST_FLAGS
733                 tprintf(", st_flags=");
734                 if (statbuf->st_flags) {
735                         printflags(fileflags, statbuf->st_flags);
736                 } else
737                         tprintf("0");
738 #endif
739 #if HAVE_ST_ACLCNT
740                 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
741 #endif
742 #if HAVE_ST_LEVEL
743                 tprintf(", st_level=%ld", statbuf->st_level);
744 #endif
745 #if HAVE_ST_FSTYPE
746                 tprintf(", st_fstype=%.*s",
747                         (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
748 #endif
749 #if HAVE_ST_GEN
750                 tprintf(", st_gen=%u", statbuf->st_gen);
751 #endif
752                 tprintf("}");
753     }
754     else
755             tprintf("...}");
756 }
757
758
759 static void
760 printstat(tcp, addr)
761 struct tcb *tcp;
762 long addr;
763 {
764         struct stat statbuf;
765
766 #ifdef LINUXSPARC
767         if (current_personality == 1) {
768                 printstatsol(tcp, addr);
769                 return;
770         }
771 #endif /* LINUXSPARC */
772
773         if (!addr) {
774                 tprintf("NULL");
775                 return;
776         }
777         if (syserror(tcp) || !verbose(tcp)) {
778                 tprintf("%#lx", addr);
779                 return;
780         }
781         if (umove(tcp, addr, &statbuf) < 0) {
782                 tprintf("{...}");
783                 return;
784         }
785
786         realprintstat(tcp, &statbuf);
787 }
788 #endif  /* !HAVE_LONG_LONG_OFF_T */
789
790 #ifdef HAVE_STAT64
791 static void
792 printstat64(tcp, addr)
793 struct tcb *tcp;
794 long addr;
795 {
796         struct stat64 statbuf;
797
798 #ifdef LINUXSPARC
799         if (current_personality == 1) {
800                 printstatsol(tcp, addr);
801                 return;
802         }
803 #endif /* LINUXSPARC */
804
805         if (!addr) {
806                 tprintf("NULL");
807                 return;
808         }
809         if (syserror(tcp) || !verbose(tcp)) {
810                 tprintf("%#lx", addr);
811                 return;
812         }
813         if (umove(tcp, addr, &statbuf) < 0) {
814                 tprintf("{...}");
815                 return;
816         }
817
818         if (!abbrev(tcp)) {
819 #ifdef HAVE_LONG_LONG
820                 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
821 #else
822                 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
823 #endif
824                         (unsigned long) major(statbuf.st_dev),
825                         (unsigned long) minor(statbuf.st_dev),
826 #ifdef HAVE_LONG_LONG
827                         (unsigned long long) statbuf.st_ino,
828 #else
829                         (unsigned long) statbuf.st_ino,
830 #endif
831                         sprintmode(statbuf.st_mode));
832                 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
833                         (unsigned long) statbuf.st_nlink,
834                         (unsigned long) statbuf.st_uid,
835                         (unsigned long) statbuf.st_gid);
836 #ifdef HAVE_ST_BLKSIZE
837                 tprintf("st_blksize=%lu, ",
838                         (unsigned long) statbuf.st_blksize);
839 #endif /* HAVE_ST_BLKSIZE */
840 #ifdef HAVE_ST_BLOCKS
841                 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
842 #endif /* HAVE_ST_BLOCKS */
843         }
844         else
845                 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
846         switch (statbuf.st_mode & S_IFMT) {
847         case S_IFCHR: case S_IFBLK:
848 #ifdef HAVE_ST_RDEV
849                 tprintf("st_rdev=makedev(%lu, %lu), ",
850                         (unsigned long) major(statbuf.st_rdev),
851                         (unsigned long) minor(statbuf.st_rdev));
852 #else /* !HAVE_ST_RDEV */
853                 tprintf("st_size=makedev(%lu, %lu), ",
854                         (unsigned long) major(statbuf.st_size),
855                         (unsigned long) minor(statbuf.st_size));
856 #endif /* !HAVE_ST_RDEV */
857                 break;
858         default:
859                 tprintf("st_size=%llu, ", statbuf.st_size);
860                 break;
861         }
862         if (!abbrev(tcp)) {
863                 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
864                 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
865                 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
866 #if HAVE_ST_FLAGS
867                 tprintf(", st_flags=");
868                 if (statbuf.st_flags) {
869                         printflags(fileflags, statbuf.st_flags);
870                 } else
871                         tprintf("0");
872 #endif
873 #if HAVE_ST_ACLCNT
874                 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
875 #endif
876 #if HAVE_ST_LEVEL
877                 tprintf(", st_level=%ld", statbuf.st_level);
878 #endif
879 #if HAVE_ST_FSTYPE
880                 tprintf(", st_fstype=%.*s",
881                         (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
882 #endif
883 #if HAVE_ST_GEN
884                 tprintf(", st_gen=%u", statbuf.st_gen);
885 #endif
886                 tprintf("}");
887         }
888         else
889                 tprintf("...}");
890 }
891 #endif /* HAVE_STAT64 */
892
893 #if defined(LINUX) && !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
894     && !defined(S390) && !defined(S390X)
895 static void
896 convertoldstat(oldbuf, newbuf)
897 const struct __old_kernel_stat *oldbuf;
898 struct stat *newbuf;
899 {
900     newbuf->st_dev=oldbuf->st_dev;
901     newbuf->st_ino=oldbuf->st_ino;
902     newbuf->st_mode=oldbuf->st_mode;
903     newbuf->st_nlink=oldbuf->st_nlink;
904     newbuf->st_uid=oldbuf->st_uid;
905     newbuf->st_gid=oldbuf->st_gid;
906     newbuf->st_rdev=oldbuf->st_rdev;
907     newbuf->st_size=oldbuf->st_size;
908     newbuf->st_atime=oldbuf->st_atime;
909     newbuf->st_mtime=oldbuf->st_mtime;
910     newbuf->st_ctime=oldbuf->st_ctime;
911     newbuf->st_blksize=0;       /* not supported in old_stat */
912     newbuf->st_blocks=0;                /* not supported in old_stat */
913 }
914
915
916 static void
917 printoldstat(tcp, addr)
918 struct tcb *tcp;
919 long addr;
920 {
921         struct __old_kernel_stat statbuf;
922         struct stat newstatbuf;
923
924 #ifdef LINUXSPARC
925         if (current_personality == 1) {
926                 printstatsol(tcp, addr);
927                 return;
928         }
929 #endif /* LINUXSPARC */
930
931         if (!addr) {
932                 tprintf("NULL");
933                 return;
934         }
935         if (syserror(tcp) || !verbose(tcp)) {
936                 tprintf("%#lx", addr);
937                 return;
938         }
939         if (umove(tcp, addr, &statbuf) < 0) {
940                 tprintf("{...}");
941                 return;
942         }
943
944         convertoldstat(&statbuf, &newstatbuf);
945         realprintstat(tcp, &newstatbuf);
946 }
947 #endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
948
949 #ifndef HAVE_LONG_LONG_OFF_T
950 int
951 sys_stat(tcp)
952 struct tcb *tcp;
953 {
954         if (entering(tcp)) {
955                 printpath(tcp, tcp->u_arg[0]);
956                 tprintf(", ");
957         } else {
958                 printstat(tcp, tcp->u_arg[1]);
959         }
960         return 0;
961 }
962 #endif
963
964 int
965 sys_stat64(tcp)
966 struct tcb *tcp;
967 {
968 #ifdef HAVE_STAT64
969         if (entering(tcp)) {
970                 printpath(tcp, tcp->u_arg[0]);
971                 tprintf(", ");
972         } else {
973                 printstat64(tcp, tcp->u_arg[1]);
974         }
975         return 0;
976 #else
977         return printargs(tcp);
978 #endif
979 }
980
981 #ifdef LINUX
982 # if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
983      && !defined(S390) && !defined(S390X)
984 int
985 sys_oldstat(tcp)
986 struct tcb *tcp;
987 {
988         if (entering(tcp)) {
989                 printpath(tcp, tcp->u_arg[0]);
990                 tprintf(", ");
991         } else {
992                 printoldstat(tcp, tcp->u_arg[1]);
993         }
994         return 0;
995 }
996 # endif /* !IA64 && !HPPA*/
997 #endif /* LINUX */
998
999 #ifndef HAVE_LONG_LONG_OFF_T
1000 int
1001 sys_fstat(tcp)
1002 struct tcb *tcp;
1003 {
1004         if (entering(tcp))
1005                 tprintf("%ld, ", tcp->u_arg[0]);
1006         else {
1007                 printstat(tcp, tcp->u_arg[1]);
1008         }
1009         return 0;
1010 }
1011 #endif
1012
1013 int
1014 sys_fstat64(tcp)
1015 struct tcb *tcp;
1016 {
1017 #ifdef HAVE_STAT64
1018         if (entering(tcp))
1019                 tprintf("%ld, ", tcp->u_arg[0]);
1020         else {
1021                 printstat64(tcp, tcp->u_arg[1]);
1022         }
1023         return 0;
1024 #else
1025         return printargs(tcp);
1026 #endif
1027 }
1028
1029 #ifdef LINUX
1030 # if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
1031      && !defined(S390) && !defined(S390X)
1032 int
1033 sys_oldfstat(tcp)
1034 struct tcb *tcp;
1035 {
1036         if (entering(tcp))
1037                 tprintf("%ld, ", tcp->u_arg[0]);
1038         else {
1039                 printoldstat(tcp, tcp->u_arg[1]);
1040         }
1041         return 0;
1042 }
1043 # endif /* !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1044 #endif
1045
1046 #ifndef HAVE_LONG_LONG_OFF_T
1047 int
1048 sys_lstat(tcp)
1049 struct tcb *tcp;
1050 {
1051         if (entering(tcp)) {
1052                 printpath(tcp, tcp->u_arg[0]);
1053                 tprintf(", ");
1054         } else {
1055                 printstat(tcp, tcp->u_arg[1]);
1056         }
1057         return 0;
1058 }
1059 #endif
1060
1061 int
1062 sys_lstat64(tcp)
1063 struct tcb *tcp;
1064 {
1065 #ifdef HAVE_STAT64
1066         if (entering(tcp)) {
1067                 printpath(tcp, tcp->u_arg[0]);
1068                 tprintf(", ");
1069         } else {
1070                 printstat64(tcp, tcp->u_arg[1]);
1071         }
1072         return 0;
1073 #else
1074         return printargs(tcp);
1075 #endif
1076 }
1077
1078 #ifdef LINUX
1079 # if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
1080      && !defined(S390) && !defined(S390X)
1081 int
1082 sys_oldlstat(tcp)
1083 struct tcb *tcp;
1084 {
1085         if (entering(tcp)) {
1086                 printpath(tcp, tcp->u_arg[0]);
1087                 tprintf(", ");
1088         } else {
1089                 printoldstat(tcp, tcp->u_arg[1]);
1090         }
1091         return 0;
1092 }
1093 # endif /* !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
1094 #endif
1095
1096
1097 #if defined(SVR4) || defined(LINUXSPARC)
1098
1099 int
1100 sys_xstat(tcp)
1101 struct tcb *tcp;
1102 {
1103         if (entering(tcp)) {
1104                 tprintf("%ld, ", tcp->u_arg[0]);
1105                 printpath(tcp, tcp->u_arg[1]);
1106                 tprintf(", ");
1107         } else {
1108 #ifdef _STAT64_VER
1109                 if (tcp->u_arg[0] == _STAT64_VER)
1110                         printstat64 (tcp, tcp->u_arg[2]);
1111                 else
1112 #endif
1113                 printstat(tcp, tcp->u_arg[2]);
1114         }
1115         return 0;
1116 }
1117
1118 int
1119 sys_fxstat(tcp)
1120 struct tcb *tcp;
1121 {
1122         if (entering(tcp))
1123                 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1124         else {
1125 #ifdef _STAT64_VER
1126                 if (tcp->u_arg[0] == _STAT64_VER)
1127                         printstat64 (tcp, tcp->u_arg[2]);
1128                 else
1129 #endif
1130                 printstat(tcp, tcp->u_arg[2]);
1131         }
1132         return 0;
1133 }
1134
1135 int
1136 sys_lxstat(tcp)
1137 struct tcb *tcp;
1138 {
1139         if (entering(tcp)) {
1140                 tprintf("%ld, ", tcp->u_arg[0]);
1141                 printpath(tcp, tcp->u_arg[1]);
1142                 tprintf(", ");
1143         } else {
1144 #ifdef _STAT64_VER
1145                 if (tcp->u_arg[0] == _STAT64_VER)
1146                         printstat64 (tcp, tcp->u_arg[2]);
1147                 else
1148 #endif
1149                 printstat(tcp, tcp->u_arg[2]);
1150         }
1151         return 0;
1152 }
1153
1154 int
1155 sys_xmknod(tcp)
1156 struct tcb *tcp;
1157 {
1158         int mode = tcp->u_arg[2];
1159
1160         if (entering(tcp)) {
1161                 tprintf("%ld, ", tcp->u_arg[0]);
1162                 printpath(tcp, tcp->u_arg[1]);
1163                 tprintf(", %s", sprintmode(mode));
1164                 switch (mode & S_IFMT) {
1165                 case S_IFCHR: case S_IFBLK:
1166 #ifdef LINUXSPARC
1167                         tprintf(", makedev(%lu, %lu)",
1168                                 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1169                                 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1170 #else           
1171                         tprintf(", makedev(%lu, %lu)",
1172                                 (unsigned long) major(tcp->u_arg[3]),
1173                                 (unsigned long) minor(tcp->u_arg[3]));
1174 #endif                          
1175                         break;
1176                 default:
1177                         break;
1178                 }
1179         }
1180         return 0;
1181 }
1182
1183 #ifdef HAVE_SYS_ACL_H
1184
1185 #include <sys/acl.h>
1186
1187 struct xlat aclcmds[] = {
1188 #ifdef SETACL
1189         { SETACL,       "SETACL"        },
1190 #endif
1191 #ifdef GETACL
1192         { GETACL,       "GETACL"        },
1193 #endif
1194 #ifdef GETACLCNT
1195         { GETACLCNT,    "GETACLCNT"     },
1196 #endif
1197 #ifdef ACL_GET
1198         { ACL_GET,      "ACL_GET"       },
1199 #endif  
1200 #ifdef ACL_SET
1201         { ACL_SET,      "ACL_SET"       },
1202 #endif  
1203 #ifdef ACL_CNT
1204         { ACL_CNT,      "ACL_CNT"       },
1205 #endif  
1206         { 0,            NULL            },
1207 };
1208
1209 int
1210 sys_acl(tcp)
1211 struct tcb *tcp;
1212 {
1213         if (entering(tcp)) {
1214                 printpath(tcp, tcp->u_arg[0]);
1215                 tprintf(", ");
1216                 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1217                 tprintf(", %ld", tcp->u_arg[2]);
1218                 /*
1219                  * FIXME - dump out the list of aclent_t's pointed to
1220                  * by "tcp->u_arg[3]" if it's not NULL.
1221                  */
1222                 if (tcp->u_arg[3])
1223                         tprintf(", %#lx", tcp->u_arg[3]);
1224                 else
1225                         tprintf(", NULL");
1226         }
1227         return 0;
1228 }
1229
1230
1231 int
1232 sys_facl(tcp)
1233 struct tcb *tcp;
1234 {
1235         if (entering(tcp)) {
1236                 tprintf("%ld, ", tcp->u_arg[0]);
1237                 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1238                 tprintf(", %ld", tcp->u_arg[2]);
1239                 /*
1240                  * FIXME - dump out the list of aclent_t's pointed to
1241                  * by "tcp->u_arg[3]" if it's not NULL.
1242                  */
1243                 if (tcp->u_arg[3])
1244                         tprintf(", %#lx", tcp->u_arg[3]);
1245                 else
1246                         tprintf(", NULL");
1247         }
1248         return 0;
1249 }
1250
1251
1252 struct xlat aclipc[] = {
1253 #ifdef IPC_SHM
1254         { IPC_SHM,      "IPC_SHM"       },
1255 #endif  
1256 #ifdef IPC_SEM
1257         { IPC_SEM,      "IPC_SEM"       },
1258 #endif  
1259 #ifdef IPC_MSG
1260         { IPC_MSG,      "IPC_MSG"       },
1261 #endif  
1262         { 0,            NULL            },
1263 };
1264
1265
1266 int
1267 sys_aclipc(tcp)
1268 struct tcb *tcp;
1269 {
1270         if (entering(tcp)) {
1271                 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1272                 tprintf(", %#lx, ", tcp->u_arg[1]);
1273                 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1274                 tprintf(", %ld", tcp->u_arg[3]);
1275                 /*
1276                  * FIXME - dump out the list of aclent_t's pointed to
1277                  * by "tcp->u_arg[4]" if it's not NULL.
1278                  */
1279                 if (tcp->u_arg[4])
1280                         tprintf(", %#lx", tcp->u_arg[4]);
1281                 else
1282                         tprintf(", NULL");
1283         }
1284         return 0;
1285 }
1286
1287
1288
1289 #endif /* HAVE_SYS_ACL_H */
1290
1291 #endif /* SVR4 || LINUXSPARC */
1292
1293 #ifdef LINUX
1294
1295 static struct xlat fsmagic[] = {
1296         { 0x73757245,   "CODA_SUPER_MAGIC"      },
1297         { 0x012ff7b7,   "COH_SUPER_MAGIC"       },
1298         { 0x1373,       "DEVFS_SUPER_MAGIC"     },
1299         { 0x1cd1,       "DEVPTS_SUPER_MAGIC"    },
1300         { 0x414A53,     "EFS_SUPER_MAGIC"       },
1301         { 0xef51,       "EXT2_OLD_SUPER_MAGIC"  },
1302         { 0xef53,       "EXT2_SUPER_MAGIC"      },
1303         { 0x137d,       "EXT_SUPER_MAGIC"       },
1304         { 0xf995e849,   "HPFS_SUPER_MAGIC"      },
1305         { 0x9660,       "ISOFS_SUPER_MAGIC"     },
1306         { 0x137f,       "MINIX_SUPER_MAGIC"     },
1307         { 0x138f,       "MINIX_SUPER_MAGIC2"    },
1308         { 0x2468,       "MINIX2_SUPER_MAGIC"    },
1309         { 0x2478,       "MINIX2_SUPER_MAGIC2"   },
1310         { 0x4d44,       "MSDOS_SUPER_MAGIC"     },
1311         { 0x564c,       "NCP_SUPER_MAGIC"       },
1312         { 0x6969,       "NFS_SUPER_MAGIC"       },
1313         { 0x9fa0,       "PROC_SUPER_MAGIC"      },
1314         { 0x002f,       "QNX4_SUPER_MAGIC"      },
1315         { 0x52654973,   "REISERFS_SUPER_MAGIC"  },
1316         { 0x02011994,   "SHMFS_SUPER_MAGIC"     },
1317         { 0x517b,       "SMB_SUPER_MAGIC"       },
1318         { 0x012ff7b6,   "SYSV2_SUPER_MAGIC"     },
1319         { 0x012ff7b5,   "SYSV4_SUPER_MAGIC"     },
1320         { 0x00011954,   "UFS_MAGIC"             },
1321         { 0x54190100,   "UFS_CIGAM"             },
1322         { 0x012ff7b4,   "XENIX_SUPER_MAGIC"     },
1323         { 0x012fd16d,   "XIAFS_SUPER_MAGIC"     },
1324         { 0,            NULL                    },
1325 };
1326
1327 #endif /* LINUX */
1328
1329 #ifndef SVR4
1330
1331 static char *
1332 sprintfstype(magic)
1333 int magic;
1334 {
1335         static char buf[32];
1336 #ifdef LINUX
1337         char *s;
1338
1339         s = xlookup(fsmagic, magic);
1340         if (s) {
1341                 sprintf(buf, "\"%s\"", s);
1342                 return buf;
1343         }
1344 #endif /* LINUX */
1345         sprintf(buf, "%#x", magic);
1346         return buf;
1347 }
1348
1349 static void
1350 printstatfs(tcp, addr)
1351 struct tcb *tcp;
1352 long addr;
1353 {
1354         struct statfs statbuf;
1355
1356         if (syserror(tcp) || !verbose(tcp)) {
1357                 tprintf("%#lx", addr);
1358                 return;
1359         }
1360         if (umove(tcp, addr, &statbuf) < 0) {
1361                 tprintf("{...}");
1362                 return;
1363         }
1364 #ifdef ALPHA
1365
1366         tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1367                 sprintfstype(statbuf.f_type),
1368                 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
1369         tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
1370                 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1371 #else /* !ALPHA */
1372         tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1373                 sprintfstype(statbuf.f_type),
1374                 (unsigned long)statbuf.f_bsize,
1375                 (unsigned long)statbuf.f_blocks,
1376                 (unsigned long)statbuf.f_bfree);
1377         tprintf("f_files=%lu, f_ffree=%lu",
1378                 (unsigned long)statbuf.f_files,
1379                 (unsigned long)statbuf.f_ffree);
1380 #ifdef LINUX
1381         tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1382 #endif /* LINUX */
1383 #endif /* !ALPHA */
1384         tprintf("}");
1385 }
1386
1387 int
1388 sys_statfs(tcp)
1389 struct tcb *tcp;
1390 {
1391         if (entering(tcp)) {
1392                 printpath(tcp, tcp->u_arg[0]);
1393                 tprintf(", ");
1394         } else {
1395                 printstatfs(tcp, tcp->u_arg[1]);
1396         }
1397         return 0;
1398 }
1399
1400 int
1401 sys_fstatfs(tcp)
1402 struct tcb *tcp;
1403 {
1404         if (entering(tcp)) {
1405                 tprintf("%lu, ", tcp->u_arg[0]);
1406         } else {
1407                 printstatfs(tcp, tcp->u_arg[1]);
1408         }
1409         return 0;
1410 }
1411
1412 #if defined(LINUX) && defined(__alpha)
1413
1414 int
1415 osf_statfs(tcp)
1416 struct tcb *tcp;
1417 {
1418         if (entering(tcp)) {
1419                 printpath(tcp, tcp->u_arg[0]);
1420                 tprintf(", ");
1421         } else {
1422                 printstatfs(tcp, tcp->u_arg[1]);
1423                 tprintf(", %lu", tcp->u_arg[2]);
1424         }
1425         return 0;
1426 }
1427
1428 int
1429 osf_fstatfs(tcp)
1430 struct tcb *tcp;
1431 {
1432         if (entering(tcp)) {
1433                 tprintf("%lu, ", tcp->u_arg[0]);
1434         } else {
1435                 printstatfs(tcp, tcp->u_arg[1]);
1436                 tprintf(", %lu", tcp->u_arg[2]);
1437         }
1438         return 0;
1439 }
1440 #endif /* LINUX && __alpha */
1441
1442 #endif /* !SVR4 */
1443
1444 #ifdef SUNOS4
1445
1446 int
1447 sys_ustat(tcp)
1448 struct tcb *tcp;
1449 {
1450         struct ustat statbuf;
1451
1452         if (entering(tcp)) {
1453                 tprintf("makedev(%lu, %lu), ",
1454                                 (long) major(tcp->u_arg[0]),
1455                                 (long) minor(tcp->u_arg[0]));
1456         }
1457         else {
1458                 if (syserror(tcp) || !verbose(tcp))
1459                         tprintf("%#lx", tcp->u_arg[1]);
1460                 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1461                         tprintf("{...}");
1462                 else {
1463                         tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1464                                 statbuf.f_tfree, statbuf.f_tinode);
1465                         tprintf("f_fname=\"%.*s\", ",
1466                                 (int) sizeof(statbuf.f_fname),
1467                                 statbuf.f_fname);
1468                         tprintf("f_fpack=\"%.*s\"}",
1469                                 (int) sizeof(statbuf.f_fpack),
1470                                 statbuf.f_fpack);
1471                 }
1472         }
1473         return 0;
1474 }
1475
1476 #endif /* SUNOS4 */
1477
1478 int
1479 sys_pivotroot(tcp)
1480 struct tcb *tcp;
1481 {
1482         if (entering(tcp)) {
1483                 printpath(tcp, tcp->u_arg[0]);
1484                 tprintf(", ");
1485                 printpath(tcp, tcp->u_arg[1]);
1486         }
1487         return 0;
1488 }
1489
1490
1491 /* directory */
1492 int
1493 sys_chdir(tcp)
1494 struct tcb *tcp;
1495 {
1496         if (entering(tcp)) {
1497                 printpath(tcp, tcp->u_arg[0]);
1498         }
1499         return 0;
1500 }
1501
1502 int
1503 sys_mkdir(tcp)
1504 struct tcb *tcp;
1505 {
1506         if (entering(tcp)) {
1507                 printpath(tcp, tcp->u_arg[0]);
1508                 tprintf(", %#lo", tcp->u_arg[1]);
1509         }
1510         return 0;
1511 }
1512
1513 int
1514 sys_rmdir(tcp)
1515 struct tcb *tcp;
1516 {
1517         if (entering(tcp)) {
1518                 printpath(tcp, tcp->u_arg[0]);
1519         }
1520         return 0;
1521 }
1522
1523 int
1524 sys_fchdir(tcp)
1525 struct tcb *tcp;
1526 {
1527         if (entering(tcp)) {
1528                 tprintf("%ld", tcp->u_arg[0]);
1529         }
1530         return 0;
1531 }
1532
1533 int
1534 sys_chroot(tcp)
1535 struct tcb *tcp;
1536 {
1537         if (entering(tcp)) {
1538                 printpath(tcp, tcp->u_arg[0]);
1539         }
1540         return 0;
1541 }
1542
1543 int
1544 sys_fchroot(tcp)
1545 struct tcb *tcp;
1546 {
1547         if (entering(tcp)) {
1548                 tprintf("%ld", tcp->u_arg[0]);
1549         }
1550         return 0;
1551 }
1552
1553 int
1554 sys_link(tcp)
1555 struct tcb *tcp;
1556 {
1557         if (entering(tcp)) {
1558                 printpath(tcp, tcp->u_arg[0]);
1559                 tprintf(", ");
1560                 printpath(tcp, tcp->u_arg[1]);
1561         }
1562         return 0;
1563 }
1564
1565 int
1566 sys_unlink(tcp)
1567 struct tcb *tcp;
1568 {
1569         if (entering(tcp)) {
1570                 printpath(tcp, tcp->u_arg[0]);
1571         }
1572         return 0;
1573 }
1574
1575 int
1576 sys_symlink(tcp)
1577 struct tcb *tcp;
1578 {
1579         if (entering(tcp)) {
1580                 printpath(tcp, tcp->u_arg[0]);
1581                 tprintf(", ");
1582                 printpath(tcp, tcp->u_arg[1]);
1583         }
1584         return 0;
1585 }
1586
1587 int
1588 sys_readlink(tcp)
1589 struct tcb *tcp;
1590 {
1591         if (entering(tcp)) {
1592                 printpath(tcp, tcp->u_arg[0]);
1593                 tprintf(", ");
1594         } else {
1595                 if (syserror(tcp))
1596                         tprintf("%#lx", tcp->u_arg[1]);
1597                 else
1598                         printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1599                 tprintf(", %lu", tcp->u_arg[2]);
1600         }
1601         return 0;
1602 }
1603
1604 int
1605 sys_rename(tcp)
1606 struct tcb *tcp;
1607 {
1608         if (entering(tcp)) {
1609                 printpath(tcp, tcp->u_arg[0]);
1610                 tprintf(", ");
1611                 printpath(tcp, tcp->u_arg[1]);
1612         }
1613         return 0;
1614 }
1615
1616 int
1617 sys_chown(tcp)
1618 struct tcb *tcp;
1619 {
1620         if (entering(tcp)) {
1621                 printpath(tcp, tcp->u_arg[0]);
1622                 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1623         }
1624         return 0;
1625 }
1626
1627 int
1628 sys_fchown(tcp)
1629 struct tcb *tcp;
1630 {
1631         if (entering(tcp)) {
1632                 tprintf("%ld, %lu, %lu",
1633                         tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1634         }
1635         return 0;
1636 }
1637
1638 int
1639 sys_chmod(tcp)
1640 struct tcb *tcp;
1641 {
1642         if (entering(tcp)) {
1643                 printpath(tcp, tcp->u_arg[0]);
1644                 tprintf(", %#lo", tcp->u_arg[1]);
1645         }
1646         return 0;
1647 }
1648
1649 int
1650 sys_fchmod(tcp)
1651 struct tcb *tcp;
1652 {
1653         if (entering(tcp)) {
1654                 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1655         }
1656         return 0;
1657 }
1658
1659 #ifdef ALPHA
1660 int
1661 sys_osf_utimes(tcp)
1662 struct tcb *tcp;
1663 {
1664     if (entering(tcp)) {
1665         printpath(tcp, tcp->u_arg[0]);
1666         tprintf(", ");
1667         printtv32(tcp, tcp->u_arg[1]);
1668     }
1669     return 0;
1670 }
1671 #endif
1672
1673 int
1674 sys_utimes(tcp)
1675 struct tcb *tcp;
1676 {
1677         if (entering(tcp)) {
1678                 printpath(tcp, tcp->u_arg[0]);
1679                 tprintf(", ");
1680                 printtv(tcp, tcp->u_arg[1]);
1681         }
1682         return 0;
1683 }
1684
1685 int
1686 sys_utime(tcp)
1687 struct tcb *tcp;
1688 {
1689         long ut[2];
1690
1691         if (entering(tcp)) {
1692                 printpath(tcp, tcp->u_arg[0]);
1693                 tprintf(", ");
1694                 if (!tcp->u_arg[1])
1695                         tprintf("NULL");
1696                 else if (!verbose(tcp))
1697                         tprintf("%#lx", tcp->u_arg[1]);
1698                 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1699                     (char *) ut) < 0)
1700                         tprintf("[?, ?]");
1701                 else {
1702                         tprintf("[%s,", sprinttime(ut[0]));
1703                         tprintf(" %s]", sprinttime(ut[1]));
1704                 }
1705         }
1706         return 0;
1707 }
1708
1709 int
1710 sys_mknod(tcp)
1711 struct tcb *tcp;
1712 {
1713         int mode = tcp->u_arg[1];
1714
1715         if (entering(tcp)) {
1716                 printpath(tcp, tcp->u_arg[0]);
1717                 tprintf(", %s", sprintmode(mode));
1718                 switch (mode & S_IFMT) {
1719                 case S_IFCHR: case S_IFBLK:
1720 #ifdef LINUXSPARC
1721                         if (current_personality == 1)
1722                         tprintf(", makedev(%lu, %lu)",
1723                                 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1724                                 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1725                         else
1726 #endif  
1727                         tprintf(", makedev(%lu, %lu)",
1728                                 (unsigned long) major(tcp->u_arg[2]),
1729                                 (unsigned long) minor(tcp->u_arg[2]));
1730                         break;
1731                 default:
1732                         break;
1733                 }
1734         }
1735         return 0;
1736 }
1737
1738 int
1739 sys_mkfifo(tcp)
1740 struct tcb *tcp;
1741 {
1742         if (entering(tcp)) {
1743                 printpath(tcp, tcp->u_arg[0]);
1744                 tprintf(", %#lo", tcp->u_arg[1]);
1745         }
1746         return 0;
1747 }
1748
1749 int
1750 sys_fsync(tcp)
1751 struct tcb *tcp;
1752 {
1753         if (entering(tcp)) {
1754                 tprintf("%ld", tcp->u_arg[0]);
1755         }
1756         return 0;
1757 }
1758
1759 #ifdef LINUX
1760
1761 static void
1762 printdir(tcp, addr)
1763 struct tcb *tcp;
1764 long addr;
1765 {
1766         struct dirent d;
1767
1768         if (!verbose(tcp)) {
1769                 tprintf("%#lx", addr);
1770                 return;
1771         }
1772         if (umove(tcp, addr, &d) < 0) {
1773                 tprintf("{...}");
1774                 return;
1775         }
1776         tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
1777         tprintf("d_name=");
1778         printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1779         tprintf("}");
1780 }
1781
1782 int
1783 sys_readdir(tcp)
1784 struct tcb *tcp;
1785 {
1786         if (entering(tcp)) {
1787                 tprintf("%lu, ", tcp->u_arg[0]);
1788         } else {
1789                 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1790                         tprintf("%#lx", tcp->u_arg[1]);
1791                 else
1792                         printdir(tcp, tcp->u_arg[1]);
1793                 /* Not much point in printing this out, it is always 1. */
1794                 if (tcp->u_arg[2] != 1)
1795                         tprintf(", %lu", tcp->u_arg[2]);
1796         }
1797         return 0;
1798 }
1799
1800 #endif /* LINUX */
1801
1802 #ifdef FREEBSD
1803 struct xlat direnttypes[] = {
1804         { DT_FIFO,      "DT_FIFO"       },
1805         { DT_CHR,       "DT_CHR"        },
1806         { DT_DIR,       "DT_DIR"        },
1807         { DT_BLK,       "DT_BLK"        },
1808         { DT_REG,       "DT_REG"        },
1809         { DT_LNK,       "DT_LNK"        },
1810         { DT_SOCK,      "DT_SOCK"       },
1811         { DT_WHT,       "DT_WHT"        },
1812         { 0,            NULL            },
1813 };
1814
1815 #endif
1816
1817 int
1818 sys_getdents(tcp)
1819 struct tcb *tcp;
1820 {
1821         int i, len, dents = 0;
1822         char *buf;
1823
1824         if (entering(tcp)) {
1825                 tprintf("%lu, ", tcp->u_arg[0]);
1826                 return 0;
1827         }
1828         if (syserror(tcp) || !verbose(tcp)) {
1829                 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1830                 return 0;
1831         }
1832         len = tcp->u_rval;
1833         if ((buf = malloc(len)) == NULL) {
1834                 tprintf("out of memory\n");
1835                 return 0;
1836         }
1837         if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1838                 tprintf("{...}, %lu", tcp->u_arg[2]);
1839                 free(buf);
1840                 return 0;
1841         }
1842         if (!abbrev(tcp))
1843                 tprintf("{");
1844         for (i = 0; i < len;) {
1845                 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1846 #ifdef LINUX
1847                 if (!abbrev(tcp)) {
1848                         tprintf("%s{d_ino=%lu, d_off=%lu, ",
1849                                 i ? " " : "", d->d_ino, d->d_off);
1850                         tprintf("d_reclen=%u, d_name=\"%s\"}",
1851                                 d->d_reclen, d->d_name);
1852                 }
1853 #endif /* LINUX */
1854 #ifdef SVR4
1855                 if (!abbrev(tcp)) {
1856                         tprintf("%s{d_ino=%lu, d_off=%lu, ",
1857                                 i ? " " : "", d->d_ino, d->d_off);
1858                         tprintf("d_reclen=%u, d_name=\"%s\"}",
1859                                 d->d_reclen, d->d_name);
1860                 }
1861 #endif /* SVR4 */
1862 #ifdef SUNOS4
1863                 if (!abbrev(tcp)) {
1864                         tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1865                                 i ? " " : "", d->d_off, d->d_fileno,
1866                                 d->d_reclen);
1867                         tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1868                                 d->d_namlen, d->d_namlen, d->d_name);
1869                 }
1870 #endif /* SUNOS4 */
1871 #ifdef FREEBSD
1872                 if (!abbrev(tcp)) {
1873                         tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1874                                 i ? " " : "", d->d_fileno, d->d_reclen);
1875                         printxval(direnttypes, d->d_type, "DT_???");
1876                         tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1877                                 d->d_namlen, d->d_namlen, d->d_name);
1878                 }
1879 #endif /* FREEBSD */            
1880                 if (!d->d_reclen) {
1881                         tprintf("/* d_reclen == 0, problem here */");
1882                         break;
1883                 }
1884                 i += d->d_reclen;
1885                 dents++;
1886         }
1887         if (!abbrev(tcp))
1888                 tprintf("}");
1889         else
1890                 tprintf("/* %u entries */", dents);
1891         tprintf(", %lu", tcp->u_arg[2]);
1892         free(buf);
1893         return 0;
1894 }
1895
1896
1897 #if _LFS64_LARGEFILE
1898 int
1899 sys_getdents64(tcp)
1900 struct tcb *tcp;
1901 {
1902         int i, len, dents = 0;
1903         char *buf;
1904
1905         if (entering(tcp)) {
1906                 tprintf("%lu, ", tcp->u_arg[0]);
1907                 return 0;
1908         }
1909         if (syserror(tcp) || !verbose(tcp)) {
1910                 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1911                 return 0;
1912         }
1913         len = tcp->u_rval;
1914         if ((buf = malloc(len)) == NULL) {
1915                 tprintf("out of memory\n");
1916                 return 0;
1917         }
1918         if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1919                 tprintf("{...}, %lu", tcp->u_arg[2]);
1920                 free(buf);
1921                 return 0;
1922         }
1923         if (!abbrev(tcp))
1924                 tprintf("{");
1925         for (i = 0; i < len;) {
1926                 struct dirent64 *d = (struct dirent64 *) &buf[i];
1927 #if defined(LINUX) || defined(SVR4)
1928                 if (!abbrev(tcp)) {
1929                         tprintf("%s{d_ino=%lu, d_off=%lu, ",
1930                                 i ? " " : "", 
1931                                 (unsigned long)d->d_ino, 
1932                                 (unsigned long)d->d_off);
1933                         tprintf("d_reclen=%u, d_name=\"%s\"}",
1934                                 d->d_reclen, d->d_name);
1935                 }
1936 #endif /* LINUX || SVR4 */
1937 #ifdef SUNOS4
1938                 if (!abbrev(tcp)) {
1939                         tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1940                                 i ? " " : "", d->d_off, d->d_fileno,
1941                                 d->d_reclen);
1942                         tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1943                                 d->d_namlen, d->d_namlen, d->d_name);
1944                 }
1945 #endif /* SUNOS4 */
1946                 i += d->d_reclen;
1947                 dents++;
1948         }
1949         if (!abbrev(tcp))
1950                 tprintf("}");
1951         else
1952                 tprintf("/* %u entries */", dents);
1953         tprintf(", %lu", tcp->u_arg[2]);
1954         free(buf);
1955         return 0;
1956 }
1957 #endif
1958  
1959 #ifdef FREEBSD
1960 int
1961 sys_getdirentries(tcp)
1962 struct tcb * tcp;
1963 {
1964         int i, len, dents = 0;
1965         long basep;
1966         char *buf;
1967
1968         if (entering(tcp)) {
1969                 tprintf("%lu, ", tcp->u_arg[0]);
1970                 return 0;
1971         }
1972         if (syserror(tcp) || !verbose(tcp)) {
1973                 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1974                 return 0;
1975         }
1976         len = tcp->u_rval;
1977         if ((buf = malloc(len)) == NULL) {
1978                 tprintf("out of memory\n");
1979                 return 0;
1980         }
1981         if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1982                 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
1983                 free(buf);
1984                 return 0;
1985         }
1986         if (!abbrev(tcp))
1987                 tprintf("{");
1988         for (i = 0; i < len;) {
1989                 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1990                 if (!abbrev(tcp)) {
1991                         tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1992                                 i ? " " : "", d->d_fileno, d->d_reclen);
1993                         printxval(direnttypes, d->d_type, "DT_???");
1994                         tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1995                                 d->d_namlen, d->d_namlen, d->d_name);
1996                 }
1997                 i += d->d_reclen;
1998                 dents++;
1999         }
2000         if (!abbrev(tcp))
2001                 tprintf("}");
2002         else
2003                 tprintf("/* %u entries */", dents);
2004         free(buf);
2005         tprintf(", %lu", tcp->u_arg[2]);
2006         if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2007                 tprintf(", %#lx", tcp->u_arg[3]);
2008         else
2009                 tprintf(", [%lu]", basep);
2010         return 0;
2011 }
2012 #endif
2013
2014 #ifdef LINUX
2015 int
2016 sys_getcwd(tcp)
2017 struct tcb *tcp;
2018 {
2019     if (exiting(tcp)) {
2020         if (syserror(tcp))
2021             tprintf("%#lx", tcp->u_arg[0]);
2022         else
2023             printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2024         tprintf(", %lu", tcp->u_arg[1]);
2025     }
2026     return 0;
2027 }
2028 #endif /* LINUX */
2029
2030 #ifdef FREEBSD
2031 int
2032 sys___getcwd(tcp)
2033 struct tcb *tcp;
2034 {
2035     if (exiting(tcp)) {
2036         if (syserror(tcp))
2037             tprintf("%#lx", tcp->u_arg[0]);
2038         else
2039             printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2040         tprintf(", %lu", tcp->u_arg[1]);
2041     }
2042     return 0;
2043 }
2044 #endif
2045
2046 #ifdef HAVE_SYS_ASYNCH_H
2047
2048 int
2049 sys_aioread(tcp)
2050 struct tcb *tcp;
2051 {
2052         struct aio_result_t res;
2053
2054         if (entering(tcp)) {
2055                 tprintf("%lu, ", tcp->u_arg[0]);
2056         } else {
2057                 if (syserror(tcp))
2058                         tprintf("%#lx", tcp->u_arg[1]);
2059                 else
2060                         printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2061                 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2062                 printxval(whence, tcp->u_arg[4], "L_???");
2063                 if (syserror(tcp) || tcp->u_arg[5] == 0
2064                     || umove(tcp, tcp->u_arg[5], &res) < 0)
2065                         tprintf(", %#lx", tcp->u_arg[5]);
2066                 else
2067                         tprintf(", {aio_return %d aio_errno %d}",
2068                                 res.aio_return, res.aio_errno);
2069         }
2070         return 0;
2071 }
2072
2073 int
2074 sys_aiowrite(tcp)
2075 struct tcb *tcp;
2076 {
2077         struct aio_result_t res;
2078
2079         if (entering(tcp)) {
2080                 tprintf("%lu, ", tcp->u_arg[0]);
2081                 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2082                 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2083                 printxval(whence, tcp->u_arg[4], "L_???");
2084         }
2085         else {
2086                 if (tcp->u_arg[5] == 0)
2087                         tprintf(", NULL");
2088                 else if (syserror(tcp)
2089                     || umove(tcp, tcp->u_arg[5], &res) < 0)
2090                         tprintf(", %#lx", tcp->u_arg[5]);
2091                 else
2092                         tprintf(", {aio_return %d aio_errno %d}",
2093                                 res.aio_return, res.aio_errno);
2094         }
2095         return 0;
2096 }
2097
2098 int
2099 sys_aiowait(tcp)
2100 struct tcb *tcp;
2101 {
2102         if (entering(tcp))
2103                 printtv(tcp, tcp->u_arg[0]);
2104         return 0;
2105 }
2106
2107 int
2108 sys_aiocancel(tcp)
2109 struct tcb *tcp;
2110 {
2111         struct aio_result_t res;
2112
2113         if (exiting(tcp)) {
2114                 if (tcp->u_arg[0] == 0)
2115                         tprintf("NULL");
2116                 else if (syserror(tcp)
2117                     || umove(tcp, tcp->u_arg[0], &res) < 0)
2118                         tprintf("%#lx", tcp->u_arg[0]);
2119                 else
2120                         tprintf("{aio_return %d aio_errno %d}",
2121                                 res.aio_return, res.aio_errno);
2122         }
2123         return 0;
2124 }
2125
2126 #endif /* HAVE_SYS_ASYNCH_H */