blob: a74beda9c47dfbff08c4e3ce9ce2c17e9b617e66 [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
38#include <linux/types.h>
39#include <linux/dirent.h>
40#undef dirent
41#else
42#define kernel_dirent dirent
43#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000044
Wichert Akkerman8bc6cfd1999-04-21 15:57:38 +000045#ifdef linux
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000046# ifdef LINUXSPARC
47struct stat {
48 unsigned short st_dev;
49 unsigned int st_ino;
50 unsigned short st_mode;
51 short st_nlink;
52 unsigned short st_uid;
53 unsigned short st_gid;
54 unsigned short st_rdev;
55 unsigned int st_size;
56 int st_atime;
57 unsigned int __unused1;
58 int st_mtime;
59 unsigned int __unused2;
60 int st_ctime;
61 unsigned int __unused3;
62 int st_blksize;
63 int st_blocks;
64 unsigned int __unused4[2];
65};
66# define stat kernel_stat
67# include <asm/stat.h>
68# undef stat
69# else
Wichert Akkerman5b4d1281999-07-09 00:32:54 +000070# undef dev_t
71# undef ino_t
72# undef mode_t
73# undef nlink_t
74# undef uid_t
75# undef gid_t
76# undef off_t
77# undef loff_t
78
Wichert Akkermana6013701999-07-08 14:00:58 +000079# define dev_t __kernel_dev_t
80# define ino_t __kernel_ino_t
81# define mode_t __kernel_mode_t
82# define nlink_t __kernel_nlink_t
83# define uid_t __kernel_uid_t
84# define gid_t __kernel_gid_t
85# define off_t __kernel_off_t
86# define loff_t __kernel_loff_t
87
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000088# include <asm/stat.h>
Wichert Akkermana6013701999-07-08 14:00:58 +000089
90# undef dev_t
91# undef ino_t
92# undef mode_t
93# undef nlink_t
94# undef uid_t
95# undef gid_t
96# undef off_t
97# undef loff_t
Wichert Akkerman5b4d1281999-07-09 00:32:54 +000098
99# define dev_t dev_t
100# define ino_t ino_t
101# define mode_t mode_t
102# define nlink_t nlink_t
103# define uid_t uid_t
104# define gid_t gid_t
105# define off_t off_t
106# define loff_t loff_t
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000107# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000108# define stat libc_stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000109# define stat64 libc_stat64
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000110# include <sys/stat.h>
111# undef stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000112# undef stat64
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000113#else
114# include <sys/stat.h>
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000115#endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000116
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000117#include <fcntl.h>
118
119#ifdef SVR4
120# include <sys/cred.h>
121#endif /* SVR4 */
122
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000123#ifdef HAVE_SYS_VFS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000124#include <sys/vfs.h>
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000125#endif
126
127#ifdef FREEBSD
128#include <sys/param.h>
129#include <sys/mount.h>
130#include <sys/stat.h>
131#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000132
133#ifdef MAJOR_IN_SYSMACROS
134#include <sys/sysmacros.h>
135#endif
136
137#ifdef MAJOR_IN_MKDEV
138#include <sys/mkdev.h>
139#endif
140
141#ifdef HAVE_SYS_ASYNCH_H
142#include <sys/asynch.h>
143#endif
144
145#ifdef SUNOS4
146#include <ustat.h>
147#endif
148
149/*
150 * This is a really dirty trick but it should always work. Traditional
151 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
152 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
153 */
154struct xlat openmodes[] = {
155 { O_RDWR+1, "O_RDWR" },
156 { O_RDONLY+1, "O_RDONLY" },
157 { O_WRONLY+1, "O_WRONLY" },
158 { O_NONBLOCK, "O_NONBLOCK" },
159 { O_APPEND, "O_APPEND" },
160 { O_CREAT, "O_CREAT" },
161 { O_TRUNC, "O_TRUNC" },
162 { O_EXCL, "O_EXCL" },
163 { O_NOCTTY, "O_NOCTTY" },
164#ifdef O_SYNC
165 { O_SYNC, "O_SYNC" },
166#endif
167#ifdef O_ASYNC
168 { O_ASYNC, "O_ASYNC" },
169#endif
170#ifdef O_DSYNC
171 { O_DSYNC, "O_DSYNC" },
172#endif
173#ifdef O_RSYNC
174 { O_RSYNC, "O_RSYNC" },
175#endif
176#ifdef O_NDELAY
177 { O_NDELAY, "O_NDELAY" },
178#endif
179#ifdef O_PRIV
180 { O_PRIV, "O_PRIV" },
181#endif
182#ifdef O_DIRECT
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000183 { O_DIRECT, "O_DIRECT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000184#endif
185#ifdef O_LARGEFILE
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000186 { O_LARGEFILE, "O_LARGEFILE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000187#endif
188#ifdef O_DIRECTORY
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000189 { O_DIRECTORY, "O_DIRECTORY" },
190#endif
191#ifdef O_NOFOLLOW
192 { O_NOFOLLOW, "O_NOFOLLOW" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000193#endif
194
195#ifdef FNDELAY
196 { FNDELAY, "FNDELAY" },
197#endif
198#ifdef FAPPEND
199 { FAPPEND, "FAPPEND" },
200#endif
201#ifdef FMARK
202 { FMARK, "FMARK" },
203#endif
204#ifdef FDEFER
205 { FDEFER, "FDEFER" },
206#endif
207#ifdef FASYNC
208 { FASYNC, "FASYNC" },
209#endif
210#ifdef FSHLOCK
211 { FSHLOCK, "FSHLOCK" },
212#endif
213#ifdef FEXLOCK
214 { FEXLOCK, "FEXLOCK" },
215#endif
216#ifdef FCREAT
217 { FCREAT, "FCREAT" },
218#endif
219#ifdef FTRUNC
220 { FTRUNC, "FTRUNC" },
221#endif
222#ifdef FEXCL
223 { FEXCL, "FEXCL" },
224#endif
225#ifdef FNBIO
226 { FNBIO, "FNBIO" },
227#endif
228#ifdef FSYNC
229 { FSYNC, "FSYNC" },
230#endif
231#ifdef FNOCTTY
232 { FNOCTTY, "FNOCTTY" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000233#endif
234#ifdef O_SHLOCK
235 { O_SHLOCK, "O_SHLOCK" },
236#endif
237#ifdef O_EXLOCK
238 { O_EXLOCK, "O_EXLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000239#endif
240 { 0, NULL },
241};
242
243int
244sys_open(tcp)
245struct tcb *tcp;
246{
247 if (entering(tcp)) {
248 printpath(tcp, tcp->u_arg[0]);
249 tprintf(", ");
250 /* flags */
251 printflags(openmodes, tcp->u_arg[1] + 1);
252 if (tcp->u_arg[1] & O_CREAT) {
253 /* mode */
254 tprintf(", %#lo", tcp->u_arg[2]);
255 }
256 }
257 return 0;
258}
259
260#ifdef LINUXSPARC
261struct xlat openmodessol[] = {
262 { 0, "O_RDWR" },
263 { 1, "O_RDONLY" },
264 { 2, "O_WRONLY" },
265 { 0x80, "O_NONBLOCK" },
266 { 8, "O_APPEND" },
267 { 0x100, "O_CREAT" },
268 { 0x200, "O_TRUNC" },
269 { 0x400, "O_EXCL" },
270 { 0x800, "O_NOCTTY" },
271 { 0x10, "O_SYNC" },
272 { 0x40, "O_DSYNC" },
273 { 0x8000, "O_RSYNC" },
274 { 4, "O_NDELAY" },
275 { 0x1000, "O_PRIV" },
276 { 0, NULL },
277};
278
279int
280solaris_open(tcp)
281struct tcb *tcp;
282{
283 if (entering(tcp)) {
284 printpath(tcp, tcp->u_arg[0]);
285 tprintf(", ");
286 /* flags */
287 printflags(openmodessol, tcp->u_arg[1] + 1);
288 if (tcp->u_arg[1] & 0x100) {
289 /* mode */
290 tprintf(", %#lo", tcp->u_arg[2]);
291 }
292 }
293 return 0;
294}
295
296#endif
297
298int
299sys_creat(tcp)
300struct tcb *tcp;
301{
302 if (entering(tcp)) {
303 printpath(tcp, tcp->u_arg[0]);
304 tprintf(", %#lo", tcp->u_arg[1]);
305 }
306 return 0;
307}
308
309static struct xlat access_flags[] = {
310 { F_OK, "F_OK", },
311 { R_OK, "R_OK" },
312 { W_OK, "W_OK" },
313 { X_OK, "X_OK" },
314#ifdef EFF_ONLY_OK
315 { EFF_ONLY_OK, "EFF_ONLY_OK" },
316#endif
317#ifdef EX_OK
318 { EX_OK, "EX_OK" },
319#endif
320 { 0, NULL },
321};
322
323int
324sys_access(tcp)
325struct tcb *tcp;
326{
327 if (entering(tcp)) {
328 printpath(tcp, tcp->u_arg[0]);
329 tprintf(", ");
330 printflags(access_flags, tcp->u_arg[1]);
331 }
332 return 0;
333}
334
335int
336sys_umask(tcp)
337struct tcb *tcp;
338{
339 if (entering(tcp)) {
340 tprintf("%#lo", tcp->u_arg[0]);
341 }
342 return RVAL_OCTAL;
343}
344
345static struct xlat whence[] = {
346 { SEEK_SET, "SEEK_SET" },
347 { SEEK_CUR, "SEEK_CUR" },
348 { SEEK_END, "SEEK_END" },
349 { 0, NULL },
350};
351
352int
353sys_lseek(tcp)
354struct tcb *tcp;
355{
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000356 off_t offset;
357 int _whence;
358
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000359 if (entering(tcp)) {
360 tprintf("%ld, ", tcp->u_arg[0]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000361#ifndef FREEBSD
362 offset = tcp->u_arg[1];
363 _whence = tcp->u_arg[2];
364 if (_whence == SEEK_SET)
365 tprintf("%lu, ", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000366 else
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000367 tprintf("%ld, ", offset);
368#else /* FREEBSD */
369 offset = ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2];
370 _whence = tcp->u_arg[4];
371 if (_whence == SEEK_SET)
372 tprintf("%llu, ", offset);
373 else
374 tprintf("%lld, ", offset);
375#endif
376 printxval(whence, _whence, "SEEK_???");
377 }
378#ifdef FREEBSD
379 else
380 if (!syserror(tcp))
381 return RVAL_LUDECIMAL;
382#endif /* FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000383 return RVAL_UDECIMAL;
384}
385
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000386#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000387int
388sys_llseek (tcp)
389struct tcb *tcp;
390{
391 if (entering(tcp)) {
392 if (tcp->u_arg[4] == SEEK_SET)
393 tprintf("%ld, %llu, ", tcp->u_arg[0],
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000394 (((long long int) tcp->u_arg[1]) << 32
395 | (unsigned long long) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000396 else
397 tprintf("%ld, %lld, ", tcp->u_arg[0],
398 (((long long int) tcp->u_arg[1]) << 32
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000399 | (unsigned long long) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000400 }
401 else {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000402 long long int off;
403 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000404 tprintf("%#lx, ", tcp->u_arg[3]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000405 else
406 tprintf("[%llu], ", off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000407 printxval(whence, tcp->u_arg[4], "SEEK_???");
408 }
409 return 0;
410}
411#endif
412
413int
414sys_truncate(tcp)
415struct tcb *tcp;
416{
417 if (entering(tcp)) {
418 printpath(tcp, tcp->u_arg[0]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000419#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000420 tprintf(", %lu", tcp->u_arg[1]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000421#else
422 tprintf(", %llu", ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2]);
423#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000424 }
425 return 0;
426}
427
428int
429sys_ftruncate(tcp)
430struct tcb *tcp;
431{
432 if (entering(tcp)) {
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000433#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000434 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000435#else
436 tprintf("%ld, %llu", tcp->u_arg[0],
437 ((off_t) tcp->u_arg[1] << 32) + tcp->u_arg[2]);
438#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000439 }
440 return 0;
441}
442
443/* several stats */
444
445static struct xlat modetypes[] = {
446 { S_IFREG, "S_IFREG" },
447 { S_IFSOCK, "S_IFSOCK" },
448 { S_IFIFO, "S_IFIFO" },
449 { S_IFLNK, "S_IFLNK" },
450 { S_IFDIR, "S_IFDIR" },
451 { S_IFBLK, "S_IFBLK" },
452 { S_IFCHR, "S_IFCHR" },
453 { 0, NULL },
454};
455
456static char *
457sprintmode(mode)
458int mode;
459{
460 static char buf[64];
461 char *s;
462
463 if ((mode & S_IFMT) == 0)
464 s = "";
465 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
466 sprintf(buf, "%#o", mode);
467 return buf;
468 }
469 sprintf(buf, "%s%s%s%s", s,
470 (mode & S_ISUID) ? "|S_ISUID" : "",
471 (mode & S_ISGID) ? "|S_ISGID" : "",
472 (mode & S_ISVTX) ? "|S_ISVTX" : "");
473 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
474 if (mode)
475 sprintf(buf + strlen(buf), "|%#o", mode);
476 s = (*buf == '|') ? buf + 1 : buf;
477 return *s ? s : "0";
478}
479
480static char *
481sprinttime(t)
482time_t t;
483{
484 struct tm *tmp;
485 static char buf[32];
486
487 if (t == 0) {
488 sprintf(buf, "0");
489 return buf;
490 }
491 tmp = localtime(&t);
492 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
Wichert Akkerman3ed6dc22000-01-11 14:41:09 +0000493 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000494 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
495 return buf;
496}
497
498#ifdef LINUXSPARC
499typedef struct {
500 int tv_sec;
501 int tv_nsec;
502} timestruct_t;
503
504struct solstat {
505 unsigned st_dev;
506 int st_pad1[3]; /* network id */
507 unsigned st_ino;
508 unsigned st_mode;
509 unsigned st_nlink;
510 unsigned st_uid;
511 unsigned st_gid;
512 unsigned st_rdev;
513 int st_pad2[2];
514 int st_size;
515 int st_pad3; /* st_size, off_t expansion */
516 timestruct_t st_atime;
517 timestruct_t st_mtime;
518 timestruct_t st_ctime;
519 int st_blksize;
520 int st_blocks;
521 char st_fstype[16];
522 int st_pad4[8]; /* expansion area */
523};
524
525static void
526printstatsol(tcp, addr)
527struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000528long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000529{
530 struct solstat statbuf;
531
532 if (!addr) {
533 tprintf("NULL");
534 return;
535 }
536 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000537 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000538 return;
539 }
540 if (umove(tcp, addr, &statbuf) < 0) {
541 tprintf("{...}");
542 return;
543 }
544 if (!abbrev(tcp)) {
545 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
546 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
547 (unsigned long) (statbuf.st_dev & 0x3ffff),
548 (unsigned long) statbuf.st_ino,
549 sprintmode(statbuf.st_mode));
550 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
551 (unsigned long) statbuf.st_nlink,
552 (unsigned long) statbuf.st_uid,
553 (unsigned long) statbuf.st_gid);
554 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
555 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
556 }
557 else
558 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
559 switch (statbuf.st_mode & S_IFMT) {
560 case S_IFCHR: case S_IFBLK:
561 tprintf("st_rdev=makedev(%lu, %lu), ",
562 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
563 (unsigned long) (statbuf.st_rdev & 0x3ffff));
564 break;
565 default:
566 tprintf("st_size=%u, ", statbuf.st_size);
567 break;
568 }
569 if (!abbrev(tcp)) {
570 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
571 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
572 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
573 }
574 else
575 tprintf("...}");
576}
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000577#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000578
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000579#ifdef FREEBSD
580static struct xlat fileflags[] = {
581 { UF_NODUMP, "UF_NODUMP" },
582 { UF_IMMUTABLE, "UF_IMMUTABLE" },
583 { UF_APPEND, "UF_APPEND" },
584 { UF_OPAQUE, "UF_OPAQUE" },
585 { UF_NOUNLINK, "UF_NOUNLINK" },
586 { SF_ARCHIVED, "SF_ARCHIVED" },
587 { SF_IMMUTABLE, "SF_IMMUTABLE" },
588 { SF_APPEND, "SF_APPEND" },
589 { SF_NOUNLINK, "SF_NOUNLINK" },
590 { 0, NULL },
591};
592
593int
594sys_chflags(tcp)
595struct tcb *tcp;
596{
597 if (entering(tcp)) {
598 printpath(tcp, tcp->u_arg[0]);
599 tprintf(", ");
600 if (tcp->u_arg[1])
601 printflags(fileflags, tcp->u_arg[1]);
602 else
603 tprintf("0");
604 }
605 return 0;
606}
607
608int
609sys_fchflags(tcp)
610struct tcb *tcp;
611{
612 if (entering(tcp)) {
613 tprintf("%ld, ", tcp->u_arg[0]);
614 if (tcp->u_arg[1])
615 printflags(fileflags, tcp->u_arg[1]);
616 else
617 tprintf("0");
618 }
619 return 0;
620}
621#endif
622
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000623static void
624realprintstat(tcp, statbuf)
625struct tcb *tcp;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000626struct stat *statbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000627{
628 if (!abbrev(tcp)) {
629 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
630 (unsigned long) major(statbuf->st_dev),
631 (unsigned long) minor(statbuf->st_dev),
632 (unsigned long) statbuf->st_ino,
633 sprintmode(statbuf->st_mode));
634 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
635 (unsigned long) statbuf->st_nlink,
636 (unsigned long) statbuf->st_uid,
637 (unsigned long) statbuf->st_gid);
638#ifdef HAVE_ST_BLKSIZE
639 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
640#endif /* HAVE_ST_BLKSIZE */
641#ifdef HAVE_ST_BLOCKS
642 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
643#endif /* HAVE_ST_BLOCKS */
644 }
645 else
646 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
647 switch (statbuf->st_mode & S_IFMT) {
648 case S_IFCHR: case S_IFBLK:
649#ifdef HAVE_ST_RDEV
650 tprintf("st_rdev=makedev(%lu, %lu), ",
651 (unsigned long) major(statbuf->st_rdev),
652 (unsigned long) minor(statbuf->st_rdev));
653#else /* !HAVE_ST_RDEV */
654 tprintf("st_size=makedev(%lu, %lu), ",
655 (unsigned long) major(statbuf->st_size),
656 (unsigned long) minor(statbuf->st_size));
657#endif /* !HAVE_ST_RDEV */
658 break;
659 default:
660 tprintf("st_size=%lu, ", statbuf->st_size);
661 break;
662 }
663 if (!abbrev(tcp)) {
664 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
665 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000666#ifndef FREEBSD
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000667 tprintf("st_ctime=%s}", sprinttime(statbuf->st_ctime));
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000668#else /* FREEBSD */
669 tprintf("st_ctime=%s, ", sprinttime(statbuf->st_ctime));
670 tprintf("st_flags=");
671 if (statbuf->st_flags) {
672 printflags(fileflags, statbuf->st_flags);
673 } else
674 tprintf("0");
675 tprintf(", st_gen=%u}", statbuf->st_gen);
676#endif /* FREEBSD */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000677 }
678 else
679 tprintf("...}");
680}
681
Nate Sammons771a6ff1999-04-05 22:39:31 +0000682
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000683static void
684printstat(tcp, addr)
685struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000686long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000687{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000688 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000689
690#ifdef LINUXSPARC
691 if (current_personality == 1) {
692 printstatsol(tcp, addr);
693 return;
694 }
695#endif /* LINUXSPARC */
696
697 if (!addr) {
698 tprintf("NULL");
699 return;
700 }
701 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000702 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000703 return;
704 }
705 if (umove(tcp, addr, &statbuf) < 0) {
706 tprintf("{...}");
707 return;
708 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000709
710 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000711}
712
Wichert Akkermanc7926982000-04-10 22:22:31 +0000713#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000714static void
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000715printstat64(tcp, addr)
716struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000717long addr;
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000718{
719 struct stat64 statbuf;
720
721#ifdef LINUXSPARC
722 if (current_personality == 1) {
723 printstatsol(tcp, addr);
724 return;
725 }
726#endif /* LINUXSPARC */
727
728 if (!addr) {
729 tprintf("NULL");
730 return;
731 }
732 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000733 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000734 return;
735 }
736 if (umove(tcp, addr, &statbuf) < 0) {
737 tprintf("{...}");
738 return;
739 }
740
741 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +0000742#ifdef HAVE_LONG_LONG
743 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
744#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000745 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
Wichert Akkermand077c452000-08-10 18:16:15 +0000746#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000747 (unsigned long) major(statbuf.st_dev),
748 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +0000749#ifdef HAVE_LONG_LONG
750 (unsigned long long) statbuf.st_ino,
751#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000752 (unsigned long) statbuf.st_ino,
Wichert Akkermand077c452000-08-10 18:16:15 +0000753#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000754 sprintmode(statbuf.st_mode));
755 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
756 (unsigned long) statbuf.st_nlink,
757 (unsigned long) statbuf.st_uid,
758 (unsigned long) statbuf.st_gid);
759#ifdef HAVE_ST_BLKSIZE
760 tprintf("st_blksize=%lu, ",
761 (unsigned long) statbuf.st_blksize);
762#endif /* HAVE_ST_BLKSIZE */
763#ifdef HAVE_ST_BLOCKS
764 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
765#endif /* HAVE_ST_BLOCKS */
766 }
767 else
768 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
769 switch (statbuf.st_mode & S_IFMT) {
770 case S_IFCHR: case S_IFBLK:
771#ifdef HAVE_ST_RDEV
772 tprintf("st_rdev=makedev(%lu, %lu), ",
773 (unsigned long) major(statbuf.st_rdev),
774 (unsigned long) minor(statbuf.st_rdev));
775#else /* !HAVE_ST_RDEV */
776 tprintf("st_size=makedev(%lu, %lu), ",
777 (unsigned long) major(statbuf.st_size),
778 (unsigned long) minor(statbuf.st_size));
779#endif /* !HAVE_ST_RDEV */
780 break;
781 default:
782 tprintf("st_size=%llu, ", statbuf.st_size);
783 break;
784 }
785 if (!abbrev(tcp)) {
786 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
787 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
788 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
789 }
790 else
791 tprintf("...}");
792}
Wichert Akkermanc7926982000-04-10 22:22:31 +0000793#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000794
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000795#if defined(linux) && !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000796static void
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000797convertoldstat(oldbuf, newbuf)
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000798const struct __old_kernel_stat *oldbuf;
799struct stat *newbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000800{
801 newbuf->st_dev=oldbuf->st_dev;
802 newbuf->st_ino=oldbuf->st_ino;
803 newbuf->st_mode=oldbuf->st_mode;
804 newbuf->st_nlink=oldbuf->st_nlink;
805 newbuf->st_uid=oldbuf->st_uid;
806 newbuf->st_gid=oldbuf->st_gid;
807 newbuf->st_rdev=oldbuf->st_rdev;
808 newbuf->st_size=oldbuf->st_size;
809 newbuf->st_atime=oldbuf->st_atime;
810 newbuf->st_mtime=oldbuf->st_mtime;
811 newbuf->st_ctime=oldbuf->st_ctime;
812 newbuf->st_blksize=0; /* not supported in old_stat */
813 newbuf->st_blocks=0; /* not supported in old_stat */
814}
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000815
816
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000817static void
818printoldstat(tcp, addr)
819struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000820long addr;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000821{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000822 struct __old_kernel_stat statbuf;
823 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000824
825#ifdef LINUXSPARC
826 if (current_personality == 1) {
827 printstatsol(tcp, addr);
828 return;
829 }
830#endif /* LINUXSPARC */
831
832 if (!addr) {
833 tprintf("NULL");
834 return;
835 }
836 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000837 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000838 return;
839 }
840 if (umove(tcp, addr, &statbuf) < 0) {
841 tprintf("{...}");
842 return;
843 }
844
845 convertoldstat(&statbuf, &newstatbuf);
846 realprintstat(tcp, &newstatbuf);
847}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000848#endif /* linux && !IA64 */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000849
850
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000851int
852sys_stat(tcp)
853struct tcb *tcp;
854{
855 if (entering(tcp)) {
856 printpath(tcp, tcp->u_arg[0]);
857 tprintf(", ");
858 } else {
859 printstat(tcp, tcp->u_arg[1]);
860 }
861 return 0;
862}
863
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000864#ifdef linux
865int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000866sys_stat64(tcp)
867struct tcb *tcp;
868{
869#ifdef HAVE_STAT64
870 if (entering(tcp)) {
871 printpath(tcp, tcp->u_arg[0]);
872 tprintf(", ");
873 } else {
874 printstat64(tcp, tcp->u_arg[1]);
875 }
876 return 0;
877#else
878 return printargs(tcp);
879#endif
880}
881
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000882# if !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000883int
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000884sys_oldstat(tcp)
885struct tcb *tcp;
886{
887 if (entering(tcp)) {
888 printpath(tcp, tcp->u_arg[0]);
889 tprintf(", ");
890 } else {
891 printoldstat(tcp, tcp->u_arg[1]);
892 }
893 return 0;
894}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000895# endif /* !IA64 */
896#endif /* linux */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000897
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000898int
899sys_fstat(tcp)
900struct tcb *tcp;
901{
902 if (entering(tcp))
903 tprintf("%ld, ", tcp->u_arg[0]);
904 else {
905 printstat(tcp, tcp->u_arg[1]);
906 }
907 return 0;
908}
909
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000910#ifdef linux
911int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000912sys_fstat64(tcp)
913struct tcb *tcp;
914{
915#ifdef HAVE_STAT64
916 if (entering(tcp))
917 tprintf("%ld, ", tcp->u_arg[0]);
918 else {
919 printstat64(tcp, tcp->u_arg[1]);
920 }
921 return 0;
922#else
923 return printargs(tcp);
924#endif
925}
926
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000927# if !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000928int
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000929sys_oldfstat(tcp)
930struct tcb *tcp;
931{
932 if (entering(tcp))
933 tprintf("%ld, ", tcp->u_arg[0]);
934 else {
935 printoldstat(tcp, tcp->u_arg[1]);
936 }
937 return 0;
938}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000939# endif /* !IA64 */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000940#endif
941
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000942int
943sys_lstat(tcp)
944struct tcb *tcp;
945{
946 if (entering(tcp)) {
947 printpath(tcp, tcp->u_arg[0]);
948 tprintf(", ");
949 } else {
950 printstat(tcp, tcp->u_arg[1]);
951 }
952 return 0;
953}
954
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000955#ifdef linux
956int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000957sys_lstat64(tcp)
958struct tcb *tcp;
959{
960#ifdef HAVE_STAT64
961 if (entering(tcp)) {
962 printpath(tcp, tcp->u_arg[0]);
963 tprintf(", ");
964 } else {
965 printstat64(tcp, tcp->u_arg[1]);
966 }
967 return 0;
968#else
969 return printargs(tcp);
970#endif
971}
972
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000973# if !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000974int
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000975sys_oldlstat(tcp)
976struct tcb *tcp;
977{
978 if (entering(tcp)) {
979 printpath(tcp, tcp->u_arg[0]);
980 tprintf(", ");
981 } else {
982 printoldstat(tcp, tcp->u_arg[1]);
983 }
984 return 0;
985}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000986# endif /* !IA64 */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000987#endif
988
989
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000990#if defined(SVR4) || defined(LINUXSPARC)
991
992int
993sys_xstat(tcp)
994struct tcb *tcp;
995{
996 if (entering(tcp)) {
997 tprintf("%ld, ", tcp->u_arg[0]);
998 printpath(tcp, tcp->u_arg[1]);
999 tprintf(", ");
1000 } else {
1001 printstat(tcp, tcp->u_arg[2]);
1002 }
1003 return 0;
1004}
1005
1006int
1007sys_fxstat(tcp)
1008struct tcb *tcp;
1009{
1010 if (entering(tcp))
1011 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1012 else {
1013 printstat(tcp, tcp->u_arg[2]);
1014 }
1015 return 0;
1016}
1017
1018int
1019sys_lxstat(tcp)
1020struct tcb *tcp;
1021{
1022 if (entering(tcp)) {
1023 tprintf("%ld, ", tcp->u_arg[0]);
1024 printpath(tcp, tcp->u_arg[1]);
1025 tprintf(", ");
1026 } else {
1027 printstat(tcp, tcp->u_arg[2]);
1028 }
1029 return 0;
1030}
1031
1032int
1033sys_xmknod(tcp)
1034struct tcb *tcp;
1035{
1036 int mode = tcp->u_arg[2];
1037
1038 if (entering(tcp)) {
1039 tprintf("%ld, ", tcp->u_arg[0]);
1040 printpath(tcp, tcp->u_arg[1]);
1041 tprintf(", %s", sprintmode(mode));
1042 switch (mode & S_IFMT) {
1043 case S_IFCHR: case S_IFBLK:
1044#ifdef LINUXSPARC
1045 tprintf(", makedev(%lu, %lu)",
1046 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1047 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1048#else
1049 tprintf(", makedev(%lu, %lu)",
1050 (unsigned long) major(tcp->u_arg[3]),
1051 (unsigned long) minor(tcp->u_arg[3]));
1052#endif
1053 break;
1054 default:
1055 break;
1056 }
1057 }
1058 return 0;
1059}
1060
Wichert Akkerman8829a551999-06-11 13:18:40 +00001061#ifdef HAVE_SYS_ACL_H
1062
1063#include <sys/acl.h>
1064
1065struct xlat aclcmds[] = {
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001066#ifdef SETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001067 { SETACL, "SETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001068#endif
1069#ifdef GETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001070 { GETACL, "GETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001071#endif
1072#ifdef GETACLCNT
Wichert Akkerman8829a551999-06-11 13:18:40 +00001073 { GETACLCNT, "GETACLCNT" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001074#endif
1075#ifdef ACL_GET
1076 { ACL_GET, "ACL_GET" },
1077#endif
1078#ifdef ACL_SET
1079 { ACL_SET, "ACL_SET" },
1080#endif
1081#ifdef ACL_CNT
1082 { ACL_CNT, "ACL_CNT" },
1083#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +00001084 { 0, NULL },
1085};
1086
1087int
1088sys_acl(tcp)
1089struct tcb *tcp;
1090{
1091 if (entering(tcp)) {
1092 printpath(tcp, tcp->u_arg[0]);
1093 tprintf(", ");
1094 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1095 tprintf(", %ld", tcp->u_arg[2]);
1096 /*
1097 * FIXME - dump out the list of aclent_t's pointed to
1098 * by "tcp->u_arg[3]" if it's not NULL.
1099 */
1100 if (tcp->u_arg[3])
1101 tprintf(", %#lx", tcp->u_arg[3]);
1102 else
1103 tprintf(", NULL");
1104 }
1105 return 0;
1106}
1107
1108
1109int
1110sys_facl(tcp)
1111struct tcb *tcp;
1112{
1113 if (entering(tcp)) {
1114 tprintf("%ld, ", tcp->u_arg[0]);
1115 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1116 tprintf(", %ld", tcp->u_arg[2]);
1117 /*
1118 * FIXME - dump out the list of aclent_t's pointed to
1119 * by "tcp->u_arg[3]" if it's not NULL.
1120 */
1121 if (tcp->u_arg[3])
1122 tprintf(", %#lx", tcp->u_arg[3]);
1123 else
1124 tprintf(", NULL");
1125 }
1126 return 0;
1127}
1128
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001129
1130struct xlat aclipc[] = {
1131#ifdef IPC_SHM
1132 { IPC_SHM, "IPC_SHM" },
1133#endif
1134#ifdef IPC_SEM
1135 { IPC_SEM, "IPC_SEM" },
1136#endif
1137#ifdef IPC_MSG
1138 { IPC_MSG, "IPC_MSG" },
1139#endif
1140 { 0, NULL },
1141};
1142
1143
1144int
1145sys_aclipc(tcp)
1146struct tcb *tcp;
1147{
1148 if (entering(tcp)) {
1149 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1150 tprintf(", %#lx, ", tcp->u_arg[1]);
1151 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1152 tprintf(", %ld", tcp->u_arg[3]);
1153 /*
1154 * FIXME - dump out the list of aclent_t's pointed to
1155 * by "tcp->u_arg[4]" if it's not NULL.
1156 */
1157 if (tcp->u_arg[4])
1158 tprintf(", %#lx", tcp->u_arg[4]);
1159 else
1160 tprintf(", NULL");
1161 }
1162 return 0;
1163}
1164
1165
1166
Wichert Akkerman8829a551999-06-11 13:18:40 +00001167#endif /* HAVE_SYS_ACL_H */
1168
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001169#endif /* SVR4 || LINUXSPARC */
1170
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001171#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001172
1173static struct xlat fsmagic[] = {
Wichert Akkerman43a74822000-06-27 17:33:32 +00001174 { 0x73757245, "CODA_SUPER_MAGIC" },
1175 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1176 { 0x1373, "DEVFS_SUPER_MAGIC" },
1177 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1178 { 0x414A53, "EFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001179 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1180 { 0xef53, "EXT2_SUPER_MAGIC" },
1181 { 0x137d, "EXT_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001182 { 0xf995e849, "HPFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001183 { 0x9660, "ISOFS_SUPER_MAGIC" },
1184 { 0x137f, "MINIX_SUPER_MAGIC" },
1185 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001186 { 0x2468, "MINIX2_SUPER_MAGIC" },
1187 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001188 { 0x4d44, "MSDOS_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001189 { 0x564c, "NCP_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001190 { 0x6969, "NFS_SUPER_MAGIC" },
1191 { 0x9fa0, "PROC_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001192 { 0x002f, "QNX4_SUPER_MAGIC" },
1193 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1194 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1195 { 0x517b, "SMB_SUPER_MAGIC" },
1196 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1197 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1198 { 0x00011954, "UFS_MAGIC" },
1199 { 0x54190100, "UFS_CIGAM" },
1200 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001201 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1202 { 0, NULL },
1203};
1204
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001205#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001206
1207#ifndef SVR4
1208
1209static char *
1210sprintfstype(magic)
1211int magic;
1212{
1213 static char buf[32];
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001214#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001215 char *s;
1216
1217 s = xlookup(fsmagic, magic);
1218 if (s) {
1219 sprintf(buf, "\"%s\"", s);
1220 return buf;
1221 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001222#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001223 sprintf(buf, "%#x", magic);
1224 return buf;
1225}
1226
1227static void
1228printstatfs(tcp, addr)
1229struct tcb *tcp;
1230long addr;
1231{
1232 struct statfs statbuf;
1233
1234 if (syserror(tcp) || !verbose(tcp)) {
1235 tprintf("%#lx", addr);
1236 return;
1237 }
1238 if (umove(tcp, addr, &statbuf) < 0) {
1239 tprintf("{...}");
1240 return;
1241 }
1242#ifdef ALPHA
1243
1244 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1245 sprintfstype(statbuf.f_type),
1246 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001247 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001248 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1249#else /* !ALPHA */
1250 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1251 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +00001252 (unsigned long)statbuf.f_bsize,
1253 (unsigned long)statbuf.f_blocks,
1254 (unsigned long)statbuf.f_bfree);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001255 tprintf("f_files=%lu, f_ffree=%lu",
Nate Sammons5c74d201999-04-06 01:37:51 +00001256 (unsigned long)statbuf.f_files,
1257 (unsigned long)statbuf.f_ffree);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001258#ifdef linux
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001259 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001260#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001261#endif /* !ALPHA */
1262 tprintf("}");
1263}
1264
1265int
1266sys_statfs(tcp)
1267struct tcb *tcp;
1268{
1269 if (entering(tcp)) {
1270 printpath(tcp, tcp->u_arg[0]);
1271 tprintf(", ");
1272 } else {
1273 printstatfs(tcp, tcp->u_arg[1]);
1274 }
1275 return 0;
1276}
1277
1278int
1279sys_fstatfs(tcp)
1280struct tcb *tcp;
1281{
1282 if (entering(tcp)) {
1283 tprintf("%lu, ", tcp->u_arg[0]);
1284 } else {
1285 printstatfs(tcp, tcp->u_arg[1]);
1286 }
1287 return 0;
1288}
1289
Wichert Akkermana0f36c61999-04-16 14:01:34 +00001290#if defined(linux) && defined(__alpha)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001291
1292int
1293osf_statfs(tcp)
1294struct tcb *tcp;
1295{
1296 if (entering(tcp)) {
1297 printpath(tcp, tcp->u_arg[0]);
1298 tprintf(", ");
1299 } else {
1300 printstatfs(tcp, tcp->u_arg[1]);
1301 tprintf(", %lu", tcp->u_arg[2]);
1302 }
1303 return 0;
1304}
1305
1306int
1307osf_fstatfs(tcp)
1308struct tcb *tcp;
1309{
1310 if (entering(tcp)) {
1311 tprintf("%lu, ", tcp->u_arg[0]);
1312 } else {
1313 printstatfs(tcp, tcp->u_arg[1]);
1314 tprintf(", %lu", tcp->u_arg[2]);
1315 }
1316 return 0;
1317}
Wichert Akkermana0f36c61999-04-16 14:01:34 +00001318#endif /* linux && __alpha */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001319
1320#endif /* !SVR4 */
1321
1322#ifdef SUNOS4
1323
1324int
1325sys_ustat(tcp)
1326struct tcb *tcp;
1327{
1328 struct ustat statbuf;
1329
1330 if (entering(tcp)) {
1331 tprintf("makedev(%lu, %lu), ",
1332 (long) major(tcp->u_arg[0]),
1333 (long) minor(tcp->u_arg[0]));
1334 }
1335 else {
1336 if (syserror(tcp) || !verbose(tcp))
1337 tprintf("%#lx", tcp->u_arg[1]);
1338 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1339 tprintf("{...}");
1340 else {
1341 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1342 statbuf.f_tfree, statbuf.f_tinode);
1343 tprintf("f_fname=\"%.*s\", ",
1344 (int) sizeof(statbuf.f_fname),
1345 statbuf.f_fname);
1346 tprintf("f_fpack=\"%.*s\"}",
1347 (int) sizeof(statbuf.f_fpack),
1348 statbuf.f_fpack);
1349 }
1350 }
1351 return 0;
1352}
1353
1354#endif /* SUNOS4 */
1355
Wichert Akkermanc7926982000-04-10 22:22:31 +00001356int
1357sys_pivotroot(tcp)
1358struct tcb *tcp;
1359{
1360 if (entering(tcp)) {
1361 printpath(tcp, tcp->u_arg[0]);
1362 tprintf(", ");
1363 printpath(tcp, tcp->u_arg[1]);
1364 }
1365 return 0;
1366}
1367
1368
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001369/* directory */
1370int
1371sys_chdir(tcp)
1372struct tcb *tcp;
1373{
1374 if (entering(tcp)) {
1375 printpath(tcp, tcp->u_arg[0]);
1376 }
1377 return 0;
1378}
1379
1380int
1381sys_mkdir(tcp)
1382struct tcb *tcp;
1383{
1384 if (entering(tcp)) {
1385 printpath(tcp, tcp->u_arg[0]);
1386 tprintf(", %#lo", tcp->u_arg[1]);
1387 }
1388 return 0;
1389}
1390
1391int
1392sys_rmdir(tcp)
1393struct tcb *tcp;
1394{
1395 if (entering(tcp)) {
1396 printpath(tcp, tcp->u_arg[0]);
1397 }
1398 return 0;
1399}
1400
1401int
1402sys_fchdir(tcp)
1403struct tcb *tcp;
1404{
1405 if (entering(tcp)) {
1406 tprintf("%ld", tcp->u_arg[0]);
1407 }
1408 return 0;
1409}
1410
1411int
1412sys_chroot(tcp)
1413struct tcb *tcp;
1414{
1415 if (entering(tcp)) {
1416 printpath(tcp, tcp->u_arg[0]);
1417 }
1418 return 0;
1419}
1420
1421int
1422sys_fchroot(tcp)
1423struct tcb *tcp;
1424{
1425 if (entering(tcp)) {
1426 tprintf("%ld", tcp->u_arg[0]);
1427 }
1428 return 0;
1429}
1430
1431int
1432sys_link(tcp)
1433struct tcb *tcp;
1434{
1435 if (entering(tcp)) {
1436 printpath(tcp, tcp->u_arg[0]);
1437 tprintf(", ");
1438 printpath(tcp, tcp->u_arg[1]);
1439 }
1440 return 0;
1441}
1442
1443int
1444sys_unlink(tcp)
1445struct tcb *tcp;
1446{
1447 if (entering(tcp)) {
1448 printpath(tcp, tcp->u_arg[0]);
1449 }
1450 return 0;
1451}
1452
1453int
1454sys_symlink(tcp)
1455struct tcb *tcp;
1456{
1457 if (entering(tcp)) {
1458 printpath(tcp, tcp->u_arg[0]);
1459 tprintf(", ");
1460 printpath(tcp, tcp->u_arg[1]);
1461 }
1462 return 0;
1463}
1464
1465int
1466sys_readlink(tcp)
1467struct tcb *tcp;
1468{
1469 if (entering(tcp)) {
1470 printpath(tcp, tcp->u_arg[0]);
1471 tprintf(", ");
1472 } else {
1473 if (syserror(tcp))
1474 tprintf("%#lx", tcp->u_arg[1]);
1475 else
1476 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1477 tprintf(", %lu", tcp->u_arg[2]);
1478 }
1479 return 0;
1480}
1481
1482int
1483sys_rename(tcp)
1484struct tcb *tcp;
1485{
1486 if (entering(tcp)) {
1487 printpath(tcp, tcp->u_arg[0]);
1488 tprintf(", ");
1489 printpath(tcp, tcp->u_arg[1]);
1490 }
1491 return 0;
1492}
1493
1494int
1495sys_chown(tcp)
1496struct tcb *tcp;
1497{
1498 if (entering(tcp)) {
1499 printpath(tcp, tcp->u_arg[0]);
1500 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1501 }
1502 return 0;
1503}
1504
1505int
1506sys_fchown(tcp)
1507struct tcb *tcp;
1508{
1509 if (entering(tcp)) {
1510 tprintf("%ld, %lu, %lu",
1511 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1512 }
1513 return 0;
1514}
1515
1516int
1517sys_chmod(tcp)
1518struct tcb *tcp;
1519{
1520 if (entering(tcp)) {
1521 printpath(tcp, tcp->u_arg[0]);
1522 tprintf(", %#lo", tcp->u_arg[1]);
1523 }
1524 return 0;
1525}
1526
1527int
1528sys_fchmod(tcp)
1529struct tcb *tcp;
1530{
1531 if (entering(tcp)) {
1532 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1533 }
1534 return 0;
1535}
1536
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001537#ifdef ALPHA
1538int
1539sys_osf_utimes(tcp)
1540struct tcb *tcp;
1541{
1542 if (entering(tcp)) {
1543 printpath(tcp, tcp->u_arg[0]);
1544 tprintf(", ");
1545 printtv32(tcp, tcp->u_arg[1]);
1546 }
1547 return 0;
1548}
1549#endif
1550
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001551int
1552sys_utimes(tcp)
1553struct tcb *tcp;
1554{
1555 if (entering(tcp)) {
1556 printpath(tcp, tcp->u_arg[0]);
1557 tprintf(", ");
1558 printtv(tcp, tcp->u_arg[1]);
1559 }
1560 return 0;
1561}
1562
1563int
1564sys_utime(tcp)
1565struct tcb *tcp;
1566{
1567 long ut[2];
1568
1569 if (entering(tcp)) {
1570 printpath(tcp, tcp->u_arg[0]);
1571 tprintf(", ");
1572 if (!tcp->u_arg[1])
1573 tprintf("NULL");
1574 else if (!verbose(tcp))
1575 tprintf("%#lx", tcp->u_arg[1]);
1576 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1577 (char *) ut) < 0)
1578 tprintf("[?, ?]");
1579 else {
1580 tprintf("[%s,", sprinttime(ut[0]));
1581 tprintf(" %s]", sprinttime(ut[1]));
1582 }
1583 }
1584 return 0;
1585}
1586
1587int
1588sys_mknod(tcp)
1589struct tcb *tcp;
1590{
1591 int mode = tcp->u_arg[1];
1592
1593 if (entering(tcp)) {
1594 printpath(tcp, tcp->u_arg[0]);
1595 tprintf(", %s", sprintmode(mode));
1596 switch (mode & S_IFMT) {
1597 case S_IFCHR: case S_IFBLK:
1598#ifdef LINUXSPARC
1599 if (current_personality == 1)
1600 tprintf(", makedev(%lu, %lu)",
1601 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1602 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1603 else
1604#endif
1605 tprintf(", makedev(%lu, %lu)",
1606 (unsigned long) major(tcp->u_arg[2]),
1607 (unsigned long) minor(tcp->u_arg[2]));
1608 break;
1609 default:
1610 break;
1611 }
1612 }
1613 return 0;
1614}
1615
1616int
1617sys_mkfifo(tcp)
1618struct tcb *tcp;
1619{
1620 if (entering(tcp)) {
1621 printpath(tcp, tcp->u_arg[0]);
1622 tprintf(", %#lo", tcp->u_arg[1]);
1623 }
1624 return 0;
1625}
1626
1627int
1628sys_fsync(tcp)
1629struct tcb *tcp;
1630{
1631 if (entering(tcp)) {
1632 tprintf("%ld", tcp->u_arg[0]);
1633 }
1634 return 0;
1635}
1636
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001637#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001638
1639static void
1640printdir(tcp, addr)
1641struct tcb *tcp;
1642long addr;
1643{
1644 struct dirent d;
1645
1646 if (!verbose(tcp)) {
1647 tprintf("%#lx", addr);
1648 return;
1649 }
1650 if (umove(tcp, addr, &d) < 0) {
1651 tprintf("{...}");
1652 return;
1653 }
1654 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001655 tprintf("d_name=");
1656 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1657 tprintf("}");
1658}
1659
1660int
1661sys_readdir(tcp)
1662struct tcb *tcp;
1663{
1664 if (entering(tcp)) {
1665 tprintf("%lu, ", tcp->u_arg[0]);
1666 } else {
1667 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1668 tprintf("%#lx", tcp->u_arg[1]);
1669 else
1670 printdir(tcp, tcp->u_arg[1]);
1671 /* Not much point in printing this out, it is always 1. */
1672 if (tcp->u_arg[2] != 1)
1673 tprintf(", %lu", tcp->u_arg[2]);
1674 }
1675 return 0;
1676}
1677
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001678#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001679
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001680#ifdef FREEBSD
1681struct xlat direnttypes[] = {
1682 { DT_FIFO, "DT_FIFO" },
1683 { DT_CHR, "DT_CHR" },
1684 { DT_DIR, "DT_DIR" },
1685 { DT_BLK, "DT_BLK" },
1686 { DT_REG, "DT_REG" },
1687 { DT_LNK, "DT_LNK" },
1688 { DT_SOCK, "DT_SOCK" },
1689 { DT_WHT, "DT_WHT" },
1690 { 0, NULL },
1691};
1692
1693#endif
1694
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001695int
1696sys_getdents(tcp)
1697struct tcb *tcp;
1698{
1699 int i, len, dents = 0;
1700 char *buf;
1701
1702 if (entering(tcp)) {
1703 tprintf("%lu, ", tcp->u_arg[0]);
1704 return 0;
1705 }
1706 if (syserror(tcp) || !verbose(tcp)) {
1707 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1708 return 0;
1709 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001710 len = tcp->u_rval;
1711 if ((buf = malloc(len)) == NULL) {
1712 tprintf("out of memory\n");
1713 return 0;
1714 }
1715 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1716 tprintf("{...}, %lu", tcp->u_arg[2]);
1717 free(buf);
1718 return 0;
1719 }
1720 if (!abbrev(tcp))
1721 tprintf("{");
1722 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00001723 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001724#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001725 if (!abbrev(tcp)) {
1726 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1727 i ? " " : "", d->d_ino, d->d_off);
1728 tprintf("d_reclen=%u, d_name=\"%s\"}",
1729 d->d_reclen, d->d_name);
1730 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001731#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001732#ifdef SVR4
1733 if (!abbrev(tcp)) {
1734 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1735 i ? " " : "", d->d_ino, d->d_off);
1736 tprintf("d_reclen=%u, d_name=\"%s\"}",
1737 d->d_reclen, d->d_name);
1738 }
1739#endif /* SVR4 */
1740#ifdef SUNOS4
1741 if (!abbrev(tcp)) {
1742 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1743 i ? " " : "", d->d_off, d->d_fileno,
1744 d->d_reclen);
1745 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1746 d->d_namlen, d->d_namlen, d->d_name);
1747 }
1748#endif /* SUNOS4 */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001749#ifdef FREEBSD
1750 if (!abbrev(tcp)) {
1751 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1752 i ? " " : "", d->d_fileno, d->d_reclen);
1753 printxval(direnttypes, d->d_type, "DT_???");
1754 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1755 d->d_namlen, d->d_namlen, d->d_name);
1756 }
1757#endif /* FREEBSD */
Pavel Machek9a9f10b2000-02-01 16:22:52 +00001758 if (!d->d_reclen) {
1759 tprintf("/* d_reclen == 0, problem here */");
1760 break;
1761 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001762 i += d->d_reclen;
1763 dents++;
1764 }
1765 if (!abbrev(tcp))
1766 tprintf("}");
1767 else
1768 tprintf("/* %u entries */", dents);
1769 tprintf(", %lu", tcp->u_arg[2]);
1770 free(buf);
1771 return 0;
1772}
1773
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001774#ifdef FREEBSD
1775int
1776sys_getdirentries(tcp)
1777struct tcb * tcp;
1778{
1779 int i, len, dents = 0;
1780 long basep;
1781 char *buf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001782
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001783 if (entering(tcp)) {
1784 tprintf("%lu, ", tcp->u_arg[0]);
1785 return 0;
1786 }
1787 if (syserror(tcp) || !verbose(tcp)) {
1788 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1789 return 0;
1790 }
1791 len = tcp->u_rval;
1792 if ((buf = malloc(len)) == NULL) {
1793 tprintf("out of memory\n");
1794 return 0;
1795 }
1796 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1797 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
1798 free(buf);
1799 return 0;
1800 }
1801 if (!abbrev(tcp))
1802 tprintf("{");
1803 for (i = 0; i < len;) {
1804 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1805 if (!abbrev(tcp)) {
1806 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1807 i ? " " : "", d->d_fileno, d->d_reclen);
1808 printxval(direnttypes, d->d_type, "DT_???");
1809 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1810 d->d_namlen, d->d_namlen, d->d_name);
1811 }
1812 i += d->d_reclen;
1813 dents++;
1814 }
1815 if (!abbrev(tcp))
1816 tprintf("}");
1817 else
1818 tprintf("/* %u entries */", dents);
1819 free(buf);
1820 tprintf(", %lu", tcp->u_arg[2]);
1821 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
1822 tprintf(", %#lx", tcp->u_arg[3]);
1823 else
1824 tprintf(", [%lu]", basep);
1825 return 0;
1826}
1827#endif
1828
1829#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001830int
1831sys_getcwd(tcp)
1832struct tcb *tcp;
1833{
1834 if (exiting(tcp)) {
1835 if (syserror(tcp))
1836 tprintf("%#lx", tcp->u_arg[0]);
1837 else
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001838 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001839 tprintf(", %lu", tcp->u_arg[1]);
1840 }
1841 return 0;
1842}
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001843#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001844
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001845#ifdef FREEBSD
1846int
1847sys___getcwd(tcp)
1848struct tcb *tcp;
1849{
1850 if (exiting(tcp)) {
1851 if (syserror(tcp))
1852 tprintf("%#lx", tcp->u_arg[0]);
1853 else
1854 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
1855 tprintf(", %lu", tcp->u_arg[1]);
1856 }
1857 return 0;
1858}
1859#endif
1860
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001861#ifdef HAVE_SYS_ASYNCH_H
1862
1863int
1864sys_aioread(tcp)
1865struct tcb *tcp;
1866{
1867 struct aio_result_t res;
1868
1869 if (entering(tcp)) {
1870 tprintf("%lu, ", tcp->u_arg[0]);
1871 } else {
1872 if (syserror(tcp))
1873 tprintf("%#lx", tcp->u_arg[1]);
1874 else
1875 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1876 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
1877 printxval(whence, tcp->u_arg[4], "L_???");
1878 if (syserror(tcp) || tcp->u_arg[5] == 0
1879 || umove(tcp, tcp->u_arg[5], &res) < 0)
1880 tprintf(", %#lx", tcp->u_arg[5]);
1881 else
1882 tprintf(", {aio_return %d aio_errno %d}",
1883 res.aio_return, res.aio_errno);
1884 }
1885 return 0;
1886}
1887
1888int
1889sys_aiowrite(tcp)
1890struct tcb *tcp;
1891{
1892 struct aio_result_t res;
1893
1894 if (entering(tcp)) {
1895 tprintf("%lu, ", tcp->u_arg[0]);
1896 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1897 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
1898 printxval(whence, tcp->u_arg[4], "L_???");
1899 }
1900 else {
1901 if (tcp->u_arg[5] == 0)
1902 tprintf(", NULL");
1903 else if (syserror(tcp)
1904 || umove(tcp, tcp->u_arg[5], &res) < 0)
1905 tprintf(", %#lx", tcp->u_arg[5]);
1906 else
1907 tprintf(", {aio_return %d aio_errno %d}",
1908 res.aio_return, res.aio_errno);
1909 }
1910 return 0;
1911}
1912
1913int
1914sys_aiowait(tcp)
1915struct tcb *tcp;
1916{
1917 if (entering(tcp))
1918 printtv(tcp, tcp->u_arg[0]);
1919 return 0;
1920}
1921
1922int
1923sys_aiocancel(tcp)
1924struct tcb *tcp;
1925{
1926 struct aio_result_t res;
1927
1928 if (exiting(tcp)) {
1929 if (tcp->u_arg[0] == 0)
1930 tprintf("NULL");
1931 else if (syserror(tcp)
1932 || umove(tcp, tcp->u_arg[0], &res) < 0)
1933 tprintf("%#lx", tcp->u_arg[0]);
1934 else
1935 tprintf("{aio_return %d aio_errno %d}",
1936 res.aio_return, res.aio_errno);
1937 }
1938 return 0;
1939}
1940
1941#endif /* HAVE_SYS_ASYNCH_H */
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001942
1943#if UNIXWARE >= 7
1944int
1945sys_lseek64 (tcp)
1946struct tcb *tcp;
1947{
1948 if (entering(tcp)) {
1949 long long offset = * (long long *) & tcp->u_arg [1];
1950 if (tcp->u_arg[3] == SEEK_SET)
1951 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
1952 else
1953 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
1954 printxval(whence, tcp->u_arg[3], "SEEK_???");
1955 }
1956 return RVAL_LDECIMAL;
1957}
1958#endif