blob: bb5f9c6f0b9d58e63d534357b4fe26792f8323da [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * $Id$
30 */
31
32#include "defs.h"
33
34#include <dirent.h>
Wichert Akkerman9524bb91999-05-25 23:11:18 +000035#ifdef linux
36#define dirent kernel_dirent
37#include <linux/types.h>
38#include <linux/dirent.h>
39#undef dirent
40#else
41#define kernel_dirent dirent
42#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000043
Wichert Akkerman8bc6cfd1999-04-21 15:57:38 +000044#ifdef linux
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000045# ifdef LINUXSPARC
46struct stat {
47 unsigned short st_dev;
48 unsigned int st_ino;
49 unsigned short st_mode;
50 short st_nlink;
51 unsigned short st_uid;
52 unsigned short st_gid;
53 unsigned short st_rdev;
54 unsigned int st_size;
55 int st_atime;
56 unsigned int __unused1;
57 int st_mtime;
58 unsigned int __unused2;
59 int st_ctime;
60 unsigned int __unused3;
61 int st_blksize;
62 int st_blocks;
63 unsigned int __unused4[2];
64};
65# define stat kernel_stat
66# include <asm/stat.h>
67# undef stat
68# else
69# include <asm/stat.h>
70# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +000071# define stat libc_stat
72# include <sys/stat.h>
73# undef stat
Wichert Akkermand4d8e921999-04-18 23:30:29 +000074#else
75# include <sys/stat.h>
Wichert Akkerman328c5e71999-04-16 00:21:26 +000076#endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +000077
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000078#include <fcntl.h>
79
80#ifdef SVR4
81# include <sys/cred.h>
82#endif /* SVR4 */
83
84#include <sys/vfs.h>
85
86#ifdef MAJOR_IN_SYSMACROS
87#include <sys/sysmacros.h>
88#endif
89
90#ifdef MAJOR_IN_MKDEV
91#include <sys/mkdev.h>
92#endif
93
94#ifdef HAVE_SYS_ASYNCH_H
95#include <sys/asynch.h>
96#endif
97
98#ifdef SUNOS4
99#include <ustat.h>
100#endif
101
102/*
103 * This is a really dirty trick but it should always work. Traditional
104 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
105 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
106 */
107struct xlat openmodes[] = {
108 { O_RDWR+1, "O_RDWR" },
109 { O_RDONLY+1, "O_RDONLY" },
110 { O_WRONLY+1, "O_WRONLY" },
111 { O_NONBLOCK, "O_NONBLOCK" },
112 { O_APPEND, "O_APPEND" },
113 { O_CREAT, "O_CREAT" },
114 { O_TRUNC, "O_TRUNC" },
115 { O_EXCL, "O_EXCL" },
116 { O_NOCTTY, "O_NOCTTY" },
117#ifdef O_SYNC
118 { O_SYNC, "O_SYNC" },
119#endif
120#ifdef O_ASYNC
121 { O_ASYNC, "O_ASYNC" },
122#endif
123#ifdef O_DSYNC
124 { O_DSYNC, "O_DSYNC" },
125#endif
126#ifdef O_RSYNC
127 { O_RSYNC, "O_RSYNC" },
128#endif
129#ifdef O_NDELAY
130 { O_NDELAY, "O_NDELAY" },
131#endif
132#ifdef O_PRIV
133 { O_PRIV, "O_PRIV" },
134#endif
135#ifdef O_DIRECT
136 { O_DIRECT, "O_DIRECT" },
137#endif
138#ifdef O_LARGEFILE
139 { O_LARGEFILE, "O_LARGEFILE" },
140#endif
141#ifdef O_DIRECTORY
142 { O_DIRECTORY, "O_DIRECTORY" },
143#endif
144
145#ifdef FNDELAY
146 { FNDELAY, "FNDELAY" },
147#endif
148#ifdef FAPPEND
149 { FAPPEND, "FAPPEND" },
150#endif
151#ifdef FMARK
152 { FMARK, "FMARK" },
153#endif
154#ifdef FDEFER
155 { FDEFER, "FDEFER" },
156#endif
157#ifdef FASYNC
158 { FASYNC, "FASYNC" },
159#endif
160#ifdef FSHLOCK
161 { FSHLOCK, "FSHLOCK" },
162#endif
163#ifdef FEXLOCK
164 { FEXLOCK, "FEXLOCK" },
165#endif
166#ifdef FCREAT
167 { FCREAT, "FCREAT" },
168#endif
169#ifdef FTRUNC
170 { FTRUNC, "FTRUNC" },
171#endif
172#ifdef FEXCL
173 { FEXCL, "FEXCL" },
174#endif
175#ifdef FNBIO
176 { FNBIO, "FNBIO" },
177#endif
178#ifdef FSYNC
179 { FSYNC, "FSYNC" },
180#endif
181#ifdef FNOCTTY
182 { FNOCTTY, "FNOCTTY" },
183#endif
184 { 0, NULL },
185};
186
187int
188sys_open(tcp)
189struct tcb *tcp;
190{
191 if (entering(tcp)) {
192 printpath(tcp, tcp->u_arg[0]);
193 tprintf(", ");
194 /* flags */
195 printflags(openmodes, tcp->u_arg[1] + 1);
196 if (tcp->u_arg[1] & O_CREAT) {
197 /* mode */
198 tprintf(", %#lo", tcp->u_arg[2]);
199 }
200 }
201 return 0;
202}
203
204#ifdef LINUXSPARC
205struct xlat openmodessol[] = {
206 { 0, "O_RDWR" },
207 { 1, "O_RDONLY" },
208 { 2, "O_WRONLY" },
209 { 0x80, "O_NONBLOCK" },
210 { 8, "O_APPEND" },
211 { 0x100, "O_CREAT" },
212 { 0x200, "O_TRUNC" },
213 { 0x400, "O_EXCL" },
214 { 0x800, "O_NOCTTY" },
215 { 0x10, "O_SYNC" },
216 { 0x40, "O_DSYNC" },
217 { 0x8000, "O_RSYNC" },
218 { 4, "O_NDELAY" },
219 { 0x1000, "O_PRIV" },
220 { 0, NULL },
221};
222
223int
224solaris_open(tcp)
225struct tcb *tcp;
226{
227 if (entering(tcp)) {
228 printpath(tcp, tcp->u_arg[0]);
229 tprintf(", ");
230 /* flags */
231 printflags(openmodessol, tcp->u_arg[1] + 1);
232 if (tcp->u_arg[1] & 0x100) {
233 /* mode */
234 tprintf(", %#lo", tcp->u_arg[2]);
235 }
236 }
237 return 0;
238}
239
240#endif
241
242int
243sys_creat(tcp)
244struct tcb *tcp;
245{
246 if (entering(tcp)) {
247 printpath(tcp, tcp->u_arg[0]);
248 tprintf(", %#lo", tcp->u_arg[1]);
249 }
250 return 0;
251}
252
253static struct xlat access_flags[] = {
254 { F_OK, "F_OK", },
255 { R_OK, "R_OK" },
256 { W_OK, "W_OK" },
257 { X_OK, "X_OK" },
258#ifdef EFF_ONLY_OK
259 { EFF_ONLY_OK, "EFF_ONLY_OK" },
260#endif
261#ifdef EX_OK
262 { EX_OK, "EX_OK" },
263#endif
264 { 0, NULL },
265};
266
267int
268sys_access(tcp)
269struct tcb *tcp;
270{
271 if (entering(tcp)) {
272 printpath(tcp, tcp->u_arg[0]);
273 tprintf(", ");
274 printflags(access_flags, tcp->u_arg[1]);
275 }
276 return 0;
277}
278
279int
280sys_umask(tcp)
281struct tcb *tcp;
282{
283 if (entering(tcp)) {
284 tprintf("%#lo", tcp->u_arg[0]);
285 }
286 return RVAL_OCTAL;
287}
288
289static struct xlat whence[] = {
290 { SEEK_SET, "SEEK_SET" },
291 { SEEK_CUR, "SEEK_CUR" },
292 { SEEK_END, "SEEK_END" },
293 { 0, NULL },
294};
295
296int
297sys_lseek(tcp)
298struct tcb *tcp;
299{
300 if (entering(tcp)) {
301 tprintf("%ld, ", tcp->u_arg[0]);
302 if (tcp->u_arg[2] == SEEK_SET)
303 tprintf("%lu, ", tcp->u_arg[1]);
304 else
305 tprintf("%ld, ", tcp->u_arg[1]);
306 printxval(whence, tcp->u_arg[2], "SEEK_???");
307 }
308 return RVAL_UDECIMAL;
309}
310
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000311#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000312int
313sys_llseek (tcp)
314struct tcb *tcp;
315{
316 if (entering(tcp)) {
317 if (tcp->u_arg[4] == SEEK_SET)
318 tprintf("%ld, %llu, ", tcp->u_arg[0],
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000319 (((long long int) tcp->u_arg[1]) << 32
320 | (unsigned long long) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000321 else
322 tprintf("%ld, %lld, ", tcp->u_arg[0],
323 (((long long int) tcp->u_arg[1]) << 32
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000324 | (unsigned long long) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000325 }
326 else {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000327 long long int off;
328 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000329 tprintf("%#lx, ", tcp->u_arg[3]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000330 else
331 tprintf("[%llu], ", off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000332 printxval(whence, tcp->u_arg[4], "SEEK_???");
333 }
334 return 0;
335}
336#endif
337
338int
339sys_truncate(tcp)
340struct tcb *tcp;
341{
342 if (entering(tcp)) {
343 printpath(tcp, tcp->u_arg[0]);
344 tprintf(", %lu", tcp->u_arg[1]);
345 }
346 return 0;
347}
348
349int
350sys_ftruncate(tcp)
351struct tcb *tcp;
352{
353 if (entering(tcp)) {
354 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
355 }
356 return 0;
357}
358
359/* several stats */
360
361static struct xlat modetypes[] = {
362 { S_IFREG, "S_IFREG" },
363 { S_IFSOCK, "S_IFSOCK" },
364 { S_IFIFO, "S_IFIFO" },
365 { S_IFLNK, "S_IFLNK" },
366 { S_IFDIR, "S_IFDIR" },
367 { S_IFBLK, "S_IFBLK" },
368 { S_IFCHR, "S_IFCHR" },
369 { 0, NULL },
370};
371
372static char *
373sprintmode(mode)
374int mode;
375{
376 static char buf[64];
377 char *s;
378
379 if ((mode & S_IFMT) == 0)
380 s = "";
381 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
382 sprintf(buf, "%#o", mode);
383 return buf;
384 }
385 sprintf(buf, "%s%s%s%s", s,
386 (mode & S_ISUID) ? "|S_ISUID" : "",
387 (mode & S_ISGID) ? "|S_ISGID" : "",
388 (mode & S_ISVTX) ? "|S_ISVTX" : "");
389 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
390 if (mode)
391 sprintf(buf + strlen(buf), "|%#o", mode);
392 s = (*buf == '|') ? buf + 1 : buf;
393 return *s ? s : "0";
394}
395
396static char *
397sprinttime(t)
398time_t t;
399{
400 struct tm *tmp;
401 static char buf[32];
402
403 if (t == 0) {
404 sprintf(buf, "0");
405 return buf;
406 }
407 tmp = localtime(&t);
408 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
409 tmp->tm_year, tmp->tm_mon + 1, tmp->tm_mday,
410 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
411 return buf;
412}
413
414#ifdef LINUXSPARC
415typedef struct {
416 int tv_sec;
417 int tv_nsec;
418} timestruct_t;
419
420struct solstat {
421 unsigned st_dev;
422 int st_pad1[3]; /* network id */
423 unsigned st_ino;
424 unsigned st_mode;
425 unsigned st_nlink;
426 unsigned st_uid;
427 unsigned st_gid;
428 unsigned st_rdev;
429 int st_pad2[2];
430 int st_size;
431 int st_pad3; /* st_size, off_t expansion */
432 timestruct_t st_atime;
433 timestruct_t st_mtime;
434 timestruct_t st_ctime;
435 int st_blksize;
436 int st_blocks;
437 char st_fstype[16];
438 int st_pad4[8]; /* expansion area */
439};
440
441static void
442printstatsol(tcp, addr)
443struct tcb *tcp;
444int addr;
445{
446 struct solstat statbuf;
447
448 if (!addr) {
449 tprintf("NULL");
450 return;
451 }
452 if (syserror(tcp) || !verbose(tcp)) {
453 tprintf("%#x", addr);
454 return;
455 }
456 if (umove(tcp, addr, &statbuf) < 0) {
457 tprintf("{...}");
458 return;
459 }
460 if (!abbrev(tcp)) {
461 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
462 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
463 (unsigned long) (statbuf.st_dev & 0x3ffff),
464 (unsigned long) statbuf.st_ino,
465 sprintmode(statbuf.st_mode));
466 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
467 (unsigned long) statbuf.st_nlink,
468 (unsigned long) statbuf.st_uid,
469 (unsigned long) statbuf.st_gid);
470 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
471 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
472 }
473 else
474 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
475 switch (statbuf.st_mode & S_IFMT) {
476 case S_IFCHR: case S_IFBLK:
477 tprintf("st_rdev=makedev(%lu, %lu), ",
478 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
479 (unsigned long) (statbuf.st_rdev & 0x3ffff));
480 break;
481 default:
482 tprintf("st_size=%u, ", statbuf.st_size);
483 break;
484 }
485 if (!abbrev(tcp)) {
486 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
487 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
488 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
489 }
490 else
491 tprintf("...}");
492}
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000493#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000494
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000495static void
496realprintstat(tcp, statbuf)
497struct tcb *tcp;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000498struct stat *statbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000499{
500 if (!abbrev(tcp)) {
501 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
502 (unsigned long) major(statbuf->st_dev),
503 (unsigned long) minor(statbuf->st_dev),
504 (unsigned long) statbuf->st_ino,
505 sprintmode(statbuf->st_mode));
506 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
507 (unsigned long) statbuf->st_nlink,
508 (unsigned long) statbuf->st_uid,
509 (unsigned long) statbuf->st_gid);
510#ifdef HAVE_ST_BLKSIZE
511 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
512#endif /* HAVE_ST_BLKSIZE */
513#ifdef HAVE_ST_BLOCKS
514 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
515#endif /* HAVE_ST_BLOCKS */
516 }
517 else
518 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
519 switch (statbuf->st_mode & S_IFMT) {
520 case S_IFCHR: case S_IFBLK:
521#ifdef HAVE_ST_RDEV
522 tprintf("st_rdev=makedev(%lu, %lu), ",
523 (unsigned long) major(statbuf->st_rdev),
524 (unsigned long) minor(statbuf->st_rdev));
525#else /* !HAVE_ST_RDEV */
526 tprintf("st_size=makedev(%lu, %lu), ",
527 (unsigned long) major(statbuf->st_size),
528 (unsigned long) minor(statbuf->st_size));
529#endif /* !HAVE_ST_RDEV */
530 break;
531 default:
532 tprintf("st_size=%lu, ", statbuf->st_size);
533 break;
534 }
535 if (!abbrev(tcp)) {
536 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
537 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
538 tprintf("st_ctime=%s}", sprinttime(statbuf->st_ctime));
539 }
540 else
541 tprintf("...}");
542}
543
Nate Sammons771a6ff1999-04-05 22:39:31 +0000544
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000545static void
546printstat(tcp, addr)
547struct tcb *tcp;
548int addr;
549{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000550 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000551
552#ifdef LINUXSPARC
553 if (current_personality == 1) {
554 printstatsol(tcp, addr);
555 return;
556 }
557#endif /* LINUXSPARC */
558
559 if (!addr) {
560 tprintf("NULL");
561 return;
562 }
563 if (syserror(tcp) || !verbose(tcp)) {
564 tprintf("%#x", addr);
565 return;
566 }
567 if (umove(tcp, addr, &statbuf) < 0) {
568 tprintf("{...}");
569 return;
570 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000571
572 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000573}
574
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000575#ifdef linux
576static void
577convertoldstat(oldbuf, newbuf)
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000578const struct __old_kernel_stat *oldbuf;
579struct stat *newbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000580{
581 newbuf->st_dev=oldbuf->st_dev;
582 newbuf->st_ino=oldbuf->st_ino;
583 newbuf->st_mode=oldbuf->st_mode;
584 newbuf->st_nlink=oldbuf->st_nlink;
585 newbuf->st_uid=oldbuf->st_uid;
586 newbuf->st_gid=oldbuf->st_gid;
587 newbuf->st_rdev=oldbuf->st_rdev;
588 newbuf->st_size=oldbuf->st_size;
589 newbuf->st_atime=oldbuf->st_atime;
590 newbuf->st_mtime=oldbuf->st_mtime;
591 newbuf->st_ctime=oldbuf->st_ctime;
592 newbuf->st_blksize=0; /* not supported in old_stat */
593 newbuf->st_blocks=0; /* not supported in old_stat */
594}
595#endif
596
597
598#ifdef linux
599static void
600printoldstat(tcp, addr)
601struct tcb *tcp;
602int addr;
603{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000604 struct __old_kernel_stat statbuf;
605 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000606
607#ifdef LINUXSPARC
608 if (current_personality == 1) {
609 printstatsol(tcp, addr);
610 return;
611 }
612#endif /* LINUXSPARC */
613
614 if (!addr) {
615 tprintf("NULL");
616 return;
617 }
618 if (syserror(tcp) || !verbose(tcp)) {
619 tprintf("%#x", addr);
620 return;
621 }
622 if (umove(tcp, addr, &statbuf) < 0) {
623 tprintf("{...}");
624 return;
625 }
626
627 convertoldstat(&statbuf, &newstatbuf);
628 realprintstat(tcp, &newstatbuf);
629}
630#endif
631
632
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000633int
634sys_stat(tcp)
635struct tcb *tcp;
636{
637 if (entering(tcp)) {
638 printpath(tcp, tcp->u_arg[0]);
639 tprintf(", ");
640 } else {
641 printstat(tcp, tcp->u_arg[1]);
642 }
643 return 0;
644}
645
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000646#ifdef linux
647int
648sys_oldstat(tcp)
649struct tcb *tcp;
650{
651 if (entering(tcp)) {
652 printpath(tcp, tcp->u_arg[0]);
653 tprintf(", ");
654 } else {
655 printoldstat(tcp, tcp->u_arg[1]);
656 }
657 return 0;
658}
659#endif
660
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000661int
662sys_fstat(tcp)
663struct tcb *tcp;
664{
665 if (entering(tcp))
666 tprintf("%ld, ", tcp->u_arg[0]);
667 else {
668 printstat(tcp, tcp->u_arg[1]);
669 }
670 return 0;
671}
672
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000673#ifdef linux
674int
675sys_oldfstat(tcp)
676struct tcb *tcp;
677{
678 if (entering(tcp))
679 tprintf("%ld, ", tcp->u_arg[0]);
680 else {
681 printoldstat(tcp, tcp->u_arg[1]);
682 }
683 return 0;
684}
685#endif
686
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000687int
688sys_lstat(tcp)
689struct tcb *tcp;
690{
691 if (entering(tcp)) {
692 printpath(tcp, tcp->u_arg[0]);
693 tprintf(", ");
694 } else {
695 printstat(tcp, tcp->u_arg[1]);
696 }
697 return 0;
698}
699
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000700#ifdef linux
701int
702sys_oldlstat(tcp)
703struct tcb *tcp;
704{
705 if (entering(tcp)) {
706 printpath(tcp, tcp->u_arg[0]);
707 tprintf(", ");
708 } else {
709 printoldstat(tcp, tcp->u_arg[1]);
710 }
711 return 0;
712}
713#endif
714
715
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000716#if defined(SVR4) || defined(LINUXSPARC)
717
718int
719sys_xstat(tcp)
720struct tcb *tcp;
721{
722 if (entering(tcp)) {
723 tprintf("%ld, ", tcp->u_arg[0]);
724 printpath(tcp, tcp->u_arg[1]);
725 tprintf(", ");
726 } else {
727 printstat(tcp, tcp->u_arg[2]);
728 }
729 return 0;
730}
731
732int
733sys_fxstat(tcp)
734struct tcb *tcp;
735{
736 if (entering(tcp))
737 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
738 else {
739 printstat(tcp, tcp->u_arg[2]);
740 }
741 return 0;
742}
743
744int
745sys_lxstat(tcp)
746struct tcb *tcp;
747{
748 if (entering(tcp)) {
749 tprintf("%ld, ", tcp->u_arg[0]);
750 printpath(tcp, tcp->u_arg[1]);
751 tprintf(", ");
752 } else {
753 printstat(tcp, tcp->u_arg[2]);
754 }
755 return 0;
756}
757
758int
759sys_xmknod(tcp)
760struct tcb *tcp;
761{
762 int mode = tcp->u_arg[2];
763
764 if (entering(tcp)) {
765 tprintf("%ld, ", tcp->u_arg[0]);
766 printpath(tcp, tcp->u_arg[1]);
767 tprintf(", %s", sprintmode(mode));
768 switch (mode & S_IFMT) {
769 case S_IFCHR: case S_IFBLK:
770#ifdef LINUXSPARC
771 tprintf(", makedev(%lu, %lu)",
772 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
773 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
774#else
775 tprintf(", makedev(%lu, %lu)",
776 (unsigned long) major(tcp->u_arg[3]),
777 (unsigned long) minor(tcp->u_arg[3]));
778#endif
779 break;
780 default:
781 break;
782 }
783 }
784 return 0;
785}
786
Wichert Akkerman8829a551999-06-11 13:18:40 +0000787#ifdef HAVE_SYS_ACL_H
788
789#include <sys/acl.h>
790
791struct xlat aclcmds[] = {
792 { SETACL, "SETACL" },
793 { GETACL, "GETACL" },
794 { GETACLCNT, "GETACLCNT" },
795 { 0, NULL },
796};
797
798int
799sys_acl(tcp)
800struct tcb *tcp;
801{
802 if (entering(tcp)) {
803 printpath(tcp, tcp->u_arg[0]);
804 tprintf(", ");
805 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
806 tprintf(", %ld", tcp->u_arg[2]);
807 /*
808 * FIXME - dump out the list of aclent_t's pointed to
809 * by "tcp->u_arg[3]" if it's not NULL.
810 */
811 if (tcp->u_arg[3])
812 tprintf(", %#lx", tcp->u_arg[3]);
813 else
814 tprintf(", NULL");
815 }
816 return 0;
817}
818
819
820int
821sys_facl(tcp)
822struct tcb *tcp;
823{
824 if (entering(tcp)) {
825 tprintf("%ld, ", tcp->u_arg[0]);
826 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
827 tprintf(", %ld", tcp->u_arg[2]);
828 /*
829 * FIXME - dump out the list of aclent_t's pointed to
830 * by "tcp->u_arg[3]" if it's not NULL.
831 */
832 if (tcp->u_arg[3])
833 tprintf(", %#lx", tcp->u_arg[3]);
834 else
835 tprintf(", NULL");
836 }
837 return 0;
838}
839
840#endif /* HAVE_SYS_ACL_H */
841
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000842#endif /* SVR4 || LINUXSPARC */
843
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000844#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000845
846static struct xlat fsmagic[] = {
847 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
848 { 0xef53, "EXT2_SUPER_MAGIC" },
849 { 0x137d, "EXT_SUPER_MAGIC" },
850 { 0x9660, "ISOFS_SUPER_MAGIC" },
851 { 0x137f, "MINIX_SUPER_MAGIC" },
852 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000853 { 0x2468, "MINIX2_SUPER_MAGIC" },
854 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000855 { 0x4d44, "MSDOS_SUPER_MAGIC" },
856 { 0x6969, "NFS_SUPER_MAGIC" },
857 { 0x9fa0, "PROC_SUPER_MAGIC" },
858 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
859 { 0, NULL },
860};
861
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000862#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000863
864#ifndef SVR4
865
866static char *
867sprintfstype(magic)
868int magic;
869{
870 static char buf[32];
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000871#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000872 char *s;
873
874 s = xlookup(fsmagic, magic);
875 if (s) {
876 sprintf(buf, "\"%s\"", s);
877 return buf;
878 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000879#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000880 sprintf(buf, "%#x", magic);
881 return buf;
882}
883
884static void
885printstatfs(tcp, addr)
886struct tcb *tcp;
887long addr;
888{
889 struct statfs statbuf;
890
891 if (syserror(tcp) || !verbose(tcp)) {
892 tprintf("%#lx", addr);
893 return;
894 }
895 if (umove(tcp, addr, &statbuf) < 0) {
896 tprintf("{...}");
897 return;
898 }
899#ifdef ALPHA
900
901 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
902 sprintfstype(statbuf.f_type),
903 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000904 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000905 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
906#else /* !ALPHA */
907 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
908 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +0000909 (unsigned long)statbuf.f_bsize,
910 (unsigned long)statbuf.f_blocks,
911 (unsigned long)statbuf.f_bfree);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000912 tprintf("f_files=%lu, f_ffree=%lu",
Nate Sammons5c74d201999-04-06 01:37:51 +0000913 (unsigned long)statbuf.f_files,
914 (unsigned long)statbuf.f_ffree);
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000915#ifdef linux
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000916 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000917#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000918#endif /* !ALPHA */
919 tprintf("}");
920}
921
922int
923sys_statfs(tcp)
924struct tcb *tcp;
925{
926 if (entering(tcp)) {
927 printpath(tcp, tcp->u_arg[0]);
928 tprintf(", ");
929 } else {
930 printstatfs(tcp, tcp->u_arg[1]);
931 }
932 return 0;
933}
934
935int
936sys_fstatfs(tcp)
937struct tcb *tcp;
938{
939 if (entering(tcp)) {
940 tprintf("%lu, ", tcp->u_arg[0]);
941 } else {
942 printstatfs(tcp, tcp->u_arg[1]);
943 }
944 return 0;
945}
946
Wichert Akkermana0f36c61999-04-16 14:01:34 +0000947#if defined(linux) && defined(__alpha)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000948
949int
950osf_statfs(tcp)
951struct tcb *tcp;
952{
953 if (entering(tcp)) {
954 printpath(tcp, tcp->u_arg[0]);
955 tprintf(", ");
956 } else {
957 printstatfs(tcp, tcp->u_arg[1]);
958 tprintf(", %lu", tcp->u_arg[2]);
959 }
960 return 0;
961}
962
963int
964osf_fstatfs(tcp)
965struct tcb *tcp;
966{
967 if (entering(tcp)) {
968 tprintf("%lu, ", tcp->u_arg[0]);
969 } else {
970 printstatfs(tcp, tcp->u_arg[1]);
971 tprintf(", %lu", tcp->u_arg[2]);
972 }
973 return 0;
974}
Wichert Akkermana0f36c61999-04-16 14:01:34 +0000975#endif /* linux && __alpha */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000976
977#endif /* !SVR4 */
978
979#ifdef SUNOS4
980
981int
982sys_ustat(tcp)
983struct tcb *tcp;
984{
985 struct ustat statbuf;
986
987 if (entering(tcp)) {
988 tprintf("makedev(%lu, %lu), ",
989 (long) major(tcp->u_arg[0]),
990 (long) minor(tcp->u_arg[0]));
991 }
992 else {
993 if (syserror(tcp) || !verbose(tcp))
994 tprintf("%#lx", tcp->u_arg[1]);
995 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
996 tprintf("{...}");
997 else {
998 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
999 statbuf.f_tfree, statbuf.f_tinode);
1000 tprintf("f_fname=\"%.*s\", ",
1001 (int) sizeof(statbuf.f_fname),
1002 statbuf.f_fname);
1003 tprintf("f_fpack=\"%.*s\"}",
1004 (int) sizeof(statbuf.f_fpack),
1005 statbuf.f_fpack);
1006 }
1007 }
1008 return 0;
1009}
1010
1011#endif /* SUNOS4 */
1012
1013/* directory */
1014int
1015sys_chdir(tcp)
1016struct tcb *tcp;
1017{
1018 if (entering(tcp)) {
1019 printpath(tcp, tcp->u_arg[0]);
1020 }
1021 return 0;
1022}
1023
1024int
1025sys_mkdir(tcp)
1026struct tcb *tcp;
1027{
1028 if (entering(tcp)) {
1029 printpath(tcp, tcp->u_arg[0]);
1030 tprintf(", %#lo", tcp->u_arg[1]);
1031 }
1032 return 0;
1033}
1034
1035int
1036sys_rmdir(tcp)
1037struct tcb *tcp;
1038{
1039 if (entering(tcp)) {
1040 printpath(tcp, tcp->u_arg[0]);
1041 }
1042 return 0;
1043}
1044
1045int
1046sys_fchdir(tcp)
1047struct tcb *tcp;
1048{
1049 if (entering(tcp)) {
1050 tprintf("%ld", tcp->u_arg[0]);
1051 }
1052 return 0;
1053}
1054
1055int
1056sys_chroot(tcp)
1057struct tcb *tcp;
1058{
1059 if (entering(tcp)) {
1060 printpath(tcp, tcp->u_arg[0]);
1061 }
1062 return 0;
1063}
1064
1065int
1066sys_fchroot(tcp)
1067struct tcb *tcp;
1068{
1069 if (entering(tcp)) {
1070 tprintf("%ld", tcp->u_arg[0]);
1071 }
1072 return 0;
1073}
1074
1075int
1076sys_link(tcp)
1077struct tcb *tcp;
1078{
1079 if (entering(tcp)) {
1080 printpath(tcp, tcp->u_arg[0]);
1081 tprintf(", ");
1082 printpath(tcp, tcp->u_arg[1]);
1083 }
1084 return 0;
1085}
1086
1087int
1088sys_unlink(tcp)
1089struct tcb *tcp;
1090{
1091 if (entering(tcp)) {
1092 printpath(tcp, tcp->u_arg[0]);
1093 }
1094 return 0;
1095}
1096
1097int
1098sys_symlink(tcp)
1099struct tcb *tcp;
1100{
1101 if (entering(tcp)) {
1102 printpath(tcp, tcp->u_arg[0]);
1103 tprintf(", ");
1104 printpath(tcp, tcp->u_arg[1]);
1105 }
1106 return 0;
1107}
1108
1109int
1110sys_readlink(tcp)
1111struct tcb *tcp;
1112{
1113 if (entering(tcp)) {
1114 printpath(tcp, tcp->u_arg[0]);
1115 tprintf(", ");
1116 } else {
1117 if (syserror(tcp))
1118 tprintf("%#lx", tcp->u_arg[1]);
1119 else
1120 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1121 tprintf(", %lu", tcp->u_arg[2]);
1122 }
1123 return 0;
1124}
1125
1126int
1127sys_rename(tcp)
1128struct tcb *tcp;
1129{
1130 if (entering(tcp)) {
1131 printpath(tcp, tcp->u_arg[0]);
1132 tprintf(", ");
1133 printpath(tcp, tcp->u_arg[1]);
1134 }
1135 return 0;
1136}
1137
1138int
1139sys_chown(tcp)
1140struct tcb *tcp;
1141{
1142 if (entering(tcp)) {
1143 printpath(tcp, tcp->u_arg[0]);
1144 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1145 }
1146 return 0;
1147}
1148
1149int
1150sys_fchown(tcp)
1151struct tcb *tcp;
1152{
1153 if (entering(tcp)) {
1154 tprintf("%ld, %lu, %lu",
1155 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1156 }
1157 return 0;
1158}
1159
1160int
1161sys_chmod(tcp)
1162struct tcb *tcp;
1163{
1164 if (entering(tcp)) {
1165 printpath(tcp, tcp->u_arg[0]);
1166 tprintf(", %#lo", tcp->u_arg[1]);
1167 }
1168 return 0;
1169}
1170
1171int
1172sys_fchmod(tcp)
1173struct tcb *tcp;
1174{
1175 if (entering(tcp)) {
1176 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1177 }
1178 return 0;
1179}
1180
1181int
1182sys_utimes(tcp)
1183struct tcb *tcp;
1184{
1185 if (entering(tcp)) {
1186 printpath(tcp, tcp->u_arg[0]);
1187 tprintf(", ");
1188 printtv(tcp, tcp->u_arg[1]);
1189 }
1190 return 0;
1191}
1192
1193int
1194sys_utime(tcp)
1195struct tcb *tcp;
1196{
1197 long ut[2];
1198
1199 if (entering(tcp)) {
1200 printpath(tcp, tcp->u_arg[0]);
1201 tprintf(", ");
1202 if (!tcp->u_arg[1])
1203 tprintf("NULL");
1204 else if (!verbose(tcp))
1205 tprintf("%#lx", tcp->u_arg[1]);
1206 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1207 (char *) ut) < 0)
1208 tprintf("[?, ?]");
1209 else {
1210 tprintf("[%s,", sprinttime(ut[0]));
1211 tprintf(" %s]", sprinttime(ut[1]));
1212 }
1213 }
1214 return 0;
1215}
1216
1217int
1218sys_mknod(tcp)
1219struct tcb *tcp;
1220{
1221 int mode = tcp->u_arg[1];
1222
1223 if (entering(tcp)) {
1224 printpath(tcp, tcp->u_arg[0]);
1225 tprintf(", %s", sprintmode(mode));
1226 switch (mode & S_IFMT) {
1227 case S_IFCHR: case S_IFBLK:
1228#ifdef LINUXSPARC
1229 if (current_personality == 1)
1230 tprintf(", makedev(%lu, %lu)",
1231 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1232 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1233 else
1234#endif
1235 tprintf(", makedev(%lu, %lu)",
1236 (unsigned long) major(tcp->u_arg[2]),
1237 (unsigned long) minor(tcp->u_arg[2]));
1238 break;
1239 default:
1240 break;
1241 }
1242 }
1243 return 0;
1244}
1245
1246int
1247sys_mkfifo(tcp)
1248struct tcb *tcp;
1249{
1250 if (entering(tcp)) {
1251 printpath(tcp, tcp->u_arg[0]);
1252 tprintf(", %#lo", tcp->u_arg[1]);
1253 }
1254 return 0;
1255}
1256
1257int
1258sys_fsync(tcp)
1259struct tcb *tcp;
1260{
1261 if (entering(tcp)) {
1262 tprintf("%ld", tcp->u_arg[0]);
1263 }
1264 return 0;
1265}
1266
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001267#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001268
1269static void
1270printdir(tcp, addr)
1271struct tcb *tcp;
1272long addr;
1273{
1274 struct dirent d;
1275
1276 if (!verbose(tcp)) {
1277 tprintf("%#lx", addr);
1278 return;
1279 }
1280 if (umove(tcp, addr, &d) < 0) {
1281 tprintf("{...}");
1282 return;
1283 }
1284 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001285 tprintf("d_name=");
1286 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1287 tprintf("}");
1288}
1289
1290int
1291sys_readdir(tcp)
1292struct tcb *tcp;
1293{
1294 if (entering(tcp)) {
1295 tprintf("%lu, ", tcp->u_arg[0]);
1296 } else {
1297 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1298 tprintf("%#lx", tcp->u_arg[1]);
1299 else
1300 printdir(tcp, tcp->u_arg[1]);
1301 /* Not much point in printing this out, it is always 1. */
1302 if (tcp->u_arg[2] != 1)
1303 tprintf(", %lu", tcp->u_arg[2]);
1304 }
1305 return 0;
1306}
1307
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001308#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001309
1310int
1311sys_getdents(tcp)
1312struct tcb *tcp;
1313{
1314 int i, len, dents = 0;
1315 char *buf;
1316
1317 if (entering(tcp)) {
1318 tprintf("%lu, ", tcp->u_arg[0]);
1319 return 0;
1320 }
1321 if (syserror(tcp) || !verbose(tcp)) {
1322 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1323 return 0;
1324 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001325 len = tcp->u_rval;
1326 if ((buf = malloc(len)) == NULL) {
1327 tprintf("out of memory\n");
1328 return 0;
1329 }
1330 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1331 tprintf("{...}, %lu", tcp->u_arg[2]);
1332 free(buf);
1333 return 0;
1334 }
1335 if (!abbrev(tcp))
1336 tprintf("{");
1337 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00001338 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001339#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001340 if (!abbrev(tcp)) {
1341 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1342 i ? " " : "", d->d_ino, d->d_off);
1343 tprintf("d_reclen=%u, d_name=\"%s\"}",
1344 d->d_reclen, d->d_name);
1345 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001346#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001347#ifdef SVR4
1348 if (!abbrev(tcp)) {
1349 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1350 i ? " " : "", d->d_ino, d->d_off);
1351 tprintf("d_reclen=%u, d_name=\"%s\"}",
1352 d->d_reclen, d->d_name);
1353 }
1354#endif /* SVR4 */
1355#ifdef SUNOS4
1356 if (!abbrev(tcp)) {
1357 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1358 i ? " " : "", d->d_off, d->d_fileno,
1359 d->d_reclen);
1360 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1361 d->d_namlen, d->d_namlen, d->d_name);
1362 }
1363#endif /* SUNOS4 */
1364 i += d->d_reclen;
1365 dents++;
1366 }
1367 if (!abbrev(tcp))
1368 tprintf("}");
1369 else
1370 tprintf("/* %u entries */", dents);
1371 tprintf(", %lu", tcp->u_arg[2]);
1372 free(buf);
1373 return 0;
1374}
1375
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001376#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001377
1378int
1379sys_getcwd(tcp)
1380struct tcb *tcp;
1381{
1382 if (exiting(tcp)) {
1383 if (syserror(tcp))
1384 tprintf("%#lx", tcp->u_arg[0]);
1385 else
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001386 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001387 tprintf(", %lu", tcp->u_arg[1]);
1388 }
1389 return 0;
1390}
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001391#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001392
1393#ifdef HAVE_SYS_ASYNCH_H
1394
1395int
1396sys_aioread(tcp)
1397struct tcb *tcp;
1398{
1399 struct aio_result_t res;
1400
1401 if (entering(tcp)) {
1402 tprintf("%lu, ", tcp->u_arg[0]);
1403 } else {
1404 if (syserror(tcp))
1405 tprintf("%#lx", tcp->u_arg[1]);
1406 else
1407 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1408 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
1409 printxval(whence, tcp->u_arg[4], "L_???");
1410 if (syserror(tcp) || tcp->u_arg[5] == 0
1411 || umove(tcp, tcp->u_arg[5], &res) < 0)
1412 tprintf(", %#lx", tcp->u_arg[5]);
1413 else
1414 tprintf(", {aio_return %d aio_errno %d}",
1415 res.aio_return, res.aio_errno);
1416 }
1417 return 0;
1418}
1419
1420int
1421sys_aiowrite(tcp)
1422struct tcb *tcp;
1423{
1424 struct aio_result_t res;
1425
1426 if (entering(tcp)) {
1427 tprintf("%lu, ", tcp->u_arg[0]);
1428 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1429 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
1430 printxval(whence, tcp->u_arg[4], "L_???");
1431 }
1432 else {
1433 if (tcp->u_arg[5] == 0)
1434 tprintf(", NULL");
1435 else if (syserror(tcp)
1436 || umove(tcp, tcp->u_arg[5], &res) < 0)
1437 tprintf(", %#lx", tcp->u_arg[5]);
1438 else
1439 tprintf(", {aio_return %d aio_errno %d}",
1440 res.aio_return, res.aio_errno);
1441 }
1442 return 0;
1443}
1444
1445int
1446sys_aiowait(tcp)
1447struct tcb *tcp;
1448{
1449 if (entering(tcp))
1450 printtv(tcp, tcp->u_arg[0]);
1451 return 0;
1452}
1453
1454int
1455sys_aiocancel(tcp)
1456struct tcb *tcp;
1457{
1458 struct aio_result_t res;
1459
1460 if (exiting(tcp)) {
1461 if (tcp->u_arg[0] == 0)
1462 tprintf("NULL");
1463 else if (syserror(tcp)
1464 || umove(tcp, tcp->u_arg[0], &res) < 0)
1465 tprintf("%#lx", tcp->u_arg[0]);
1466 else
1467 tprintf("{aio_return %d aio_errno %d}",
1468 res.aio_return, res.aio_errno);
1469 }
1470 return 0;
1471}
1472
1473#endif /* HAVE_SYS_ASYNCH_H */