blob: e618b0360cf8061beb5740d29127a0204df6a078 [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>
John Hughes70623be2001-03-08 13:59:00 +0000133#endif
134
135#if HAVE_LONG_LONG_OFF_T
136/*
137 * Ugly hacks for systems that have typedef long long off_t
138 */
John Hughesb8c9f772001-03-07 16:53:07 +0000139
140#define stat64 stat
141#define HAVE_STAT64 1 /* Ugly hack */
John Hughes70623be2001-03-08 13:59:00 +0000142
143#define sys_stat64 sys_stat
144#define sys_fstat64 sys_fstat
145#define sys_lstat64 sys_lstat
146#define sys_lseek64 sys_lseek
147#define sys_truncate64 sys_truncate
148#define sys_ftruncate64 sys_ftruncate
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000149#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000150
151#ifdef MAJOR_IN_SYSMACROS
152#include <sys/sysmacros.h>
153#endif
154
155#ifdef MAJOR_IN_MKDEV
156#include <sys/mkdev.h>
157#endif
158
159#ifdef HAVE_SYS_ASYNCH_H
160#include <sys/asynch.h>
161#endif
162
163#ifdef SUNOS4
164#include <ustat.h>
165#endif
166
167/*
168 * This is a really dirty trick but it should always work. Traditional
169 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
170 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
171 */
172struct xlat openmodes[] = {
173 { O_RDWR+1, "O_RDWR" },
174 { O_RDONLY+1, "O_RDONLY" },
175 { O_WRONLY+1, "O_WRONLY" },
176 { O_NONBLOCK, "O_NONBLOCK" },
177 { O_APPEND, "O_APPEND" },
178 { O_CREAT, "O_CREAT" },
179 { O_TRUNC, "O_TRUNC" },
180 { O_EXCL, "O_EXCL" },
181 { O_NOCTTY, "O_NOCTTY" },
182#ifdef O_SYNC
183 { O_SYNC, "O_SYNC" },
184#endif
185#ifdef O_ASYNC
186 { O_ASYNC, "O_ASYNC" },
187#endif
188#ifdef O_DSYNC
189 { O_DSYNC, "O_DSYNC" },
190#endif
191#ifdef O_RSYNC
192 { O_RSYNC, "O_RSYNC" },
193#endif
194#ifdef O_NDELAY
195 { O_NDELAY, "O_NDELAY" },
196#endif
197#ifdef O_PRIV
198 { O_PRIV, "O_PRIV" },
199#endif
200#ifdef O_DIRECT
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000201 { O_DIRECT, "O_DIRECT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000202#endif
203#ifdef O_LARGEFILE
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000204 { O_LARGEFILE, "O_LARGEFILE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000205#endif
206#ifdef O_DIRECTORY
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000207 { O_DIRECTORY, "O_DIRECTORY" },
208#endif
209#ifdef O_NOFOLLOW
210 { O_NOFOLLOW, "O_NOFOLLOW" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000211#endif
212
213#ifdef FNDELAY
214 { FNDELAY, "FNDELAY" },
215#endif
216#ifdef FAPPEND
217 { FAPPEND, "FAPPEND" },
218#endif
219#ifdef FMARK
220 { FMARK, "FMARK" },
221#endif
222#ifdef FDEFER
223 { FDEFER, "FDEFER" },
224#endif
225#ifdef FASYNC
226 { FASYNC, "FASYNC" },
227#endif
228#ifdef FSHLOCK
229 { FSHLOCK, "FSHLOCK" },
230#endif
231#ifdef FEXLOCK
232 { FEXLOCK, "FEXLOCK" },
233#endif
234#ifdef FCREAT
235 { FCREAT, "FCREAT" },
236#endif
237#ifdef FTRUNC
238 { FTRUNC, "FTRUNC" },
239#endif
240#ifdef FEXCL
241 { FEXCL, "FEXCL" },
242#endif
243#ifdef FNBIO
244 { FNBIO, "FNBIO" },
245#endif
246#ifdef FSYNC
247 { FSYNC, "FSYNC" },
248#endif
249#ifdef FNOCTTY
250 { FNOCTTY, "FNOCTTY" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000251#endif
252#ifdef O_SHLOCK
253 { O_SHLOCK, "O_SHLOCK" },
254#endif
255#ifdef O_EXLOCK
256 { O_EXLOCK, "O_EXLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000257#endif
258 { 0, NULL },
259};
260
261int
262sys_open(tcp)
263struct tcb *tcp;
264{
265 if (entering(tcp)) {
266 printpath(tcp, tcp->u_arg[0]);
267 tprintf(", ");
268 /* flags */
269 printflags(openmodes, tcp->u_arg[1] + 1);
270 if (tcp->u_arg[1] & O_CREAT) {
271 /* mode */
272 tprintf(", %#lo", tcp->u_arg[2]);
273 }
274 }
275 return 0;
276}
277
278#ifdef LINUXSPARC
279struct xlat openmodessol[] = {
280 { 0, "O_RDWR" },
281 { 1, "O_RDONLY" },
282 { 2, "O_WRONLY" },
283 { 0x80, "O_NONBLOCK" },
284 { 8, "O_APPEND" },
285 { 0x100, "O_CREAT" },
286 { 0x200, "O_TRUNC" },
287 { 0x400, "O_EXCL" },
288 { 0x800, "O_NOCTTY" },
289 { 0x10, "O_SYNC" },
290 { 0x40, "O_DSYNC" },
291 { 0x8000, "O_RSYNC" },
292 { 4, "O_NDELAY" },
293 { 0x1000, "O_PRIV" },
294 { 0, NULL },
295};
296
297int
298solaris_open(tcp)
299struct tcb *tcp;
300{
301 if (entering(tcp)) {
302 printpath(tcp, tcp->u_arg[0]);
303 tprintf(", ");
304 /* flags */
305 printflags(openmodessol, tcp->u_arg[1] + 1);
306 if (tcp->u_arg[1] & 0x100) {
307 /* mode */
308 tprintf(", %#lo", tcp->u_arg[2]);
309 }
310 }
311 return 0;
312}
313
314#endif
315
316int
317sys_creat(tcp)
318struct tcb *tcp;
319{
320 if (entering(tcp)) {
321 printpath(tcp, tcp->u_arg[0]);
322 tprintf(", %#lo", tcp->u_arg[1]);
323 }
324 return 0;
325}
326
327static struct xlat access_flags[] = {
328 { F_OK, "F_OK", },
329 { R_OK, "R_OK" },
330 { W_OK, "W_OK" },
331 { X_OK, "X_OK" },
332#ifdef EFF_ONLY_OK
333 { EFF_ONLY_OK, "EFF_ONLY_OK" },
334#endif
335#ifdef EX_OK
336 { EX_OK, "EX_OK" },
337#endif
338 { 0, NULL },
339};
340
341int
342sys_access(tcp)
343struct tcb *tcp;
344{
345 if (entering(tcp)) {
346 printpath(tcp, tcp->u_arg[0]);
347 tprintf(", ");
348 printflags(access_flags, tcp->u_arg[1]);
349 }
350 return 0;
351}
352
353int
354sys_umask(tcp)
355struct tcb *tcp;
356{
357 if (entering(tcp)) {
358 tprintf("%#lo", tcp->u_arg[0]);
359 }
360 return RVAL_OCTAL;
361}
362
363static struct xlat whence[] = {
364 { SEEK_SET, "SEEK_SET" },
365 { SEEK_CUR, "SEEK_CUR" },
366 { SEEK_END, "SEEK_END" },
367 { 0, NULL },
368};
369
John Hughes70623be2001-03-08 13:59:00 +0000370#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000371int
372sys_lseek(tcp)
373struct tcb *tcp;
374{
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000375 off_t offset;
376 int _whence;
377
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000378 if (entering(tcp)) {
379 tprintf("%ld, ", tcp->u_arg[0]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000380 offset = tcp->u_arg[1];
381 _whence = tcp->u_arg[2];
382 if (_whence == SEEK_SET)
383 tprintf("%lu, ", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000384 else
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000385 tprintf("%ld, ", offset);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000386 printxval(whence, _whence, "SEEK_???");
387 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000388 return RVAL_UDECIMAL;
389}
John Hughes5a826b82001-03-07 13:21:24 +0000390#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000391
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000392#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000393int
394sys_llseek (tcp)
395struct tcb *tcp;
396{
397 if (entering(tcp)) {
398 if (tcp->u_arg[4] == SEEK_SET)
399 tprintf("%ld, %llu, ", tcp->u_arg[0],
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000400 (((long long int) tcp->u_arg[1]) << 32
401 | (unsigned long long) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000402 else
403 tprintf("%ld, %lld, ", tcp->u_arg[0],
404 (((long long int) tcp->u_arg[1]) << 32
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000405 | (unsigned long long) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000406 }
407 else {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000408 long long int off;
409 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000410 tprintf("%#lx, ", tcp->u_arg[3]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000411 else
412 tprintf("[%llu], ", off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000413 printxval(whence, tcp->u_arg[4], "SEEK_???");
414 }
415 return 0;
416}
417#endif
418
John Hughes70623be2001-03-08 13:59:00 +0000419#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughesbdf48f52001-03-06 15:08:09 +0000420int
421sys_lseek64 (tcp)
422struct tcb *tcp;
423{
424 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000425 long long offset;
426 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
John Hughes0c79e012001-03-08 14:40:06 +0000427 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
John Hughesbdf48f52001-03-06 15:08:09 +0000428 if (tcp->u_arg[3] == SEEK_SET)
429 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
430 else
431 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
432 printxval(whence, tcp->u_arg[3], "SEEK_???");
433 }
434 return RVAL_LUDECIMAL;
435}
436#endif
437
John Hughes70623be2001-03-08 13:59:00 +0000438#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000439int
440sys_truncate(tcp)
441struct tcb *tcp;
442{
443 if (entering(tcp)) {
444 printpath(tcp, tcp->u_arg[0]);
445 tprintf(", %lu", tcp->u_arg[1]);
446 }
447 return 0;
448}
John Hughes5a826b82001-03-07 13:21:24 +0000449#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000450
John Hughes70623be2001-03-08 13:59:00 +0000451#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000452int
453sys_truncate64(tcp)
454struct tcb *tcp;
455{
456 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000457 ALIGN64 (tcp, 1);
John Hughes96f51472001-03-06 16:50:41 +0000458 printpath(tcp, tcp->u_arg[0]);
John Hughes0c79e012001-03-08 14:40:06 +0000459 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
John Hughes96f51472001-03-06 16:50:41 +0000460 }
461 return 0;
462}
463#endif
464
John Hughes70623be2001-03-08 13:59:00 +0000465#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000466int
467sys_ftruncate(tcp)
468struct tcb *tcp;
469{
470 if (entering(tcp)) {
471 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
472 }
473 return 0;
474}
John Hughes5a826b82001-03-07 13:21:24 +0000475#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000476
John Hughes70623be2001-03-08 13:59:00 +0000477#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000478int
479sys_ftruncate64(tcp)
480struct tcb *tcp;
481{
482 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000483 ALIGN64 (tcp, 1);
John Hughes96f51472001-03-06 16:50:41 +0000484 tprintf("%ld, %llu", tcp->u_arg[0],
John Hughes0c79e012001-03-08 14:40:06 +0000485 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
John Hughes96f51472001-03-06 16:50:41 +0000486 }
487 return 0;
488}
489#endif
490
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000491/* several stats */
492
493static struct xlat modetypes[] = {
494 { S_IFREG, "S_IFREG" },
495 { S_IFSOCK, "S_IFSOCK" },
496 { S_IFIFO, "S_IFIFO" },
497 { S_IFLNK, "S_IFLNK" },
498 { S_IFDIR, "S_IFDIR" },
499 { S_IFBLK, "S_IFBLK" },
500 { S_IFCHR, "S_IFCHR" },
501 { 0, NULL },
502};
503
504static char *
505sprintmode(mode)
506int mode;
507{
508 static char buf[64];
509 char *s;
510
511 if ((mode & S_IFMT) == 0)
512 s = "";
513 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
514 sprintf(buf, "%#o", mode);
515 return buf;
516 }
517 sprintf(buf, "%s%s%s%s", s,
518 (mode & S_ISUID) ? "|S_ISUID" : "",
519 (mode & S_ISGID) ? "|S_ISGID" : "",
520 (mode & S_ISVTX) ? "|S_ISVTX" : "");
521 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
522 if (mode)
523 sprintf(buf + strlen(buf), "|%#o", mode);
524 s = (*buf == '|') ? buf + 1 : buf;
525 return *s ? s : "0";
526}
527
528static char *
529sprinttime(t)
530time_t t;
531{
532 struct tm *tmp;
533 static char buf[32];
534
535 if (t == 0) {
536 sprintf(buf, "0");
537 return buf;
538 }
539 tmp = localtime(&t);
540 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
Wichert Akkerman3ed6dc22000-01-11 14:41:09 +0000541 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000542 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
543 return buf;
544}
545
546#ifdef LINUXSPARC
547typedef struct {
548 int tv_sec;
549 int tv_nsec;
550} timestruct_t;
551
552struct solstat {
553 unsigned st_dev;
554 int st_pad1[3]; /* network id */
555 unsigned st_ino;
556 unsigned st_mode;
557 unsigned st_nlink;
558 unsigned st_uid;
559 unsigned st_gid;
560 unsigned st_rdev;
561 int st_pad2[2];
562 int st_size;
563 int st_pad3; /* st_size, off_t expansion */
564 timestruct_t st_atime;
565 timestruct_t st_mtime;
566 timestruct_t st_ctime;
567 int st_blksize;
568 int st_blocks;
569 char st_fstype[16];
570 int st_pad4[8]; /* expansion area */
571};
572
573static void
574printstatsol(tcp, addr)
575struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000576long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000577{
578 struct solstat statbuf;
579
580 if (!addr) {
581 tprintf("NULL");
582 return;
583 }
584 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000585 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000586 return;
587 }
588 if (umove(tcp, addr, &statbuf) < 0) {
589 tprintf("{...}");
590 return;
591 }
592 if (!abbrev(tcp)) {
593 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
594 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
595 (unsigned long) (statbuf.st_dev & 0x3ffff),
596 (unsigned long) statbuf.st_ino,
597 sprintmode(statbuf.st_mode));
598 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
599 (unsigned long) statbuf.st_nlink,
600 (unsigned long) statbuf.st_uid,
601 (unsigned long) statbuf.st_gid);
602 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
603 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
604 }
605 else
606 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
607 switch (statbuf.st_mode & S_IFMT) {
608 case S_IFCHR: case S_IFBLK:
609 tprintf("st_rdev=makedev(%lu, %lu), ",
610 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
611 (unsigned long) (statbuf.st_rdev & 0x3ffff));
612 break;
613 default:
614 tprintf("st_size=%u, ", statbuf.st_size);
615 break;
616 }
617 if (!abbrev(tcp)) {
618 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
619 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
620 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
621 }
622 else
623 tprintf("...}");
624}
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000625#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000626
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000627#ifdef FREEBSD
628static struct xlat fileflags[] = {
629 { UF_NODUMP, "UF_NODUMP" },
630 { UF_IMMUTABLE, "UF_IMMUTABLE" },
631 { UF_APPEND, "UF_APPEND" },
632 { UF_OPAQUE, "UF_OPAQUE" },
633 { UF_NOUNLINK, "UF_NOUNLINK" },
634 { SF_ARCHIVED, "SF_ARCHIVED" },
635 { SF_IMMUTABLE, "SF_IMMUTABLE" },
636 { SF_APPEND, "SF_APPEND" },
637 { SF_NOUNLINK, "SF_NOUNLINK" },
638 { 0, NULL },
639};
640
641int
642sys_chflags(tcp)
643struct tcb *tcp;
644{
645 if (entering(tcp)) {
646 printpath(tcp, tcp->u_arg[0]);
647 tprintf(", ");
648 if (tcp->u_arg[1])
649 printflags(fileflags, tcp->u_arg[1]);
650 else
651 tprintf("0");
652 }
653 return 0;
654}
655
656int
657sys_fchflags(tcp)
658struct tcb *tcp;
659{
660 if (entering(tcp)) {
661 tprintf("%ld, ", tcp->u_arg[0]);
662 if (tcp->u_arg[1])
663 printflags(fileflags, tcp->u_arg[1]);
664 else
665 tprintf("0");
666 }
667 return 0;
668}
669#endif
670
John Hughes70623be2001-03-08 13:59:00 +0000671#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000672static void
673realprintstat(tcp, statbuf)
674struct tcb *tcp;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000675struct stat *statbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000676{
677 if (!abbrev(tcp)) {
678 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
679 (unsigned long) major(statbuf->st_dev),
680 (unsigned long) minor(statbuf->st_dev),
681 (unsigned long) statbuf->st_ino,
682 sprintmode(statbuf->st_mode));
683 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
684 (unsigned long) statbuf->st_nlink,
685 (unsigned long) statbuf->st_uid,
686 (unsigned long) statbuf->st_gid);
687#ifdef HAVE_ST_BLKSIZE
688 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
689#endif /* HAVE_ST_BLKSIZE */
690#ifdef HAVE_ST_BLOCKS
691 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
692#endif /* HAVE_ST_BLOCKS */
693 }
694 else
695 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
696 switch (statbuf->st_mode & S_IFMT) {
697 case S_IFCHR: case S_IFBLK:
698#ifdef HAVE_ST_RDEV
699 tprintf("st_rdev=makedev(%lu, %lu), ",
700 (unsigned long) major(statbuf->st_rdev),
701 (unsigned long) minor(statbuf->st_rdev));
702#else /* !HAVE_ST_RDEV */
703 tprintf("st_size=makedev(%lu, %lu), ",
704 (unsigned long) major(statbuf->st_size),
705 (unsigned long) minor(statbuf->st_size));
706#endif /* !HAVE_ST_RDEV */
707 break;
708 default:
709 tprintf("st_size=%lu, ", statbuf->st_size);
710 break;
711 }
712 if (!abbrev(tcp)) {
713 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
714 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
715 tprintf("st_ctime=%s}", sprinttime(statbuf->st_ctime));
716 }
717 else
718 tprintf("...}");
719}
720
Nate Sammons771a6ff1999-04-05 22:39:31 +0000721
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000722static void
723printstat(tcp, addr)
724struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000725long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000726{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000727 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000728
729#ifdef LINUXSPARC
730 if (current_personality == 1) {
731 printstatsol(tcp, addr);
732 return;
733 }
734#endif /* LINUXSPARC */
735
736 if (!addr) {
737 tprintf("NULL");
738 return;
739 }
740 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000741 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000742 return;
743 }
744 if (umove(tcp, addr, &statbuf) < 0) {
745 tprintf("{...}");
746 return;
747 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000748
749 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000750}
John Hughes70623be2001-03-08 13:59:00 +0000751#endif /* !HAVE_LONG_LONG_OFF_T */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000752
Wichert Akkermanc7926982000-04-10 22:22:31 +0000753#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000754static void
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000755printstat64(tcp, addr)
756struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000757long addr;
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000758{
759 struct stat64 statbuf;
760
761#ifdef LINUXSPARC
762 if (current_personality == 1) {
763 printstatsol(tcp, addr);
764 return;
765 }
766#endif /* LINUXSPARC */
767
768 if (!addr) {
769 tprintf("NULL");
770 return;
771 }
772 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000773 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000774 return;
775 }
776 if (umove(tcp, addr, &statbuf) < 0) {
777 tprintf("{...}");
778 return;
779 }
780
781 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +0000782#ifdef HAVE_LONG_LONG
783 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
784#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000785 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
Wichert Akkermand077c452000-08-10 18:16:15 +0000786#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000787 (unsigned long) major(statbuf.st_dev),
788 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +0000789#ifdef HAVE_LONG_LONG
790 (unsigned long long) statbuf.st_ino,
791#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000792 (unsigned long) statbuf.st_ino,
Wichert Akkermand077c452000-08-10 18:16:15 +0000793#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000794 sprintmode(statbuf.st_mode));
795 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
796 (unsigned long) statbuf.st_nlink,
797 (unsigned long) statbuf.st_uid,
798 (unsigned long) statbuf.st_gid);
799#ifdef HAVE_ST_BLKSIZE
800 tprintf("st_blksize=%lu, ",
801 (unsigned long) statbuf.st_blksize);
802#endif /* HAVE_ST_BLKSIZE */
803#ifdef HAVE_ST_BLOCKS
804 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
805#endif /* HAVE_ST_BLOCKS */
806 }
807 else
808 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
809 switch (statbuf.st_mode & S_IFMT) {
810 case S_IFCHR: case S_IFBLK:
811#ifdef HAVE_ST_RDEV
812 tprintf("st_rdev=makedev(%lu, %lu), ",
813 (unsigned long) major(statbuf.st_rdev),
814 (unsigned long) minor(statbuf.st_rdev));
815#else /* !HAVE_ST_RDEV */
816 tprintf("st_size=makedev(%lu, %lu), ",
817 (unsigned long) major(statbuf.st_size),
818 (unsigned long) minor(statbuf.st_size));
819#endif /* !HAVE_ST_RDEV */
820 break;
821 default:
822 tprintf("st_size=%llu, ", statbuf.st_size);
823 break;
824 }
825 if (!abbrev(tcp)) {
826 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
827 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
John Hughesb8c9f772001-03-07 16:53:07 +0000828#ifndef FREEBSD
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000829 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
John Hughesb8c9f772001-03-07 16:53:07 +0000830#else /* FREEBSD */
831 tprintf("st_ctime=%s, ", sprinttime(statbuf.st_ctime));
832 tprintf("st_flags=");
833 if (statbuf.st_flags) {
834 printflags(fileflags, statbuf.st_flags);
835 } else
836 tprintf("0");
837 tprintf(", st_gen=%u}", statbuf.st_gen);
838#endif /* FREEBSD */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000839 }
840 else
841 tprintf("...}");
842}
Wichert Akkermanc7926982000-04-10 22:22:31 +0000843#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000844
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000845#if defined(linux) && !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000846static void
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000847convertoldstat(oldbuf, newbuf)
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000848const struct __old_kernel_stat *oldbuf;
849struct stat *newbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000850{
851 newbuf->st_dev=oldbuf->st_dev;
852 newbuf->st_ino=oldbuf->st_ino;
853 newbuf->st_mode=oldbuf->st_mode;
854 newbuf->st_nlink=oldbuf->st_nlink;
855 newbuf->st_uid=oldbuf->st_uid;
856 newbuf->st_gid=oldbuf->st_gid;
857 newbuf->st_rdev=oldbuf->st_rdev;
858 newbuf->st_size=oldbuf->st_size;
859 newbuf->st_atime=oldbuf->st_atime;
860 newbuf->st_mtime=oldbuf->st_mtime;
861 newbuf->st_ctime=oldbuf->st_ctime;
862 newbuf->st_blksize=0; /* not supported in old_stat */
863 newbuf->st_blocks=0; /* not supported in old_stat */
864}
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000865
866
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000867static void
868printoldstat(tcp, addr)
869struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000870long addr;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000871{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000872 struct __old_kernel_stat statbuf;
873 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000874
875#ifdef LINUXSPARC
876 if (current_personality == 1) {
877 printstatsol(tcp, addr);
878 return;
879 }
880#endif /* LINUXSPARC */
881
882 if (!addr) {
883 tprintf("NULL");
884 return;
885 }
886 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000887 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000888 return;
889 }
890 if (umove(tcp, addr, &statbuf) < 0) {
891 tprintf("{...}");
892 return;
893 }
894
895 convertoldstat(&statbuf, &newstatbuf);
896 realprintstat(tcp, &newstatbuf);
897}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000898#endif /* linux && !IA64 */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000899
John Hughes70623be2001-03-08 13:59:00 +0000900#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000901int
902sys_stat(tcp)
903struct tcb *tcp;
904{
905 if (entering(tcp)) {
906 printpath(tcp, tcp->u_arg[0]);
907 tprintf(", ");
908 } else {
909 printstat(tcp, tcp->u_arg[1]);
910 }
911 return 0;
912}
John Hughesb8c9f772001-03-07 16:53:07 +0000913#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000914
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000915int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000916sys_stat64(tcp)
917struct tcb *tcp;
918{
919#ifdef HAVE_STAT64
920 if (entering(tcp)) {
921 printpath(tcp, tcp->u_arg[0]);
922 tprintf(", ");
923 } else {
924 printstat64(tcp, tcp->u_arg[1]);
925 }
926 return 0;
927#else
928 return printargs(tcp);
929#endif
930}
931
John Hughese2f6d872001-03-07 16:03:20 +0000932#ifdef linux
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000933# if !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000934int
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000935sys_oldstat(tcp)
936struct tcb *tcp;
937{
938 if (entering(tcp)) {
939 printpath(tcp, tcp->u_arg[0]);
940 tprintf(", ");
941 } else {
942 printoldstat(tcp, tcp->u_arg[1]);
943 }
944 return 0;
945}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000946# endif /* !IA64 */
947#endif /* linux */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000948
John Hughes70623be2001-03-08 13:59:00 +0000949#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000950int
951sys_fstat(tcp)
952struct tcb *tcp;
953{
954 if (entering(tcp))
955 tprintf("%ld, ", tcp->u_arg[0]);
956 else {
957 printstat(tcp, tcp->u_arg[1]);
958 }
959 return 0;
960}
John Hughesb8c9f772001-03-07 16:53:07 +0000961#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000962
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000963int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000964sys_fstat64(tcp)
965struct tcb *tcp;
966{
967#ifdef HAVE_STAT64
968 if (entering(tcp))
969 tprintf("%ld, ", tcp->u_arg[0]);
970 else {
971 printstat64(tcp, tcp->u_arg[1]);
972 }
973 return 0;
974#else
975 return printargs(tcp);
976#endif
977}
978
John Hughese2f6d872001-03-07 16:03:20 +0000979#ifdef linux
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000980# if !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000981int
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000982sys_oldfstat(tcp)
983struct tcb *tcp;
984{
985 if (entering(tcp))
986 tprintf("%ld, ", tcp->u_arg[0]);
987 else {
988 printoldstat(tcp, tcp->u_arg[1]);
989 }
990 return 0;
991}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000992# endif /* !IA64 */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000993#endif
994
John Hughes70623be2001-03-08 13:59:00 +0000995#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000996int
997sys_lstat(tcp)
998struct tcb *tcp;
999{
1000 if (entering(tcp)) {
1001 printpath(tcp, tcp->u_arg[0]);
1002 tprintf(", ");
1003 } else {
1004 printstat(tcp, tcp->u_arg[1]);
1005 }
1006 return 0;
1007}
John Hughesb8c9f772001-03-07 16:53:07 +00001008#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001009
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001010int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001011sys_lstat64(tcp)
1012struct tcb *tcp;
1013{
1014#ifdef HAVE_STAT64
1015 if (entering(tcp)) {
1016 printpath(tcp, tcp->u_arg[0]);
1017 tprintf(", ");
1018 } else {
1019 printstat64(tcp, tcp->u_arg[1]);
1020 }
1021 return 0;
1022#else
1023 return printargs(tcp);
1024#endif
1025}
1026
John Hughese2f6d872001-03-07 16:03:20 +00001027#ifdef linux
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001028# if !defined(IA64)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001029int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001030sys_oldlstat(tcp)
1031struct tcb *tcp;
1032{
1033 if (entering(tcp)) {
1034 printpath(tcp, tcp->u_arg[0]);
1035 tprintf(", ");
1036 } else {
1037 printoldstat(tcp, tcp->u_arg[1]);
1038 }
1039 return 0;
1040}
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001041# endif /* !IA64 */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001042#endif
1043
1044
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001045#if defined(SVR4) || defined(LINUXSPARC)
1046
1047int
1048sys_xstat(tcp)
1049struct tcb *tcp;
1050{
1051 if (entering(tcp)) {
1052 tprintf("%ld, ", tcp->u_arg[0]);
1053 printpath(tcp, tcp->u_arg[1]);
1054 tprintf(", ");
1055 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001056#ifdef _STAT64_VER
1057 if (tcp->u_arg[0] == _STAT64_VER)
1058 printstat64 (tcp, tcp->u_arg[2]);
1059 else
1060#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001061 printstat(tcp, tcp->u_arg[2]);
1062 }
1063 return 0;
1064}
1065
1066int
1067sys_fxstat(tcp)
1068struct tcb *tcp;
1069{
1070 if (entering(tcp))
1071 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1072 else {
John Hughes8fe2c982001-03-06 09:45:18 +00001073#ifdef _STAT64_VER
1074 if (tcp->u_arg[0] == _STAT64_VER)
1075 printstat64 (tcp, tcp->u_arg[2]);
1076 else
1077#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001078 printstat(tcp, tcp->u_arg[2]);
1079 }
1080 return 0;
1081}
1082
1083int
1084sys_lxstat(tcp)
1085struct tcb *tcp;
1086{
1087 if (entering(tcp)) {
1088 tprintf("%ld, ", tcp->u_arg[0]);
1089 printpath(tcp, tcp->u_arg[1]);
1090 tprintf(", ");
1091 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001092#ifdef _STAT64_VER
1093 if (tcp->u_arg[0] == _STAT64_VER)
1094 printstat64 (tcp, tcp->u_arg[2]);
1095 else
1096#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001097 printstat(tcp, tcp->u_arg[2]);
1098 }
1099 return 0;
1100}
1101
1102int
1103sys_xmknod(tcp)
1104struct tcb *tcp;
1105{
1106 int mode = tcp->u_arg[2];
1107
1108 if (entering(tcp)) {
1109 tprintf("%ld, ", tcp->u_arg[0]);
1110 printpath(tcp, tcp->u_arg[1]);
1111 tprintf(", %s", sprintmode(mode));
1112 switch (mode & S_IFMT) {
1113 case S_IFCHR: case S_IFBLK:
1114#ifdef LINUXSPARC
1115 tprintf(", makedev(%lu, %lu)",
1116 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1117 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
1118#else
1119 tprintf(", makedev(%lu, %lu)",
1120 (unsigned long) major(tcp->u_arg[3]),
1121 (unsigned long) minor(tcp->u_arg[3]));
1122#endif
1123 break;
1124 default:
1125 break;
1126 }
1127 }
1128 return 0;
1129}
1130
Wichert Akkerman8829a551999-06-11 13:18:40 +00001131#ifdef HAVE_SYS_ACL_H
1132
1133#include <sys/acl.h>
1134
1135struct xlat aclcmds[] = {
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001136#ifdef SETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001137 { SETACL, "SETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001138#endif
1139#ifdef GETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001140 { GETACL, "GETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001141#endif
1142#ifdef GETACLCNT
Wichert Akkerman8829a551999-06-11 13:18:40 +00001143 { GETACLCNT, "GETACLCNT" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001144#endif
1145#ifdef ACL_GET
1146 { ACL_GET, "ACL_GET" },
1147#endif
1148#ifdef ACL_SET
1149 { ACL_SET, "ACL_SET" },
1150#endif
1151#ifdef ACL_CNT
1152 { ACL_CNT, "ACL_CNT" },
1153#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +00001154 { 0, NULL },
1155};
1156
1157int
1158sys_acl(tcp)
1159struct tcb *tcp;
1160{
1161 if (entering(tcp)) {
1162 printpath(tcp, tcp->u_arg[0]);
1163 tprintf(", ");
1164 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1165 tprintf(", %ld", tcp->u_arg[2]);
1166 /*
1167 * FIXME - dump out the list of aclent_t's pointed to
1168 * by "tcp->u_arg[3]" if it's not NULL.
1169 */
1170 if (tcp->u_arg[3])
1171 tprintf(", %#lx", tcp->u_arg[3]);
1172 else
1173 tprintf(", NULL");
1174 }
1175 return 0;
1176}
1177
1178
1179int
1180sys_facl(tcp)
1181struct tcb *tcp;
1182{
1183 if (entering(tcp)) {
1184 tprintf("%ld, ", tcp->u_arg[0]);
1185 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1186 tprintf(", %ld", tcp->u_arg[2]);
1187 /*
1188 * FIXME - dump out the list of aclent_t's pointed to
1189 * by "tcp->u_arg[3]" if it's not NULL.
1190 */
1191 if (tcp->u_arg[3])
1192 tprintf(", %#lx", tcp->u_arg[3]);
1193 else
1194 tprintf(", NULL");
1195 }
1196 return 0;
1197}
1198
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001199
1200struct xlat aclipc[] = {
1201#ifdef IPC_SHM
1202 { IPC_SHM, "IPC_SHM" },
1203#endif
1204#ifdef IPC_SEM
1205 { IPC_SEM, "IPC_SEM" },
1206#endif
1207#ifdef IPC_MSG
1208 { IPC_MSG, "IPC_MSG" },
1209#endif
1210 { 0, NULL },
1211};
1212
1213
1214int
1215sys_aclipc(tcp)
1216struct tcb *tcp;
1217{
1218 if (entering(tcp)) {
1219 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1220 tprintf(", %#lx, ", tcp->u_arg[1]);
1221 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1222 tprintf(", %ld", tcp->u_arg[3]);
1223 /*
1224 * FIXME - dump out the list of aclent_t's pointed to
1225 * by "tcp->u_arg[4]" if it's not NULL.
1226 */
1227 if (tcp->u_arg[4])
1228 tprintf(", %#lx", tcp->u_arg[4]);
1229 else
1230 tprintf(", NULL");
1231 }
1232 return 0;
1233}
1234
1235
1236
Wichert Akkerman8829a551999-06-11 13:18:40 +00001237#endif /* HAVE_SYS_ACL_H */
1238
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001239#endif /* SVR4 || LINUXSPARC */
1240
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001241#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001242
1243static struct xlat fsmagic[] = {
Wichert Akkerman43a74822000-06-27 17:33:32 +00001244 { 0x73757245, "CODA_SUPER_MAGIC" },
1245 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1246 { 0x1373, "DEVFS_SUPER_MAGIC" },
1247 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1248 { 0x414A53, "EFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001249 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1250 { 0xef53, "EXT2_SUPER_MAGIC" },
1251 { 0x137d, "EXT_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001252 { 0xf995e849, "HPFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001253 { 0x9660, "ISOFS_SUPER_MAGIC" },
1254 { 0x137f, "MINIX_SUPER_MAGIC" },
1255 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001256 { 0x2468, "MINIX2_SUPER_MAGIC" },
1257 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001258 { 0x4d44, "MSDOS_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001259 { 0x564c, "NCP_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001260 { 0x6969, "NFS_SUPER_MAGIC" },
1261 { 0x9fa0, "PROC_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001262 { 0x002f, "QNX4_SUPER_MAGIC" },
1263 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1264 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1265 { 0x517b, "SMB_SUPER_MAGIC" },
1266 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1267 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1268 { 0x00011954, "UFS_MAGIC" },
1269 { 0x54190100, "UFS_CIGAM" },
1270 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001271 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1272 { 0, NULL },
1273};
1274
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001275#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001276
1277#ifndef SVR4
1278
1279static char *
1280sprintfstype(magic)
1281int magic;
1282{
1283 static char buf[32];
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001284#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001285 char *s;
1286
1287 s = xlookup(fsmagic, magic);
1288 if (s) {
1289 sprintf(buf, "\"%s\"", s);
1290 return buf;
1291 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001292#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001293 sprintf(buf, "%#x", magic);
1294 return buf;
1295}
1296
1297static void
1298printstatfs(tcp, addr)
1299struct tcb *tcp;
1300long addr;
1301{
1302 struct statfs statbuf;
1303
1304 if (syserror(tcp) || !verbose(tcp)) {
1305 tprintf("%#lx", addr);
1306 return;
1307 }
1308 if (umove(tcp, addr, &statbuf) < 0) {
1309 tprintf("{...}");
1310 return;
1311 }
1312#ifdef ALPHA
1313
1314 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1315 sprintfstype(statbuf.f_type),
1316 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001317 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001318 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1319#else /* !ALPHA */
1320 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1321 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +00001322 (unsigned long)statbuf.f_bsize,
1323 (unsigned long)statbuf.f_blocks,
1324 (unsigned long)statbuf.f_bfree);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001325 tprintf("f_files=%lu, f_ffree=%lu",
Nate Sammons5c74d201999-04-06 01:37:51 +00001326 (unsigned long)statbuf.f_files,
1327 (unsigned long)statbuf.f_ffree);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001328#ifdef linux
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001329 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001330#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001331#endif /* !ALPHA */
1332 tprintf("}");
1333}
1334
1335int
1336sys_statfs(tcp)
1337struct tcb *tcp;
1338{
1339 if (entering(tcp)) {
1340 printpath(tcp, tcp->u_arg[0]);
1341 tprintf(", ");
1342 } else {
1343 printstatfs(tcp, tcp->u_arg[1]);
1344 }
1345 return 0;
1346}
1347
1348int
1349sys_fstatfs(tcp)
1350struct tcb *tcp;
1351{
1352 if (entering(tcp)) {
1353 tprintf("%lu, ", tcp->u_arg[0]);
1354 } else {
1355 printstatfs(tcp, tcp->u_arg[1]);
1356 }
1357 return 0;
1358}
1359
Wichert Akkermana0f36c61999-04-16 14:01:34 +00001360#if defined(linux) && defined(__alpha)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001361
1362int
1363osf_statfs(tcp)
1364struct tcb *tcp;
1365{
1366 if (entering(tcp)) {
1367 printpath(tcp, tcp->u_arg[0]);
1368 tprintf(", ");
1369 } else {
1370 printstatfs(tcp, tcp->u_arg[1]);
1371 tprintf(", %lu", tcp->u_arg[2]);
1372 }
1373 return 0;
1374}
1375
1376int
1377osf_fstatfs(tcp)
1378struct tcb *tcp;
1379{
1380 if (entering(tcp)) {
1381 tprintf("%lu, ", tcp->u_arg[0]);
1382 } else {
1383 printstatfs(tcp, tcp->u_arg[1]);
1384 tprintf(", %lu", tcp->u_arg[2]);
1385 }
1386 return 0;
1387}
Wichert Akkermana0f36c61999-04-16 14:01:34 +00001388#endif /* linux && __alpha */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001389
1390#endif /* !SVR4 */
1391
1392#ifdef SUNOS4
1393
1394int
1395sys_ustat(tcp)
1396struct tcb *tcp;
1397{
1398 struct ustat statbuf;
1399
1400 if (entering(tcp)) {
1401 tprintf("makedev(%lu, %lu), ",
1402 (long) major(tcp->u_arg[0]),
1403 (long) minor(tcp->u_arg[0]));
1404 }
1405 else {
1406 if (syserror(tcp) || !verbose(tcp))
1407 tprintf("%#lx", tcp->u_arg[1]);
1408 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1409 tprintf("{...}");
1410 else {
1411 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1412 statbuf.f_tfree, statbuf.f_tinode);
1413 tprintf("f_fname=\"%.*s\", ",
1414 (int) sizeof(statbuf.f_fname),
1415 statbuf.f_fname);
1416 tprintf("f_fpack=\"%.*s\"}",
1417 (int) sizeof(statbuf.f_fpack),
1418 statbuf.f_fpack);
1419 }
1420 }
1421 return 0;
1422}
1423
1424#endif /* SUNOS4 */
1425
Wichert Akkermanc7926982000-04-10 22:22:31 +00001426int
1427sys_pivotroot(tcp)
1428struct tcb *tcp;
1429{
1430 if (entering(tcp)) {
1431 printpath(tcp, tcp->u_arg[0]);
1432 tprintf(", ");
1433 printpath(tcp, tcp->u_arg[1]);
1434 }
1435 return 0;
1436}
1437
1438
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001439/* directory */
1440int
1441sys_chdir(tcp)
1442struct tcb *tcp;
1443{
1444 if (entering(tcp)) {
1445 printpath(tcp, tcp->u_arg[0]);
1446 }
1447 return 0;
1448}
1449
1450int
1451sys_mkdir(tcp)
1452struct tcb *tcp;
1453{
1454 if (entering(tcp)) {
1455 printpath(tcp, tcp->u_arg[0]);
1456 tprintf(", %#lo", tcp->u_arg[1]);
1457 }
1458 return 0;
1459}
1460
1461int
1462sys_rmdir(tcp)
1463struct tcb *tcp;
1464{
1465 if (entering(tcp)) {
1466 printpath(tcp, tcp->u_arg[0]);
1467 }
1468 return 0;
1469}
1470
1471int
1472sys_fchdir(tcp)
1473struct tcb *tcp;
1474{
1475 if (entering(tcp)) {
1476 tprintf("%ld", tcp->u_arg[0]);
1477 }
1478 return 0;
1479}
1480
1481int
1482sys_chroot(tcp)
1483struct tcb *tcp;
1484{
1485 if (entering(tcp)) {
1486 printpath(tcp, tcp->u_arg[0]);
1487 }
1488 return 0;
1489}
1490
1491int
1492sys_fchroot(tcp)
1493struct tcb *tcp;
1494{
1495 if (entering(tcp)) {
1496 tprintf("%ld", tcp->u_arg[0]);
1497 }
1498 return 0;
1499}
1500
1501int
1502sys_link(tcp)
1503struct tcb *tcp;
1504{
1505 if (entering(tcp)) {
1506 printpath(tcp, tcp->u_arg[0]);
1507 tprintf(", ");
1508 printpath(tcp, tcp->u_arg[1]);
1509 }
1510 return 0;
1511}
1512
1513int
1514sys_unlink(tcp)
1515struct tcb *tcp;
1516{
1517 if (entering(tcp)) {
1518 printpath(tcp, tcp->u_arg[0]);
1519 }
1520 return 0;
1521}
1522
1523int
1524sys_symlink(tcp)
1525struct tcb *tcp;
1526{
1527 if (entering(tcp)) {
1528 printpath(tcp, tcp->u_arg[0]);
1529 tprintf(", ");
1530 printpath(tcp, tcp->u_arg[1]);
1531 }
1532 return 0;
1533}
1534
1535int
1536sys_readlink(tcp)
1537struct tcb *tcp;
1538{
1539 if (entering(tcp)) {
1540 printpath(tcp, tcp->u_arg[0]);
1541 tprintf(", ");
1542 } else {
1543 if (syserror(tcp))
1544 tprintf("%#lx", tcp->u_arg[1]);
1545 else
1546 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1547 tprintf(", %lu", tcp->u_arg[2]);
1548 }
1549 return 0;
1550}
1551
1552int
1553sys_rename(tcp)
1554struct tcb *tcp;
1555{
1556 if (entering(tcp)) {
1557 printpath(tcp, tcp->u_arg[0]);
1558 tprintf(", ");
1559 printpath(tcp, tcp->u_arg[1]);
1560 }
1561 return 0;
1562}
1563
1564int
1565sys_chown(tcp)
1566struct tcb *tcp;
1567{
1568 if (entering(tcp)) {
1569 printpath(tcp, tcp->u_arg[0]);
1570 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1571 }
1572 return 0;
1573}
1574
1575int
1576sys_fchown(tcp)
1577struct tcb *tcp;
1578{
1579 if (entering(tcp)) {
1580 tprintf("%ld, %lu, %lu",
1581 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1582 }
1583 return 0;
1584}
1585
1586int
1587sys_chmod(tcp)
1588struct tcb *tcp;
1589{
1590 if (entering(tcp)) {
1591 printpath(tcp, tcp->u_arg[0]);
1592 tprintf(", %#lo", tcp->u_arg[1]);
1593 }
1594 return 0;
1595}
1596
1597int
1598sys_fchmod(tcp)
1599struct tcb *tcp;
1600{
1601 if (entering(tcp)) {
1602 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1603 }
1604 return 0;
1605}
1606
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001607#ifdef ALPHA
1608int
1609sys_osf_utimes(tcp)
1610struct tcb *tcp;
1611{
1612 if (entering(tcp)) {
1613 printpath(tcp, tcp->u_arg[0]);
1614 tprintf(", ");
1615 printtv32(tcp, tcp->u_arg[1]);
1616 }
1617 return 0;
1618}
1619#endif
1620
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001621int
1622sys_utimes(tcp)
1623struct tcb *tcp;
1624{
1625 if (entering(tcp)) {
1626 printpath(tcp, tcp->u_arg[0]);
1627 tprintf(", ");
1628 printtv(tcp, tcp->u_arg[1]);
1629 }
1630 return 0;
1631}
1632
1633int
1634sys_utime(tcp)
1635struct tcb *tcp;
1636{
1637 long ut[2];
1638
1639 if (entering(tcp)) {
1640 printpath(tcp, tcp->u_arg[0]);
1641 tprintf(", ");
1642 if (!tcp->u_arg[1])
1643 tprintf("NULL");
1644 else if (!verbose(tcp))
1645 tprintf("%#lx", tcp->u_arg[1]);
1646 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1647 (char *) ut) < 0)
1648 tprintf("[?, ?]");
1649 else {
1650 tprintf("[%s,", sprinttime(ut[0]));
1651 tprintf(" %s]", sprinttime(ut[1]));
1652 }
1653 }
1654 return 0;
1655}
1656
1657int
1658sys_mknod(tcp)
1659struct tcb *tcp;
1660{
1661 int mode = tcp->u_arg[1];
1662
1663 if (entering(tcp)) {
1664 printpath(tcp, tcp->u_arg[0]);
1665 tprintf(", %s", sprintmode(mode));
1666 switch (mode & S_IFMT) {
1667 case S_IFCHR: case S_IFBLK:
1668#ifdef LINUXSPARC
1669 if (current_personality == 1)
1670 tprintf(", makedev(%lu, %lu)",
1671 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1672 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1673 else
1674#endif
1675 tprintf(", makedev(%lu, %lu)",
1676 (unsigned long) major(tcp->u_arg[2]),
1677 (unsigned long) minor(tcp->u_arg[2]));
1678 break;
1679 default:
1680 break;
1681 }
1682 }
1683 return 0;
1684}
1685
1686int
1687sys_mkfifo(tcp)
1688struct tcb *tcp;
1689{
1690 if (entering(tcp)) {
1691 printpath(tcp, tcp->u_arg[0]);
1692 tprintf(", %#lo", tcp->u_arg[1]);
1693 }
1694 return 0;
1695}
1696
1697int
1698sys_fsync(tcp)
1699struct tcb *tcp;
1700{
1701 if (entering(tcp)) {
1702 tprintf("%ld", tcp->u_arg[0]);
1703 }
1704 return 0;
1705}
1706
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001707#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001708
1709static void
1710printdir(tcp, addr)
1711struct tcb *tcp;
1712long addr;
1713{
1714 struct dirent d;
1715
1716 if (!verbose(tcp)) {
1717 tprintf("%#lx", addr);
1718 return;
1719 }
1720 if (umove(tcp, addr, &d) < 0) {
1721 tprintf("{...}");
1722 return;
1723 }
1724 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001725 tprintf("d_name=");
1726 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1727 tprintf("}");
1728}
1729
1730int
1731sys_readdir(tcp)
1732struct tcb *tcp;
1733{
1734 if (entering(tcp)) {
1735 tprintf("%lu, ", tcp->u_arg[0]);
1736 } else {
1737 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1738 tprintf("%#lx", tcp->u_arg[1]);
1739 else
1740 printdir(tcp, tcp->u_arg[1]);
1741 /* Not much point in printing this out, it is always 1. */
1742 if (tcp->u_arg[2] != 1)
1743 tprintf(", %lu", tcp->u_arg[2]);
1744 }
1745 return 0;
1746}
1747
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001748#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001749
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001750#ifdef FREEBSD
1751struct xlat direnttypes[] = {
1752 { DT_FIFO, "DT_FIFO" },
1753 { DT_CHR, "DT_CHR" },
1754 { DT_DIR, "DT_DIR" },
1755 { DT_BLK, "DT_BLK" },
1756 { DT_REG, "DT_REG" },
1757 { DT_LNK, "DT_LNK" },
1758 { DT_SOCK, "DT_SOCK" },
1759 { DT_WHT, "DT_WHT" },
1760 { 0, NULL },
1761};
1762
1763#endif
1764
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001765int
1766sys_getdents(tcp)
1767struct tcb *tcp;
1768{
1769 int i, len, dents = 0;
1770 char *buf;
1771
1772 if (entering(tcp)) {
1773 tprintf("%lu, ", tcp->u_arg[0]);
1774 return 0;
1775 }
1776 if (syserror(tcp) || !verbose(tcp)) {
1777 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1778 return 0;
1779 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001780 len = tcp->u_rval;
1781 if ((buf = malloc(len)) == NULL) {
1782 tprintf("out of memory\n");
1783 return 0;
1784 }
1785 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1786 tprintf("{...}, %lu", tcp->u_arg[2]);
1787 free(buf);
1788 return 0;
1789 }
1790 if (!abbrev(tcp))
1791 tprintf("{");
1792 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00001793 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001794#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001795 if (!abbrev(tcp)) {
1796 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1797 i ? " " : "", d->d_ino, d->d_off);
1798 tprintf("d_reclen=%u, d_name=\"%s\"}",
1799 d->d_reclen, d->d_name);
1800 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001801#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001802#ifdef SVR4
1803 if (!abbrev(tcp)) {
1804 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1805 i ? " " : "", d->d_ino, d->d_off);
1806 tprintf("d_reclen=%u, d_name=\"%s\"}",
1807 d->d_reclen, d->d_name);
1808 }
1809#endif /* SVR4 */
1810#ifdef SUNOS4
1811 if (!abbrev(tcp)) {
1812 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1813 i ? " " : "", d->d_off, d->d_fileno,
1814 d->d_reclen);
1815 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1816 d->d_namlen, d->d_namlen, d->d_name);
1817 }
1818#endif /* SUNOS4 */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001819#ifdef FREEBSD
1820 if (!abbrev(tcp)) {
1821 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1822 i ? " " : "", d->d_fileno, d->d_reclen);
1823 printxval(direnttypes, d->d_type, "DT_???");
1824 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1825 d->d_namlen, d->d_namlen, d->d_name);
1826 }
1827#endif /* FREEBSD */
Pavel Machek9a9f10b2000-02-01 16:22:52 +00001828 if (!d->d_reclen) {
1829 tprintf("/* d_reclen == 0, problem here */");
1830 break;
1831 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001832 i += d->d_reclen;
1833 dents++;
1834 }
1835 if (!abbrev(tcp))
1836 tprintf("}");
1837 else
1838 tprintf("/* %u entries */", dents);
1839 tprintf(", %lu", tcp->u_arg[2]);
1840 free(buf);
1841 return 0;
1842}
1843
John Hughesbdf48f52001-03-06 15:08:09 +00001844
1845#if _LFS64_LARGEFILE
1846int
1847sys_getdents64(tcp)
1848struct tcb *tcp;
1849{
1850 int i, len, dents = 0;
1851 char *buf;
1852
1853 if (entering(tcp)) {
1854 tprintf("%lu, ", tcp->u_arg[0]);
1855 return 0;
1856 }
1857 if (syserror(tcp) || !verbose(tcp)) {
1858 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1859 return 0;
1860 }
1861 len = tcp->u_rval;
1862 if ((buf = malloc(len)) == NULL) {
1863 tprintf("out of memory\n");
1864 return 0;
1865 }
1866 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1867 tprintf("{...}, %lu", tcp->u_arg[2]);
1868 free(buf);
1869 return 0;
1870 }
1871 if (!abbrev(tcp))
1872 tprintf("{");
1873 for (i = 0; i < len;) {
1874 struct dirent64 *d = (struct dirent64 *) &buf[i];
1875#ifdef linux
1876 if (!abbrev(tcp)) {
1877 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1878 i ? " " : "", d->d_ino, d->d_off);
1879 tprintf("d_reclen=%u, d_name=\"%s\"}",
1880 d->d_reclen, d->d_name);
1881 }
1882#endif /* linux */
1883#ifdef SVR4
1884 if (!abbrev(tcp)) {
1885 tprintf("%s{d_ino=%llu, d_off=%llu, ",
1886 i ? " " : "", d->d_ino, d->d_off);
1887 tprintf("d_reclen=%u, d_name=\"%s\"}",
1888 d->d_reclen, d->d_name);
1889 }
1890#endif /* SVR4 */
1891#ifdef SUNOS4
1892 if (!abbrev(tcp)) {
1893 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1894 i ? " " : "", d->d_off, d->d_fileno,
1895 d->d_reclen);
1896 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1897 d->d_namlen, d->d_namlen, d->d_name);
1898 }
1899#endif /* SUNOS4 */
1900 i += d->d_reclen;
1901 dents++;
1902 }
1903 if (!abbrev(tcp))
1904 tprintf("}");
1905 else
1906 tprintf("/* %u entries */", dents);
1907 tprintf(", %lu", tcp->u_arg[2]);
1908 free(buf);
1909 return 0;
1910}
1911#endif
1912
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001913#ifdef FREEBSD
1914int
1915sys_getdirentries(tcp)
1916struct tcb * tcp;
1917{
1918 int i, len, dents = 0;
1919 long basep;
1920 char *buf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001921
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001922 if (entering(tcp)) {
1923 tprintf("%lu, ", tcp->u_arg[0]);
1924 return 0;
1925 }
1926 if (syserror(tcp) || !verbose(tcp)) {
1927 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1928 return 0;
1929 }
1930 len = tcp->u_rval;
1931 if ((buf = malloc(len)) == NULL) {
1932 tprintf("out of memory\n");
1933 return 0;
1934 }
1935 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1936 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
1937 free(buf);
1938 return 0;
1939 }
1940 if (!abbrev(tcp))
1941 tprintf("{");
1942 for (i = 0; i < len;) {
1943 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
1944 if (!abbrev(tcp)) {
1945 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1946 i ? " " : "", d->d_fileno, d->d_reclen);
1947 printxval(direnttypes, d->d_type, "DT_???");
1948 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1949 d->d_namlen, d->d_namlen, d->d_name);
1950 }
1951 i += d->d_reclen;
1952 dents++;
1953 }
1954 if (!abbrev(tcp))
1955 tprintf("}");
1956 else
1957 tprintf("/* %u entries */", dents);
1958 free(buf);
1959 tprintf(", %lu", tcp->u_arg[2]);
1960 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
1961 tprintf(", %#lx", tcp->u_arg[3]);
1962 else
1963 tprintf(", [%lu]", basep);
1964 return 0;
1965}
1966#endif
1967
1968#ifdef linux
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001969int
1970sys_getcwd(tcp)
1971struct tcb *tcp;
1972{
1973 if (exiting(tcp)) {
1974 if (syserror(tcp))
1975 tprintf("%#lx", tcp->u_arg[0]);
1976 else
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001977 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001978 tprintf(", %lu", tcp->u_arg[1]);
1979 }
1980 return 0;
1981}
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001982#endif /* linux */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001983
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001984#ifdef FREEBSD
1985int
1986sys___getcwd(tcp)
1987struct tcb *tcp;
1988{
1989 if (exiting(tcp)) {
1990 if (syserror(tcp))
1991 tprintf("%#lx", tcp->u_arg[0]);
1992 else
1993 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
1994 tprintf(", %lu", tcp->u_arg[1]);
1995 }
1996 return 0;
1997}
1998#endif
1999
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002000#ifdef HAVE_SYS_ASYNCH_H
2001
2002int
2003sys_aioread(tcp)
2004struct tcb *tcp;
2005{
2006 struct aio_result_t res;
2007
2008 if (entering(tcp)) {
2009 tprintf("%lu, ", tcp->u_arg[0]);
2010 } else {
2011 if (syserror(tcp))
2012 tprintf("%#lx", tcp->u_arg[1]);
2013 else
2014 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2015 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2016 printxval(whence, tcp->u_arg[4], "L_???");
2017 if (syserror(tcp) || tcp->u_arg[5] == 0
2018 || umove(tcp, tcp->u_arg[5], &res) < 0)
2019 tprintf(", %#lx", tcp->u_arg[5]);
2020 else
2021 tprintf(", {aio_return %d aio_errno %d}",
2022 res.aio_return, res.aio_errno);
2023 }
2024 return 0;
2025}
2026
2027int
2028sys_aiowrite(tcp)
2029struct tcb *tcp;
2030{
2031 struct aio_result_t res;
2032
2033 if (entering(tcp)) {
2034 tprintf("%lu, ", tcp->u_arg[0]);
2035 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2036 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2037 printxval(whence, tcp->u_arg[4], "L_???");
2038 }
2039 else {
2040 if (tcp->u_arg[5] == 0)
2041 tprintf(", NULL");
2042 else if (syserror(tcp)
2043 || umove(tcp, tcp->u_arg[5], &res) < 0)
2044 tprintf(", %#lx", tcp->u_arg[5]);
2045 else
2046 tprintf(", {aio_return %d aio_errno %d}",
2047 res.aio_return, res.aio_errno);
2048 }
2049 return 0;
2050}
2051
2052int
2053sys_aiowait(tcp)
2054struct tcb *tcp;
2055{
2056 if (entering(tcp))
2057 printtv(tcp, tcp->u_arg[0]);
2058 return 0;
2059}
2060
2061int
2062sys_aiocancel(tcp)
2063struct tcb *tcp;
2064{
2065 struct aio_result_t res;
2066
2067 if (exiting(tcp)) {
2068 if (tcp->u_arg[0] == 0)
2069 tprintf("NULL");
2070 else if (syserror(tcp)
2071 || umove(tcp, tcp->u_arg[0], &res) < 0)
2072 tprintf("%#lx", tcp->u_arg[0]);
2073 else
2074 tprintf("{aio_return %d aio_errno %d}",
2075 res.aio_return, res.aio_errno);
2076 }
2077 return 0;
2078}
2079
2080#endif /* HAVE_SYS_ASYNCH_H */