blob: fe2bbbc752f7fcd809983a83f9b7b43c81cb3a24 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
Michal Ludvig53b320f2002-09-23 13:30:09 +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>
Michal Ludvig53b320f2002-09-23 13:30:09 +000037#ifdef LINUX
Wichert Akkerman9524bb91999-05-25 23:11:18 +000038#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
Michal Ludvig10a88d02002-10-07 14:31:00 +000043#undef dirent64
Wichert Akkerman9524bb91999-05-25 23:11:18 +000044#else
45#define kernel_dirent dirent
46#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000047
Michal Ludvig53b320f2002-09-23 13:30:09 +000048#ifdef LINUX
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000049# ifdef LINUXSPARC
50struct stat {
51 unsigned short st_dev;
52 unsigned int st_ino;
53 unsigned short st_mode;
54 short st_nlink;
55 unsigned short st_uid;
56 unsigned short st_gid;
57 unsigned short st_rdev;
58 unsigned int st_size;
59 int st_atime;
60 unsigned int __unused1;
61 int st_mtime;
62 unsigned int __unused2;
63 int st_ctime;
64 unsigned int __unused3;
65 int st_blksize;
66 int st_blocks;
67 unsigned int __unused4[2];
68};
69# define stat kernel_stat
70# include <asm/stat.h>
71# undef stat
72# else
Wichert Akkerman5b4d1281999-07-09 00:32:54 +000073# undef dev_t
74# undef ino_t
75# undef mode_t
76# undef nlink_t
77# undef uid_t
78# undef gid_t
79# undef off_t
80# undef loff_t
81
Wichert Akkermana6013701999-07-08 14:00:58 +000082# define dev_t __kernel_dev_t
83# define ino_t __kernel_ino_t
84# define mode_t __kernel_mode_t
85# define nlink_t __kernel_nlink_t
86# define uid_t __kernel_uid_t
87# define gid_t __kernel_gid_t
88# define off_t __kernel_off_t
89# define loff_t __kernel_loff_t
90
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000091# include <asm/stat.h>
Wichert Akkermana6013701999-07-08 14:00:58 +000092
93# undef dev_t
94# undef ino_t
95# undef mode_t
96# undef nlink_t
97# undef uid_t
98# undef gid_t
99# undef off_t
100# undef loff_t
Wichert Akkerman5b4d1281999-07-09 00:32:54 +0000101
102# define dev_t dev_t
103# define ino_t ino_t
104# define mode_t mode_t
105# define nlink_t nlink_t
106# define uid_t uid_t
107# define gid_t gid_t
108# define off_t off_t
109# define loff_t loff_t
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000110# endif
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000111# ifdef HPPA /* asm-parisc/stat.h defines stat64 */
112# undef stat64
113# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000114# define stat libc_stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000115# define stat64 libc_stat64
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000116# include <sys/stat.h>
117# undef stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000118# undef stat64
Roland McGrathca16a402003-01-09 06:53:22 +0000119 /* These might be macros. */
120# undef st_atime
121# undef st_mtime
122# undef st_ctime
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000123# ifdef HPPA
124# define stat64 hpux_stat64
125# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000126#else
127# include <sys/stat.h>
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000128#endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000129
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000130#include <fcntl.h>
131
132#ifdef SVR4
133# include <sys/cred.h>
134#endif /* SVR4 */
135
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000136#ifdef HAVE_SYS_VFS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000137#include <sys/vfs.h>
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000138#endif
139
Roland McGrath186c5ac2002-12-15 23:58:23 +0000140#ifdef HAVE_LINUX_XATTR_H
141#include <linux/xattr.h>
142#elif defined linux
143#define XATTR_CREATE 1
144#define XATTR_REPLACE 2
145#endif
146
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000147#ifdef FREEBSD
148#include <sys/param.h>
149#include <sys/mount.h>
150#include <sys/stat.h>
John Hughes70623be2001-03-08 13:59:00 +0000151#endif
152
153#if HAVE_LONG_LONG_OFF_T
154/*
155 * Ugly hacks for systems that have typedef long long off_t
156 */
John Hughesb8c9f772001-03-07 16:53:07 +0000157
158#define stat64 stat
159#define HAVE_STAT64 1 /* Ugly hack */
John Hughes70623be2001-03-08 13:59:00 +0000160
161#define sys_stat64 sys_stat
162#define sys_fstat64 sys_fstat
163#define sys_lstat64 sys_lstat
164#define sys_lseek64 sys_lseek
165#define sys_truncate64 sys_truncate
166#define sys_ftruncate64 sys_ftruncate
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000167#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000168
169#ifdef MAJOR_IN_SYSMACROS
170#include <sys/sysmacros.h>
171#endif
172
173#ifdef MAJOR_IN_MKDEV
174#include <sys/mkdev.h>
175#endif
176
177#ifdef HAVE_SYS_ASYNCH_H
178#include <sys/asynch.h>
179#endif
180
181#ifdef SUNOS4
182#include <ustat.h>
183#endif
184
185/*
186 * This is a really dirty trick but it should always work. Traditional
187 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
188 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
189 */
190struct xlat openmodes[] = {
191 { O_RDWR+1, "O_RDWR" },
192 { O_RDONLY+1, "O_RDONLY" },
193 { O_WRONLY+1, "O_WRONLY" },
194 { O_NONBLOCK, "O_NONBLOCK" },
195 { O_APPEND, "O_APPEND" },
196 { O_CREAT, "O_CREAT" },
197 { O_TRUNC, "O_TRUNC" },
198 { O_EXCL, "O_EXCL" },
199 { O_NOCTTY, "O_NOCTTY" },
200#ifdef O_SYNC
201 { O_SYNC, "O_SYNC" },
202#endif
203#ifdef O_ASYNC
204 { O_ASYNC, "O_ASYNC" },
205#endif
206#ifdef O_DSYNC
207 { O_DSYNC, "O_DSYNC" },
208#endif
209#ifdef O_RSYNC
210 { O_RSYNC, "O_RSYNC" },
211#endif
212#ifdef O_NDELAY
213 { O_NDELAY, "O_NDELAY" },
214#endif
215#ifdef O_PRIV
216 { O_PRIV, "O_PRIV" },
217#endif
218#ifdef O_DIRECT
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000219 { O_DIRECT, "O_DIRECT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000220#endif
221#ifdef O_LARGEFILE
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000222 { O_LARGEFILE, "O_LARGEFILE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000223#endif
224#ifdef O_DIRECTORY
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000225 { O_DIRECTORY, "O_DIRECTORY" },
226#endif
227#ifdef O_NOFOLLOW
228 { O_NOFOLLOW, "O_NOFOLLOW" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000229#endif
230
231#ifdef FNDELAY
232 { FNDELAY, "FNDELAY" },
233#endif
234#ifdef FAPPEND
235 { FAPPEND, "FAPPEND" },
236#endif
237#ifdef FMARK
238 { FMARK, "FMARK" },
239#endif
240#ifdef FDEFER
241 { FDEFER, "FDEFER" },
242#endif
243#ifdef FASYNC
244 { FASYNC, "FASYNC" },
245#endif
246#ifdef FSHLOCK
247 { FSHLOCK, "FSHLOCK" },
248#endif
249#ifdef FEXLOCK
250 { FEXLOCK, "FEXLOCK" },
251#endif
252#ifdef FCREAT
253 { FCREAT, "FCREAT" },
254#endif
255#ifdef FTRUNC
256 { FTRUNC, "FTRUNC" },
257#endif
258#ifdef FEXCL
259 { FEXCL, "FEXCL" },
260#endif
261#ifdef FNBIO
262 { FNBIO, "FNBIO" },
263#endif
264#ifdef FSYNC
265 { FSYNC, "FSYNC" },
266#endif
267#ifdef FNOCTTY
268 { FNOCTTY, "FNOCTTY" },
Roland McGrath186c5ac2002-12-15 23:58:23 +0000269#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000270#ifdef O_SHLOCK
271 { O_SHLOCK, "O_SHLOCK" },
272#endif
273#ifdef O_EXLOCK
274 { O_EXLOCK, "O_EXLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000275#endif
276 { 0, NULL },
277};
278
279int
280sys_open(tcp)
281struct tcb *tcp;
282{
283 if (entering(tcp)) {
284 printpath(tcp, tcp->u_arg[0]);
285 tprintf(", ");
286 /* flags */
287 printflags(openmodes, tcp->u_arg[1] + 1);
288 if (tcp->u_arg[1] & O_CREAT) {
289 /* mode */
290 tprintf(", %#lo", tcp->u_arg[2]);
291 }
292 }
293 return 0;
294}
295
296#ifdef LINUXSPARC
297struct xlat openmodessol[] = {
298 { 0, "O_RDWR" },
299 { 1, "O_RDONLY" },
300 { 2, "O_WRONLY" },
301 { 0x80, "O_NONBLOCK" },
302 { 8, "O_APPEND" },
303 { 0x100, "O_CREAT" },
304 { 0x200, "O_TRUNC" },
305 { 0x400, "O_EXCL" },
306 { 0x800, "O_NOCTTY" },
307 { 0x10, "O_SYNC" },
308 { 0x40, "O_DSYNC" },
309 { 0x8000, "O_RSYNC" },
310 { 4, "O_NDELAY" },
311 { 0x1000, "O_PRIV" },
312 { 0, NULL },
313};
314
315int
316solaris_open(tcp)
317struct tcb *tcp;
318{
319 if (entering(tcp)) {
320 printpath(tcp, tcp->u_arg[0]);
321 tprintf(", ");
322 /* flags */
323 printflags(openmodessol, tcp->u_arg[1] + 1);
324 if (tcp->u_arg[1] & 0x100) {
325 /* mode */
326 tprintf(", %#lo", tcp->u_arg[2]);
327 }
328 }
329 return 0;
330}
331
332#endif
333
334int
335sys_creat(tcp)
336struct tcb *tcp;
337{
338 if (entering(tcp)) {
339 printpath(tcp, tcp->u_arg[0]);
340 tprintf(", %#lo", tcp->u_arg[1]);
341 }
342 return 0;
343}
344
345static struct xlat access_flags[] = {
346 { F_OK, "F_OK", },
347 { R_OK, "R_OK" },
348 { W_OK, "W_OK" },
349 { X_OK, "X_OK" },
350#ifdef EFF_ONLY_OK
351 { EFF_ONLY_OK, "EFF_ONLY_OK" },
352#endif
353#ifdef EX_OK
354 { EX_OK, "EX_OK" },
355#endif
356 { 0, NULL },
357};
358
359int
360sys_access(tcp)
361struct tcb *tcp;
362{
363 if (entering(tcp)) {
364 printpath(tcp, tcp->u_arg[0]);
365 tprintf(", ");
366 printflags(access_flags, tcp->u_arg[1]);
367 }
368 return 0;
369}
370
371int
372sys_umask(tcp)
373struct tcb *tcp;
374{
375 if (entering(tcp)) {
376 tprintf("%#lo", tcp->u_arg[0]);
377 }
378 return RVAL_OCTAL;
379}
380
381static struct xlat whence[] = {
382 { SEEK_SET, "SEEK_SET" },
383 { SEEK_CUR, "SEEK_CUR" },
384 { SEEK_END, "SEEK_END" },
385 { 0, NULL },
386};
387
John Hughes70623be2001-03-08 13:59:00 +0000388#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000389int
390sys_lseek(tcp)
391struct tcb *tcp;
392{
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000393 off_t offset;
394 int _whence;
395
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000396 if (entering(tcp)) {
397 tprintf("%ld, ", tcp->u_arg[0]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000398 offset = tcp->u_arg[1];
399 _whence = tcp->u_arg[2];
400 if (_whence == SEEK_SET)
401 tprintf("%lu, ", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000402 else
Roland McGrath186c5ac2002-12-15 23:58:23 +0000403 tprintf("%ld, ", offset);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000404 printxval(whence, _whence, "SEEK_???");
Roland McGrath186c5ac2002-12-15 23:58:23 +0000405 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000406 return RVAL_UDECIMAL;
407}
John Hughes5a826b82001-03-07 13:21:24 +0000408#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000409
Michal Ludvig53b320f2002-09-23 13:30:09 +0000410#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000411int
412sys_llseek (tcp)
413struct tcb *tcp;
414{
415 if (entering(tcp)) {
416 if (tcp->u_arg[4] == SEEK_SET)
417 tprintf("%ld, %llu, ", tcp->u_arg[0],
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000418 (((long long int) tcp->u_arg[1]) << 32
Wichert Akkerman7ab47b62002-03-31 19:00:02 +0000419 | (unsigned long long) (unsigned) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000420 else
421 tprintf("%ld, %lld, ", tcp->u_arg[0],
422 (((long long int) tcp->u_arg[1]) << 32
Wichert Akkerman7ab47b62002-03-31 19:00:02 +0000423 | (unsigned long long) (unsigned) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000424 }
425 else {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000426 long long int off;
427 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000428 tprintf("%#lx, ", tcp->u_arg[3]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000429 else
430 tprintf("[%llu], ", off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000431 printxval(whence, tcp->u_arg[4], "SEEK_???");
432 }
433 return 0;
434}
Roland McGrath186c5ac2002-12-15 23:58:23 +0000435
436int
437sys_readahead (tcp)
438struct tcb *tcp;
439{
440 if (entering(tcp)) {
441 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
442# if defined IA64 || defined X86_64 || defined ALPHA
443 (long long int) tcp->u_arg[1], tcp->u_arg[2]
444# else
445 (((long long int) tcp->u_arg[1]) << 32
446 | ((unsigned long *) tcp->u_arg)[2]),
447 tcp->u_arg[3]
448# endif
449 );
450 }
451 return 0;
452}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000453#endif
454
John Hughes70623be2001-03-08 13:59:00 +0000455#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughesbdf48f52001-03-06 15:08:09 +0000456int
457sys_lseek64 (tcp)
458struct tcb *tcp;
459{
460 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000461 long long offset;
462 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
John Hughes0c79e012001-03-08 14:40:06 +0000463 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
John Hughesbdf48f52001-03-06 15:08:09 +0000464 if (tcp->u_arg[3] == SEEK_SET)
465 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
466 else
467 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
468 printxval(whence, tcp->u_arg[3], "SEEK_???");
469 }
470 return RVAL_LUDECIMAL;
471}
472#endif
473
John Hughes70623be2001-03-08 13:59:00 +0000474#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000475int
476sys_truncate(tcp)
477struct tcb *tcp;
478{
479 if (entering(tcp)) {
480 printpath(tcp, tcp->u_arg[0]);
481 tprintf(", %lu", tcp->u_arg[1]);
482 }
483 return 0;
484}
John Hughes5a826b82001-03-07 13:21:24 +0000485#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000486
John Hughes70623be2001-03-08 13:59:00 +0000487#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000488int
489sys_truncate64(tcp)
490struct tcb *tcp;
491{
492 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000493 ALIGN64 (tcp, 1);
John Hughes96f51472001-03-06 16:50:41 +0000494 printpath(tcp, tcp->u_arg[0]);
John Hughes0c79e012001-03-08 14:40:06 +0000495 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
John Hughes96f51472001-03-06 16:50:41 +0000496 }
497 return 0;
498}
499#endif
500
John Hughes70623be2001-03-08 13:59:00 +0000501#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000502int
503sys_ftruncate(tcp)
504struct tcb *tcp;
505{
506 if (entering(tcp)) {
507 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
508 }
509 return 0;
510}
John Hughes5a826b82001-03-07 13:21:24 +0000511#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000512
John Hughes70623be2001-03-08 13:59:00 +0000513#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000514int
515sys_ftruncate64(tcp)
516struct tcb *tcp;
517{
518 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000519 ALIGN64 (tcp, 1);
John Hughes96f51472001-03-06 16:50:41 +0000520 tprintf("%ld, %llu", tcp->u_arg[0],
John Hughes0c79e012001-03-08 14:40:06 +0000521 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
John Hughes96f51472001-03-06 16:50:41 +0000522 }
523 return 0;
524}
525#endif
526
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000527/* several stats */
528
529static struct xlat modetypes[] = {
530 { S_IFREG, "S_IFREG" },
531 { S_IFSOCK, "S_IFSOCK" },
532 { S_IFIFO, "S_IFIFO" },
533 { S_IFLNK, "S_IFLNK" },
534 { S_IFDIR, "S_IFDIR" },
535 { S_IFBLK, "S_IFBLK" },
536 { S_IFCHR, "S_IFCHR" },
537 { 0, NULL },
538};
539
540static char *
541sprintmode(mode)
542int mode;
543{
544 static char buf[64];
545 char *s;
546
547 if ((mode & S_IFMT) == 0)
548 s = "";
549 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
550 sprintf(buf, "%#o", mode);
551 return buf;
552 }
553 sprintf(buf, "%s%s%s%s", s,
554 (mode & S_ISUID) ? "|S_ISUID" : "",
555 (mode & S_ISGID) ? "|S_ISGID" : "",
556 (mode & S_ISVTX) ? "|S_ISVTX" : "");
557 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
558 if (mode)
559 sprintf(buf + strlen(buf), "|%#o", mode);
560 s = (*buf == '|') ? buf + 1 : buf;
561 return *s ? s : "0";
562}
563
564static char *
565sprinttime(t)
566time_t t;
567{
568 struct tm *tmp;
569 static char buf[32];
570
571 if (t == 0) {
572 sprintf(buf, "0");
573 return buf;
574 }
575 tmp = localtime(&t);
576 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
Wichert Akkerman3ed6dc22000-01-11 14:41:09 +0000577 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000578 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
579 return buf;
580}
581
582#ifdef LINUXSPARC
583typedef struct {
584 int tv_sec;
585 int tv_nsec;
586} timestruct_t;
587
588struct solstat {
589 unsigned st_dev;
590 int st_pad1[3]; /* network id */
591 unsigned st_ino;
592 unsigned st_mode;
593 unsigned st_nlink;
594 unsigned st_uid;
595 unsigned st_gid;
596 unsigned st_rdev;
597 int st_pad2[2];
598 int st_size;
599 int st_pad3; /* st_size, off_t expansion */
600 timestruct_t st_atime;
601 timestruct_t st_mtime;
602 timestruct_t st_ctime;
603 int st_blksize;
604 int st_blocks;
605 char st_fstype[16];
606 int st_pad4[8]; /* expansion area */
607};
608
609static void
610printstatsol(tcp, addr)
611struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000612long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000613{
614 struct solstat statbuf;
615
616 if (!addr) {
617 tprintf("NULL");
618 return;
619 }
620 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000621 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000622 return;
623 }
624 if (umove(tcp, addr, &statbuf) < 0) {
625 tprintf("{...}");
626 return;
627 }
628 if (!abbrev(tcp)) {
629 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
630 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
631 (unsigned long) (statbuf.st_dev & 0x3ffff),
632 (unsigned long) statbuf.st_ino,
633 sprintmode(statbuf.st_mode));
634 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
635 (unsigned long) statbuf.st_nlink,
636 (unsigned long) statbuf.st_uid,
637 (unsigned long) statbuf.st_gid);
638 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
639 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
640 }
641 else
642 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
643 switch (statbuf.st_mode & S_IFMT) {
644 case S_IFCHR: case S_IFBLK:
645 tprintf("st_rdev=makedev(%lu, %lu), ",
646 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
647 (unsigned long) (statbuf.st_rdev & 0x3ffff));
648 break;
649 default:
650 tprintf("st_size=%u, ", statbuf.st_size);
651 break;
652 }
653 if (!abbrev(tcp)) {
654 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
655 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
656 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
657 }
658 else
659 tprintf("...}");
660}
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000661#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000662
Michal Ludvig53b320f2002-09-23 13:30:09 +0000663struct xlat fileflags[] = {
John Hughesc0fc3fd2001-03-08 16:10:40 +0000664#ifdef FREEBSD
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000665 { UF_NODUMP, "UF_NODUMP" },
666 { UF_IMMUTABLE, "UF_IMMUTABLE" },
667 { UF_APPEND, "UF_APPEND" },
668 { UF_OPAQUE, "UF_OPAQUE" },
669 { UF_NOUNLINK, "UF_NOUNLINK" },
670 { SF_ARCHIVED, "SF_ARCHIVED" },
671 { SF_IMMUTABLE, "SF_IMMUTABLE" },
672 { SF_APPEND, "SF_APPEND" },
673 { SF_NOUNLINK, "SF_NOUNLINK" },
John Hughesc0fc3fd2001-03-08 16:10:40 +0000674#elif UNIXWARE >= 2
675#ifdef _S_ISMLD
676 { _S_ISMLD, "_S_ISMLD" },
677#endif
678#ifdef _S_ISMOUNTED
679 { _S_ISMOUNTED, "_S_ISMOUNTED" },
680#endif
681#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000682 { 0, NULL },
683};
684
John Hughesc0fc3fd2001-03-08 16:10:40 +0000685#ifdef FREEBSD
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000686int
687sys_chflags(tcp)
688struct tcb *tcp;
689{
690 if (entering(tcp)) {
691 printpath(tcp, tcp->u_arg[0]);
692 tprintf(", ");
693 if (tcp->u_arg[1])
694 printflags(fileflags, tcp->u_arg[1]);
695 else
696 tprintf("0");
697 }
698 return 0;
699}
700
701int
702sys_fchflags(tcp)
703struct tcb *tcp;
704{
705 if (entering(tcp)) {
706 tprintf("%ld, ", tcp->u_arg[0]);
707 if (tcp->u_arg[1])
708 printflags(fileflags, tcp->u_arg[1]);
709 else
710 tprintf("0");
711 }
712 return 0;
713}
714#endif
715
John Hughes70623be2001-03-08 13:59:00 +0000716#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000717static void
718realprintstat(tcp, statbuf)
719struct tcb *tcp;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000720struct stat *statbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000721{
722 if (!abbrev(tcp)) {
723 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
724 (unsigned long) major(statbuf->st_dev),
725 (unsigned long) minor(statbuf->st_dev),
726 (unsigned long) statbuf->st_ino,
727 sprintmode(statbuf->st_mode));
728 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
729 (unsigned long) statbuf->st_nlink,
730 (unsigned long) statbuf->st_uid,
731 (unsigned long) statbuf->st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000732#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000733 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000734#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
735#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000736 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000737#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000738 }
739 else
740 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
741 switch (statbuf->st_mode & S_IFMT) {
742 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +0000743#ifdef HAVE_STRUCT_STAT_ST_RDEV
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000744 tprintf("st_rdev=makedev(%lu, %lu), ",
745 (unsigned long) major(statbuf->st_rdev),
746 (unsigned long) minor(statbuf->st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000747#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000748 tprintf("st_size=makedev(%lu, %lu), ",
749 (unsigned long) major(statbuf->st_size),
750 (unsigned long) minor(statbuf->st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000751#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000752 break;
753 default:
754 tprintf("st_size=%lu, ", statbuf->st_size);
755 break;
756 }
757 if (!abbrev(tcp)) {
758 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
759 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +0000760 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000761#if HAVE_STRUCT_STAT_ST_FLAGS
John Hughesc0fc3fd2001-03-08 16:10:40 +0000762 tprintf(", st_flags=");
763 if (statbuf->st_flags) {
764 printflags(fileflags, statbuf->st_flags);
765 } else
766 tprintf("0");
767#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000768#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +0000769 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
770#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000771#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +0000772 tprintf(", st_level=%ld", statbuf->st_level);
773#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000774#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +0000775 tprintf(", st_fstype=%.*s",
776 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
777#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000778#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +0000779 tprintf(", st_gen=%u", statbuf->st_gen);
780#endif
781 tprintf("}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000782 }
783 else
784 tprintf("...}");
785}
786
Nate Sammons771a6ff1999-04-05 22:39:31 +0000787
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000788static void
789printstat(tcp, addr)
790struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000791long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000792{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000793 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000794
795#ifdef LINUXSPARC
796 if (current_personality == 1) {
797 printstatsol(tcp, addr);
798 return;
799 }
800#endif /* LINUXSPARC */
801
802 if (!addr) {
803 tprintf("NULL");
804 return;
805 }
806 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000807 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000808 return;
809 }
810 if (umove(tcp, addr, &statbuf) < 0) {
811 tprintf("{...}");
812 return;
813 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000814
815 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000816}
John Hughes70623be2001-03-08 13:59:00 +0000817#endif /* !HAVE_LONG_LONG_OFF_T */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000818
Wichert Akkermanc7926982000-04-10 22:22:31 +0000819#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000820static void
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000821printstat64(tcp, addr)
822struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000823long addr;
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000824{
825 struct stat64 statbuf;
826
827#ifdef LINUXSPARC
828 if (current_personality == 1) {
829 printstatsol(tcp, addr);
830 return;
831 }
832#endif /* LINUXSPARC */
833
834 if (!addr) {
835 tprintf("NULL");
836 return;
837 }
838 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000839 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000840 return;
841 }
842 if (umove(tcp, addr, &statbuf) < 0) {
843 tprintf("{...}");
844 return;
845 }
846
847 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +0000848#ifdef HAVE_LONG_LONG
849 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
850#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000851 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
Wichert Akkermand077c452000-08-10 18:16:15 +0000852#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000853 (unsigned long) major(statbuf.st_dev),
854 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +0000855#ifdef HAVE_LONG_LONG
856 (unsigned long long) statbuf.st_ino,
857#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000858 (unsigned long) statbuf.st_ino,
Wichert Akkermand077c452000-08-10 18:16:15 +0000859#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000860 sprintmode(statbuf.st_mode));
861 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
862 (unsigned long) statbuf.st_nlink,
863 (unsigned long) statbuf.st_uid,
864 (unsigned long) statbuf.st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000865#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000866 tprintf("st_blksize=%lu, ",
867 (unsigned long) statbuf.st_blksize);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000868#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
869#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000870 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000871#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000872 }
873 else
874 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
875 switch (statbuf.st_mode & S_IFMT) {
876 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +0000877#ifdef HAVE_STRUCT_STAT_ST_RDEV
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000878 tprintf("st_rdev=makedev(%lu, %lu), ",
879 (unsigned long) major(statbuf.st_rdev),
880 (unsigned long) minor(statbuf.st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000881#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000882 tprintf("st_size=makedev(%lu, %lu), ",
883 (unsigned long) major(statbuf.st_size),
884 (unsigned long) minor(statbuf.st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000885#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000886 break;
887 default:
888 tprintf("st_size=%llu, ", statbuf.st_size);
889 break;
890 }
891 if (!abbrev(tcp)) {
892 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
893 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +0000894 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000895#if HAVE_STRUCT_STAT_ST_FLAGS
John Hughesc0fc3fd2001-03-08 16:10:40 +0000896 tprintf(", st_flags=");
John Hughesb8c9f772001-03-07 16:53:07 +0000897 if (statbuf.st_flags) {
898 printflags(fileflags, statbuf.st_flags);
899 } else
900 tprintf("0");
John Hughesc0fc3fd2001-03-08 16:10:40 +0000901#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000902#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +0000903 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
904#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000905#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +0000906 tprintf(", st_level=%ld", statbuf.st_level);
907#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000908#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +0000909 tprintf(", st_fstype=%.*s",
910 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
911#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000912#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +0000913 tprintf(", st_gen=%u", statbuf.st_gen);
914#endif
915 tprintf("}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000916 }
917 else
918 tprintf("...}");
919}
Wichert Akkermanc7926982000-04-10 22:22:31 +0000920#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000921
Roland McGrath79db8af2003-06-27 21:20:09 +0000922#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000923static void
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000924convertoldstat(oldbuf, newbuf)
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000925const struct __old_kernel_stat *oldbuf;
926struct stat *newbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000927{
928 newbuf->st_dev=oldbuf->st_dev;
929 newbuf->st_ino=oldbuf->st_ino;
930 newbuf->st_mode=oldbuf->st_mode;
931 newbuf->st_nlink=oldbuf->st_nlink;
932 newbuf->st_uid=oldbuf->st_uid;
933 newbuf->st_gid=oldbuf->st_gid;
934 newbuf->st_rdev=oldbuf->st_rdev;
935 newbuf->st_size=oldbuf->st_size;
936 newbuf->st_atime=oldbuf->st_atime;
937 newbuf->st_mtime=oldbuf->st_mtime;
938 newbuf->st_ctime=oldbuf->st_ctime;
939 newbuf->st_blksize=0; /* not supported in old_stat */
940 newbuf->st_blocks=0; /* not supported in old_stat */
941}
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000942
943
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000944static void
945printoldstat(tcp, addr)
946struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000947long addr;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000948{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000949 struct __old_kernel_stat statbuf;
950 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000951
952#ifdef LINUXSPARC
953 if (current_personality == 1) {
954 printstatsol(tcp, addr);
955 return;
956 }
957#endif /* LINUXSPARC */
958
959 if (!addr) {
960 tprintf("NULL");
961 return;
962 }
963 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000964 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000965 return;
966 }
967 if (umove(tcp, addr, &statbuf) < 0) {
968 tprintf("{...}");
969 return;
970 }
971
972 convertoldstat(&statbuf, &newstatbuf);
973 realprintstat(tcp, &newstatbuf);
974}
Michal Ludvig10a88d02002-10-07 14:31:00 +0000975#endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000976
John Hughes70623be2001-03-08 13:59:00 +0000977#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000978int
979sys_stat(tcp)
980struct tcb *tcp;
981{
982 if (entering(tcp)) {
983 printpath(tcp, tcp->u_arg[0]);
984 tprintf(", ");
985 } else {
986 printstat(tcp, tcp->u_arg[1]);
987 }
988 return 0;
989}
John Hughesb8c9f772001-03-07 16:53:07 +0000990#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000991
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000992int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000993sys_stat64(tcp)
994struct tcb *tcp;
995{
996#ifdef HAVE_STAT64
997 if (entering(tcp)) {
998 printpath(tcp, tcp->u_arg[0]);
999 tprintf(", ");
1000 } else {
1001 printstat64(tcp, tcp->u_arg[1]);
1002 }
1003 return 0;
1004#else
1005 return printargs(tcp);
1006#endif
1007}
1008
Roland McGrath79db8af2003-06-27 21:20:09 +00001009#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001010int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001011sys_oldstat(tcp)
1012struct tcb *tcp;
1013{
1014 if (entering(tcp)) {
1015 printpath(tcp, tcp->u_arg[0]);
1016 tprintf(", ");
1017 } else {
1018 printoldstat(tcp, tcp->u_arg[1]);
1019 }
1020 return 0;
1021}
Roland McGrath79db8af2003-06-27 21:20:09 +00001022#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001023
John Hughes70623be2001-03-08 13:59:00 +00001024#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001025int
1026sys_fstat(tcp)
1027struct tcb *tcp;
1028{
1029 if (entering(tcp))
1030 tprintf("%ld, ", tcp->u_arg[0]);
1031 else {
1032 printstat(tcp, tcp->u_arg[1]);
1033 }
1034 return 0;
1035}
John Hughesb8c9f772001-03-07 16:53:07 +00001036#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001037
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001038int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001039sys_fstat64(tcp)
1040struct tcb *tcp;
1041{
1042#ifdef HAVE_STAT64
1043 if (entering(tcp))
1044 tprintf("%ld, ", tcp->u_arg[0]);
1045 else {
1046 printstat64(tcp, tcp->u_arg[1]);
1047 }
1048 return 0;
1049#else
1050 return printargs(tcp);
1051#endif
1052}
1053
Roland McGrath79db8af2003-06-27 21:20:09 +00001054#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001055int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001056sys_oldfstat(tcp)
1057struct tcb *tcp;
1058{
1059 if (entering(tcp))
1060 tprintf("%ld, ", tcp->u_arg[0]);
1061 else {
1062 printoldstat(tcp, tcp->u_arg[1]);
1063 }
1064 return 0;
1065}
Roland McGrath79db8af2003-06-27 21:20:09 +00001066#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001067
John Hughes70623be2001-03-08 13:59:00 +00001068#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001069int
1070sys_lstat(tcp)
1071struct tcb *tcp;
1072{
1073 if (entering(tcp)) {
1074 printpath(tcp, tcp->u_arg[0]);
1075 tprintf(", ");
1076 } else {
1077 printstat(tcp, tcp->u_arg[1]);
1078 }
1079 return 0;
1080}
John Hughesb8c9f772001-03-07 16:53:07 +00001081#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001082
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001083int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001084sys_lstat64(tcp)
1085struct tcb *tcp;
1086{
1087#ifdef HAVE_STAT64
1088 if (entering(tcp)) {
1089 printpath(tcp, tcp->u_arg[0]);
1090 tprintf(", ");
1091 } else {
1092 printstat64(tcp, tcp->u_arg[1]);
1093 }
1094 return 0;
1095#else
1096 return printargs(tcp);
1097#endif
1098}
1099
Roland McGrath79db8af2003-06-27 21:20:09 +00001100#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001101int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001102sys_oldlstat(tcp)
1103struct tcb *tcp;
1104{
1105 if (entering(tcp)) {
1106 printpath(tcp, tcp->u_arg[0]);
1107 tprintf(", ");
1108 } else {
1109 printoldstat(tcp, tcp->u_arg[1]);
1110 }
1111 return 0;
1112}
Roland McGrath79db8af2003-06-27 21:20:09 +00001113#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001114
1115
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001116#if defined(SVR4) || defined(LINUXSPARC)
1117
1118int
1119sys_xstat(tcp)
1120struct tcb *tcp;
1121{
1122 if (entering(tcp)) {
1123 tprintf("%ld, ", tcp->u_arg[0]);
1124 printpath(tcp, tcp->u_arg[1]);
1125 tprintf(", ");
1126 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001127#ifdef _STAT64_VER
1128 if (tcp->u_arg[0] == _STAT64_VER)
1129 printstat64 (tcp, tcp->u_arg[2]);
1130 else
1131#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001132 printstat(tcp, tcp->u_arg[2]);
1133 }
1134 return 0;
1135}
1136
1137int
1138sys_fxstat(tcp)
1139struct tcb *tcp;
1140{
1141 if (entering(tcp))
1142 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1143 else {
John Hughes8fe2c982001-03-06 09:45:18 +00001144#ifdef _STAT64_VER
1145 if (tcp->u_arg[0] == _STAT64_VER)
1146 printstat64 (tcp, tcp->u_arg[2]);
1147 else
1148#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001149 printstat(tcp, tcp->u_arg[2]);
1150 }
1151 return 0;
1152}
1153
1154int
1155sys_lxstat(tcp)
1156struct tcb *tcp;
1157{
1158 if (entering(tcp)) {
1159 tprintf("%ld, ", tcp->u_arg[0]);
1160 printpath(tcp, tcp->u_arg[1]);
1161 tprintf(", ");
1162 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001163#ifdef _STAT64_VER
1164 if (tcp->u_arg[0] == _STAT64_VER)
1165 printstat64 (tcp, tcp->u_arg[2]);
1166 else
1167#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001168 printstat(tcp, tcp->u_arg[2]);
1169 }
1170 return 0;
1171}
1172
1173int
1174sys_xmknod(tcp)
1175struct tcb *tcp;
1176{
1177 int mode = tcp->u_arg[2];
1178
1179 if (entering(tcp)) {
1180 tprintf("%ld, ", tcp->u_arg[0]);
1181 printpath(tcp, tcp->u_arg[1]);
1182 tprintf(", %s", sprintmode(mode));
1183 switch (mode & S_IFMT) {
1184 case S_IFCHR: case S_IFBLK:
1185#ifdef LINUXSPARC
1186 tprintf(", makedev(%lu, %lu)",
1187 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1188 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
Roland McGrath186c5ac2002-12-15 23:58:23 +00001189#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001190 tprintf(", makedev(%lu, %lu)",
1191 (unsigned long) major(tcp->u_arg[3]),
1192 (unsigned long) minor(tcp->u_arg[3]));
Roland McGrath186c5ac2002-12-15 23:58:23 +00001193#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001194 break;
1195 default:
1196 break;
1197 }
1198 }
1199 return 0;
1200}
1201
Wichert Akkerman8829a551999-06-11 13:18:40 +00001202#ifdef HAVE_SYS_ACL_H
1203
1204#include <sys/acl.h>
1205
1206struct xlat aclcmds[] = {
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001207#ifdef SETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001208 { SETACL, "SETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001209#endif
1210#ifdef GETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001211 { GETACL, "GETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001212#endif
1213#ifdef GETACLCNT
Wichert Akkerman8829a551999-06-11 13:18:40 +00001214 { GETACLCNT, "GETACLCNT" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001215#endif
1216#ifdef ACL_GET
1217 { ACL_GET, "ACL_GET" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001218#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001219#ifdef ACL_SET
1220 { ACL_SET, "ACL_SET" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001221#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001222#ifdef ACL_CNT
1223 { ACL_CNT, "ACL_CNT" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001224#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +00001225 { 0, NULL },
1226};
1227
1228int
1229sys_acl(tcp)
1230struct tcb *tcp;
1231{
1232 if (entering(tcp)) {
1233 printpath(tcp, tcp->u_arg[0]);
1234 tprintf(", ");
1235 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1236 tprintf(", %ld", tcp->u_arg[2]);
1237 /*
1238 * FIXME - dump out the list of aclent_t's pointed to
1239 * by "tcp->u_arg[3]" if it's not NULL.
1240 */
1241 if (tcp->u_arg[3])
1242 tprintf(", %#lx", tcp->u_arg[3]);
1243 else
1244 tprintf(", NULL");
1245 }
1246 return 0;
1247}
1248
1249
1250int
1251sys_facl(tcp)
1252struct tcb *tcp;
1253{
1254 if (entering(tcp)) {
1255 tprintf("%ld, ", tcp->u_arg[0]);
1256 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1257 tprintf(", %ld", tcp->u_arg[2]);
1258 /*
1259 * FIXME - dump out the list of aclent_t's pointed to
1260 * by "tcp->u_arg[3]" if it's not NULL.
1261 */
1262 if (tcp->u_arg[3])
1263 tprintf(", %#lx", tcp->u_arg[3]);
1264 else
1265 tprintf(", NULL");
1266 }
1267 return 0;
1268}
1269
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001270
1271struct xlat aclipc[] = {
1272#ifdef IPC_SHM
1273 { IPC_SHM, "IPC_SHM" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001274#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001275#ifdef IPC_SEM
1276 { IPC_SEM, "IPC_SEM" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001277#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001278#ifdef IPC_MSG
1279 { IPC_MSG, "IPC_MSG" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001280#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001281 { 0, NULL },
1282};
1283
1284
1285int
1286sys_aclipc(tcp)
1287struct tcb *tcp;
1288{
1289 if (entering(tcp)) {
1290 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1291 tprintf(", %#lx, ", tcp->u_arg[1]);
1292 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1293 tprintf(", %ld", tcp->u_arg[3]);
1294 /*
1295 * FIXME - dump out the list of aclent_t's pointed to
1296 * by "tcp->u_arg[4]" if it's not NULL.
1297 */
1298 if (tcp->u_arg[4])
1299 tprintf(", %#lx", tcp->u_arg[4]);
1300 else
1301 tprintf(", NULL");
1302 }
1303 return 0;
1304}
1305
1306
1307
Wichert Akkerman8829a551999-06-11 13:18:40 +00001308#endif /* HAVE_SYS_ACL_H */
1309
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001310#endif /* SVR4 || LINUXSPARC */
1311
Michal Ludvig53b320f2002-09-23 13:30:09 +00001312#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001313
1314static struct xlat fsmagic[] = {
Wichert Akkerman43a74822000-06-27 17:33:32 +00001315 { 0x73757245, "CODA_SUPER_MAGIC" },
1316 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1317 { 0x1373, "DEVFS_SUPER_MAGIC" },
1318 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1319 { 0x414A53, "EFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001320 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1321 { 0xef53, "EXT2_SUPER_MAGIC" },
1322 { 0x137d, "EXT_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001323 { 0xf995e849, "HPFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001324 { 0x9660, "ISOFS_SUPER_MAGIC" },
1325 { 0x137f, "MINIX_SUPER_MAGIC" },
1326 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001327 { 0x2468, "MINIX2_SUPER_MAGIC" },
1328 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001329 { 0x4d44, "MSDOS_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001330 { 0x564c, "NCP_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001331 { 0x6969, "NFS_SUPER_MAGIC" },
1332 { 0x9fa0, "PROC_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001333 { 0x002f, "QNX4_SUPER_MAGIC" },
1334 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1335 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1336 { 0x517b, "SMB_SUPER_MAGIC" },
1337 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1338 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1339 { 0x00011954, "UFS_MAGIC" },
1340 { 0x54190100, "UFS_CIGAM" },
1341 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001342 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
1343 { 0, NULL },
1344};
1345
Michal Ludvig53b320f2002-09-23 13:30:09 +00001346#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001347
1348#ifndef SVR4
1349
1350static char *
1351sprintfstype(magic)
1352int magic;
1353{
1354 static char buf[32];
Michal Ludvig53b320f2002-09-23 13:30:09 +00001355#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001356 char *s;
1357
1358 s = xlookup(fsmagic, magic);
1359 if (s) {
1360 sprintf(buf, "\"%s\"", s);
1361 return buf;
1362 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00001363#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001364 sprintf(buf, "%#x", magic);
1365 return buf;
1366}
1367
1368static void
1369printstatfs(tcp, addr)
1370struct tcb *tcp;
1371long addr;
1372{
1373 struct statfs statbuf;
1374
1375 if (syserror(tcp) || !verbose(tcp)) {
1376 tprintf("%#lx", addr);
1377 return;
1378 }
1379 if (umove(tcp, addr, &statbuf) < 0) {
1380 tprintf("{...}");
1381 return;
1382 }
1383#ifdef ALPHA
1384
1385 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1386 sprintfstype(statbuf.f_type),
1387 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001388 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_namelen=%u",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001389 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree, statbuf.f_namelen);
1390#else /* !ALPHA */
1391 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1392 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +00001393 (unsigned long)statbuf.f_bsize,
1394 (unsigned long)statbuf.f_blocks,
1395 (unsigned long)statbuf.f_bfree);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001396 tprintf("f_files=%lu, f_ffree=%lu",
Nate Sammons5c74d201999-04-06 01:37:51 +00001397 (unsigned long)statbuf.f_files,
1398 (unsigned long)statbuf.f_ffree);
Michal Ludvig53b320f2002-09-23 13:30:09 +00001399#ifdef LINUX
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001400 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Michal Ludvig53b320f2002-09-23 13:30:09 +00001401#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001402#endif /* !ALPHA */
1403 tprintf("}");
1404}
1405
1406int
1407sys_statfs(tcp)
1408struct tcb *tcp;
1409{
1410 if (entering(tcp)) {
1411 printpath(tcp, tcp->u_arg[0]);
1412 tprintf(", ");
1413 } else {
1414 printstatfs(tcp, tcp->u_arg[1]);
1415 }
1416 return 0;
1417}
1418
1419int
1420sys_fstatfs(tcp)
1421struct tcb *tcp;
1422{
1423 if (entering(tcp)) {
1424 tprintf("%lu, ", tcp->u_arg[0]);
1425 } else {
1426 printstatfs(tcp, tcp->u_arg[1]);
1427 }
1428 return 0;
1429}
1430
Michal Ludvig53b320f2002-09-23 13:30:09 +00001431#if defined(LINUX) && defined(__alpha)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001432
1433int
1434osf_statfs(tcp)
1435struct tcb *tcp;
1436{
1437 if (entering(tcp)) {
1438 printpath(tcp, tcp->u_arg[0]);
1439 tprintf(", ");
1440 } else {
1441 printstatfs(tcp, tcp->u_arg[1]);
1442 tprintf(", %lu", tcp->u_arg[2]);
1443 }
1444 return 0;
1445}
1446
1447int
1448osf_fstatfs(tcp)
1449struct tcb *tcp;
1450{
1451 if (entering(tcp)) {
1452 tprintf("%lu, ", tcp->u_arg[0]);
1453 } else {
1454 printstatfs(tcp, tcp->u_arg[1]);
1455 tprintf(", %lu", tcp->u_arg[2]);
1456 }
1457 return 0;
1458}
Michal Ludvig53b320f2002-09-23 13:30:09 +00001459#endif /* LINUX && __alpha */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001460
1461#endif /* !SVR4 */
1462
1463#ifdef SUNOS4
1464
1465int
1466sys_ustat(tcp)
1467struct tcb *tcp;
1468{
1469 struct ustat statbuf;
1470
1471 if (entering(tcp)) {
1472 tprintf("makedev(%lu, %lu), ",
1473 (long) major(tcp->u_arg[0]),
1474 (long) minor(tcp->u_arg[0]));
1475 }
1476 else {
1477 if (syserror(tcp) || !verbose(tcp))
1478 tprintf("%#lx", tcp->u_arg[1]);
1479 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1480 tprintf("{...}");
1481 else {
1482 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1483 statbuf.f_tfree, statbuf.f_tinode);
1484 tprintf("f_fname=\"%.*s\", ",
1485 (int) sizeof(statbuf.f_fname),
1486 statbuf.f_fname);
1487 tprintf("f_fpack=\"%.*s\"}",
1488 (int) sizeof(statbuf.f_fpack),
1489 statbuf.f_fpack);
1490 }
1491 }
1492 return 0;
1493}
1494
1495#endif /* SUNOS4 */
1496
Wichert Akkermanc7926982000-04-10 22:22:31 +00001497int
1498sys_pivotroot(tcp)
1499struct tcb *tcp;
1500{
1501 if (entering(tcp)) {
1502 printpath(tcp, tcp->u_arg[0]);
1503 tprintf(", ");
1504 printpath(tcp, tcp->u_arg[1]);
1505 }
1506 return 0;
1507}
1508
1509
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001510/* directory */
1511int
1512sys_chdir(tcp)
1513struct tcb *tcp;
1514{
1515 if (entering(tcp)) {
1516 printpath(tcp, tcp->u_arg[0]);
1517 }
1518 return 0;
1519}
1520
1521int
1522sys_mkdir(tcp)
1523struct tcb *tcp;
1524{
1525 if (entering(tcp)) {
1526 printpath(tcp, tcp->u_arg[0]);
1527 tprintf(", %#lo", tcp->u_arg[1]);
1528 }
1529 return 0;
1530}
1531
1532int
1533sys_rmdir(tcp)
1534struct tcb *tcp;
1535{
1536 if (entering(tcp)) {
1537 printpath(tcp, tcp->u_arg[0]);
1538 }
1539 return 0;
1540}
1541
1542int
1543sys_fchdir(tcp)
1544struct tcb *tcp;
1545{
1546 if (entering(tcp)) {
1547 tprintf("%ld", tcp->u_arg[0]);
1548 }
1549 return 0;
1550}
1551
1552int
1553sys_chroot(tcp)
1554struct tcb *tcp;
1555{
1556 if (entering(tcp)) {
1557 printpath(tcp, tcp->u_arg[0]);
1558 }
1559 return 0;
1560}
1561
1562int
1563sys_fchroot(tcp)
1564struct tcb *tcp;
1565{
1566 if (entering(tcp)) {
1567 tprintf("%ld", tcp->u_arg[0]);
1568 }
1569 return 0;
1570}
1571
1572int
1573sys_link(tcp)
1574struct tcb *tcp;
1575{
1576 if (entering(tcp)) {
1577 printpath(tcp, tcp->u_arg[0]);
1578 tprintf(", ");
1579 printpath(tcp, tcp->u_arg[1]);
1580 }
1581 return 0;
1582}
1583
1584int
1585sys_unlink(tcp)
1586struct tcb *tcp;
1587{
1588 if (entering(tcp)) {
1589 printpath(tcp, tcp->u_arg[0]);
1590 }
1591 return 0;
1592}
1593
1594int
1595sys_symlink(tcp)
1596struct tcb *tcp;
1597{
1598 if (entering(tcp)) {
1599 printpath(tcp, tcp->u_arg[0]);
1600 tprintf(", ");
1601 printpath(tcp, tcp->u_arg[1]);
1602 }
1603 return 0;
1604}
1605
1606int
1607sys_readlink(tcp)
1608struct tcb *tcp;
1609{
1610 if (entering(tcp)) {
1611 printpath(tcp, tcp->u_arg[0]);
1612 tprintf(", ");
1613 } else {
1614 if (syserror(tcp))
1615 tprintf("%#lx", tcp->u_arg[1]);
1616 else
1617 printpathn(tcp, tcp->u_arg[1], tcp->u_rval);
1618 tprintf(", %lu", tcp->u_arg[2]);
1619 }
1620 return 0;
1621}
1622
1623int
1624sys_rename(tcp)
1625struct tcb *tcp;
1626{
1627 if (entering(tcp)) {
1628 printpath(tcp, tcp->u_arg[0]);
1629 tprintf(", ");
1630 printpath(tcp, tcp->u_arg[1]);
1631 }
1632 return 0;
1633}
1634
1635int
1636sys_chown(tcp)
1637struct tcb *tcp;
1638{
1639 if (entering(tcp)) {
1640 printpath(tcp, tcp->u_arg[0]);
1641 tprintf(", %lu, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1642 }
1643 return 0;
1644}
1645
1646int
1647sys_fchown(tcp)
1648struct tcb *tcp;
1649{
1650 if (entering(tcp)) {
1651 tprintf("%ld, %lu, %lu",
1652 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1653 }
1654 return 0;
1655}
1656
1657int
1658sys_chmod(tcp)
1659struct tcb *tcp;
1660{
1661 if (entering(tcp)) {
1662 printpath(tcp, tcp->u_arg[0]);
1663 tprintf(", %#lo", tcp->u_arg[1]);
1664 }
1665 return 0;
1666}
1667
1668int
1669sys_fchmod(tcp)
1670struct tcb *tcp;
1671{
1672 if (entering(tcp)) {
1673 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
1674 }
1675 return 0;
1676}
1677
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001678#ifdef ALPHA
1679int
1680sys_osf_utimes(tcp)
1681struct tcb *tcp;
1682{
1683 if (entering(tcp)) {
1684 printpath(tcp, tcp->u_arg[0]);
1685 tprintf(", ");
1686 printtv32(tcp, tcp->u_arg[1]);
1687 }
1688 return 0;
1689}
1690#endif
1691
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001692int
1693sys_utimes(tcp)
1694struct tcb *tcp;
1695{
1696 if (entering(tcp)) {
1697 printpath(tcp, tcp->u_arg[0]);
1698 tprintf(", ");
1699 printtv(tcp, tcp->u_arg[1]);
1700 }
1701 return 0;
1702}
1703
1704int
1705sys_utime(tcp)
1706struct tcb *tcp;
1707{
1708 long ut[2];
1709
1710 if (entering(tcp)) {
1711 printpath(tcp, tcp->u_arg[0]);
1712 tprintf(", ");
1713 if (!tcp->u_arg[1])
1714 tprintf("NULL");
1715 else if (!verbose(tcp))
1716 tprintf("%#lx", tcp->u_arg[1]);
1717 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
1718 (char *) ut) < 0)
1719 tprintf("[?, ?]");
1720 else {
1721 tprintf("[%s,", sprinttime(ut[0]));
1722 tprintf(" %s]", sprinttime(ut[1]));
1723 }
1724 }
1725 return 0;
1726}
1727
1728int
1729sys_mknod(tcp)
1730struct tcb *tcp;
1731{
1732 int mode = tcp->u_arg[1];
1733
1734 if (entering(tcp)) {
1735 printpath(tcp, tcp->u_arg[0]);
1736 tprintf(", %s", sprintmode(mode));
1737 switch (mode & S_IFMT) {
1738 case S_IFCHR: case S_IFBLK:
1739#ifdef LINUXSPARC
1740 if (current_personality == 1)
1741 tprintf(", makedev(%lu, %lu)",
1742 (unsigned long) ((tcp->u_arg[2] >> 18) & 0x3fff),
1743 (unsigned long) (tcp->u_arg[2] & 0x3ffff));
1744 else
Roland McGrath186c5ac2002-12-15 23:58:23 +00001745#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001746 tprintf(", makedev(%lu, %lu)",
1747 (unsigned long) major(tcp->u_arg[2]),
1748 (unsigned long) minor(tcp->u_arg[2]));
1749 break;
1750 default:
1751 break;
1752 }
1753 }
1754 return 0;
1755}
1756
1757int
1758sys_mkfifo(tcp)
1759struct tcb *tcp;
1760{
1761 if (entering(tcp)) {
1762 printpath(tcp, tcp->u_arg[0]);
1763 tprintf(", %#lo", tcp->u_arg[1]);
1764 }
1765 return 0;
1766}
1767
1768int
1769sys_fsync(tcp)
1770struct tcb *tcp;
1771{
1772 if (entering(tcp)) {
1773 tprintf("%ld", tcp->u_arg[0]);
1774 }
1775 return 0;
1776}
1777
Michal Ludvig53b320f2002-09-23 13:30:09 +00001778#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001779
1780static void
1781printdir(tcp, addr)
1782struct tcb *tcp;
1783long addr;
1784{
1785 struct dirent d;
1786
1787 if (!verbose(tcp)) {
1788 tprintf("%#lx", addr);
1789 return;
1790 }
1791 if (umove(tcp, addr, &d) < 0) {
1792 tprintf("{...}");
1793 return;
1794 }
1795 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001796 tprintf("d_name=");
1797 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
1798 tprintf("}");
1799}
1800
1801int
1802sys_readdir(tcp)
1803struct tcb *tcp;
1804{
1805 if (entering(tcp)) {
1806 tprintf("%lu, ", tcp->u_arg[0]);
1807 } else {
1808 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
1809 tprintf("%#lx", tcp->u_arg[1]);
1810 else
1811 printdir(tcp, tcp->u_arg[1]);
1812 /* Not much point in printing this out, it is always 1. */
1813 if (tcp->u_arg[2] != 1)
1814 tprintf(", %lu", tcp->u_arg[2]);
1815 }
1816 return 0;
1817}
1818
Michal Ludvig53b320f2002-09-23 13:30:09 +00001819#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001820
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001821#ifdef FREEBSD
1822struct xlat direnttypes[] = {
1823 { DT_FIFO, "DT_FIFO" },
1824 { DT_CHR, "DT_CHR" },
1825 { DT_DIR, "DT_DIR" },
1826 { DT_BLK, "DT_BLK" },
1827 { DT_REG, "DT_REG" },
1828 { DT_LNK, "DT_LNK" },
1829 { DT_SOCK, "DT_SOCK" },
1830 { DT_WHT, "DT_WHT" },
1831 { 0, NULL },
1832};
1833
1834#endif
1835
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001836int
1837sys_getdents(tcp)
1838struct tcb *tcp;
1839{
1840 int i, len, dents = 0;
1841 char *buf;
1842
1843 if (entering(tcp)) {
1844 tprintf("%lu, ", tcp->u_arg[0]);
1845 return 0;
1846 }
1847 if (syserror(tcp) || !verbose(tcp)) {
1848 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1849 return 0;
1850 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001851 len = tcp->u_rval;
1852 if ((buf = malloc(len)) == NULL) {
1853 tprintf("out of memory\n");
1854 return 0;
1855 }
1856 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1857 tprintf("{...}, %lu", tcp->u_arg[2]);
1858 free(buf);
1859 return 0;
1860 }
1861 if (!abbrev(tcp))
1862 tprintf("{");
1863 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00001864 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Michal Ludvig53b320f2002-09-23 13:30:09 +00001865#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001866 if (!abbrev(tcp)) {
1867 tprintf("%s{d_ino=%lu, d_off=%lu, ",
1868 i ? " " : "", d->d_ino, d->d_off);
1869 tprintf("d_reclen=%u, d_name=\"%s\"}",
1870 d->d_reclen, d->d_name);
1871 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00001872#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001873#ifdef SVR4
1874 if (!abbrev(tcp)) {
1875 tprintf("%s{d_ino=%lu, d_off=%lu, ",
Roland McGrath186c5ac2002-12-15 23:58:23 +00001876 i ? " " : "",
1877 (unsigned long) d->d_ino,
1878 (unsigned long) d->d_off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001879 tprintf("d_reclen=%u, d_name=\"%s\"}",
1880 d->d_reclen, d->d_name);
1881 }
1882#endif /* SVR4 */
1883#ifdef SUNOS4
1884 if (!abbrev(tcp)) {
1885 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1886 i ? " " : "", d->d_off, d->d_fileno,
1887 d->d_reclen);
1888 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1889 d->d_namlen, d->d_namlen, d->d_name);
1890 }
1891#endif /* SUNOS4 */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001892#ifdef FREEBSD
1893 if (!abbrev(tcp)) {
1894 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
1895 i ? " " : "", d->d_fileno, d->d_reclen);
1896 printxval(direnttypes, d->d_type, "DT_???");
1897 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
1898 d->d_namlen, d->d_namlen, d->d_name);
1899 }
Roland McGrath186c5ac2002-12-15 23:58:23 +00001900#endif /* FREEBSD */
Pavel Machek9a9f10b2000-02-01 16:22:52 +00001901 if (!d->d_reclen) {
1902 tprintf("/* d_reclen == 0, problem here */");
1903 break;
1904 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001905 i += d->d_reclen;
1906 dents++;
1907 }
1908 if (!abbrev(tcp))
1909 tprintf("}");
1910 else
1911 tprintf("/* %u entries */", dents);
1912 tprintf(", %lu", tcp->u_arg[2]);
1913 free(buf);
1914 return 0;
1915}
1916
John Hughesbdf48f52001-03-06 15:08:09 +00001917
1918#if _LFS64_LARGEFILE
1919int
1920sys_getdents64(tcp)
1921struct tcb *tcp;
1922{
1923 int i, len, dents = 0;
1924 char *buf;
1925
1926 if (entering(tcp)) {
1927 tprintf("%lu, ", tcp->u_arg[0]);
1928 return 0;
1929 }
1930 if (syserror(tcp) || !verbose(tcp)) {
1931 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
1932 return 0;
1933 }
1934 len = tcp->u_rval;
1935 if ((buf = malloc(len)) == NULL) {
1936 tprintf("out of memory\n");
1937 return 0;
1938 }
1939 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
1940 tprintf("{...}, %lu", tcp->u_arg[2]);
1941 free(buf);
1942 return 0;
1943 }
1944 if (!abbrev(tcp))
1945 tprintf("{");
1946 for (i = 0; i < len;) {
1947 struct dirent64 *d = (struct dirent64 *) &buf[i];
Michal Ludvig53b320f2002-09-23 13:30:09 +00001948#if defined(LINUX) || defined(SVR4)
John Hughesbdf48f52001-03-06 15:08:09 +00001949 if (!abbrev(tcp)) {
1950 tprintf("%s{d_ino=%lu, d_off=%lu, ",
Roland McGrath186c5ac2002-12-15 23:58:23 +00001951 i ? " " : "",
1952 (unsigned long)d->d_ino,
Michal Ludvig53b320f2002-09-23 13:30:09 +00001953 (unsigned long)d->d_off);
John Hughesbdf48f52001-03-06 15:08:09 +00001954 tprintf("d_reclen=%u, d_name=\"%s\"}",
1955 d->d_reclen, d->d_name);
1956 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00001957#endif /* LINUX || SVR4 */
John Hughesbdf48f52001-03-06 15:08:09 +00001958#ifdef SUNOS4
1959 if (!abbrev(tcp)) {
1960 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
1961 i ? " " : "", d->d_off, d->d_fileno,
1962 d->d_reclen);
1963 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
1964 d->d_namlen, d->d_namlen, d->d_name);
1965 }
1966#endif /* SUNOS4 */
1967 i += d->d_reclen;
1968 dents++;
1969 }
1970 if (!abbrev(tcp))
1971 tprintf("}");
1972 else
1973 tprintf("/* %u entries */", dents);
1974 tprintf(", %lu", tcp->u_arg[2]);
1975 free(buf);
1976 return 0;
1977}
1978#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +00001979
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001980#ifdef FREEBSD
1981int
1982sys_getdirentries(tcp)
1983struct tcb * tcp;
1984{
1985 int i, len, dents = 0;
1986 long basep;
1987 char *buf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001988
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001989 if (entering(tcp)) {
1990 tprintf("%lu, ", tcp->u_arg[0]);
1991 return 0;
1992 }
1993 if (syserror(tcp) || !verbose(tcp)) {
1994 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
1995 return 0;
1996 }
1997 len = tcp->u_rval;
1998 if ((buf = malloc(len)) == NULL) {
1999 tprintf("out of memory\n");
2000 return 0;
2001 }
2002 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
2003 tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);
2004 free(buf);
2005 return 0;
2006 }
2007 if (!abbrev(tcp))
2008 tprintf("{");
2009 for (i = 0; i < len;) {
2010 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2011 if (!abbrev(tcp)) {
2012 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2013 i ? " " : "", d->d_fileno, d->d_reclen);
2014 printxval(direnttypes, d->d_type, "DT_???");
2015 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2016 d->d_namlen, d->d_namlen, d->d_name);
2017 }
2018 i += d->d_reclen;
2019 dents++;
2020 }
2021 if (!abbrev(tcp))
2022 tprintf("}");
2023 else
2024 tprintf("/* %u entries */", dents);
2025 free(buf);
2026 tprintf(", %lu", tcp->u_arg[2]);
2027 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2028 tprintf(", %#lx", tcp->u_arg[3]);
2029 else
2030 tprintf(", [%lu]", basep);
2031 return 0;
2032}
2033#endif
2034
Michal Ludvig53b320f2002-09-23 13:30:09 +00002035#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002036int
2037sys_getcwd(tcp)
2038struct tcb *tcp;
2039{
2040 if (exiting(tcp)) {
2041 if (syserror(tcp))
2042 tprintf("%#lx", tcp->u_arg[0]);
2043 else
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00002044 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002045 tprintf(", %lu", tcp->u_arg[1]);
2046 }
2047 return 0;
2048}
Michal Ludvig53b320f2002-09-23 13:30:09 +00002049#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002050
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002051#ifdef FREEBSD
2052int
2053sys___getcwd(tcp)
2054struct tcb *tcp;
2055{
2056 if (exiting(tcp)) {
2057 if (syserror(tcp))
2058 tprintf("%#lx", tcp->u_arg[0]);
2059 else
2060 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2061 tprintf(", %lu", tcp->u_arg[1]);
2062 }
2063 return 0;
2064}
2065#endif
2066
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002067#ifdef HAVE_SYS_ASYNCH_H
2068
2069int
2070sys_aioread(tcp)
2071struct tcb *tcp;
2072{
2073 struct aio_result_t res;
2074
2075 if (entering(tcp)) {
2076 tprintf("%lu, ", tcp->u_arg[0]);
2077 } else {
2078 if (syserror(tcp))
2079 tprintf("%#lx", tcp->u_arg[1]);
2080 else
2081 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2082 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2083 printxval(whence, tcp->u_arg[4], "L_???");
2084 if (syserror(tcp) || tcp->u_arg[5] == 0
2085 || umove(tcp, tcp->u_arg[5], &res) < 0)
2086 tprintf(", %#lx", tcp->u_arg[5]);
2087 else
2088 tprintf(", {aio_return %d aio_errno %d}",
2089 res.aio_return, res.aio_errno);
2090 }
2091 return 0;
2092}
2093
2094int
2095sys_aiowrite(tcp)
2096struct tcb *tcp;
2097{
2098 struct aio_result_t res;
2099
2100 if (entering(tcp)) {
2101 tprintf("%lu, ", tcp->u_arg[0]);
2102 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2103 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2104 printxval(whence, tcp->u_arg[4], "L_???");
2105 }
2106 else {
2107 if (tcp->u_arg[5] == 0)
2108 tprintf(", NULL");
2109 else if (syserror(tcp)
2110 || umove(tcp, tcp->u_arg[5], &res) < 0)
2111 tprintf(", %#lx", tcp->u_arg[5]);
2112 else
2113 tprintf(", {aio_return %d aio_errno %d}",
2114 res.aio_return, res.aio_errno);
2115 }
2116 return 0;
2117}
2118
2119int
2120sys_aiowait(tcp)
2121struct tcb *tcp;
2122{
2123 if (entering(tcp))
2124 printtv(tcp, tcp->u_arg[0]);
2125 return 0;
2126}
2127
2128int
2129sys_aiocancel(tcp)
2130struct tcb *tcp;
2131{
2132 struct aio_result_t res;
2133
2134 if (exiting(tcp)) {
2135 if (tcp->u_arg[0] == 0)
2136 tprintf("NULL");
2137 else if (syserror(tcp)
2138 || umove(tcp, tcp->u_arg[0], &res) < 0)
2139 tprintf("%#lx", tcp->u_arg[0]);
2140 else
2141 tprintf("{aio_return %d aio_errno %d}",
2142 res.aio_return, res.aio_errno);
2143 }
2144 return 0;
2145}
2146
2147#endif /* HAVE_SYS_ASYNCH_H */
Roland McGrath186c5ac2002-12-15 23:58:23 +00002148
Roland McGrath186c5ac2002-12-15 23:58:23 +00002149struct xlat xattrflags[] = {
Roland McGrath561c7992003-04-02 01:10:44 +00002150#ifdef XATTR_CREATE
Roland McGrath186c5ac2002-12-15 23:58:23 +00002151 { XATTR_CREATE, "XATTR_CREATE" },
2152 { XATTR_REPLACE, "XATTR_REPLACE" },
Roland McGrath561c7992003-04-02 01:10:44 +00002153#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +00002154 { 0, NULL }
2155};
2156
2157int
2158sys_setxattr(tcp)
2159struct tcb *tcp;
2160{
2161 if (entering(tcp)) {
2162 printpath(tcp, tcp->u_arg[0]);
2163 tprintf(", ");
2164 printstr(tcp, tcp->u_arg[1], -1);
2165 /* XXX Print value in format */
2166 tprintf(", %p, %ld, ", (void *) tcp->u_arg[2], tcp->u_arg[3]);
2167 printflags(xattrflags, tcp->u_arg[4]);
2168 }
2169 return 0;
2170}
2171
2172int
2173sys_fsetxattr(tcp)
2174struct tcb *tcp;
2175{
2176 if (entering(tcp)) {
2177 tprintf("%ld, ", tcp->u_arg[0]);
2178 printstr(tcp, tcp->u_arg[1], -1);
2179 /* XXX Print value in format */
2180 tprintf(", %p, %ld, ", (void *) tcp->u_arg[2], tcp->u_arg[3]);
2181 printflags(xattrflags, tcp->u_arg[4]);
2182 }
2183 return 0;
2184}
2185
2186int
2187sys_getxattr(tcp)
2188struct tcb *tcp;
2189{
2190 if (entering(tcp)) {
2191 printpath(tcp, tcp->u_arg[0]);
2192 tprintf(", ");
2193 printstr(tcp, tcp->u_arg[1], -1);
2194 } else {
2195 /* XXX Print value in format */
2196 tprintf(", %p, %ld", (void *) tcp->u_arg[2], tcp->u_arg[3]);
2197 }
2198 return 0;
2199}
2200
2201int
2202sys_fgetxattr(tcp)
2203struct tcb *tcp;
2204{
2205 if (entering(tcp)) {
2206 tprintf("%ld, ", tcp->u_arg[0]);
2207 printstr(tcp, tcp->u_arg[1], -1);
2208 } else {
2209 /* XXX Print value in format */
2210 tprintf(", %p, %ld", (void *) tcp->u_arg[2], tcp->u_arg[3]);
2211 }
2212 return 0;
2213}
2214
2215int
2216sys_listxattr(tcp)
2217struct tcb *tcp;
2218{
2219 if (entering(tcp)) {
2220 printpath(tcp, tcp->u_arg[0]);
2221 } else {
2222 /* XXX Print value in format */
2223 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2224 }
2225 return 0;
2226}
2227
2228int
2229sys_flistxattr(tcp)
2230struct tcb *tcp;
2231{
2232 if (entering(tcp)) {
2233 tprintf("%ld", tcp->u_arg[0]);
2234 } else {
2235 /* XXX Print value in format */
2236 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2237 }
2238 return 0;
2239}
2240
2241int
2242sys_removexattr(tcp)
2243struct tcb *tcp;
2244{
2245 if (entering(tcp)) {
2246 printpath(tcp, tcp->u_arg[0]);
2247 tprintf(", ");
2248 printstr(tcp, tcp->u_arg[1], -1);
2249 }
2250 return 0;
2251}
2252
2253int
2254sys_fremovexattr(tcp)
2255struct tcb *tcp;
2256{
2257 if (entering(tcp)) {
2258 tprintf("%ld, ", tcp->u_arg[0]);
2259 printstr(tcp, tcp->u_arg[1], -1);
2260 }
2261 return 0;
2262}