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