blob: 911090c89b6bf357ddbb30ba647072643dba5de9 [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>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00006 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Id$
31 */
32
33#include "defs.h"
34
35#include <dirent.h>
Wichert Akkerman9524bb91999-05-25 23:11:18 +000036#ifdef linux
37#define dirent kernel_dirent
Wichert Akkerman9b0c31d2000-09-03 21:56:29 +000038#define dirent64 kernel_dirent64
Wichert Akkerman9524bb91999-05-25 23:11:18 +000039#include <linux/types.h>
40#include <linux/dirent.h>
41#undef dirent
42#else
43#define kernel_dirent dirent
44#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000045
Wichert Akkerman8bc6cfd1999-04-21 15:57:38 +000046#ifdef linux
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000047# ifdef LINUXSPARC
48struct stat {
49 unsigned short st_dev;
50 unsigned int st_ino;
51 unsigned short st_mode;
52 short st_nlink;
53 unsigned short st_uid;
54 unsigned short st_gid;
55 unsigned short st_rdev;
56 unsigned int st_size;
57 int st_atime;
58 unsigned int __unused1;
59 int st_mtime;
60 unsigned int __unused2;
61 int st_ctime;
62 unsigned int __unused3;
63 int st_blksize;
64 int st_blocks;
65 unsigned int __unused4[2];
66};
67# define stat kernel_stat
68# include <asm/stat.h>
69# undef stat
70# else
Wichert Akkerman5b4d1281999-07-09 00:32:54 +000071# undef dev_t
72# undef ino_t
73# undef mode_t
74# undef nlink_t
75# undef uid_t
76# undef gid_t
77# undef off_t
78# undef loff_t
79
Wichert Akkermana6013701999-07-08 14:00:58 +000080# define dev_t __kernel_dev_t
81# define ino_t __kernel_ino_t
82# define mode_t __kernel_mode_t
83# define nlink_t __kernel_nlink_t
84# define uid_t __kernel_uid_t
85# define gid_t __kernel_gid_t
86# define off_t __kernel_off_t
87# define loff_t __kernel_loff_t
88
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000089# include <asm/stat.h>
Wichert Akkermana6013701999-07-08 14:00:58 +000090
91# undef dev_t
92# undef ino_t
93# undef mode_t
94# undef nlink_t
95# undef uid_t
96# undef gid_t
97# undef off_t
98# undef loff_t
Wichert Akkerman5b4d1281999-07-09 00:32:54 +000099
100# define dev_t dev_t
101# define ino_t ino_t
102# define mode_t mode_t
103# define nlink_t nlink_t
104# define uid_t uid_t
105# define gid_t gid_t
106# define off_t off_t
107# define loff_t loff_t
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000108# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000109# define stat libc_stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000110# define stat64 libc_stat64
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000111# include <sys/stat.h>
112# undef stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000113# undef stat64
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000114#else
115# include <sys/stat.h>
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000116#endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000117
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000118#include <fcntl.h>
119
120#ifdef SVR4
121# include <sys/cred.h>
122#endif /* SVR4 */
123
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000124#ifdef HAVE_SYS_VFS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000125#include <sys/vfs.h>
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000126#endif
127
128#ifdef FREEBSD
129#include <sys/param.h>
130#include <sys/mount.h>
131#include <sys/stat.h>
132#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000133
134#ifdef MAJOR_IN_SYSMACROS
135#include <sys/sysmacros.h>
136#endif
137
138#ifdef MAJOR_IN_MKDEV
139#include <sys/mkdev.h>
140#endif
141
142#ifdef HAVE_SYS_ASYNCH_H
143#include <sys/asynch.h>
144#endif
145
146#ifdef SUNOS4
147#include <ustat.h>
148#endif
149
150/*
151 * This is a really dirty trick but it should always work. Traditional
152 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
153 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
154 */
155struct xlat openmodes[] = {
156 { O_RDWR+1, "O_RDWR" },
157 { O_RDONLY+1, "O_RDONLY" },
158 { O_WRONLY+1, "O_WRONLY" },
159 { O_NONBLOCK, "O_NONBLOCK" },
160 { O_APPEND, "O_APPEND" },
161 { O_CREAT, "O_CREAT" },
162 { O_TRUNC, "O_TRUNC" },
163 { O_EXCL, "O_EXCL" },
164 { O_NOCTTY, "O_NOCTTY" },
165#ifdef O_SYNC
166 { O_SYNC, "O_SYNC" },
167#endif
168#ifdef O_ASYNC
169 { O_ASYNC, "O_ASYNC" },
170#endif
171#ifdef O_DSYNC
172 { O_DSYNC, "O_DSYNC" },
173#endif
174#ifdef O_RSYNC
175 { O_RSYNC, "O_RSYNC" },
176#endif
177#ifdef O_NDELAY
178 { O_NDELAY, "O_NDELAY" },
179#endif
180#ifdef O_PRIV
181 { O_PRIV, "O_PRIV" },
182#endif
183#ifdef O_DIRECT
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000184 { O_DIRECT, "O_DIRECT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000185#endif
186#ifdef O_LARGEFILE
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000187 { O_LARGEFILE, "O_LARGEFILE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000188#endif
189#ifdef O_DIRECTORY
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000190 { O_DIRECTORY, "O_DIRECTORY" },
191#endif
192#ifdef O_NOFOLLOW
193 { O_NOFOLLOW, "O_NOFOLLOW" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000194#endif
195
196#ifdef FNDELAY
197 { FNDELAY, "FNDELAY" },
198#endif
199#ifdef FAPPEND
200 { FAPPEND, "FAPPEND" },
201#endif
202#ifdef FMARK
203 { FMARK, "FMARK" },
204#endif
205#ifdef FDEFER
206 { FDEFER, "FDEFER" },
207#endif
208#ifdef FASYNC
209 { FASYNC, "FASYNC" },
210#endif
211#ifdef FSHLOCK
212 { FSHLOCK, "FSHLOCK" },
213#endif
214#ifdef FEXLOCK
215 { FEXLOCK, "FEXLOCK" },
216#endif
217#ifdef FCREAT
218 { FCREAT, "FCREAT" },
219#endif
220#ifdef FTRUNC
221 { FTRUNC, "FTRUNC" },
222#endif
223#ifdef FEXCL
224 { FEXCL, "FEXCL" },
225#endif
226#ifdef FNBIO
227 { FNBIO, "FNBIO" },
228#endif
229#ifdef FSYNC
230 { FSYNC, "FSYNC" },
231#endif
232#ifdef FNOCTTY
233 { FNOCTTY, "FNOCTTY" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000234#endif
235#ifdef O_SHLOCK
236 { O_SHLOCK, "O_SHLOCK" },
237#endif
238#ifdef O_EXLOCK
239 { O_EXLOCK, "O_EXLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000240#endif
241 { 0, NULL },
242};
243
244int
245sys_open(tcp)
246struct tcb *tcp;
247{
248 if (entering(tcp)) {
249 printpath(tcp, tcp->u_arg[0]);
250 tprintf(", ");
251 /* flags */
252 printflags(openmodes, tcp->u_arg[1] + 1);
253 if (tcp->u_arg[1] & O_CREAT) {
254 /* mode */
255 tprintf(", %#lo", tcp->u_arg[2]);
256 }
257 }
258 return 0;
259}
260
261#ifdef LINUXSPARC
262struct xlat openmodessol[] = {
263 { 0, "O_RDWR" },
264 { 1, "O_RDONLY" },
265 { 2, "O_WRONLY" },
266 { 0x80, "O_NONBLOCK" },
267 { 8, "O_APPEND" },
268 { 0x100, "O_CREAT" },
269 { 0x200, "O_TRUNC" },
270 { 0x400, "O_EXCL" },
271 { 0x800, "O_NOCTTY" },
272 { 0x10, "O_SYNC" },
273 { 0x40, "O_DSYNC" },
274 { 0x8000, "O_RSYNC" },
275 { 4, "O_NDELAY" },
276 { 0x1000, "O_PRIV" },
277 { 0, NULL },
278};
279
280int
281solaris_open(tcp)
282struct tcb *tcp;
283{
284 if (entering(tcp)) {
285 printpath(tcp, tcp->u_arg[0]);
286 tprintf(", ");
287 /* flags */
288 printflags(openmodessol, tcp->u_arg[1] + 1);
289 if (tcp->u_arg[1] & 0x100) {
290 /* mode */
291 tprintf(", %#lo", tcp->u_arg[2]);
292 }
293 }
294 return 0;
295}
296
297#endif
298
299int
300sys_creat(tcp)
301struct tcb *tcp;
302{
303 if (entering(tcp)) {
304 printpath(tcp, tcp->u_arg[0]);
305 tprintf(", %#lo", tcp->u_arg[1]);
306 }
307 return 0;
308}
309
310static struct xlat access_flags[] = {
311 { F_OK, "F_OK", },
312 { R_OK, "R_OK" },
313 { W_OK, "W_OK" },
314 { X_OK, "X_OK" },
315#ifdef EFF_ONLY_OK
316 { EFF_ONLY_OK, "EFF_ONLY_OK" },
317#endif
318#ifdef EX_OK
319 { EX_OK, "EX_OK" },
320#endif
321 { 0, NULL },
322};
323
324int
325sys_access(tcp)
326struct tcb *tcp;
327{
328 if (entering(tcp)) {
329 printpath(tcp, tcp->u_arg[0]);
330 tprintf(", ");
331 printflags(access_flags, tcp->u_arg[1]);
332 }
333 return 0;
334}
335
336int
337sys_umask(tcp)
338struct tcb *tcp;
339{
340 if (entering(tcp)) {
341 tprintf("%#lo", tcp->u_arg[0]);
342 }
343 return RVAL_OCTAL;
344}
345
346static struct xlat whence[] = {
347 { SEEK_SET, "SEEK_SET" },
348 { SEEK_CUR, "SEEK_CUR" },
349 { SEEK_END, "SEEK_END" },
350 { 0, NULL },
351};
352
353int
354sys_lseek(tcp)
355struct tcb *tcp;
356{
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000357 off_t offset;
358 int _whence;
359
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000360 if (entering(tcp)) {
361 tprintf("%ld, ", tcp->u_arg[0]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000362#ifndef FREEBSD
363 offset = tcp->u_arg[1];
364 _whence = tcp->u_arg[2];
365 if (_whence == SEEK_SET)
366 tprintf("%lu, ", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000367 else
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000368 tprintf("%ld, ", offset);
369#else /* FREEBSD */
370 offset = ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2];
371 _whence = tcp->u_arg[4];
372 if (_whence == SEEK_SET)
373 tprintf("%llu, ", offset);
374 else
375 tprintf("%lld, ", offset);
376#endif
377 printxval(whence, _whence, "SEEK_???");
378 }
379#ifdef FREEBSD
380 else
381 if (!syserror(tcp))
382 return RVAL_LUDECIMAL;
383#endif /* FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000384 return RVAL_UDECIMAL;
385}
386
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000387#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000388int
389sys_llseek (tcp)
390struct tcb *tcp;
391{
392 if (entering(tcp)) {
393 if (tcp->u_arg[4] == SEEK_SET)
394 tprintf("%ld, %llu, ", tcp->u_arg[0],
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000395 (((long long int) tcp->u_arg[1]) << 32
396 | (unsigned long long) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000397 else
398 tprintf("%ld, %lld, ", tcp->u_arg[0],
399 (((long long int) tcp->u_arg[1]) << 32
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000400 | (unsigned long long) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000401 }
402 else {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000403 long long int off;
404 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000405 tprintf("%#lx, ", tcp->u_arg[3]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000406 else
407 tprintf("[%llu], ", off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000408 printxval(whence, tcp->u_arg[4], "SEEK_???");
409 }
410 return 0;
411}
412#endif
413
414int
415sys_truncate(tcp)
416struct tcb *tcp;
417{
418 if (entering(tcp)) {
419 printpath(tcp, tcp->u_arg[0]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000420#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000421 tprintf(", %lu", tcp->u_arg[1]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000422#else
423 tprintf(", %llu", ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2]);
424#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000425 }
426 return 0;
427}
428
429int
430sys_ftruncate(tcp)
431struct tcb *tcp;
432{
433 if (entering(tcp)) {
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000434#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000435 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000436#else
437 tprintf("%ld, %llu", tcp->u_arg[0],
438 ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2]);
439#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000440 }
441 return 0;
442}
443
444/* several stats */
445
446static struct xlat modetypes[] = {
447 { S_IFREG, "S_IFREG" },
448 { S_IFSOCK, "S_IFSOCK" },
449 { S_IFIFO, "S_IFIFO" },
450 { S_IFLNK, "S_IFLNK" },
451 { S_IFDIR, "S_IFDIR" },
452 { S_IFBLK, "S_IFBLK" },
453 { S_IFCHR, "S_IFCHR" },
454 { 0, NULL },
455};
456
457static char *
458sprintmode(mode)
459int mode;
460{
461 static char buf[64];
462 char *s;
463
464 if ((mode & S_IFMT) == 0)
465 s = "";
466 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
467 sprintf(buf, "%#o", mode);
468 return buf;
469 }
470 sprintf(buf, "%s%s%s%s", s,
471 (mode & S_ISUID) ? "|S_ISUID" : "",
472 (mode & S_ISGID) ? "|S_ISGID" : "",
473 (mode & S_ISVTX) ? "|S_ISVTX" : "");
474 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
475 if (mode)
476 sprintf(buf + strlen(buf), "|%#o", mode);
477 s = (*buf == '|') ? buf + 1 : buf;
478 return *s ? s : "0";
479}
480
481static char *
482sprinttime(t)
483time_t t;
484{
485 struct tm *tmp;
486 static char buf[32];
487
488 if (t == 0) {
489 sprintf(buf, "0");
490 return buf;
491 }
492 tmp = localtime(&t);
493 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
Wichert Akkerman3ed6dc22000-01-11 14:41:09 +0000494 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000495 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
496 return buf;
497}
498
499#ifdef LINUXSPARC
500typedef struct {
501 int tv_sec;
502 int tv_nsec;
503} timestruct_t;
504
505struct solstat {
506 unsigned st_dev;
507 int st_pad1[3]; /* network id */
508 unsigned st_ino;
509 unsigned st_mode;
510 unsigned st_nlink;
511 unsigned st_uid;
512 unsigned st_gid;
513 unsigned st_rdev;
514 int st_pad2[2];
515 int st_size;
516 int st_pad3; /* st_size, off_t expansion */
517 timestruct_t st_atime;
518 timestruct_t st_mtime;
519 timestruct_t st_ctime;
520 int st_blksize;
521 int st_blocks;
522 char st_fstype[16];
523 int st_pad4[8]; /* expansion area */
524};
525
526static void
527printstatsol(tcp, addr)
528struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000529long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000530{
531 struct solstat statbuf;
532
533 if (!addr) {
534 tprintf("NULL");
535 return;
536 }
537 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000538 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000539 return;
540 }
541 if (umove(tcp, addr, &statbuf) < 0) {
542 tprintf("{...}");
543 return;
544 }
545 if (!abbrev(tcp)) {
546 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
547 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
548 (unsigned long) (statbuf.st_dev & 0x3ffff),
549 (unsigned long) statbuf.st_ino,
550 sprintmode(statbuf.st_mode));
551 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
552 (unsigned long) statbuf.st_nlink,
553 (unsigned long) statbuf.st_uid,
554 (unsigned long) statbuf.st_gid);
555 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
556 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
557 }
558 else
559 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
560 switch (statbuf.st_mode & S_IFMT) {
561 case S_IFCHR: case S_IFBLK:
562 tprintf("st_rdev=makedev(%lu, %lu), ",
563 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
564 (unsigned long) (statbuf.st_rdev & 0x3ffff));
565 break;
566 default:
567 tprintf("st_size=%u, ", statbuf.st_size);
568 break;
569 }
570 if (!abbrev(tcp)) {
571 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
572 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
573 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
574 }
575 else
576 tprintf("...}");
577}
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000578#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000579
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000580#ifdef FREEBSD
581static struct xlat fileflags[] = {
582 { UF_NODUMP, "UF_NODUMP" },
583 { UF_IMMUTABLE, "UF_IMMUTABLE" },
584 { UF_APPEND, "UF_APPEND" },
585 { UF_OPAQUE, "UF_OPAQUE" },
586 { UF_NOUNLINK, "UF_NOUNLINK" },
587 { SF_ARCHIVED, "SF_ARCHIVED" },
588 { SF_IMMUTABLE, "SF_IMMUTABLE" },
589 { SF_APPEND, "SF_APPEND" },
590 { SF_NOUNLINK, "SF_NOUNLINK" },
591 { 0, NULL },
592};
593
594int
595sys_chflags(tcp)
596struct tcb *tcp;
597{
598 if (entering(tcp)) {
599 printpath(tcp, tcp->u_arg[0]);
600 tprintf(", ");
601 if (tcp->u_arg[1])
602 printflags(fileflags, tcp->u_arg[1]);
603 else
604 tprintf("0");
605 }
606 return 0;
607}
608
609int
610sys_fchflags(tcp)
611struct tcb *tcp;
612{
613 if (entering(tcp)) {
614 tprintf("%ld, ", tcp->u_arg[0]);
615 if (tcp->u_arg[1])
616 printflags(fileflags, tcp->u_arg[1]);
617 else
618 tprintf("0");
619 }
620 return 0;
621}
622#endif
623
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000624static void
625realprintstat(tcp, statbuf)
626struct tcb *tcp;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000627struct stat *statbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000628{
629 if (!abbrev(tcp)) {
630 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
631 (unsigned long) major(statbuf->st_dev),
632 (unsigned long) minor(statbuf->st_dev),
633 (unsigned long) statbuf->st_ino,
634 sprintmode(statbuf->st_mode));
635 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
636 (unsigned long) statbuf->st_nlink,
637 (unsigned long) statbuf->st_uid,
638 (unsigned long) statbuf->st_gid);
639#ifdef HAVE_ST_BLKSIZE
640 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
641#endif /* HAVE_ST_BLKSIZE */
642#ifdef HAVE_ST_BLOCKS
643 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
644#endif /* HAVE_ST_BLOCKS */
645 }
646 else
647 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
648 switch (statbuf->st_mode & S_IFMT) {
649 case S_IFCHR: case S_IFBLK:
650#ifdef HAVE_ST_RDEV
651 tprintf("st_rdev=makedev(%lu, %lu), ",
652 (unsigned long) major(statbuf->st_rdev),
653 (unsigned long) minor(statbuf->st_rdev));
654#else /* !HAVE_ST_RDEV */
655 tprintf("st_size=makedev(%lu, %lu), ",
656 (unsigned long) major(statbuf->st_size),
657 (unsigned long) minor(statbuf->st_size));
658#endif /* !HAVE_ST_RDEV */
659 break;
660 default:
661 tprintf("st_size=%lu, ", statbuf->st_size);
662 break;
663 }
664 if (!abbrev(tcp)) {
665 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
666 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000667#ifndef FREEBSD
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000668 tprintf("st_ctime=%s}", sprinttime(statbuf->st_ctime));
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000669#else /* FREEBSD */
670 tprintf("st_ctime=%s, ", sprinttime(statbuf->st_ctime));
671 tprintf("st_flags=");
672 if (statbuf->st_flags) {
673 printflags(fileflags, statbuf->st_flags);
674 } else
675 tprintf("0");
676 tprintf(", st_gen=%u}", statbuf->st_gen);
677#endif /* FREEBSD */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000678 }
679 else
680 tprintf("...}");
681}
682
Nate Sammons771a6ff1999-04-05 22:39:31 +0000683
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000684static void
685printstat(tcp, addr)
686struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000687long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000688{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000689 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000690
691#ifdef LINUXSPARC
692 if (current_personality == 1) {
693 printstatsol(tcp, addr);
694 return;
695 }
696#endif /* LINUXSPARC */
697
698 if (!addr) {
699 tprintf("NULL");
700 return;
701 }
702 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000703 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000704 return;
705 }
706 if (umove(tcp, addr, &statbuf) < 0) {
707 tprintf("{...}");
708 return;
709 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000710
711 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000712}
713
Wichert Akkermanc7926982000-04-10 22:22:31 +0000714#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000715static void
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000716printstat64(tcp, addr)
717struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000718long addr;
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000719{
720 struct stat64 statbuf;
721
722#ifdef LINUXSPARC
723 if (current_personality == 1) {
724 printstatsol(tcp, addr);
725 return;
726 }
727#endif /* LINUXSPARC */
728
729 if (!addr) {
730 tprintf("NULL");
731 return;
732 }
733 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000734 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000735 return;
736 }
737 if (umove(tcp, addr, &statbuf) < 0) {
738 tprintf("{...}");
739 return;
740 }
741
742 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +0000743#ifdef HAVE_LONG_LONG
744 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
745#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000746 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
Wichert Akkermand077c452000-08-10 18:16:15 +0000747#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000748 (unsigned long) major(statbuf.st_dev),
749 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +0000750#ifdef HAVE_LONG_LONG
751 (unsigned long long) statbuf.st_ino,
752#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000753 (unsigned long) statbuf.st_ino,
Wichert Akkermand077c452000-08-10 18:16:15 +0000754#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000755 sprintmode(statbuf.st_mode));
756 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
757 (unsigned long) statbuf.st_nlink,
758 (unsigned long) statbuf.st_uid,
759 (unsigned long) statbuf.st_gid);
760#ifdef HAVE_ST_BLKSIZE
761 tprintf("st_blksize=%lu, ",
762 (unsigned long) statbuf.st_blksize);
763#endif /* HAVE_ST_BLKSIZE */
764#ifdef HAVE_ST_BLOCKS
765 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
766#endif /* HAVE_ST_BLOCKS */
767 }
768 else
769 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
770 switch (statbuf.st_mode & S_IFMT) {
771 case S_IFCHR: case S_IFBLK:
772#ifdef HAVE_ST_RDEV
773 tprintf("st_rdev=makedev(%lu, %lu), ",
774 (unsigned long) major(statbuf.st_rdev),
775 (unsigned long) minor(statbuf.st_rdev));
776#else /* !HAVE_ST_RDEV */
777 tprintf("st_size=makedev(%lu, %lu), ",
778 (unsigned long) major(statbuf.st_size),
779 (unsigned long) minor(statbuf.st_size));
780#endif /* !HAVE_ST_RDEV */
781 break;
782 default:
783 tprintf("st_size=%llu, ", statbuf.st_size);
784 break;
785 }
786 if (!abbrev(tcp)) {
787 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
788 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
789 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
790 }
791 else
792 tprintf("...}");
793}
Wichert Akkermanc7926982000-04-10 22:22:31 +0000794#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000795
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000796#if defined(linux) && !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000797static void
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000798convertoldstat(oldbuf, newbuf)
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000799const struct __old_kernel_stat *oldbuf;
800struct stat *newbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000801{
802 newbuf->st_dev=oldbuf->st_dev;
803 newbuf->st_ino=oldbuf->st_ino;
804 newbuf->st_mode=oldbuf->st_mode;
805 newbuf->st_nlink=oldbuf->st_nlink;
806 newbuf->st_uid=oldbuf->st_uid;
807 newbuf->st_gid=oldbuf->st_gid;
808 newbuf->st_rdev=oldbuf->st_rdev;
809 newbuf->st_size=oldbuf->st_size;
810 newbuf->st_atime=oldbuf->st_atime;
811 newbuf->st_mtime=oldbuf->st_mtime;
812 newbuf->st_ctime=oldbuf->st_ctime;
813 newbuf->st_blksize=0; /* not supported in old_stat */
814 newbuf->st_blocks=0; /* not supported in old_stat */
815}
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000816
817
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000818static void
819printoldstat(tcp, addr)
820struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000821long addr;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000822{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000823 struct __old_kernel_stat statbuf;
824 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000825
826#ifdef LINUXSPARC
827 if (current_personality == 1) {
828 printstatsol(tcp, addr);
829 return;
830 }
831#endif /* LINUXSPARC */
832
833 if (!addr) {
834 tprintf("NULL");
835 return;
836 }
837 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000838 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000839 return;
840 }
841 if (umove(tcp, addr, &statbuf) < 0) {
842 tprintf("{...}");
843 return;
844 }
845
846 convertoldstat(&statbuf, &newstatbuf);
847 realprintstat(tcp, &newstatbuf);
848}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000849#endif /* linux && !IA64 */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000850
851
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000852int
853sys_stat(tcp)
854struct tcb *tcp;
855{
856 if (entering(tcp)) {
857 printpath(tcp, tcp->u_arg[0]);
858 tprintf(", ");
859 } else {
860 printstat(tcp, tcp->u_arg[1]);
861 }
862 return 0;
863}
864
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000865#ifdef linux
866int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000867sys_stat64(tcp)
868struct tcb *tcp;
869{
870#ifdef HAVE_STAT64
871 if (entering(tcp)) {
872 printpath(tcp, tcp->u_arg[0]);
873 tprintf(", ");
874 } else {
875 printstat64(tcp, tcp->u_arg[1]);
876 }
877 return 0;
878#else
879 return printargs(tcp);
880#endif
881}
882
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000883# if !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000884int
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000885sys_oldstat(tcp)
886struct tcb *tcp;
887{
888 if (entering(tcp)) {
889 printpath(tcp, tcp->u_arg[0]);
890 tprintf(", ");
891 } else {
892 printoldstat(tcp, tcp->u_arg[1]);
893 }
894 return 0;
895}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000896# endif /* !IA64 */
897#endif /* linux */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000898
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000899int
900sys_fstat(tcp)
901struct tcb *tcp;
902{
903 if (entering(tcp))
904 tprintf("%ld, ", tcp->u_arg[0]);
905 else {
906 printstat(tcp, tcp->u_arg[1]);
907 }
908 return 0;
909}
910
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000911#ifdef linux
912int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000913sys_fstat64(tcp)
914struct tcb *tcp;
915{
916#ifdef HAVE_STAT64
917 if (entering(tcp))
918 tprintf("%ld, ", tcp->u_arg[0]);
919 else {
920 printstat64(tcp, tcp->u_arg[1]);
921 }
922 return 0;
923#else
924 return printargs(tcp);
925#endif
926}
927
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000928# if !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000929int
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000930sys_oldfstat(tcp)
931struct tcb *tcp;
932{
933 if (entering(tcp))
934 tprintf("%ld, ", tcp->u_arg[0]);
935 else {
936 printoldstat(tcp, tcp->u_arg[1]);
937 }
938 return 0;
939}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000940# endif /* !IA64 */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000941#endif
942
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000943int
944sys_lstat(tcp)
945struct tcb *tcp;
946{
947 if (entering(tcp)) {
948 printpath(tcp, tcp->u_arg[0]);
949 tprintf(", ");
950 } else {
951 printstat(tcp, tcp->u_arg[1]);
952 }
953 return 0;
954}
955
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000956#ifdef linux
957int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000958sys_lstat64(tcp)
959struct tcb *tcp;
960{
961#ifdef HAVE_STAT64
962 if (entering(tcp)) {
963 printpath(tcp, tcp->u_arg[0]);
964 tprintf(", ");
965 } else {
966 printstat64(tcp, tcp->u_arg[1]);
967 }
968 return 0;
969#else
970 return printargs(tcp);
971#endif
972}
973
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000974# if !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000975int
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000976sys_oldlstat(tcp)
977struct tcb *tcp;
978{
979 if (entering(tcp)) {
980 printpath(tcp, tcp->u_arg[0]);
981 tprintf(", ");
982 } else {
983 printoldstat(tcp, tcp->u_arg[1]);
984 }
985 return 0;
986}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000987# endif /* !IA64 */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000988#endif
989
990
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000991#if defined(SVR4) || defined(LINUXSPARC)
992
993int
994sys_xstat(tcp)
995struct tcb *tcp;
996{
997 if (entering(tcp)) {
998 tprintf("%ld, ", tcp->u_arg[0]);
999 printpath(tcp, tcp->u_arg[1]);
1000 tprintf(", ");
1001 } else {
1002 printstat(tcp, tcp->u_arg[2]);
1003 }
1004 return 0;
1005}
1006
1007int
1008sys_fxstat(tcp)
1009struct tcb *tcp;
1010{
1011 if (entering(tcp))
1012 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1013 else {
1014 printstat(tcp, tcp->u_arg[2]);
1015 }
1016 return 0;
1017}
1018
1019int
1020sys_lxstat(tcp)
1021struct tcb *tcp;
1022{
1023 if (entering(tcp)) {
1024 tprintf("%ld, ", tcp->u_arg[0]);
1025 printpath(tcp, tcp->u_arg[1]);
1026 tprintf(", ");
1027 } else {
1028 printstat(tcp, tcp->u_arg[2]);
1029 }
1030 return 0;
1031}
1032
1033int
1034sys_xmknod(tcp)
1035struct tcb *tcp;
1036{
1037 int mode = tcp->u_arg[2];
1038
1039 if (entering(tcp)) {
1040 tprintf("%ld, ", tcp->u_arg[0]);
1041 printpath(tcp, tcp->u_arg[1]);
1042 tprintf(", %s", sprintmode(mode));
1043 switch (mode & S_IFMT) {
1044 case S_IFCHR: case S_IFBLK:
1045#ifdef LINUXSPARC
1046 tprintf(", makedev(%lu, %lu)",
1047 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1048 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1049#else
1050 tprintf(", makedev(%lu, %lu)",
1051 (unsigned long) major(tcp->u_arg[3]),
1052 (unsigned long) minor(tcp->u_arg[3]));
1053#endif
1054 break;
1055 default:
1056 break;
1057 }
1058 }
1059 return 0;
1060}
1061
Wichert Akkerman8829a551999-06-11 13:18:40 +00001062#ifdef HAVE_SYS_ACL_H
1063
1064#include <sys/acl.h>
1065
1066struct xlat aclcmds[] = {
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001067#ifdef SETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001068 { SETACL, "SETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001069#endif
1070#ifdef GETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001071 { GETACL, "GETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001072#endif
1073#ifdef GETACLCNT
Wichert Akkerman8829a551999-06-11 13:18:40 +00001074 { GETACLCNT, "GETACLCNT" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001075#endif
1076#ifdef ACL_GET
1077 { ACL_GET, "ACL_GET" },
1078#endif
1079#ifdef ACL_SET
1080 { ACL_SET, "ACL_SET" },
1081#endif
1082#ifdef ACL_CNT
1083 { ACL_CNT, "ACL_CNT" },
1084#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +00001085 { 0, NULL },
1086};
1087
1088int
1089sys_acl(tcp)
1090struct tcb *tcp;
1091{
1092 if (entering(tcp)) {
1093 printpath(tcp, tcp->u_arg[0]);
1094 tprintf(", ");
1095 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1096 tprintf(", %ld", tcp->u_arg[2]);
1097 /*
1098 * FIXME - dump out the list of aclent_t's pointed to
1099 * by "tcp->u_arg[3]" if it's not NULL.
1100 */
1101 if (tcp->u_arg[3])
1102 tprintf(", %#lx", tcp->u_arg[3]);
1103 else
1104 tprintf(", NULL");
1105 }
1106 return 0;
1107}
1108
1109
1110int
1111sys_facl(tcp)
1112struct tcb *tcp;
1113{
1114 if (entering(tcp)) {
1115 tprintf("%ld, ", tcp->u_arg[0]);
1116 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1117 tprintf(", %ld", tcp->u_arg[2]);
1118 /*
1119 * FIXME - dump out the list of aclent_t's pointed to
1120 * by "tcp->u_arg[3]" if it's not NULL.
1121 */
1122 if (tcp->u_arg[3])
1123 tprintf(", %#lx", tcp->u_arg[3]);
1124 else
1125 tprintf(", NULL");
1126 }
1127 return 0;
1128}
1129
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001130
1131struct xlat aclipc[] = {
1132#ifdef IPC_SHM
1133 { IPC_SHM, "IPC_SHM" },
1134#endif
1135#ifdef IPC_SEM
1136 { IPC_SEM, "IPC_SEM" },
1137#endif
1138#ifdef IPC_MSG
1139 { IPC_MSG, "IPC_MSG" },
1140#endif
1141 { 0, NULL },
1142};
1143
1144
1145int
1146sys_aclipc(tcp)
1147struct tcb *tcp;
1148{
1149 if (entering(tcp)) {
1150 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1151 tprintf(", %#lx, ", tcp->u_arg[1]);
1152 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1153 tprintf(", %ld", tcp->u_arg[3]);
1154 /*
1155 * FIXME - dump out the list of aclent_t's pointed to
1156 * by "tcp->u_arg[4]" if it's not NULL.
1157 */
1158 if (tcp->u_arg[4])
1159 tprintf(", %#lx", tcp->u_arg[4]);
1160 else
1161 tprintf(", NULL");
1162 }
1163 return 0;
1164}
1165
1166
1167
Wichert Akkerman8829a551999-06-11 13:18:40 +00001168#endif /* HAVE_SYS_ACL_H */
1169
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001170#endif /* SVR4 || LINUXSPARC */
1171
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001172#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001173
1174static struct xlat fsmagic[] = {
Wichert Akkerman43a74822000-06-27 17:33:32 +00001175 { 0x73757245, "CODA_SUPER_MAGIC" },
1176 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1177 { 0x1373, "DEVFS_SUPER_MAGIC" },
1178 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1179 { 0x414A53, "EFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001180 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1181 { 0xef53, "EXT2_SUPER_MAGIC" },
1182 { 0x137d, "EXT_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001183 { 0xf995e849, "HPFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001184 { 0x9660, "ISOFS_SUPER_MAGIC" },
1185 { 0x137f, "MINIX_SUPER_MAGIC" },
1186 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001187 { 0x2468, "MINIX2_SUPER_MAGIC" },
1188 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001189 { 0x4d44, "MSDOS_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001190 { 0x564c, "NCP_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001191 { 0x6969, "NFS_SUPER_MAGIC" },
1192 { 0x9fa0, "PROC_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001193 { 0x002f, "QNX4_SUPER_MAGIC" },
1194 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1195 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1196 { 0x517b, "SMB_SUPER_MAGIC" },
1197 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1198 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1199 { 0x00011954, "UFS_MAGIC" },
1200 { 0x54190100, "UFS_CIGAM" },
1201 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001202 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1203 { 0, NULL },
1204};
1205
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001206#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001207
1208#ifndef SVR4
1209
1210static char *
1211sprintfstype(magic)
1212int magic;
1213{
1214 static char buf[32];
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001215#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001216 char *s;
1217
1218 s = xlookup(fsmagic, magic);
1219 if (s) {
1220 sprintf(buf, "\"%s\"", s);
1221 return buf;
1222 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001223#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001224 sprintf(buf, "%#x", magic);
1225 return buf;
1226}
1227
1228static void
1229printstatfs(tcp, addr)
1230struct tcb *tcp;
1231long addr;
1232{
1233 struct statfs statbuf;
1234
1235 if (syserror(tcp) || !verbose(tcp)) {
1236 tprintf("%#lx", addr);
1237 return;
1238 }
1239 if (umove(tcp, addr, &statbuf) < 0) {
1240 tprintf("{...}");
1241 return;
1242 }
1243#ifdef ALPHA
1244
1245 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1246 sprintfstype(statbuf.f_type),
1247 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001248 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001249 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1250#else /* !ALPHA */
1251 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1252 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +00001253 (unsigned long)statbuf.f_bsize,
1254 (unsigned long)statbuf.f_blocks,
1255 (unsigned long)statbuf.f_bfree);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001256 tprintf("f_files=%lu, f_ffree=%lu",
Nate Sammons5c74d201999-04-06 01:37:51 +00001257 (unsigned long)statbuf.f_files,
1258 (unsigned long)statbuf.f_ffree);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001259#ifdef linux
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001260 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001261#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001262#endif /* !ALPHA */
1263 tprintf("}");
1264}
1265
1266int
1267sys_statfs(tcp)
1268struct tcb *tcp;
1269{
1270 if (entering(tcp)) {
1271 printpath(tcp, tcp->u_arg[0]);
1272 tprintf(", ");
1273 } else {
1274 printstatfs(tcp, tcp->u_arg[1]);
1275 }
1276 return 0;
1277}
1278
1279int
1280sys_fstatfs(tcp)
1281struct tcb *tcp;
1282{
1283 if (entering(tcp)) {
1284 tprintf("%lu, ", tcp->u_arg[0]);
1285 } else {
1286 printstatfs(tcp, tcp->u_arg[1]);
1287 }
1288 return 0;
1289}
1290
Wichert Akkermana0f36c61999-04-16 14:01:34 +00001291#if defined(linux) && defined(__alpha)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001292
1293int
1294osf_statfs(tcp)
1295struct tcb *tcp;
1296{
1297 if (entering(tcp)) {
1298 printpath(tcp, tcp->u_arg[0]);
1299 tprintf(", ");
1300 } else {
1301 printstatfs(tcp, tcp->u_arg[1]);
1302 tprintf(", %lu", tcp->u_arg[2]);
1303 }
1304 return 0;
1305}
1306
1307int
1308osf_fstatfs(tcp)
1309struct tcb *tcp;
1310{
1311 if (entering(tcp)) {
1312 tprintf("%lu, ", tcp->u_arg[0]);
1313 } else {
1314 printstatfs(tcp, tcp->u_arg[1]);
1315 tprintf(", %lu", tcp->u_arg[2]);
1316 }
1317 return 0;
1318}
Wichert Akkermana0f36c61999-04-16 14:01:34 +00001319#endif /* linux && __alpha */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001320
1321#endif /* !SVR4 */
1322
1323#ifdef SUNOS4
1324
1325int
1326sys_ustat(tcp)
1327struct tcb *tcp;
1328{
1329 struct ustat statbuf;
1330
1331 if (entering(tcp)) {
1332 tprintf("makedev(%lu, %lu), ",
1333 (long) major(tcp->u_arg[0]),
1334 (long) minor(tcp->u_arg[0]));
1335 }
1336 else {
1337 if (syserror(tcp) || !verbose(tcp))
1338 tprintf("%#lx", tcp->u_arg[1]);
1339 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1340 tprintf("{...}");
1341 else {
1342 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1343 statbuf.f_tfree, statbuf.f_tinode);
1344 tprintf("f_fname=\"%.*s\", ",
1345 (int) sizeof(statbuf.f_fname),
1346 statbuf.f_fname);
1347 tprintf("f_fpack=\"%.*s\"}",
1348 (int) sizeof(statbuf.f_fpack),
1349 statbuf.f_fpack);
1350 }
1351 }
1352 return 0;
1353}
1354
1355#endif /* SUNOS4 */
1356
Wichert Akkermanc7926982000-04-10 22:22:31 +00001357int
1358sys_pivotroot(tcp)
1359struct tcb *tcp;
1360{
1361 if (entering(tcp)) {
1362 printpath(tcp, tcp->u_arg[0]);
1363 tprintf(", ");
1364 printpath(tcp, tcp->u_arg[1]);
1365 }
1366 return 0;
1367}
1368
1369
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001370/* directory */
1371int
1372sys_chdir(tcp)
1373struct tcb *tcp;
1374{
1375 if (entering(tcp)) {
1376 printpath(tcp, tcp->u_arg[0]);
1377 }
1378 return 0;
1379}
1380
1381int
1382sys_mkdir(tcp)
1383struct tcb *tcp;
1384{
1385 if (entering(tcp)) {
1386 printpath(tcp, tcp->u_arg[0]);
1387 tprintf(", %#lo", tcp->u_arg[1]);
1388 }
1389 return 0;
1390}
1391
1392int
1393sys_rmdir(tcp)
1394struct tcb *tcp;
1395{
1396 if (entering(tcp)) {
1397 printpath(tcp, tcp->u_arg[0]);
1398 }
1399 return 0;
1400}
1401
1402int
1403sys_fchdir(tcp)
1404struct tcb *tcp;
1405{
1406 if (entering(tcp)) {
1407 tprintf("%ld", tcp->u_arg[0]);
1408 }
1409 return 0;
1410}
1411
1412int
1413sys_chroot(tcp)
1414struct tcb *tcp;
1415{
1416 if (entering(tcp)) {
1417 printpath(tcp, tcp->u_arg[0]);
1418 }
1419 return 0;
1420}
1421
1422int
1423sys_fchroot(tcp)
1424struct tcb *tcp;
1425{
1426 if (entering(tcp)) {
1427 tprintf("%ld", tcp->u_arg[0]);
1428 }
1429 return 0;
1430}
1431
1432int
1433sys_link(tcp)
1434struct tcb *tcp;
1435{
1436 if (entering(tcp)) {
1437 printpath(tcp, tcp->u_arg[0]);
1438 tprintf(", ");
1439 printpath(tcp, tcp->u_arg[1]);
1440 }
1441 return 0;
1442}
1443
1444int
1445sys_unlink(tcp)
1446struct tcb *tcp;
1447{
1448 if (entering(tcp)) {
1449 printpath(tcp, tcp->u_arg[0]);
1450 }
1451 return 0;
1452}
1453
1454int
1455sys_symlink(tcp)
1456struct tcb *tcp;
1457{
1458 if (entering(tcp)) {
1459 printpath(tcp, tcp->u_arg[0]);
1460 tprintf(", ");
1461 printpath(tcp, tcp->u_arg[1]);
1462 }
1463 return 0;
1464}
1465
1466int
1467sys_readlink(tcp)
1468struct tcb *tcp;
1469{
1470 if (entering(tcp)) {
1471 printpath(tcp, tcp->u_arg[0]);
1472 tprintf(", ");
1473 } else {
1474 if (syserror(tcp))
1475 tprintf("%#lx", tcp->u_arg[1]);
1476 else
1477 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1478 tprintf(", %lu", tcp->u_arg[2]);
1479 }
1480 return 0;
1481}
1482
1483int
1484sys_rename(tcp)
1485struct tcb *tcp;
1486{
1487 if (entering(tcp)) {
1488 printpath(tcp, tcp->u_arg[0]);
1489 tprintf(", ");
1490 printpath(tcp, tcp->u_arg[1]);
1491 }
1492 return 0;
1493}
1494
1495int
1496sys_chown(tcp)
1497struct tcb *tcp;
1498{
1499 if (entering(tcp)) {
1500 printpath(tcp, tcp->u_arg[0]);
1501 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1502 }
1503 return 0;
1504}
1505
1506int
1507sys_fchown(tcp)
1508struct tcb *tcp;
1509{
1510 if (entering(tcp)) {
1511 tprintf("%ld, %lu, %lu",
1512 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1513 }
1514 return 0;
1515}
1516
1517int
1518sys_chmod(tcp)
1519struct tcb *tcp;
1520{
1521 if (entering(tcp)) {
1522 printpath(tcp, tcp->u_arg[0]);
1523 tprintf(", %#lo", tcp->u_arg[1]);
1524 }
1525 return 0;
1526}
1527
1528int
1529sys_fchmod(tcp)
1530struct tcb *tcp;
1531{
1532 if (entering(tcp)) {
1533 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1534 }
1535 return 0;
1536}
1537
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001538#ifdef ALPHA
1539int
1540sys_osf_utimes(tcp)
1541struct tcb *tcp;
1542{
1543 if (entering(tcp)) {
1544 printpath(tcp, tcp->u_arg[0]);
1545 tprintf(", ");
1546 printtv32(tcp, tcp->u_arg[1]);
1547 }
1548 return 0;
1549}
1550#endif
1551
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001552int
1553sys_utimes(tcp)
1554struct tcb *tcp;
1555{
1556 if (entering(tcp)) {
1557 printpath(tcp, tcp->u_arg[0]);
1558 tprintf(", ");
1559 printtv(tcp, tcp->u_arg[1]);
1560 }
1561 return 0;
1562}
1563
1564int
1565sys_utime(tcp)
1566struct tcb *tcp;
1567{
1568 long ut[2];
1569
1570 if (entering(tcp)) {
1571 printpath(tcp, tcp->u_arg[0]);
1572 tprintf(", ");
1573 if (!tcp->u_arg[1])
1574 tprintf("NULL");
1575 else if (!verbose(tcp))
1576 tprintf("%#lx", tcp->u_arg[1]);
1577 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1578 (char *) ut) < 0)
1579 tprintf("[?, ?]");
1580 else {
1581 tprintf("[%s,", sprinttime(ut[0]));
1582 tprintf(" %s]", sprinttime(ut[1]));
1583 }
1584 }
1585 return 0;
1586}
1587
1588int
1589sys_mknod(tcp)
1590struct tcb *tcp;
1591{
1592 int mode = tcp->u_arg[1];
1593
1594 if (entering(tcp)) {
1595 printpath(tcp, tcp->u_arg[0]);
1596 tprintf(", %s", sprintmode(mode));
1597 switch (mode & S_IFMT) {
1598 case S_IFCHR: case S_IFBLK:
1599#ifdef LINUXSPARC
1600 if (current_personality == 1)
1601 tprintf(", makedev(%lu, %lu)",
1602 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1603 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1604 else
1605#endif
1606 tprintf(", makedev(%lu, %lu)",
1607 (unsigned long) major(tcp->u_arg[2]),
1608 (unsigned long) minor(tcp->u_arg[2]));
1609 break;
1610 default:
1611 break;
1612 }
1613 }
1614 return 0;
1615}
1616
1617int
1618sys_mkfifo(tcp)
1619struct tcb *tcp;
1620{
1621 if (entering(tcp)) {
1622 printpath(tcp, tcp->u_arg[0]);
1623 tprintf(", %#lo", tcp->u_arg[1]);
1624 }
1625 return 0;
1626}
1627
1628int
1629sys_fsync(tcp)
1630struct tcb *tcp;
1631{
1632 if (entering(tcp)) {
1633 tprintf("%ld", tcp->u_arg[0]);
1634 }
1635 return 0;
1636}
1637
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001638#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001639
1640static void
1641printdir(tcp, addr)
1642struct tcb *tcp;
1643long addr;
1644{
1645 struct dirent d;
1646
1647 if (!verbose(tcp)) {
1648 tprintf("%#lx", addr);
1649 return;
1650 }
1651 if (umove(tcp, addr, &d) < 0) {
1652 tprintf("{...}");
1653 return;
1654 }
1655 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001656 tprintf("d_name=");
1657 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1658 tprintf("}");
1659}
1660
1661int
1662sys_readdir(tcp)
1663struct tcb *tcp;
1664{
1665 if (entering(tcp)) {
1666 tprintf("%lu, ", tcp->u_arg[0]);
1667 } else {
1668 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1669 tprintf("%#lx", tcp->u_arg[1]);
1670 else
1671 printdir(tcp, tcp->u_arg[1]);
1672 /* Not much point in printing this out, it is always 1. */
1673 if (tcp->u_arg[2] != 1)
1674 tprintf(", %lu", tcp->u_arg[2]);
1675 }
1676 return 0;
1677}
1678
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001679#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001680
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001681#ifdef FREEBSD
1682struct xlat direnttypes[] = {
1683 { DT_FIFO, "DT_FIFO" },
1684 { DT_CHR, "DT_CHR" },
1685 { DT_DIR, "DT_DIR" },
1686 { DT_BLK, "DT_BLK" },
1687 { DT_REG, "DT_REG" },
1688 { DT_LNK, "DT_LNK" },
1689 { DT_SOCK, "DT_SOCK" },
1690 { DT_WHT, "DT_WHT" },
1691 { 0, NULL },
1692};
1693
1694#endif
1695
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001696int
1697sys_getdents(tcp)
1698struct tcb *tcp;
1699{
1700 int i, len, dents = 0;
1701 char *buf;
1702
1703 if (entering(tcp)) {
1704 tprintf("%lu, ", tcp->u_arg[0]);
1705 return 0;
1706 }
1707 if (syserror(tcp) || !verbose(tcp)) {
1708 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1709 return 0;
1710 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001711 len = tcp->u_rval;
1712 if ((buf = malloc(len)) == NULL) {
1713 tprintf("out of memory\n");
1714 return 0;
1715 }
1716 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1717 tprintf("{...}, %lu", tcp->u_arg[2]);
1718 free(buf);
1719 return 0;
1720 }
1721 if (!abbrev(tcp))
1722 tprintf("{");
1723 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00001724 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001725#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001726 if (!abbrev(tcp)) {
1727 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1728 i ? " " : "", d->d_ino, d->d_off);
1729 tprintf("d_reclen=%u, d_name=\"%s\"}",
1730 d->d_reclen, d->d_name);
1731 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001732#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001733#ifdef SVR4
1734 if (!abbrev(tcp)) {
1735 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1736 i ? " " : "", d->d_ino, d->d_off);
1737 tprintf("d_reclen=%u, d_name=\"%s\"}",
1738 d->d_reclen, d->d_name);
1739 }
1740#endif /* SVR4 */
1741#ifdef SUNOS4
1742 if (!abbrev(tcp)) {
1743 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1744 i ? " " : "", d->d_off, d->d_fileno,
1745 d->d_reclen);
1746 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1747 d->d_namlen, d->d_namlen, d->d_name);
1748 }
1749#endif /* SUNOS4 */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001750#ifdef FREEBSD
1751 if (!abbrev(tcp)) {
1752 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1753 i ? " " : "", d->d_fileno, d->d_reclen);
1754 printxval(direnttypes, d->d_type, "DT_???");
1755 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1756 d->d_namlen, d->d_namlen, d->d_name);
1757 }
1758#endif /* FREEBSD */
Pavel Machek9a9f10b2000-02-01 16:22:52 +00001759 if (!d->d_reclen) {
1760 tprintf("/* d_reclen == 0, problem here */");
1761 break;
1762 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001763 i += d->d_reclen;
1764 dents++;
1765 }
1766 if (!abbrev(tcp))
1767 tprintf("}");
1768 else
1769 tprintf("/* %u entries */", dents);
1770 tprintf(", %lu", tcp->u_arg[2]);
1771 free(buf);
1772 return 0;
1773}
1774
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001775#ifdef FREEBSD
1776int
1777sys_getdirentries(tcp)
1778struct tcb * tcp;
1779{
1780 int i, len, dents = 0;
1781 long basep;
1782 char *buf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001783
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001784 if (entering(tcp)) {
1785 tprintf("%lu, ", tcp->u_arg[0]);
1786 return 0;
1787 }
1788 if (syserror(tcp) || !verbose(tcp)) {
1789 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1790 return 0;
1791 }
1792 len = tcp->u_rval;
1793 if ((buf = malloc(len)) == NULL) {
1794 tprintf("out of memory\n");
1795 return 0;
1796 }
1797 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1798 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
1799 free(buf);
1800 return 0;
1801 }
1802 if (!abbrev(tcp))
1803 tprintf("{");
1804 for (i = 0; i < len;) {
1805 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1806 if (!abbrev(tcp)) {
1807 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1808 i ? " " : "", d->d_fileno, d->d_reclen);
1809 printxval(direnttypes, d->d_type, "DT_???");
1810 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1811 d->d_namlen, d->d_namlen, d->d_name);
1812 }
1813 i += d->d_reclen;
1814 dents++;
1815 }
1816 if (!abbrev(tcp))
1817 tprintf("}");
1818 else
1819 tprintf("/* %u entries */", dents);
1820 free(buf);
1821 tprintf(", %lu", tcp->u_arg[2]);
1822 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
1823 tprintf(", %#lx", tcp->u_arg[3]);
1824 else
1825 tprintf(", [%lu]", basep);
1826 return 0;
1827}
1828#endif
1829
1830#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001831int
1832sys_getcwd(tcp)
1833struct tcb *tcp;
1834{
1835 if (exiting(tcp)) {
1836 if (syserror(tcp))
1837 tprintf("%#lx", tcp->u_arg[0]);
1838 else
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001839 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001840 tprintf(", %lu", tcp->u_arg[1]);
1841 }
1842 return 0;
1843}
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001844#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001845
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001846#ifdef FREEBSD
1847int
1848sys___getcwd(tcp)
1849struct tcb *tcp;
1850{
1851 if (exiting(tcp)) {
1852 if (syserror(tcp))
1853 tprintf("%#lx", tcp->u_arg[0]);
1854 else
1855 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
1856 tprintf(", %lu", tcp->u_arg[1]);
1857 }
1858 return 0;
1859}
1860#endif
1861
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001862#ifdef HAVE_SYS_ASYNCH_H
1863
1864int
1865sys_aioread(tcp)
1866struct tcb *tcp;
1867{
1868 struct aio_result_t res;
1869
1870 if (entering(tcp)) {
1871 tprintf("%lu, ", tcp->u_arg[0]);
1872 } else {
1873 if (syserror(tcp))
1874 tprintf("%#lx", tcp->u_arg[1]);
1875 else
1876 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1877 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
1878 printxval(whence, tcp->u_arg[4], "L_???");
1879 if (syserror(tcp) || tcp->u_arg[5] == 0
1880 || umove(tcp, tcp->u_arg[5], &res) < 0)
1881 tprintf(", %#lx", tcp->u_arg[5]);
1882 else
1883 tprintf(", {aio_return %d aio_errno %d}",
1884 res.aio_return, res.aio_errno);
1885 }
1886 return 0;
1887}
1888
1889int
1890sys_aiowrite(tcp)
1891struct tcb *tcp;
1892{
1893 struct aio_result_t res;
1894
1895 if (entering(tcp)) {
1896 tprintf("%lu, ", tcp->u_arg[0]);
1897 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1898 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
1899 printxval(whence, tcp->u_arg[4], "L_???");
1900 }
1901 else {
1902 if (tcp->u_arg[5] == 0)
1903 tprintf(", NULL");
1904 else if (syserror(tcp)
1905 || umove(tcp, tcp->u_arg[5], &res) < 0)
1906 tprintf(", %#lx", tcp->u_arg[5]);
1907 else
1908 tprintf(", {aio_return %d aio_errno %d}",
1909 res.aio_return, res.aio_errno);
1910 }
1911 return 0;
1912}
1913
1914int
1915sys_aiowait(tcp)
1916struct tcb *tcp;
1917{
1918 if (entering(tcp))
1919 printtv(tcp, tcp->u_arg[0]);
1920 return 0;
1921}
1922
1923int
1924sys_aiocancel(tcp)
1925struct tcb *tcp;
1926{
1927 struct aio_result_t res;
1928
1929 if (exiting(tcp)) {
1930 if (tcp->u_arg[0] == 0)
1931 tprintf("NULL");
1932 else if (syserror(tcp)
1933 || umove(tcp, tcp->u_arg[0], &res) < 0)
1934 tprintf("%#lx", tcp->u_arg[0]);
1935 else
1936 tprintf("{aio_return %d aio_errno %d}",
1937 res.aio_return, res.aio_errno);
1938 }
1939 return 0;
1940}
1941
1942#endif /* HAVE_SYS_ASYNCH_H */
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001943
1944#if UNIXWARE >= 7
1945int
1946sys_lseek64 (tcp)
1947struct tcb *tcp;
1948{
1949 if (entering(tcp)) {
1950 long long offset = * (long long *) & tcp->u_arg [1];
1951 if (tcp->u_arg[3] == SEEK_SET)
1952 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
1953 else
1954 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
1955 printxval(whence, tcp->u_arg[3], "SEEK_???");
1956 }
1957 return RVAL_LDECIMAL;
1958}
1959#endif