blob: 50fdd4ac87b96f8413b0fa3e1166c454469d40d9 [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 {
John Hughes8fe2c982001-03-06 09:45:18 +00001002#ifdef _STAT64_VER
1003 if (tcp->u_arg[0] == _STAT64_VER)
1004 printstat64 (tcp, tcp->u_arg[2]);
1005 else
1006#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001007 printstat(tcp, tcp->u_arg[2]);
1008 }
1009 return 0;
1010}
1011
1012int
1013sys_fxstat(tcp)
1014struct tcb *tcp;
1015{
1016 if (entering(tcp))
1017 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1018 else {
John Hughes8fe2c982001-03-06 09:45:18 +00001019#ifdef _STAT64_VER
1020 if (tcp->u_arg[0] == _STAT64_VER)
1021 printstat64 (tcp, tcp->u_arg[2]);
1022 else
1023#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001024 printstat(tcp, tcp->u_arg[2]);
1025 }
1026 return 0;
1027}
1028
1029int
1030sys_lxstat(tcp)
1031struct tcb *tcp;
1032{
1033 if (entering(tcp)) {
1034 tprintf("%ld, ", tcp->u_arg[0]);
1035 printpath(tcp, tcp->u_arg[1]);
1036 tprintf(", ");
1037 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001038#ifdef _STAT64_VER
1039 if (tcp->u_arg[0] == _STAT64_VER)
1040 printstat64 (tcp, tcp->u_arg[2]);
1041 else
1042#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001043 printstat(tcp, tcp->u_arg[2]);
1044 }
1045 return 0;
1046}
1047
1048int
1049sys_xmknod(tcp)
1050struct tcb *tcp;
1051{
1052 int mode = tcp->u_arg[2];
1053
1054 if (entering(tcp)) {
1055 tprintf("%ld, ", tcp->u_arg[0]);
1056 printpath(tcp, tcp->u_arg[1]);
1057 tprintf(", %s", sprintmode(mode));
1058 switch (mode & S_IFMT) {
1059 case S_IFCHR: case S_IFBLK:
1060#ifdef LINUXSPARC
1061 tprintf(", makedev(%lu, %lu)",
1062 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1063 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1064#else
1065 tprintf(", makedev(%lu, %lu)",
1066 (unsigned long) major(tcp->u_arg[3]),
1067 (unsigned long) minor(tcp->u_arg[3]));
1068#endif
1069 break;
1070 default:
1071 break;
1072 }
1073 }
1074 return 0;
1075}
1076
Wichert Akkerman8829a551999-06-11 13:18:40 +00001077#ifdef HAVE_SYS_ACL_H
1078
1079#include <sys/acl.h>
1080
1081struct xlat aclcmds[] = {
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001082#ifdef SETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001083 { SETACL, "SETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001084#endif
1085#ifdef GETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001086 { GETACL, "GETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001087#endif
1088#ifdef GETACLCNT
Wichert Akkerman8829a551999-06-11 13:18:40 +00001089 { GETACLCNT, "GETACLCNT" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001090#endif
1091#ifdef ACL_GET
1092 { ACL_GET, "ACL_GET" },
1093#endif
1094#ifdef ACL_SET
1095 { ACL_SET, "ACL_SET" },
1096#endif
1097#ifdef ACL_CNT
1098 { ACL_CNT, "ACL_CNT" },
1099#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +00001100 { 0, NULL },
1101};
1102
1103int
1104sys_acl(tcp)
1105struct tcb *tcp;
1106{
1107 if (entering(tcp)) {
1108 printpath(tcp, tcp->u_arg[0]);
1109 tprintf(", ");
1110 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1111 tprintf(", %ld", tcp->u_arg[2]);
1112 /*
1113 * FIXME - dump out the list of aclent_t's pointed to
1114 * by "tcp->u_arg[3]" if it's not NULL.
1115 */
1116 if (tcp->u_arg[3])
1117 tprintf(", %#lx", tcp->u_arg[3]);
1118 else
1119 tprintf(", NULL");
1120 }
1121 return 0;
1122}
1123
1124
1125int
1126sys_facl(tcp)
1127struct tcb *tcp;
1128{
1129 if (entering(tcp)) {
1130 tprintf("%ld, ", tcp->u_arg[0]);
1131 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1132 tprintf(", %ld", tcp->u_arg[2]);
1133 /*
1134 * FIXME - dump out the list of aclent_t's pointed to
1135 * by "tcp->u_arg[3]" if it's not NULL.
1136 */
1137 if (tcp->u_arg[3])
1138 tprintf(", %#lx", tcp->u_arg[3]);
1139 else
1140 tprintf(", NULL");
1141 }
1142 return 0;
1143}
1144
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001145
1146struct xlat aclipc[] = {
1147#ifdef IPC_SHM
1148 { IPC_SHM, "IPC_SHM" },
1149#endif
1150#ifdef IPC_SEM
1151 { IPC_SEM, "IPC_SEM" },
1152#endif
1153#ifdef IPC_MSG
1154 { IPC_MSG, "IPC_MSG" },
1155#endif
1156 { 0, NULL },
1157};
1158
1159
1160int
1161sys_aclipc(tcp)
1162struct tcb *tcp;
1163{
1164 if (entering(tcp)) {
1165 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1166 tprintf(", %#lx, ", tcp->u_arg[1]);
1167 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1168 tprintf(", %ld", tcp->u_arg[3]);
1169 /*
1170 * FIXME - dump out the list of aclent_t's pointed to
1171 * by "tcp->u_arg[4]" if it's not NULL.
1172 */
1173 if (tcp->u_arg[4])
1174 tprintf(", %#lx", tcp->u_arg[4]);
1175 else
1176 tprintf(", NULL");
1177 }
1178 return 0;
1179}
1180
1181
1182
Wichert Akkerman8829a551999-06-11 13:18:40 +00001183#endif /* HAVE_SYS_ACL_H */
1184
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001185#endif /* SVR4 || LINUXSPARC */
1186
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001187#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001188
1189static struct xlat fsmagic[] = {
Wichert Akkerman43a74822000-06-27 17:33:32 +00001190 { 0x73757245, "CODA_SUPER_MAGIC" },
1191 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1192 { 0x1373, "DEVFS_SUPER_MAGIC" },
1193 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1194 { 0x414A53, "EFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001195 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1196 { 0xef53, "EXT2_SUPER_MAGIC" },
1197 { 0x137d, "EXT_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001198 { 0xf995e849, "HPFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001199 { 0x9660, "ISOFS_SUPER_MAGIC" },
1200 { 0x137f, "MINIX_SUPER_MAGIC" },
1201 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001202 { 0x2468, "MINIX2_SUPER_MAGIC" },
1203 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001204 { 0x4d44, "MSDOS_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001205 { 0x564c, "NCP_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001206 { 0x6969, "NFS_SUPER_MAGIC" },
1207 { 0x9fa0, "PROC_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001208 { 0x002f, "QNX4_SUPER_MAGIC" },
1209 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1210 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1211 { 0x517b, "SMB_SUPER_MAGIC" },
1212 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1213 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1214 { 0x00011954, "UFS_MAGIC" },
1215 { 0x54190100, "UFS_CIGAM" },
1216 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001217 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1218 { 0, NULL },
1219};
1220
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001221#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001222
1223#ifndef SVR4
1224
1225static char *
1226sprintfstype(magic)
1227int magic;
1228{
1229 static char buf[32];
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001230#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001231 char *s;
1232
1233 s = xlookup(fsmagic, magic);
1234 if (s) {
1235 sprintf(buf, "\"%s\"", s);
1236 return buf;
1237 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001238#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001239 sprintf(buf, "%#x", magic);
1240 return buf;
1241}
1242
1243static void
1244printstatfs(tcp, addr)
1245struct tcb *tcp;
1246long addr;
1247{
1248 struct statfs statbuf;
1249
1250 if (syserror(tcp) || !verbose(tcp)) {
1251 tprintf("%#lx", addr);
1252 return;
1253 }
1254 if (umove(tcp, addr, &statbuf) < 0) {
1255 tprintf("{...}");
1256 return;
1257 }
1258#ifdef ALPHA
1259
1260 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1261 sprintfstype(statbuf.f_type),
1262 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001263 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001264 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1265#else /* !ALPHA */
1266 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1267 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +00001268 (unsigned long)statbuf.f_bsize,
1269 (unsigned long)statbuf.f_blocks,
1270 (unsigned long)statbuf.f_bfree);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001271 tprintf("f_files=%lu, f_ffree=%lu",
Nate Sammons5c74d201999-04-06 01:37:51 +00001272 (unsigned long)statbuf.f_files,
1273 (unsigned long)statbuf.f_ffree);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001274#ifdef linux
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001275 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001276#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001277#endif /* !ALPHA */
1278 tprintf("}");
1279}
1280
1281int
1282sys_statfs(tcp)
1283struct tcb *tcp;
1284{
1285 if (entering(tcp)) {
1286 printpath(tcp, tcp->u_arg[0]);
1287 tprintf(", ");
1288 } else {
1289 printstatfs(tcp, tcp->u_arg[1]);
1290 }
1291 return 0;
1292}
1293
1294int
1295sys_fstatfs(tcp)
1296struct tcb *tcp;
1297{
1298 if (entering(tcp)) {
1299 tprintf("%lu, ", tcp->u_arg[0]);
1300 } else {
1301 printstatfs(tcp, tcp->u_arg[1]);
1302 }
1303 return 0;
1304}
1305
Wichert Akkermana0f36c61999-04-16 14:01:34 +00001306#if defined(linux) && defined(__alpha)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001307
1308int
1309osf_statfs(tcp)
1310struct tcb *tcp;
1311{
1312 if (entering(tcp)) {
1313 printpath(tcp, tcp->u_arg[0]);
1314 tprintf(", ");
1315 } else {
1316 printstatfs(tcp, tcp->u_arg[1]);
1317 tprintf(", %lu", tcp->u_arg[2]);
1318 }
1319 return 0;
1320}
1321
1322int
1323osf_fstatfs(tcp)
1324struct tcb *tcp;
1325{
1326 if (entering(tcp)) {
1327 tprintf("%lu, ", tcp->u_arg[0]);
1328 } else {
1329 printstatfs(tcp, tcp->u_arg[1]);
1330 tprintf(", %lu", tcp->u_arg[2]);
1331 }
1332 return 0;
1333}
Wichert Akkermana0f36c61999-04-16 14:01:34 +00001334#endif /* linux && __alpha */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001335
1336#endif /* !SVR4 */
1337
1338#ifdef SUNOS4
1339
1340int
1341sys_ustat(tcp)
1342struct tcb *tcp;
1343{
1344 struct ustat statbuf;
1345
1346 if (entering(tcp)) {
1347 tprintf("makedev(%lu, %lu), ",
1348 (long) major(tcp->u_arg[0]),
1349 (long) minor(tcp->u_arg[0]));
1350 }
1351 else {
1352 if (syserror(tcp) || !verbose(tcp))
1353 tprintf("%#lx", tcp->u_arg[1]);
1354 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1355 tprintf("{...}");
1356 else {
1357 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1358 statbuf.f_tfree, statbuf.f_tinode);
1359 tprintf("f_fname=\"%.*s\", ",
1360 (int) sizeof(statbuf.f_fname),
1361 statbuf.f_fname);
1362 tprintf("f_fpack=\"%.*s\"}",
1363 (int) sizeof(statbuf.f_fpack),
1364 statbuf.f_fpack);
1365 }
1366 }
1367 return 0;
1368}
1369
1370#endif /* SUNOS4 */
1371
Wichert Akkermanc7926982000-04-10 22:22:31 +00001372int
1373sys_pivotroot(tcp)
1374struct tcb *tcp;
1375{
1376 if (entering(tcp)) {
1377 printpath(tcp, tcp->u_arg[0]);
1378 tprintf(", ");
1379 printpath(tcp, tcp->u_arg[1]);
1380 }
1381 return 0;
1382}
1383
1384
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001385/* directory */
1386int
1387sys_chdir(tcp)
1388struct tcb *tcp;
1389{
1390 if (entering(tcp)) {
1391 printpath(tcp, tcp->u_arg[0]);
1392 }
1393 return 0;
1394}
1395
1396int
1397sys_mkdir(tcp)
1398struct tcb *tcp;
1399{
1400 if (entering(tcp)) {
1401 printpath(tcp, tcp->u_arg[0]);
1402 tprintf(", %#lo", tcp->u_arg[1]);
1403 }
1404 return 0;
1405}
1406
1407int
1408sys_rmdir(tcp)
1409struct tcb *tcp;
1410{
1411 if (entering(tcp)) {
1412 printpath(tcp, tcp->u_arg[0]);
1413 }
1414 return 0;
1415}
1416
1417int
1418sys_fchdir(tcp)
1419struct tcb *tcp;
1420{
1421 if (entering(tcp)) {
1422 tprintf("%ld", tcp->u_arg[0]);
1423 }
1424 return 0;
1425}
1426
1427int
1428sys_chroot(tcp)
1429struct tcb *tcp;
1430{
1431 if (entering(tcp)) {
1432 printpath(tcp, tcp->u_arg[0]);
1433 }
1434 return 0;
1435}
1436
1437int
1438sys_fchroot(tcp)
1439struct tcb *tcp;
1440{
1441 if (entering(tcp)) {
1442 tprintf("%ld", tcp->u_arg[0]);
1443 }
1444 return 0;
1445}
1446
1447int
1448sys_link(tcp)
1449struct tcb *tcp;
1450{
1451 if (entering(tcp)) {
1452 printpath(tcp, tcp->u_arg[0]);
1453 tprintf(", ");
1454 printpath(tcp, tcp->u_arg[1]);
1455 }
1456 return 0;
1457}
1458
1459int
1460sys_unlink(tcp)
1461struct tcb *tcp;
1462{
1463 if (entering(tcp)) {
1464 printpath(tcp, tcp->u_arg[0]);
1465 }
1466 return 0;
1467}
1468
1469int
1470sys_symlink(tcp)
1471struct tcb *tcp;
1472{
1473 if (entering(tcp)) {
1474 printpath(tcp, tcp->u_arg[0]);
1475 tprintf(", ");
1476 printpath(tcp, tcp->u_arg[1]);
1477 }
1478 return 0;
1479}
1480
1481int
1482sys_readlink(tcp)
1483struct tcb *tcp;
1484{
1485 if (entering(tcp)) {
1486 printpath(tcp, tcp->u_arg[0]);
1487 tprintf(", ");
1488 } else {
1489 if (syserror(tcp))
1490 tprintf("%#lx", tcp->u_arg[1]);
1491 else
1492 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1493 tprintf(", %lu", tcp->u_arg[2]);
1494 }
1495 return 0;
1496}
1497
1498int
1499sys_rename(tcp)
1500struct tcb *tcp;
1501{
1502 if (entering(tcp)) {
1503 printpath(tcp, tcp->u_arg[0]);
1504 tprintf(", ");
1505 printpath(tcp, tcp->u_arg[1]);
1506 }
1507 return 0;
1508}
1509
1510int
1511sys_chown(tcp)
1512struct tcb *tcp;
1513{
1514 if (entering(tcp)) {
1515 printpath(tcp, tcp->u_arg[0]);
1516 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1517 }
1518 return 0;
1519}
1520
1521int
1522sys_fchown(tcp)
1523struct tcb *tcp;
1524{
1525 if (entering(tcp)) {
1526 tprintf("%ld, %lu, %lu",
1527 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1528 }
1529 return 0;
1530}
1531
1532int
1533sys_chmod(tcp)
1534struct tcb *tcp;
1535{
1536 if (entering(tcp)) {
1537 printpath(tcp, tcp->u_arg[0]);
1538 tprintf(", %#lo", tcp->u_arg[1]);
1539 }
1540 return 0;
1541}
1542
1543int
1544sys_fchmod(tcp)
1545struct tcb *tcp;
1546{
1547 if (entering(tcp)) {
1548 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1549 }
1550 return 0;
1551}
1552
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001553#ifdef ALPHA
1554int
1555sys_osf_utimes(tcp)
1556struct tcb *tcp;
1557{
1558 if (entering(tcp)) {
1559 printpath(tcp, tcp->u_arg[0]);
1560 tprintf(", ");
1561 printtv32(tcp, tcp->u_arg[1]);
1562 }
1563 return 0;
1564}
1565#endif
1566
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001567int
1568sys_utimes(tcp)
1569struct tcb *tcp;
1570{
1571 if (entering(tcp)) {
1572 printpath(tcp, tcp->u_arg[0]);
1573 tprintf(", ");
1574 printtv(tcp, tcp->u_arg[1]);
1575 }
1576 return 0;
1577}
1578
1579int
1580sys_utime(tcp)
1581struct tcb *tcp;
1582{
1583 long ut[2];
1584
1585 if (entering(tcp)) {
1586 printpath(tcp, tcp->u_arg[0]);
1587 tprintf(", ");
1588 if (!tcp->u_arg[1])
1589 tprintf("NULL");
1590 else if (!verbose(tcp))
1591 tprintf("%#lx", tcp->u_arg[1]);
1592 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1593 (char *) ut) < 0)
1594 tprintf("[?, ?]");
1595 else {
1596 tprintf("[%s,", sprinttime(ut[0]));
1597 tprintf(" %s]", sprinttime(ut[1]));
1598 }
1599 }
1600 return 0;
1601}
1602
1603int
1604sys_mknod(tcp)
1605struct tcb *tcp;
1606{
1607 int mode = tcp->u_arg[1];
1608
1609 if (entering(tcp)) {
1610 printpath(tcp, tcp->u_arg[0]);
1611 tprintf(", %s", sprintmode(mode));
1612 switch (mode & S_IFMT) {
1613 case S_IFCHR: case S_IFBLK:
1614#ifdef LINUXSPARC
1615 if (current_personality == 1)
1616 tprintf(", makedev(%lu, %lu)",
1617 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1618 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1619 else
1620#endif
1621 tprintf(", makedev(%lu, %lu)",
1622 (unsigned long) major(tcp->u_arg[2]),
1623 (unsigned long) minor(tcp->u_arg[2]));
1624 break;
1625 default:
1626 break;
1627 }
1628 }
1629 return 0;
1630}
1631
1632int
1633sys_mkfifo(tcp)
1634struct tcb *tcp;
1635{
1636 if (entering(tcp)) {
1637 printpath(tcp, tcp->u_arg[0]);
1638 tprintf(", %#lo", tcp->u_arg[1]);
1639 }
1640 return 0;
1641}
1642
1643int
1644sys_fsync(tcp)
1645struct tcb *tcp;
1646{
1647 if (entering(tcp)) {
1648 tprintf("%ld", tcp->u_arg[0]);
1649 }
1650 return 0;
1651}
1652
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001653#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001654
1655static void
1656printdir(tcp, addr)
1657struct tcb *tcp;
1658long addr;
1659{
1660 struct dirent d;
1661
1662 if (!verbose(tcp)) {
1663 tprintf("%#lx", addr);
1664 return;
1665 }
1666 if (umove(tcp, addr, &d) < 0) {
1667 tprintf("{...}");
1668 return;
1669 }
1670 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001671 tprintf("d_name=");
1672 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1673 tprintf("}");
1674}
1675
1676int
1677sys_readdir(tcp)
1678struct tcb *tcp;
1679{
1680 if (entering(tcp)) {
1681 tprintf("%lu, ", tcp->u_arg[0]);
1682 } else {
1683 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1684 tprintf("%#lx", tcp->u_arg[1]);
1685 else
1686 printdir(tcp, tcp->u_arg[1]);
1687 /* Not much point in printing this out, it is always 1. */
1688 if (tcp->u_arg[2] != 1)
1689 tprintf(", %lu", tcp->u_arg[2]);
1690 }
1691 return 0;
1692}
1693
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001694#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001695
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001696#ifdef FREEBSD
1697struct xlat direnttypes[] = {
1698 { DT_FIFO, "DT_FIFO" },
1699 { DT_CHR, "DT_CHR" },
1700 { DT_DIR, "DT_DIR" },
1701 { DT_BLK, "DT_BLK" },
1702 { DT_REG, "DT_REG" },
1703 { DT_LNK, "DT_LNK" },
1704 { DT_SOCK, "DT_SOCK" },
1705 { DT_WHT, "DT_WHT" },
1706 { 0, NULL },
1707};
1708
1709#endif
1710
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001711int
1712sys_getdents(tcp)
1713struct tcb *tcp;
1714{
1715 int i, len, dents = 0;
1716 char *buf;
1717
1718 if (entering(tcp)) {
1719 tprintf("%lu, ", tcp->u_arg[0]);
1720 return 0;
1721 }
1722 if (syserror(tcp) || !verbose(tcp)) {
1723 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1724 return 0;
1725 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001726 len = tcp->u_rval;
1727 if ((buf = malloc(len)) == NULL) {
1728 tprintf("out of memory\n");
1729 return 0;
1730 }
1731 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1732 tprintf("{...}, %lu", tcp->u_arg[2]);
1733 free(buf);
1734 return 0;
1735 }
1736 if (!abbrev(tcp))
1737 tprintf("{");
1738 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00001739 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001740#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001741 if (!abbrev(tcp)) {
1742 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1743 i ? " " : "", d->d_ino, d->d_off);
1744 tprintf("d_reclen=%u, d_name=\"%s\"}",
1745 d->d_reclen, d->d_name);
1746 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001747#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001748#ifdef SVR4
1749 if (!abbrev(tcp)) {
1750 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1751 i ? " " : "", d->d_ino, d->d_off);
1752 tprintf("d_reclen=%u, d_name=\"%s\"}",
1753 d->d_reclen, d->d_name);
1754 }
1755#endif /* SVR4 */
1756#ifdef SUNOS4
1757 if (!abbrev(tcp)) {
1758 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1759 i ? " " : "", d->d_off, d->d_fileno,
1760 d->d_reclen);
1761 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1762 d->d_namlen, d->d_namlen, d->d_name);
1763 }
1764#endif /* SUNOS4 */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001765#ifdef FREEBSD
1766 if (!abbrev(tcp)) {
1767 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1768 i ? " " : "", d->d_fileno, d->d_reclen);
1769 printxval(direnttypes, d->d_type, "DT_???");
1770 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1771 d->d_namlen, d->d_namlen, d->d_name);
1772 }
1773#endif /* FREEBSD */
Pavel Machek9a9f10b2000-02-01 16:22:52 +00001774 if (!d->d_reclen) {
1775 tprintf("/* d_reclen == 0, problem here */");
1776 break;
1777 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001778 i += d->d_reclen;
1779 dents++;
1780 }
1781 if (!abbrev(tcp))
1782 tprintf("}");
1783 else
1784 tprintf("/* %u entries */", dents);
1785 tprintf(", %lu", tcp->u_arg[2]);
1786 free(buf);
1787 return 0;
1788}
1789
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001790#ifdef FREEBSD
1791int
1792sys_getdirentries(tcp)
1793struct tcb * tcp;
1794{
1795 int i, len, dents = 0;
1796 long basep;
1797 char *buf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001798
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001799 if (entering(tcp)) {
1800 tprintf("%lu, ", tcp->u_arg[0]);
1801 return 0;
1802 }
1803 if (syserror(tcp) || !verbose(tcp)) {
1804 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1805 return 0;
1806 }
1807 len = tcp->u_rval;
1808 if ((buf = malloc(len)) == NULL) {
1809 tprintf("out of memory\n");
1810 return 0;
1811 }
1812 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1813 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
1814 free(buf);
1815 return 0;
1816 }
1817 if (!abbrev(tcp))
1818 tprintf("{");
1819 for (i = 0; i < len;) {
1820 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1821 if (!abbrev(tcp)) {
1822 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1823 i ? " " : "", d->d_fileno, d->d_reclen);
1824 printxval(direnttypes, d->d_type, "DT_???");
1825 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1826 d->d_namlen, d->d_namlen, d->d_name);
1827 }
1828 i += d->d_reclen;
1829 dents++;
1830 }
1831 if (!abbrev(tcp))
1832 tprintf("}");
1833 else
1834 tprintf("/* %u entries */", dents);
1835 free(buf);
1836 tprintf(", %lu", tcp->u_arg[2]);
1837 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
1838 tprintf(", %#lx", tcp->u_arg[3]);
1839 else
1840 tprintf(", [%lu]", basep);
1841 return 0;
1842}
1843#endif
1844
1845#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001846int
1847sys_getcwd(tcp)
1848struct tcb *tcp;
1849{
1850 if (exiting(tcp)) {
1851 if (syserror(tcp))
1852 tprintf("%#lx", tcp->u_arg[0]);
1853 else
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001854 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001855 tprintf(", %lu", tcp->u_arg[1]);
1856 }
1857 return 0;
1858}
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001859#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001860
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001861#ifdef FREEBSD
1862int
1863sys___getcwd(tcp)
1864struct tcb *tcp;
1865{
1866 if (exiting(tcp)) {
1867 if (syserror(tcp))
1868 tprintf("%#lx", tcp->u_arg[0]);
1869 else
1870 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
1871 tprintf(", %lu", tcp->u_arg[1]);
1872 }
1873 return 0;
1874}
1875#endif
1876
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001877#ifdef HAVE_SYS_ASYNCH_H
1878
1879int
1880sys_aioread(tcp)
1881struct tcb *tcp;
1882{
1883 struct aio_result_t res;
1884
1885 if (entering(tcp)) {
1886 tprintf("%lu, ", tcp->u_arg[0]);
1887 } else {
1888 if (syserror(tcp))
1889 tprintf("%#lx", tcp->u_arg[1]);
1890 else
1891 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1892 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
1893 printxval(whence, tcp->u_arg[4], "L_???");
1894 if (syserror(tcp) || tcp->u_arg[5] == 0
1895 || umove(tcp, tcp->u_arg[5], &res) < 0)
1896 tprintf(", %#lx", tcp->u_arg[5]);
1897 else
1898 tprintf(", {aio_return %d aio_errno %d}",
1899 res.aio_return, res.aio_errno);
1900 }
1901 return 0;
1902}
1903
1904int
1905sys_aiowrite(tcp)
1906struct tcb *tcp;
1907{
1908 struct aio_result_t res;
1909
1910 if (entering(tcp)) {
1911 tprintf("%lu, ", tcp->u_arg[0]);
1912 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1913 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
1914 printxval(whence, tcp->u_arg[4], "L_???");
1915 }
1916 else {
1917 if (tcp->u_arg[5] == 0)
1918 tprintf(", NULL");
1919 else if (syserror(tcp)
1920 || umove(tcp, tcp->u_arg[5], &res) < 0)
1921 tprintf(", %#lx", tcp->u_arg[5]);
1922 else
1923 tprintf(", {aio_return %d aio_errno %d}",
1924 res.aio_return, res.aio_errno);
1925 }
1926 return 0;
1927}
1928
1929int
1930sys_aiowait(tcp)
1931struct tcb *tcp;
1932{
1933 if (entering(tcp))
1934 printtv(tcp, tcp->u_arg[0]);
1935 return 0;
1936}
1937
1938int
1939sys_aiocancel(tcp)
1940struct tcb *tcp;
1941{
1942 struct aio_result_t res;
1943
1944 if (exiting(tcp)) {
1945 if (tcp->u_arg[0] == 0)
1946 tprintf("NULL");
1947 else if (syserror(tcp)
1948 || umove(tcp, tcp->u_arg[0], &res) < 0)
1949 tprintf("%#lx", tcp->u_arg[0]);
1950 else
1951 tprintf("{aio_return %d aio_errno %d}",
1952 res.aio_return, res.aio_errno);
1953 }
1954 return 0;
1955}
1956
1957#endif /* HAVE_SYS_ASYNCH_H */
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001958
1959#if UNIXWARE >= 7
1960int
1961sys_lseek64 (tcp)
1962struct tcb *tcp;
1963{
1964 if (entering(tcp)) {
1965 long long offset = * (long long *) & tcp->u_arg [1];
1966 if (tcp->u_arg[3] == SEEK_SET)
1967 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
1968 else
1969 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
1970 printxval(whence, tcp->u_arg[3], "SEEK_???");
1971 }
1972 return RVAL_LDECIMAL;
1973}
1974#endif