blob: f1c8f3ab69a0c97f91f5b57cf9dd445d5a206ac2 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
John Hughese2f6d872001-03-07 16:03:20 +00002#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00003 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
4 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
5 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00006 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00007 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 * $Id$
32 */
33
34#include "defs.h"
35
36#include <dirent.h>
Wichert Akkerman9524bb91999-05-25 23:11:18 +000037#ifdef linux
38#define dirent kernel_dirent
Wichert Akkerman9b0c31d2000-09-03 21:56:29 +000039#define dirent64 kernel_dirent64
Wichert Akkerman9524bb91999-05-25 23:11:18 +000040#include <linux/types.h>
41#include <linux/dirent.h>
42#undef dirent
43#else
44#define kernel_dirent dirent
45#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000046
Wichert Akkerman8bc6cfd1999-04-21 15:57:38 +000047#ifdef linux
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000048# ifdef LINUXSPARC
49struct stat {
50 unsigned short st_dev;
51 unsigned int st_ino;
52 unsigned short st_mode;
53 short st_nlink;
54 unsigned short st_uid;
55 unsigned short st_gid;
56 unsigned short st_rdev;
57 unsigned int st_size;
58 int st_atime;
59 unsigned int __unused1;
60 int st_mtime;
61 unsigned int __unused2;
62 int st_ctime;
63 unsigned int __unused3;
64 int st_blksize;
65 int st_blocks;
66 unsigned int __unused4[2];
67};
68# define stat kernel_stat
69# include <asm/stat.h>
70# undef stat
71# else
Wichert Akkerman5b4d1281999-07-09 00:32:54 +000072# undef dev_t
73# undef ino_t
74# undef mode_t
75# undef nlink_t
76# undef uid_t
77# undef gid_t
78# undef off_t
79# undef loff_t
80
Wichert Akkermana6013701999-07-08 14:00:58 +000081# define dev_t __kernel_dev_t
82# define ino_t __kernel_ino_t
83# define mode_t __kernel_mode_t
84# define nlink_t __kernel_nlink_t
85# define uid_t __kernel_uid_t
86# define gid_t __kernel_gid_t
87# define off_t __kernel_off_t
88# define loff_t __kernel_loff_t
89
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000090# include <asm/stat.h>
Wichert Akkermana6013701999-07-08 14:00:58 +000091
92# undef dev_t
93# undef ino_t
94# undef mode_t
95# undef nlink_t
96# undef uid_t
97# undef gid_t
98# undef off_t
99# undef loff_t
Wichert Akkerman5b4d1281999-07-09 00:32:54 +0000100
101# define dev_t dev_t
102# define ino_t ino_t
103# define mode_t mode_t
104# define nlink_t nlink_t
105# define uid_t uid_t
106# define gid_t gid_t
107# define off_t off_t
108# define loff_t loff_t
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000109# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000110# define stat libc_stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000111# define stat64 libc_stat64
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000112# include <sys/stat.h>
113# undef stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000114# undef stat64
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000115#else
116# include <sys/stat.h>
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000117#endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000118
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000119#include <fcntl.h>
120
121#ifdef SVR4
122# include <sys/cred.h>
123#endif /* SVR4 */
124
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000125#ifdef HAVE_SYS_VFS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000126#include <sys/vfs.h>
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000127#endif
128
129#ifdef FREEBSD
130#include <sys/param.h>
131#include <sys/mount.h>
132#include <sys/stat.h>
133#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000134
135#ifdef MAJOR_IN_SYSMACROS
136#include <sys/sysmacros.h>
137#endif
138
139#ifdef MAJOR_IN_MKDEV
140#include <sys/mkdev.h>
141#endif
142
143#ifdef HAVE_SYS_ASYNCH_H
144#include <sys/asynch.h>
145#endif
146
147#ifdef SUNOS4
148#include <ustat.h>
149#endif
150
151/*
152 * This is a really dirty trick but it should always work. Traditional
153 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
154 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
155 */
156struct xlat openmodes[] = {
157 { O_RDWR+1, "O_RDWR" },
158 { O_RDONLY+1, "O_RDONLY" },
159 { O_WRONLY+1, "O_WRONLY" },
160 { O_NONBLOCK, "O_NONBLOCK" },
161 { O_APPEND, "O_APPEND" },
162 { O_CREAT, "O_CREAT" },
163 { O_TRUNC, "O_TRUNC" },
164 { O_EXCL, "O_EXCL" },
165 { O_NOCTTY, "O_NOCTTY" },
166#ifdef O_SYNC
167 { O_SYNC, "O_SYNC" },
168#endif
169#ifdef O_ASYNC
170 { O_ASYNC, "O_ASYNC" },
171#endif
172#ifdef O_DSYNC
173 { O_DSYNC, "O_DSYNC" },
174#endif
175#ifdef O_RSYNC
176 { O_RSYNC, "O_RSYNC" },
177#endif
178#ifdef O_NDELAY
179 { O_NDELAY, "O_NDELAY" },
180#endif
181#ifdef O_PRIV
182 { O_PRIV, "O_PRIV" },
183#endif
184#ifdef O_DIRECT
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000185 { O_DIRECT, "O_DIRECT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000186#endif
187#ifdef O_LARGEFILE
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000188 { O_LARGEFILE, "O_LARGEFILE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000189#endif
190#ifdef O_DIRECTORY
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000191 { O_DIRECTORY, "O_DIRECTORY" },
192#endif
193#ifdef O_NOFOLLOW
194 { O_NOFOLLOW, "O_NOFOLLOW" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000195#endif
196
197#ifdef FNDELAY
198 { FNDELAY, "FNDELAY" },
199#endif
200#ifdef FAPPEND
201 { FAPPEND, "FAPPEND" },
202#endif
203#ifdef FMARK
204 { FMARK, "FMARK" },
205#endif
206#ifdef FDEFER
207 { FDEFER, "FDEFER" },
208#endif
209#ifdef FASYNC
210 { FASYNC, "FASYNC" },
211#endif
212#ifdef FSHLOCK
213 { FSHLOCK, "FSHLOCK" },
214#endif
215#ifdef FEXLOCK
216 { FEXLOCK, "FEXLOCK" },
217#endif
218#ifdef FCREAT
219 { FCREAT, "FCREAT" },
220#endif
221#ifdef FTRUNC
222 { FTRUNC, "FTRUNC" },
223#endif
224#ifdef FEXCL
225 { FEXCL, "FEXCL" },
226#endif
227#ifdef FNBIO
228 { FNBIO, "FNBIO" },
229#endif
230#ifdef FSYNC
231 { FSYNC, "FSYNC" },
232#endif
233#ifdef FNOCTTY
234 { FNOCTTY, "FNOCTTY" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000235#endif
236#ifdef O_SHLOCK
237 { O_SHLOCK, "O_SHLOCK" },
238#endif
239#ifdef O_EXLOCK
240 { O_EXLOCK, "O_EXLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000241#endif
242 { 0, NULL },
243};
244
245int
246sys_open(tcp)
247struct tcb *tcp;
248{
249 if (entering(tcp)) {
250 printpath(tcp, tcp->u_arg[0]);
251 tprintf(", ");
252 /* flags */
253 printflags(openmodes, tcp->u_arg[1] + 1);
254 if (tcp->u_arg[1] & O_CREAT) {
255 /* mode */
256 tprintf(", %#lo", tcp->u_arg[2]);
257 }
258 }
259 return 0;
260}
261
262#ifdef LINUXSPARC
263struct xlat openmodessol[] = {
264 { 0, "O_RDWR" },
265 { 1, "O_RDONLY" },
266 { 2, "O_WRONLY" },
267 { 0x80, "O_NONBLOCK" },
268 { 8, "O_APPEND" },
269 { 0x100, "O_CREAT" },
270 { 0x200, "O_TRUNC" },
271 { 0x400, "O_EXCL" },
272 { 0x800, "O_NOCTTY" },
273 { 0x10, "O_SYNC" },
274 { 0x40, "O_DSYNC" },
275 { 0x8000, "O_RSYNC" },
276 { 4, "O_NDELAY" },
277 { 0x1000, "O_PRIV" },
278 { 0, NULL },
279};
280
281int
282solaris_open(tcp)
283struct tcb *tcp;
284{
285 if (entering(tcp)) {
286 printpath(tcp, tcp->u_arg[0]);
287 tprintf(", ");
288 /* flags */
289 printflags(openmodessol, tcp->u_arg[1] + 1);
290 if (tcp->u_arg[1] & 0x100) {
291 /* mode */
292 tprintf(", %#lo", tcp->u_arg[2]);
293 }
294 }
295 return 0;
296}
297
298#endif
299
300int
301sys_creat(tcp)
302struct tcb *tcp;
303{
304 if (entering(tcp)) {
305 printpath(tcp, tcp->u_arg[0]);
306 tprintf(", %#lo", tcp->u_arg[1]);
307 }
308 return 0;
309}
310
311static struct xlat access_flags[] = {
312 { F_OK, "F_OK", },
313 { R_OK, "R_OK" },
314 { W_OK, "W_OK" },
315 { X_OK, "X_OK" },
316#ifdef EFF_ONLY_OK
317 { EFF_ONLY_OK, "EFF_ONLY_OK" },
318#endif
319#ifdef EX_OK
320 { EX_OK, "EX_OK" },
321#endif
322 { 0, NULL },
323};
324
325int
326sys_access(tcp)
327struct tcb *tcp;
328{
329 if (entering(tcp)) {
330 printpath(tcp, tcp->u_arg[0]);
331 tprintf(", ");
332 printflags(access_flags, tcp->u_arg[1]);
333 }
334 return 0;
335}
336
337int
338sys_umask(tcp)
339struct tcb *tcp;
340{
341 if (entering(tcp)) {
342 tprintf("%#lo", tcp->u_arg[0]);
343 }
344 return RVAL_OCTAL;
345}
346
347static struct xlat whence[] = {
348 { SEEK_SET, "SEEK_SET" },
349 { SEEK_CUR, "SEEK_CUR" },
350 { SEEK_END, "SEEK_END" },
351 { 0, NULL },
352};
353
John Hughes5a826b82001-03-07 13:21:24 +0000354#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000355int
356sys_lseek(tcp)
357struct tcb *tcp;
358{
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000359 off_t offset;
360 int _whence;
361
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000362 if (entering(tcp)) {
363 tprintf("%ld, ", tcp->u_arg[0]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000364 offset = tcp->u_arg[1];
365 _whence = tcp->u_arg[2];
366 if (_whence == SEEK_SET)
367 tprintf("%lu, ", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000368 else
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000369 tprintf("%ld, ", offset);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000370 printxval(whence, _whence, "SEEK_???");
371 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000372 return RVAL_UDECIMAL;
373}
John Hughes5a826b82001-03-07 13:21:24 +0000374#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000375
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000376#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000377int
378sys_llseek (tcp)
379struct tcb *tcp;
380{
381 if (entering(tcp)) {
382 if (tcp->u_arg[4] == SEEK_SET)
383 tprintf("%ld, %llu, ", tcp->u_arg[0],
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000384 (((long long int) tcp->u_arg[1]) << 32
385 | (unsigned long long) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000386 else
387 tprintf("%ld, %lld, ", tcp->u_arg[0],
388 (((long long int) tcp->u_arg[1]) << 32
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000389 | (unsigned long long) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000390 }
391 else {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000392 long long int off;
393 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000394 tprintf("%#lx, ", tcp->u_arg[3]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000395 else
396 tprintf("[%llu], ", off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000397 printxval(whence, tcp->u_arg[4], "SEEK_???");
398 }
399 return 0;
400}
401#endif
402
John Hughes5a826b82001-03-07 13:21:24 +0000403#if _LFS64_LARGEFILE || FREEBSD
John Hughesbdf48f52001-03-06 15:08:09 +0000404int
405sys_lseek64 (tcp)
406struct tcb *tcp;
407{
408 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000409 long long offset;
410 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
411 offset = get64(tcp->u_arg [1], tcp->u_arg[2]);
John Hughesbdf48f52001-03-06 15:08:09 +0000412 if (tcp->u_arg[3] == SEEK_SET)
413 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
414 else
415 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
416 printxval(whence, tcp->u_arg[3], "SEEK_???");
417 }
418 return RVAL_LUDECIMAL;
419}
420#endif
421
John Hughes5a826b82001-03-07 13:21:24 +0000422#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000423int
424sys_truncate(tcp)
425struct tcb *tcp;
426{
427 if (entering(tcp)) {
428 printpath(tcp, tcp->u_arg[0]);
429 tprintf(", %lu", tcp->u_arg[1]);
430 }
431 return 0;
432}
John Hughes5a826b82001-03-07 13:21:24 +0000433#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000434
John Hughes5a826b82001-03-07 13:21:24 +0000435#if _LFS64_LARGEFILE || FREEBSD
John Hughes96f51472001-03-06 16:50:41 +0000436int
437sys_truncate64(tcp)
438struct tcb *tcp;
439{
440 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000441 ALIGN64 (tcp, 1);
John Hughes96f51472001-03-06 16:50:41 +0000442 printpath(tcp, tcp->u_arg[0]);
443 tprintf(", %llu", get64(tcp->u_arg[1],tcp->u_arg[2]));
444 }
445 return 0;
446}
447#endif
448
John Hughes5a826b82001-03-07 13:21:24 +0000449#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000450int
451sys_ftruncate(tcp)
452struct tcb *tcp;
453{
454 if (entering(tcp)) {
455 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
456 }
457 return 0;
458}
John Hughes5a826b82001-03-07 13:21:24 +0000459#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000460
John Hughes5a826b82001-03-07 13:21:24 +0000461#if _LFS64_LARGEFILE || FREEBSD
John Hughes96f51472001-03-06 16:50:41 +0000462int
463sys_ftruncate64(tcp)
464struct tcb *tcp;
465{
466 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000467 ALIGN64 (tcp, 1);
John Hughes96f51472001-03-06 16:50:41 +0000468 tprintf("%ld, %llu", tcp->u_arg[0],
469 get64(tcp->u_arg[1] ,tcp->u_arg[2]));
470 }
471 return 0;
472}
473#endif
474
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000475/* several stats */
476
477static struct xlat modetypes[] = {
478 { S_IFREG, "S_IFREG" },
479 { S_IFSOCK, "S_IFSOCK" },
480 { S_IFIFO, "S_IFIFO" },
481 { S_IFLNK, "S_IFLNK" },
482 { S_IFDIR, "S_IFDIR" },
483 { S_IFBLK, "S_IFBLK" },
484 { S_IFCHR, "S_IFCHR" },
485 { 0, NULL },
486};
487
488static char *
489sprintmode(mode)
490int mode;
491{
492 static char buf[64];
493 char *s;
494
495 if ((mode & S_IFMT) == 0)
496 s = "";
497 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
498 sprintf(buf, "%#o", mode);
499 return buf;
500 }
501 sprintf(buf, "%s%s%s%s", s,
502 (mode & S_ISUID) ? "|S_ISUID" : "",
503 (mode & S_ISGID) ? "|S_ISGID" : "",
504 (mode & S_ISVTX) ? "|S_ISVTX" : "");
505 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
506 if (mode)
507 sprintf(buf + strlen(buf), "|%#o", mode);
508 s = (*buf == '|') ? buf + 1 : buf;
509 return *s ? s : "0";
510}
511
512static char *
513sprinttime(t)
514time_t t;
515{
516 struct tm *tmp;
517 static char buf[32];
518
519 if (t == 0) {
520 sprintf(buf, "0");
521 return buf;
522 }
523 tmp = localtime(&t);
524 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
Wichert Akkerman3ed6dc22000-01-11 14:41:09 +0000525 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000526 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
527 return buf;
528}
529
530#ifdef LINUXSPARC
531typedef struct {
532 int tv_sec;
533 int tv_nsec;
534} timestruct_t;
535
536struct solstat {
537 unsigned st_dev;
538 int st_pad1[3]; /* network id */
539 unsigned st_ino;
540 unsigned st_mode;
541 unsigned st_nlink;
542 unsigned st_uid;
543 unsigned st_gid;
544 unsigned st_rdev;
545 int st_pad2[2];
546 int st_size;
547 int st_pad3; /* st_size, off_t expansion */
548 timestruct_t st_atime;
549 timestruct_t st_mtime;
550 timestruct_t st_ctime;
551 int st_blksize;
552 int st_blocks;
553 char st_fstype[16];
554 int st_pad4[8]; /* expansion area */
555};
556
557static void
558printstatsol(tcp, addr)
559struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000560long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000561{
562 struct solstat statbuf;
563
564 if (!addr) {
565 tprintf("NULL");
566 return;
567 }
568 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000569 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000570 return;
571 }
572 if (umove(tcp, addr, &statbuf) < 0) {
573 tprintf("{...}");
574 return;
575 }
576 if (!abbrev(tcp)) {
577 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
578 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
579 (unsigned long) (statbuf.st_dev & 0x3ffff),
580 (unsigned long) statbuf.st_ino,
581 sprintmode(statbuf.st_mode));
582 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
583 (unsigned long) statbuf.st_nlink,
584 (unsigned long) statbuf.st_uid,
585 (unsigned long) statbuf.st_gid);
586 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
587 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
588 }
589 else
590 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
591 switch (statbuf.st_mode & S_IFMT) {
592 case S_IFCHR: case S_IFBLK:
593 tprintf("st_rdev=makedev(%lu, %lu), ",
594 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
595 (unsigned long) (statbuf.st_rdev & 0x3ffff));
596 break;
597 default:
598 tprintf("st_size=%u, ", statbuf.st_size);
599 break;
600 }
601 if (!abbrev(tcp)) {
602 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
603 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
604 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
605 }
606 else
607 tprintf("...}");
608}
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000609#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000610
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000611#ifdef FREEBSD
612static struct xlat fileflags[] = {
613 { UF_NODUMP, "UF_NODUMP" },
614 { UF_IMMUTABLE, "UF_IMMUTABLE" },
615 { UF_APPEND, "UF_APPEND" },
616 { UF_OPAQUE, "UF_OPAQUE" },
617 { UF_NOUNLINK, "UF_NOUNLINK" },
618 { SF_ARCHIVED, "SF_ARCHIVED" },
619 { SF_IMMUTABLE, "SF_IMMUTABLE" },
620 { SF_APPEND, "SF_APPEND" },
621 { SF_NOUNLINK, "SF_NOUNLINK" },
622 { 0, NULL },
623};
624
625int
626sys_chflags(tcp)
627struct tcb *tcp;
628{
629 if (entering(tcp)) {
630 printpath(tcp, tcp->u_arg[0]);
631 tprintf(", ");
632 if (tcp->u_arg[1])
633 printflags(fileflags, tcp->u_arg[1]);
634 else
635 tprintf("0");
636 }
637 return 0;
638}
639
640int
641sys_fchflags(tcp)
642struct tcb *tcp;
643{
644 if (entering(tcp)) {
645 tprintf("%ld, ", tcp->u_arg[0]);
646 if (tcp->u_arg[1])
647 printflags(fileflags, tcp->u_arg[1]);
648 else
649 tprintf("0");
650 }
651 return 0;
652}
653#endif
654
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000655static void
656realprintstat(tcp, statbuf)
657struct tcb *tcp;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000658struct stat *statbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000659{
660 if (!abbrev(tcp)) {
661 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
662 (unsigned long) major(statbuf->st_dev),
663 (unsigned long) minor(statbuf->st_dev),
664 (unsigned long) statbuf->st_ino,
665 sprintmode(statbuf->st_mode));
666 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
667 (unsigned long) statbuf->st_nlink,
668 (unsigned long) statbuf->st_uid,
669 (unsigned long) statbuf->st_gid);
670#ifdef HAVE_ST_BLKSIZE
671 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
672#endif /* HAVE_ST_BLKSIZE */
673#ifdef HAVE_ST_BLOCKS
674 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
675#endif /* HAVE_ST_BLOCKS */
676 }
677 else
678 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
679 switch (statbuf->st_mode & S_IFMT) {
680 case S_IFCHR: case S_IFBLK:
681#ifdef HAVE_ST_RDEV
682 tprintf("st_rdev=makedev(%lu, %lu), ",
683 (unsigned long) major(statbuf->st_rdev),
684 (unsigned long) minor(statbuf->st_rdev));
685#else /* !HAVE_ST_RDEV */
686 tprintf("st_size=makedev(%lu, %lu), ",
687 (unsigned long) major(statbuf->st_size),
688 (unsigned long) minor(statbuf->st_size));
689#endif /* !HAVE_ST_RDEV */
690 break;
691 default:
692 tprintf("st_size=%lu, ", statbuf->st_size);
693 break;
694 }
695 if (!abbrev(tcp)) {
696 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
697 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000698#ifndef FREEBSD
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000699 tprintf("st_ctime=%s}", sprinttime(statbuf->st_ctime));
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000700#else /* FREEBSD */
701 tprintf("st_ctime=%s, ", sprinttime(statbuf->st_ctime));
702 tprintf("st_flags=");
703 if (statbuf->st_flags) {
704 printflags(fileflags, statbuf->st_flags);
705 } else
706 tprintf("0");
707 tprintf(", st_gen=%u}", statbuf->st_gen);
708#endif /* FREEBSD */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000709 }
710 else
711 tprintf("...}");
712}
713
Nate Sammons771a6ff1999-04-05 22:39:31 +0000714
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000715static void
716printstat(tcp, addr)
717struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000718long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000719{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000720 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000721
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);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000735 return;
736 }
737 if (umove(tcp, addr, &statbuf) < 0) {
738 tprintf("{...}");
739 return;
740 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000741
742 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000743}
744
Wichert Akkermanc7926982000-04-10 22:22:31 +0000745#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000746static void
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000747printstat64(tcp, addr)
748struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000749long addr;
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000750{
751 struct stat64 statbuf;
752
753#ifdef LINUXSPARC
754 if (current_personality == 1) {
755 printstatsol(tcp, addr);
756 return;
757 }
758#endif /* LINUXSPARC */
759
760 if (!addr) {
761 tprintf("NULL");
762 return;
763 }
764 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000765 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000766 return;
767 }
768 if (umove(tcp, addr, &statbuf) < 0) {
769 tprintf("{...}");
770 return;
771 }
772
773 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +0000774#ifdef HAVE_LONG_LONG
775 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
776#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000777 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
Wichert Akkermand077c452000-08-10 18:16:15 +0000778#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000779 (unsigned long) major(statbuf.st_dev),
780 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +0000781#ifdef HAVE_LONG_LONG
782 (unsigned long long) statbuf.st_ino,
783#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000784 (unsigned long) statbuf.st_ino,
Wichert Akkermand077c452000-08-10 18:16:15 +0000785#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000786 sprintmode(statbuf.st_mode));
787 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
788 (unsigned long) statbuf.st_nlink,
789 (unsigned long) statbuf.st_uid,
790 (unsigned long) statbuf.st_gid);
791#ifdef HAVE_ST_BLKSIZE
792 tprintf("st_blksize=%lu, ",
793 (unsigned long) statbuf.st_blksize);
794#endif /* HAVE_ST_BLKSIZE */
795#ifdef HAVE_ST_BLOCKS
796 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
797#endif /* HAVE_ST_BLOCKS */
798 }
799 else
800 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
801 switch (statbuf.st_mode & S_IFMT) {
802 case S_IFCHR: case S_IFBLK:
803#ifdef HAVE_ST_RDEV
804 tprintf("st_rdev=makedev(%lu, %lu), ",
805 (unsigned long) major(statbuf.st_rdev),
806 (unsigned long) minor(statbuf.st_rdev));
807#else /* !HAVE_ST_RDEV */
808 tprintf("st_size=makedev(%lu, %lu), ",
809 (unsigned long) major(statbuf.st_size),
810 (unsigned long) minor(statbuf.st_size));
811#endif /* !HAVE_ST_RDEV */
812 break;
813 default:
814 tprintf("st_size=%llu, ", statbuf.st_size);
815 break;
816 }
817 if (!abbrev(tcp)) {
818 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
819 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
820 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
821 }
822 else
823 tprintf("...}");
824}
Wichert Akkermanc7926982000-04-10 22:22:31 +0000825#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000826
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000827#if defined(linux) && !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000828static void
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000829convertoldstat(oldbuf, newbuf)
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000830const struct __old_kernel_stat *oldbuf;
831struct stat *newbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000832{
833 newbuf->st_dev=oldbuf->st_dev;
834 newbuf->st_ino=oldbuf->st_ino;
835 newbuf->st_mode=oldbuf->st_mode;
836 newbuf->st_nlink=oldbuf->st_nlink;
837 newbuf->st_uid=oldbuf->st_uid;
838 newbuf->st_gid=oldbuf->st_gid;
839 newbuf->st_rdev=oldbuf->st_rdev;
840 newbuf->st_size=oldbuf->st_size;
841 newbuf->st_atime=oldbuf->st_atime;
842 newbuf->st_mtime=oldbuf->st_mtime;
843 newbuf->st_ctime=oldbuf->st_ctime;
844 newbuf->st_blksize=0; /* not supported in old_stat */
845 newbuf->st_blocks=0; /* not supported in old_stat */
846}
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000847
848
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000849static void
850printoldstat(tcp, addr)
851struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000852long addr;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000853{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000854 struct __old_kernel_stat statbuf;
855 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000856
857#ifdef LINUXSPARC
858 if (current_personality == 1) {
859 printstatsol(tcp, addr);
860 return;
861 }
862#endif /* LINUXSPARC */
863
864 if (!addr) {
865 tprintf("NULL");
866 return;
867 }
868 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000869 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000870 return;
871 }
872 if (umove(tcp, addr, &statbuf) < 0) {
873 tprintf("{...}");
874 return;
875 }
876
877 convertoldstat(&statbuf, &newstatbuf);
878 realprintstat(tcp, &newstatbuf);
879}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000880#endif /* linux && !IA64 */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000881
882
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000883int
884sys_stat(tcp)
885struct tcb *tcp;
886{
887 if (entering(tcp)) {
888 printpath(tcp, tcp->u_arg[0]);
889 tprintf(", ");
890 } else {
891 printstat(tcp, tcp->u_arg[1]);
892 }
893 return 0;
894}
895
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000896int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000897sys_stat64(tcp)
898struct tcb *tcp;
899{
900#ifdef HAVE_STAT64
901 if (entering(tcp)) {
902 printpath(tcp, tcp->u_arg[0]);
903 tprintf(", ");
904 } else {
905 printstat64(tcp, tcp->u_arg[1]);
906 }
907 return 0;
908#else
909 return printargs(tcp);
910#endif
911}
912
John Hughese2f6d872001-03-07 16:03:20 +0000913#ifdef linux
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000914# if !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000915int
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000916sys_oldstat(tcp)
917struct tcb *tcp;
918{
919 if (entering(tcp)) {
920 printpath(tcp, tcp->u_arg[0]);
921 tprintf(", ");
922 } else {
923 printoldstat(tcp, tcp->u_arg[1]);
924 }
925 return 0;
926}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000927# endif /* !IA64 */
928#endif /* linux */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000929
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000930int
931sys_fstat(tcp)
932struct tcb *tcp;
933{
934 if (entering(tcp))
935 tprintf("%ld, ", tcp->u_arg[0]);
936 else {
937 printstat(tcp, tcp->u_arg[1]);
938 }
939 return 0;
940}
941
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000942int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000943sys_fstat64(tcp)
944struct tcb *tcp;
945{
946#ifdef HAVE_STAT64
947 if (entering(tcp))
948 tprintf("%ld, ", tcp->u_arg[0]);
949 else {
950 printstat64(tcp, tcp->u_arg[1]);
951 }
952 return 0;
953#else
954 return printargs(tcp);
955#endif
956}
957
John Hughese2f6d872001-03-07 16:03:20 +0000958#ifdef linux
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000959# if !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000960int
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000961sys_oldfstat(tcp)
962struct tcb *tcp;
963{
964 if (entering(tcp))
965 tprintf("%ld, ", tcp->u_arg[0]);
966 else {
967 printoldstat(tcp, tcp->u_arg[1]);
968 }
969 return 0;
970}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000971# endif /* !IA64 */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000972#endif
973
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000974int
975sys_lstat(tcp)
976struct tcb *tcp;
977{
978 if (entering(tcp)) {
979 printpath(tcp, tcp->u_arg[0]);
980 tprintf(", ");
981 } else {
982 printstat(tcp, tcp->u_arg[1]);
983 }
984 return 0;
985}
986
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000987int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000988sys_lstat64(tcp)
989struct tcb *tcp;
990{
991#ifdef HAVE_STAT64
992 if (entering(tcp)) {
993 printpath(tcp, tcp->u_arg[0]);
994 tprintf(", ");
995 } else {
996 printstat64(tcp, tcp->u_arg[1]);
997 }
998 return 0;
999#else
1000 return printargs(tcp);
1001#endif
1002}
1003
John Hughese2f6d872001-03-07 16:03:20 +00001004#ifdef linux
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001005# if !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001006int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001007sys_oldlstat(tcp)
1008struct tcb *tcp;
1009{
1010 if (entering(tcp)) {
1011 printpath(tcp, tcp->u_arg[0]);
1012 tprintf(", ");
1013 } else {
1014 printoldstat(tcp, tcp->u_arg[1]);
1015 }
1016 return 0;
1017}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001018# endif /* !IA64 */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001019#endif
1020
1021
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001022#if defined(SVR4) || defined(LINUXSPARC)
1023
1024int
1025sys_xstat(tcp)
1026struct tcb *tcp;
1027{
1028 if (entering(tcp)) {
1029 tprintf("%ld, ", tcp->u_arg[0]);
1030 printpath(tcp, tcp->u_arg[1]);
1031 tprintf(", ");
1032 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001033#ifdef _STAT64_VER
1034 if (tcp->u_arg[0] == _STAT64_VER)
1035 printstat64 (tcp, tcp->u_arg[2]);
1036 else
1037#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001038 printstat(tcp, tcp->u_arg[2]);
1039 }
1040 return 0;
1041}
1042
1043int
1044sys_fxstat(tcp)
1045struct tcb *tcp;
1046{
1047 if (entering(tcp))
1048 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1049 else {
John Hughes8fe2c982001-03-06 09:45:18 +00001050#ifdef _STAT64_VER
1051 if (tcp->u_arg[0] == _STAT64_VER)
1052 printstat64 (tcp, tcp->u_arg[2]);
1053 else
1054#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001055 printstat(tcp, tcp->u_arg[2]);
1056 }
1057 return 0;
1058}
1059
1060int
1061sys_lxstat(tcp)
1062struct tcb *tcp;
1063{
1064 if (entering(tcp)) {
1065 tprintf("%ld, ", tcp->u_arg[0]);
1066 printpath(tcp, tcp->u_arg[1]);
1067 tprintf(", ");
1068 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001069#ifdef _STAT64_VER
1070 if (tcp->u_arg[0] == _STAT64_VER)
1071 printstat64 (tcp, tcp->u_arg[2]);
1072 else
1073#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001074 printstat(tcp, tcp->u_arg[2]);
1075 }
1076 return 0;
1077}
1078
1079int
1080sys_xmknod(tcp)
1081struct tcb *tcp;
1082{
1083 int mode = tcp->u_arg[2];
1084
1085 if (entering(tcp)) {
1086 tprintf("%ld, ", tcp->u_arg[0]);
1087 printpath(tcp, tcp->u_arg[1]);
1088 tprintf(", %s", sprintmode(mode));
1089 switch (mode & S_IFMT) {
1090 case S_IFCHR: case S_IFBLK:
1091#ifdef LINUXSPARC
1092 tprintf(", makedev(%lu, %lu)",
1093 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1094 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1095#else
1096 tprintf(", makedev(%lu, %lu)",
1097 (unsigned long) major(tcp->u_arg[3]),
1098 (unsigned long) minor(tcp->u_arg[3]));
1099#endif
1100 break;
1101 default:
1102 break;
1103 }
1104 }
1105 return 0;
1106}
1107
Wichert Akkerman8829a551999-06-11 13:18:40 +00001108#ifdef HAVE_SYS_ACL_H
1109
1110#include <sys/acl.h>
1111
1112struct xlat aclcmds[] = {
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001113#ifdef SETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001114 { SETACL, "SETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001115#endif
1116#ifdef GETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001117 { GETACL, "GETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001118#endif
1119#ifdef GETACLCNT
Wichert Akkerman8829a551999-06-11 13:18:40 +00001120 { GETACLCNT, "GETACLCNT" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001121#endif
1122#ifdef ACL_GET
1123 { ACL_GET, "ACL_GET" },
1124#endif
1125#ifdef ACL_SET
1126 { ACL_SET, "ACL_SET" },
1127#endif
1128#ifdef ACL_CNT
1129 { ACL_CNT, "ACL_CNT" },
1130#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +00001131 { 0, NULL },
1132};
1133
1134int
1135sys_acl(tcp)
1136struct tcb *tcp;
1137{
1138 if (entering(tcp)) {
1139 printpath(tcp, tcp->u_arg[0]);
1140 tprintf(", ");
1141 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1142 tprintf(", %ld", tcp->u_arg[2]);
1143 /*
1144 * FIXME - dump out the list of aclent_t's pointed to
1145 * by "tcp->u_arg[3]" if it's not NULL.
1146 */
1147 if (tcp->u_arg[3])
1148 tprintf(", %#lx", tcp->u_arg[3]);
1149 else
1150 tprintf(", NULL");
1151 }
1152 return 0;
1153}
1154
1155
1156int
1157sys_facl(tcp)
1158struct tcb *tcp;
1159{
1160 if (entering(tcp)) {
1161 tprintf("%ld, ", tcp->u_arg[0]);
1162 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1163 tprintf(", %ld", tcp->u_arg[2]);
1164 /*
1165 * FIXME - dump out the list of aclent_t's pointed to
1166 * by "tcp->u_arg[3]" if it's not NULL.
1167 */
1168 if (tcp->u_arg[3])
1169 tprintf(", %#lx", tcp->u_arg[3]);
1170 else
1171 tprintf(", NULL");
1172 }
1173 return 0;
1174}
1175
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001176
1177struct xlat aclipc[] = {
1178#ifdef IPC_SHM
1179 { IPC_SHM, "IPC_SHM" },
1180#endif
1181#ifdef IPC_SEM
1182 { IPC_SEM, "IPC_SEM" },
1183#endif
1184#ifdef IPC_MSG
1185 { IPC_MSG, "IPC_MSG" },
1186#endif
1187 { 0, NULL },
1188};
1189
1190
1191int
1192sys_aclipc(tcp)
1193struct tcb *tcp;
1194{
1195 if (entering(tcp)) {
1196 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1197 tprintf(", %#lx, ", tcp->u_arg[1]);
1198 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1199 tprintf(", %ld", tcp->u_arg[3]);
1200 /*
1201 * FIXME - dump out the list of aclent_t's pointed to
1202 * by "tcp->u_arg[4]" if it's not NULL.
1203 */
1204 if (tcp->u_arg[4])
1205 tprintf(", %#lx", tcp->u_arg[4]);
1206 else
1207 tprintf(", NULL");
1208 }
1209 return 0;
1210}
1211
1212
1213
Wichert Akkerman8829a551999-06-11 13:18:40 +00001214#endif /* HAVE_SYS_ACL_H */
1215
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001216#endif /* SVR4 || LINUXSPARC */
1217
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001218#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001219
1220static struct xlat fsmagic[] = {
Wichert Akkerman43a74822000-06-27 17:33:32 +00001221 { 0x73757245, "CODA_SUPER_MAGIC" },
1222 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1223 { 0x1373, "DEVFS_SUPER_MAGIC" },
1224 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1225 { 0x414A53, "EFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001226 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1227 { 0xef53, "EXT2_SUPER_MAGIC" },
1228 { 0x137d, "EXT_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001229 { 0xf995e849, "HPFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001230 { 0x9660, "ISOFS_SUPER_MAGIC" },
1231 { 0x137f, "MINIX_SUPER_MAGIC" },
1232 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001233 { 0x2468, "MINIX2_SUPER_MAGIC" },
1234 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001235 { 0x4d44, "MSDOS_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001236 { 0x564c, "NCP_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001237 { 0x6969, "NFS_SUPER_MAGIC" },
1238 { 0x9fa0, "PROC_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001239 { 0x002f, "QNX4_SUPER_MAGIC" },
1240 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1241 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1242 { 0x517b, "SMB_SUPER_MAGIC" },
1243 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1244 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1245 { 0x00011954, "UFS_MAGIC" },
1246 { 0x54190100, "UFS_CIGAM" },
1247 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001248 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1249 { 0, NULL },
1250};
1251
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001252#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001253
1254#ifndef SVR4
1255
1256static char *
1257sprintfstype(magic)
1258int magic;
1259{
1260 static char buf[32];
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001261#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001262 char *s;
1263
1264 s = xlookup(fsmagic, magic);
1265 if (s) {
1266 sprintf(buf, "\"%s\"", s);
1267 return buf;
1268 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001269#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001270 sprintf(buf, "%#x", magic);
1271 return buf;
1272}
1273
1274static void
1275printstatfs(tcp, addr)
1276struct tcb *tcp;
1277long addr;
1278{
1279 struct statfs statbuf;
1280
1281 if (syserror(tcp) || !verbose(tcp)) {
1282 tprintf("%#lx", addr);
1283 return;
1284 }
1285 if (umove(tcp, addr, &statbuf) < 0) {
1286 tprintf("{...}");
1287 return;
1288 }
1289#ifdef ALPHA
1290
1291 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1292 sprintfstype(statbuf.f_type),
1293 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001294 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001295 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1296#else /* !ALPHA */
1297 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1298 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +00001299 (unsigned long)statbuf.f_bsize,
1300 (unsigned long)statbuf.f_blocks,
1301 (unsigned long)statbuf.f_bfree);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001302 tprintf("f_files=%lu, f_ffree=%lu",
Nate Sammons5c74d201999-04-06 01:37:51 +00001303 (unsigned long)statbuf.f_files,
1304 (unsigned long)statbuf.f_ffree);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001305#ifdef linux
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001306 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001307#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001308#endif /* !ALPHA */
1309 tprintf("}");
1310}
1311
1312int
1313sys_statfs(tcp)
1314struct tcb *tcp;
1315{
1316 if (entering(tcp)) {
1317 printpath(tcp, tcp->u_arg[0]);
1318 tprintf(", ");
1319 } else {
1320 printstatfs(tcp, tcp->u_arg[1]);
1321 }
1322 return 0;
1323}
1324
1325int
1326sys_fstatfs(tcp)
1327struct tcb *tcp;
1328{
1329 if (entering(tcp)) {
1330 tprintf("%lu, ", tcp->u_arg[0]);
1331 } else {
1332 printstatfs(tcp, tcp->u_arg[1]);
1333 }
1334 return 0;
1335}
1336
Wichert Akkermana0f36c61999-04-16 14:01:34 +00001337#if defined(linux) && defined(__alpha)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001338
1339int
1340osf_statfs(tcp)
1341struct tcb *tcp;
1342{
1343 if (entering(tcp)) {
1344 printpath(tcp, tcp->u_arg[0]);
1345 tprintf(", ");
1346 } else {
1347 printstatfs(tcp, tcp->u_arg[1]);
1348 tprintf(", %lu", tcp->u_arg[2]);
1349 }
1350 return 0;
1351}
1352
1353int
1354osf_fstatfs(tcp)
1355struct tcb *tcp;
1356{
1357 if (entering(tcp)) {
1358 tprintf("%lu, ", tcp->u_arg[0]);
1359 } else {
1360 printstatfs(tcp, tcp->u_arg[1]);
1361 tprintf(", %lu", tcp->u_arg[2]);
1362 }
1363 return 0;
1364}
Wichert Akkermana0f36c61999-04-16 14:01:34 +00001365#endif /* linux && __alpha */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001366
1367#endif /* !SVR4 */
1368
1369#ifdef SUNOS4
1370
1371int
1372sys_ustat(tcp)
1373struct tcb *tcp;
1374{
1375 struct ustat statbuf;
1376
1377 if (entering(tcp)) {
1378 tprintf("makedev(%lu, %lu), ",
1379 (long) major(tcp->u_arg[0]),
1380 (long) minor(tcp->u_arg[0]));
1381 }
1382 else {
1383 if (syserror(tcp) || !verbose(tcp))
1384 tprintf("%#lx", tcp->u_arg[1]);
1385 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1386 tprintf("{...}");
1387 else {
1388 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1389 statbuf.f_tfree, statbuf.f_tinode);
1390 tprintf("f_fname=\"%.*s\", ",
1391 (int) sizeof(statbuf.f_fname),
1392 statbuf.f_fname);
1393 tprintf("f_fpack=\"%.*s\"}",
1394 (int) sizeof(statbuf.f_fpack),
1395 statbuf.f_fpack);
1396 }
1397 }
1398 return 0;
1399}
1400
1401#endif /* SUNOS4 */
1402
Wichert Akkermanc7926982000-04-10 22:22:31 +00001403int
1404sys_pivotroot(tcp)
1405struct tcb *tcp;
1406{
1407 if (entering(tcp)) {
1408 printpath(tcp, tcp->u_arg[0]);
1409 tprintf(", ");
1410 printpath(tcp, tcp->u_arg[1]);
1411 }
1412 return 0;
1413}
1414
1415
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001416/* directory */
1417int
1418sys_chdir(tcp)
1419struct tcb *tcp;
1420{
1421 if (entering(tcp)) {
1422 printpath(tcp, tcp->u_arg[0]);
1423 }
1424 return 0;
1425}
1426
1427int
1428sys_mkdir(tcp)
1429struct tcb *tcp;
1430{
1431 if (entering(tcp)) {
1432 printpath(tcp, tcp->u_arg[0]);
1433 tprintf(", %#lo", tcp->u_arg[1]);
1434 }
1435 return 0;
1436}
1437
1438int
1439sys_rmdir(tcp)
1440struct tcb *tcp;
1441{
1442 if (entering(tcp)) {
1443 printpath(tcp, tcp->u_arg[0]);
1444 }
1445 return 0;
1446}
1447
1448int
1449sys_fchdir(tcp)
1450struct tcb *tcp;
1451{
1452 if (entering(tcp)) {
1453 tprintf("%ld", tcp->u_arg[0]);
1454 }
1455 return 0;
1456}
1457
1458int
1459sys_chroot(tcp)
1460struct tcb *tcp;
1461{
1462 if (entering(tcp)) {
1463 printpath(tcp, tcp->u_arg[0]);
1464 }
1465 return 0;
1466}
1467
1468int
1469sys_fchroot(tcp)
1470struct tcb *tcp;
1471{
1472 if (entering(tcp)) {
1473 tprintf("%ld", tcp->u_arg[0]);
1474 }
1475 return 0;
1476}
1477
1478int
1479sys_link(tcp)
1480struct tcb *tcp;
1481{
1482 if (entering(tcp)) {
1483 printpath(tcp, tcp->u_arg[0]);
1484 tprintf(", ");
1485 printpath(tcp, tcp->u_arg[1]);
1486 }
1487 return 0;
1488}
1489
1490int
1491sys_unlink(tcp)
1492struct tcb *tcp;
1493{
1494 if (entering(tcp)) {
1495 printpath(tcp, tcp->u_arg[0]);
1496 }
1497 return 0;
1498}
1499
1500int
1501sys_symlink(tcp)
1502struct tcb *tcp;
1503{
1504 if (entering(tcp)) {
1505 printpath(tcp, tcp->u_arg[0]);
1506 tprintf(", ");
1507 printpath(tcp, tcp->u_arg[1]);
1508 }
1509 return 0;
1510}
1511
1512int
1513sys_readlink(tcp)
1514struct tcb *tcp;
1515{
1516 if (entering(tcp)) {
1517 printpath(tcp, tcp->u_arg[0]);
1518 tprintf(", ");
1519 } else {
1520 if (syserror(tcp))
1521 tprintf("%#lx", tcp->u_arg[1]);
1522 else
1523 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1524 tprintf(", %lu", tcp->u_arg[2]);
1525 }
1526 return 0;
1527}
1528
1529int
1530sys_rename(tcp)
1531struct tcb *tcp;
1532{
1533 if (entering(tcp)) {
1534 printpath(tcp, tcp->u_arg[0]);
1535 tprintf(", ");
1536 printpath(tcp, tcp->u_arg[1]);
1537 }
1538 return 0;
1539}
1540
1541int
1542sys_chown(tcp)
1543struct tcb *tcp;
1544{
1545 if (entering(tcp)) {
1546 printpath(tcp, tcp->u_arg[0]);
1547 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1548 }
1549 return 0;
1550}
1551
1552int
1553sys_fchown(tcp)
1554struct tcb *tcp;
1555{
1556 if (entering(tcp)) {
1557 tprintf("%ld, %lu, %lu",
1558 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1559 }
1560 return 0;
1561}
1562
1563int
1564sys_chmod(tcp)
1565struct tcb *tcp;
1566{
1567 if (entering(tcp)) {
1568 printpath(tcp, tcp->u_arg[0]);
1569 tprintf(", %#lo", tcp->u_arg[1]);
1570 }
1571 return 0;
1572}
1573
1574int
1575sys_fchmod(tcp)
1576struct tcb *tcp;
1577{
1578 if (entering(tcp)) {
1579 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1580 }
1581 return 0;
1582}
1583
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001584#ifdef ALPHA
1585int
1586sys_osf_utimes(tcp)
1587struct tcb *tcp;
1588{
1589 if (entering(tcp)) {
1590 printpath(tcp, tcp->u_arg[0]);
1591 tprintf(", ");
1592 printtv32(tcp, tcp->u_arg[1]);
1593 }
1594 return 0;
1595}
1596#endif
1597
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001598int
1599sys_utimes(tcp)
1600struct tcb *tcp;
1601{
1602 if (entering(tcp)) {
1603 printpath(tcp, tcp->u_arg[0]);
1604 tprintf(", ");
1605 printtv(tcp, tcp->u_arg[1]);
1606 }
1607 return 0;
1608}
1609
1610int
1611sys_utime(tcp)
1612struct tcb *tcp;
1613{
1614 long ut[2];
1615
1616 if (entering(tcp)) {
1617 printpath(tcp, tcp->u_arg[0]);
1618 tprintf(", ");
1619 if (!tcp->u_arg[1])
1620 tprintf("NULL");
1621 else if (!verbose(tcp))
1622 tprintf("%#lx", tcp->u_arg[1]);
1623 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1624 (char *) ut) < 0)
1625 tprintf("[?, ?]");
1626 else {
1627 tprintf("[%s,", sprinttime(ut[0]));
1628 tprintf(" %s]", sprinttime(ut[1]));
1629 }
1630 }
1631 return 0;
1632}
1633
1634int
1635sys_mknod(tcp)
1636struct tcb *tcp;
1637{
1638 int mode = tcp->u_arg[1];
1639
1640 if (entering(tcp)) {
1641 printpath(tcp, tcp->u_arg[0]);
1642 tprintf(", %s", sprintmode(mode));
1643 switch (mode & S_IFMT) {
1644 case S_IFCHR: case S_IFBLK:
1645#ifdef LINUXSPARC
1646 if (current_personality == 1)
1647 tprintf(", makedev(%lu, %lu)",
1648 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1649 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1650 else
1651#endif
1652 tprintf(", makedev(%lu, %lu)",
1653 (unsigned long) major(tcp->u_arg[2]),
1654 (unsigned long) minor(tcp->u_arg[2]));
1655 break;
1656 default:
1657 break;
1658 }
1659 }
1660 return 0;
1661}
1662
1663int
1664sys_mkfifo(tcp)
1665struct tcb *tcp;
1666{
1667 if (entering(tcp)) {
1668 printpath(tcp, tcp->u_arg[0]);
1669 tprintf(", %#lo", tcp->u_arg[1]);
1670 }
1671 return 0;
1672}
1673
1674int
1675sys_fsync(tcp)
1676struct tcb *tcp;
1677{
1678 if (entering(tcp)) {
1679 tprintf("%ld", tcp->u_arg[0]);
1680 }
1681 return 0;
1682}
1683
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001684#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001685
1686static void
1687printdir(tcp, addr)
1688struct tcb *tcp;
1689long addr;
1690{
1691 struct dirent d;
1692
1693 if (!verbose(tcp)) {
1694 tprintf("%#lx", addr);
1695 return;
1696 }
1697 if (umove(tcp, addr, &d) < 0) {
1698 tprintf("{...}");
1699 return;
1700 }
1701 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001702 tprintf("d_name=");
1703 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1704 tprintf("}");
1705}
1706
1707int
1708sys_readdir(tcp)
1709struct tcb *tcp;
1710{
1711 if (entering(tcp)) {
1712 tprintf("%lu, ", tcp->u_arg[0]);
1713 } else {
1714 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1715 tprintf("%#lx", tcp->u_arg[1]);
1716 else
1717 printdir(tcp, tcp->u_arg[1]);
1718 /* Not much point in printing this out, it is always 1. */
1719 if (tcp->u_arg[2] != 1)
1720 tprintf(", %lu", tcp->u_arg[2]);
1721 }
1722 return 0;
1723}
1724
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001725#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001726
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001727#ifdef FREEBSD
1728struct xlat direnttypes[] = {
1729 { DT_FIFO, "DT_FIFO" },
1730 { DT_CHR, "DT_CHR" },
1731 { DT_DIR, "DT_DIR" },
1732 { DT_BLK, "DT_BLK" },
1733 { DT_REG, "DT_REG" },
1734 { DT_LNK, "DT_LNK" },
1735 { DT_SOCK, "DT_SOCK" },
1736 { DT_WHT, "DT_WHT" },
1737 { 0, NULL },
1738};
1739
1740#endif
1741
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001742int
1743sys_getdents(tcp)
1744struct tcb *tcp;
1745{
1746 int i, len, dents = 0;
1747 char *buf;
1748
1749 if (entering(tcp)) {
1750 tprintf("%lu, ", tcp->u_arg[0]);
1751 return 0;
1752 }
1753 if (syserror(tcp) || !verbose(tcp)) {
1754 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1755 return 0;
1756 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001757 len = tcp->u_rval;
1758 if ((buf = malloc(len)) == NULL) {
1759 tprintf("out of memory\n");
1760 return 0;
1761 }
1762 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1763 tprintf("{...}, %lu", tcp->u_arg[2]);
1764 free(buf);
1765 return 0;
1766 }
1767 if (!abbrev(tcp))
1768 tprintf("{");
1769 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00001770 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001771#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001772 if (!abbrev(tcp)) {
1773 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1774 i ? " " : "", d->d_ino, d->d_off);
1775 tprintf("d_reclen=%u, d_name=\"%s\"}",
1776 d->d_reclen, d->d_name);
1777 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001778#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001779#ifdef SVR4
1780 if (!abbrev(tcp)) {
1781 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1782 i ? " " : "", d->d_ino, d->d_off);
1783 tprintf("d_reclen=%u, d_name=\"%s\"}",
1784 d->d_reclen, d->d_name);
1785 }
1786#endif /* SVR4 */
1787#ifdef SUNOS4
1788 if (!abbrev(tcp)) {
1789 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1790 i ? " " : "", d->d_off, d->d_fileno,
1791 d->d_reclen);
1792 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1793 d->d_namlen, d->d_namlen, d->d_name);
1794 }
1795#endif /* SUNOS4 */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001796#ifdef FREEBSD
1797 if (!abbrev(tcp)) {
1798 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1799 i ? " " : "", d->d_fileno, d->d_reclen);
1800 printxval(direnttypes, d->d_type, "DT_???");
1801 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1802 d->d_namlen, d->d_namlen, d->d_name);
1803 }
1804#endif /* FREEBSD */
Pavel Machek9a9f10b2000-02-01 16:22:52 +00001805 if (!d->d_reclen) {
1806 tprintf("/* d_reclen == 0, problem here */");
1807 break;
1808 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001809 i += d->d_reclen;
1810 dents++;
1811 }
1812 if (!abbrev(tcp))
1813 tprintf("}");
1814 else
1815 tprintf("/* %u entries */", dents);
1816 tprintf(", %lu", tcp->u_arg[2]);
1817 free(buf);
1818 return 0;
1819}
1820
John Hughesbdf48f52001-03-06 15:08:09 +00001821
1822#if _LFS64_LARGEFILE
1823int
1824sys_getdents64(tcp)
1825struct tcb *tcp;
1826{
1827 int i, len, dents = 0;
1828 char *buf;
1829
1830 if (entering(tcp)) {
1831 tprintf("%lu, ", tcp->u_arg[0]);
1832 return 0;
1833 }
1834 if (syserror(tcp) || !verbose(tcp)) {
1835 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1836 return 0;
1837 }
1838 len = tcp->u_rval;
1839 if ((buf = malloc(len)) == NULL) {
1840 tprintf("out of memory\n");
1841 return 0;
1842 }
1843 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1844 tprintf("{...}, %lu", tcp->u_arg[2]);
1845 free(buf);
1846 return 0;
1847 }
1848 if (!abbrev(tcp))
1849 tprintf("{");
1850 for (i = 0; i < len;) {
1851 struct dirent64 *d = (struct dirent64 *) &buf[i];
1852#ifdef linux
1853 if (!abbrev(tcp)) {
1854 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1855 i ? " " : "", d->d_ino, d->d_off);
1856 tprintf("d_reclen=%u, d_name=\"%s\"}",
1857 d->d_reclen, d->d_name);
1858 }
1859#endif /* linux */
1860#ifdef SVR4
1861 if (!abbrev(tcp)) {
1862 tprintf("%s{d_ino=%llu, d_off=%llu, ",
1863 i ? " " : "", d->d_ino, d->d_off);
1864 tprintf("d_reclen=%u, d_name=\"%s\"}",
1865 d->d_reclen, d->d_name);
1866 }
1867#endif /* SVR4 */
1868#ifdef SUNOS4
1869 if (!abbrev(tcp)) {
1870 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1871 i ? " " : "", d->d_off, d->d_fileno,
1872 d->d_reclen);
1873 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1874 d->d_namlen, d->d_namlen, d->d_name);
1875 }
1876#endif /* SUNOS4 */
1877 i += d->d_reclen;
1878 dents++;
1879 }
1880 if (!abbrev(tcp))
1881 tprintf("}");
1882 else
1883 tprintf("/* %u entries */", dents);
1884 tprintf(", %lu", tcp->u_arg[2]);
1885 free(buf);
1886 return 0;
1887}
1888#endif
1889
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001890#ifdef FREEBSD
1891int
1892sys_getdirentries(tcp)
1893struct tcb * tcp;
1894{
1895 int i, len, dents = 0;
1896 long basep;
1897 char *buf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001898
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001899 if (entering(tcp)) {
1900 tprintf("%lu, ", tcp->u_arg[0]);
1901 return 0;
1902 }
1903 if (syserror(tcp) || !verbose(tcp)) {
1904 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1905 return 0;
1906 }
1907 len = tcp->u_rval;
1908 if ((buf = malloc(len)) == NULL) {
1909 tprintf("out of memory\n");
1910 return 0;
1911 }
1912 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1913 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
1914 free(buf);
1915 return 0;
1916 }
1917 if (!abbrev(tcp))
1918 tprintf("{");
1919 for (i = 0; i < len;) {
1920 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1921 if (!abbrev(tcp)) {
1922 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1923 i ? " " : "", d->d_fileno, d->d_reclen);
1924 printxval(direnttypes, d->d_type, "DT_???");
1925 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1926 d->d_namlen, d->d_namlen, d->d_name);
1927 }
1928 i += d->d_reclen;
1929 dents++;
1930 }
1931 if (!abbrev(tcp))
1932 tprintf("}");
1933 else
1934 tprintf("/* %u entries */", dents);
1935 free(buf);
1936 tprintf(", %lu", tcp->u_arg[2]);
1937 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
1938 tprintf(", %#lx", tcp->u_arg[3]);
1939 else
1940 tprintf(", [%lu]", basep);
1941 return 0;
1942}
1943#endif
1944
1945#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001946int
1947sys_getcwd(tcp)
1948struct tcb *tcp;
1949{
1950 if (exiting(tcp)) {
1951 if (syserror(tcp))
1952 tprintf("%#lx", tcp->u_arg[0]);
1953 else
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001954 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001955 tprintf(", %lu", tcp->u_arg[1]);
1956 }
1957 return 0;
1958}
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001959#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001960
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001961#ifdef FREEBSD
1962int
1963sys___getcwd(tcp)
1964struct tcb *tcp;
1965{
1966 if (exiting(tcp)) {
1967 if (syserror(tcp))
1968 tprintf("%#lx", tcp->u_arg[0]);
1969 else
1970 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
1971 tprintf(", %lu", tcp->u_arg[1]);
1972 }
1973 return 0;
1974}
1975#endif
1976
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001977#ifdef HAVE_SYS_ASYNCH_H
1978
1979int
1980sys_aioread(tcp)
1981struct tcb *tcp;
1982{
1983 struct aio_result_t res;
1984
1985 if (entering(tcp)) {
1986 tprintf("%lu, ", tcp->u_arg[0]);
1987 } else {
1988 if (syserror(tcp))
1989 tprintf("%#lx", tcp->u_arg[1]);
1990 else
1991 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1992 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
1993 printxval(whence, tcp->u_arg[4], "L_???");
1994 if (syserror(tcp) || tcp->u_arg[5] == 0
1995 || umove(tcp, tcp->u_arg[5], &res) < 0)
1996 tprintf(", %#lx", tcp->u_arg[5]);
1997 else
1998 tprintf(", {aio_return %d aio_errno %d}",
1999 res.aio_return, res.aio_errno);
2000 }
2001 return 0;
2002}
2003
2004int
2005sys_aiowrite(tcp)
2006struct tcb *tcp;
2007{
2008 struct aio_result_t res;
2009
2010 if (entering(tcp)) {
2011 tprintf("%lu, ", tcp->u_arg[0]);
2012 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2013 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2014 printxval(whence, tcp->u_arg[4], "L_???");
2015 }
2016 else {
2017 if (tcp->u_arg[5] == 0)
2018 tprintf(", NULL");
2019 else if (syserror(tcp)
2020 || umove(tcp, tcp->u_arg[5], &res) < 0)
2021 tprintf(", %#lx", tcp->u_arg[5]);
2022 else
2023 tprintf(", {aio_return %d aio_errno %d}",
2024 res.aio_return, res.aio_errno);
2025 }
2026 return 0;
2027}
2028
2029int
2030sys_aiowait(tcp)
2031struct tcb *tcp;
2032{
2033 if (entering(tcp))
2034 printtv(tcp, tcp->u_arg[0]);
2035 return 0;
2036}
2037
2038int
2039sys_aiocancel(tcp)
2040struct tcb *tcp;
2041{
2042 struct aio_result_t res;
2043
2044 if (exiting(tcp)) {
2045 if (tcp->u_arg[0] == 0)
2046 tprintf("NULL");
2047 else if (syserror(tcp)
2048 || umove(tcp, tcp->u_arg[0], &res) < 0)
2049 tprintf("%#lx", tcp->u_arg[0]);
2050 else
2051 tprintf("{aio_return %d aio_errno %d}",
2052 res.aio_return, res.aio_errno);
2053 }
2054 return 0;
2055}
2056
2057#endif /* HAVE_SYS_ASYNCH_H */