blob: cb0c53595525538d81d5ea78c1ec1ad84ed4a9e6 [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};
Roland McGrath6d1a65c2004-07-12 07:44:08 +000069#if defined(SPARC64)
70struct stat_sparc64 {
71 unsigned int st_dev;
72 unsigned long st_ino;
73 unsigned int st_mode;
74 unsigned int st_nlink;
75 unsigned int st_uid;
76 unsigned int st_gid;
77 unsigned int st_rdev;
78 long st_size;
79 long st_atime;
80 long st_mtime;
81 long st_ctime;
82 long st_blksize;
83 long st_blocks;
84 unsigned long __unused4[2];
85};
86#endif /* SPARC64 */
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000087# define stat kernel_stat
88# include <asm/stat.h>
89# undef stat
90# else
Wichert Akkerman5b4d1281999-07-09 00:32:54 +000091# undef dev_t
92# undef ino_t
93# undef mode_t
94# undef nlink_t
95# undef uid_t
96# undef gid_t
97# undef off_t
98# undef loff_t
99
Wichert Akkermana6013701999-07-08 14:00:58 +0000100# define dev_t __kernel_dev_t
101# define ino_t __kernel_ino_t
102# define mode_t __kernel_mode_t
103# define nlink_t __kernel_nlink_t
104# define uid_t __kernel_uid_t
105# define gid_t __kernel_gid_t
106# define off_t __kernel_off_t
107# define loff_t __kernel_loff_t
108
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000109# include <asm/stat.h>
Wichert Akkermana6013701999-07-08 14:00:58 +0000110
111# undef dev_t
112# undef ino_t
113# undef mode_t
114# undef nlink_t
115# undef uid_t
116# undef gid_t
117# undef off_t
118# undef loff_t
Wichert Akkerman5b4d1281999-07-09 00:32:54 +0000119
120# define dev_t dev_t
121# define ino_t ino_t
122# define mode_t mode_t
123# define nlink_t nlink_t
124# define uid_t uid_t
125# define gid_t gid_t
126# define off_t off_t
127# define loff_t loff_t
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000128# endif
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000129# ifdef HPPA /* asm-parisc/stat.h defines stat64 */
130# undef stat64
131# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000132# define stat libc_stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000133# define stat64 libc_stat64
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000134# include <sys/stat.h>
135# undef stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000136# undef stat64
Roland McGrathca16a402003-01-09 06:53:22 +0000137 /* These might be macros. */
138# undef st_atime
139# undef st_mtime
140# undef st_ctime
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000141# ifdef HPPA
142# define stat64 hpux_stat64
143# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000144#else
145# include <sys/stat.h>
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000146#endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000147
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000148#include <fcntl.h>
149
150#ifdef SVR4
151# include <sys/cred.h>
152#endif /* SVR4 */
153
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000154#ifdef HAVE_SYS_VFS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000155#include <sys/vfs.h>
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000156#endif
157
Roland McGrath186c5ac2002-12-15 23:58:23 +0000158#ifdef HAVE_LINUX_XATTR_H
159#include <linux/xattr.h>
160#elif defined linux
161#define XATTR_CREATE 1
162#define XATTR_REPLACE 2
163#endif
164
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000165#ifdef FREEBSD
166#include <sys/param.h>
167#include <sys/mount.h>
168#include <sys/stat.h>
John Hughes70623be2001-03-08 13:59:00 +0000169#endif
170
Dmitry V. Levin1f336e52006-10-14 20:20:46 +0000171#if _LFS64_LARGEFILE && (defined(LINUX) || defined(SVR4))
172# ifdef HAVE_INTTYPES_H
173# include <inttypes.h>
174# else
175# define PRId64 "lld"
176# define PRIu64 "llu"
177# endif
178#endif
179
John Hughes70623be2001-03-08 13:59:00 +0000180#if HAVE_LONG_LONG_OFF_T
181/*
182 * Ugly hacks for systems that have typedef long long off_t
183 */
John Hughesb8c9f772001-03-07 16:53:07 +0000184
185#define stat64 stat
186#define HAVE_STAT64 1 /* Ugly hack */
John Hughes70623be2001-03-08 13:59:00 +0000187
188#define sys_stat64 sys_stat
189#define sys_fstat64 sys_fstat
190#define sys_lstat64 sys_lstat
191#define sys_lseek64 sys_lseek
192#define sys_truncate64 sys_truncate
193#define sys_ftruncate64 sys_ftruncate
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000194#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000195
196#ifdef MAJOR_IN_SYSMACROS
197#include <sys/sysmacros.h>
198#endif
199
200#ifdef MAJOR_IN_MKDEV
201#include <sys/mkdev.h>
202#endif
203
204#ifdef HAVE_SYS_ASYNCH_H
205#include <sys/asynch.h>
206#endif
207
208#ifdef SUNOS4
209#include <ustat.h>
210#endif
211
212/*
213 * This is a really dirty trick but it should always work. Traditional
214 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
215 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
216 */
Roland McGrathd9f816f2004-09-04 03:39:20 +0000217const struct xlat openmodes[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000218 { O_RDWR+1, "O_RDWR" },
219 { O_RDONLY+1, "O_RDONLY" },
220 { O_WRONLY+1, "O_WRONLY" },
221 { O_NONBLOCK, "O_NONBLOCK" },
222 { O_APPEND, "O_APPEND" },
223 { O_CREAT, "O_CREAT" },
224 { O_TRUNC, "O_TRUNC" },
225 { O_EXCL, "O_EXCL" },
226 { O_NOCTTY, "O_NOCTTY" },
227#ifdef O_SYNC
228 { O_SYNC, "O_SYNC" },
229#endif
230#ifdef O_ASYNC
231 { O_ASYNC, "O_ASYNC" },
232#endif
233#ifdef O_DSYNC
234 { O_DSYNC, "O_DSYNC" },
235#endif
236#ifdef O_RSYNC
237 { O_RSYNC, "O_RSYNC" },
238#endif
239#ifdef O_NDELAY
240 { O_NDELAY, "O_NDELAY" },
241#endif
242#ifdef O_PRIV
243 { O_PRIV, "O_PRIV" },
244#endif
245#ifdef O_DIRECT
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000246 { O_DIRECT, "O_DIRECT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000247#endif
248#ifdef O_LARGEFILE
Roland McGrathfee836e2005-02-02 22:11:32 +0000249# if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
250# undef O_LARGEFILE
251# ifdef SPARC64
252# define O_LARGEFILE 0x40000
253# elif defined X86_64 || defined S390X
254# define O_LARGEFILE 0100000
255# endif
256# endif
Roland McGrath663a8a02005-02-04 09:49:56 +0000257# ifdef O_LARGEFILE
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000258 { O_LARGEFILE, "O_LARGEFILE" },
Roland McGrath663a8a02005-02-04 09:49:56 +0000259# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000260#endif
261#ifdef O_DIRECTORY
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000262 { O_DIRECTORY, "O_DIRECTORY" },
263#endif
264#ifdef O_NOFOLLOW
265 { O_NOFOLLOW, "O_NOFOLLOW" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000266#endif
Roland McGrath1025c3e2005-05-09 07:40:35 +0000267#ifdef O_NOATIME
268 { O_NOATIME, "O_NOATIME" },
269#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000270
271#ifdef FNDELAY
272 { FNDELAY, "FNDELAY" },
273#endif
274#ifdef FAPPEND
275 { FAPPEND, "FAPPEND" },
276#endif
277#ifdef FMARK
278 { FMARK, "FMARK" },
279#endif
280#ifdef FDEFER
281 { FDEFER, "FDEFER" },
282#endif
283#ifdef FASYNC
284 { FASYNC, "FASYNC" },
285#endif
286#ifdef FSHLOCK
287 { FSHLOCK, "FSHLOCK" },
288#endif
289#ifdef FEXLOCK
290 { FEXLOCK, "FEXLOCK" },
291#endif
292#ifdef FCREAT
293 { FCREAT, "FCREAT" },
294#endif
295#ifdef FTRUNC
296 { FTRUNC, "FTRUNC" },
297#endif
298#ifdef FEXCL
299 { FEXCL, "FEXCL" },
300#endif
301#ifdef FNBIO
302 { FNBIO, "FNBIO" },
303#endif
304#ifdef FSYNC
305 { FSYNC, "FSYNC" },
306#endif
307#ifdef FNOCTTY
308 { FNOCTTY, "FNOCTTY" },
Roland McGrath186c5ac2002-12-15 23:58:23 +0000309#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000310#ifdef O_SHLOCK
311 { O_SHLOCK, "O_SHLOCK" },
312#endif
313#ifdef O_EXLOCK
314 { O_EXLOCK, "O_EXLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000315#endif
316 { 0, NULL },
317};
318
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000319#ifdef LINUX
320
321#ifndef AT_FDCWD
322# define AT_FDCWD -100
323#endif
324
325static void
326print_dirfd(long fd)
327{
328 if (fd == AT_FDCWD)
329 tprintf("AT_FDCWD, ");
330 else
331 tprintf("%ld, ", fd);
332}
333#endif
334
335static int
336decode_open(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000337{
338 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000339 printpath(tcp, tcp->u_arg[offset]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000340 tprintf(", ");
341 /* flags */
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000342 printflags(openmodes, tcp->u_arg[offset + 1] + 1, "O_???");
343 if (tcp->u_arg[offset + 1] & O_CREAT) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000344 /* mode */
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000345 tprintf(", %#lo", tcp->u_arg[offset + 2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000346 }
347 }
348 return 0;
349}
350
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000351int
352sys_open(struct tcb *tcp)
353{
354 return decode_open(tcp, 0);
355}
356
357#ifdef LINUX
358int
359sys_openat(struct tcb *tcp)
360{
361 if (entering(tcp))
362 print_dirfd(tcp->u_arg[0]);
363 return decode_open(tcp, 1);
364}
365#endif
366
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000367#ifdef LINUXSPARC
Roland McGratha4d48532005-06-08 20:45:28 +0000368static const struct xlat openmodessol[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000369 { 0, "O_RDWR" },
370 { 1, "O_RDONLY" },
371 { 2, "O_WRONLY" },
372 { 0x80, "O_NONBLOCK" },
373 { 8, "O_APPEND" },
374 { 0x100, "O_CREAT" },
375 { 0x200, "O_TRUNC" },
376 { 0x400, "O_EXCL" },
377 { 0x800, "O_NOCTTY" },
378 { 0x10, "O_SYNC" },
379 { 0x40, "O_DSYNC" },
380 { 0x8000, "O_RSYNC" },
381 { 4, "O_NDELAY" },
382 { 0x1000, "O_PRIV" },
383 { 0, NULL },
384};
385
386int
387solaris_open(tcp)
388struct tcb *tcp;
389{
390 if (entering(tcp)) {
391 printpath(tcp, tcp->u_arg[0]);
392 tprintf(", ");
393 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000394 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000395 if (tcp->u_arg[1] & 0x100) {
396 /* mode */
397 tprintf(", %#lo", tcp->u_arg[2]);
398 }
399 }
400 return 0;
401}
402
403#endif
404
405int
406sys_creat(tcp)
407struct tcb *tcp;
408{
409 if (entering(tcp)) {
410 printpath(tcp, tcp->u_arg[0]);
411 tprintf(", %#lo", tcp->u_arg[1]);
412 }
413 return 0;
414}
415
Roland McGrathd9f816f2004-09-04 03:39:20 +0000416static const struct xlat access_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000417 { F_OK, "F_OK", },
418 { R_OK, "R_OK" },
419 { W_OK, "W_OK" },
420 { X_OK, "X_OK" },
421#ifdef EFF_ONLY_OK
422 { EFF_ONLY_OK, "EFF_ONLY_OK" },
423#endif
424#ifdef EX_OK
425 { EX_OK, "EX_OK" },
426#endif
427 { 0, NULL },
428};
429
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000430static int
431decode_access(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000432{
433 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000434 printpath(tcp, tcp->u_arg[offset]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000435 tprintf(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000436 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000437 }
438 return 0;
439}
440
441int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000442sys_access(struct tcb *tcp)
443{
444 return decode_access(tcp, 0);
445}
446
447#ifdef LINUX
448int
449sys_faccessat(struct tcb *tcp)
450{
451 if (entering(tcp))
452 print_dirfd(tcp->u_arg[0]);
453 return decode_access(tcp, 1);
454}
455#endif
456
457int
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000458sys_umask(tcp)
459struct tcb *tcp;
460{
461 if (entering(tcp)) {
462 tprintf("%#lo", tcp->u_arg[0]);
463 }
464 return RVAL_OCTAL;
465}
466
Roland McGrathd9f816f2004-09-04 03:39:20 +0000467static const struct xlat whence[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000468 { SEEK_SET, "SEEK_SET" },
469 { SEEK_CUR, "SEEK_CUR" },
470 { SEEK_END, "SEEK_END" },
471 { 0, NULL },
472};
473
John Hughes70623be2001-03-08 13:59:00 +0000474#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000475int
476sys_lseek(tcp)
477struct tcb *tcp;
478{
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000479 off_t offset;
480 int _whence;
481
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000482 if (entering(tcp)) {
483 tprintf("%ld, ", tcp->u_arg[0]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000484 offset = tcp->u_arg[1];
485 _whence = tcp->u_arg[2];
486 if (_whence == SEEK_SET)
487 tprintf("%lu, ", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000488 else
Roland McGrath186c5ac2002-12-15 23:58:23 +0000489 tprintf("%ld, ", offset);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000490 printxval(whence, _whence, "SEEK_???");
Roland McGrath186c5ac2002-12-15 23:58:23 +0000491 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000492 return RVAL_UDECIMAL;
493}
John Hughes5a826b82001-03-07 13:21:24 +0000494#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000495
Michal Ludvig53b320f2002-09-23 13:30:09 +0000496#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000497int
498sys_llseek (tcp)
499struct tcb *tcp;
500{
501 if (entering(tcp)) {
Roland McGrath8c304bc2004-10-19 22:59:55 +0000502 /*
503 * This one call takes explicitly two 32-bit arguments hi, lo,
504 * rather than one 64-bit argument for which LONG_LONG works
505 * appropriate for the native byte order.
506 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000507 if (tcp->u_arg[4] == SEEK_SET)
508 tprintf("%ld, %llu, ", tcp->u_arg[0],
Roland McGrath8c304bc2004-10-19 22:59:55 +0000509 (((long long int) tcp->u_arg[1]) << 32
510 | (unsigned long long) (unsigned) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000511 else
512 tprintf("%ld, %lld, ", tcp->u_arg[0],
Roland McGrath8c304bc2004-10-19 22:59:55 +0000513 (((long long int) tcp->u_arg[1]) << 32
514 | (unsigned long long) (unsigned) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000515 }
516 else {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000517 long long int off;
518 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000519 tprintf("%#lx, ", tcp->u_arg[3]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000520 else
521 tprintf("[%llu], ", off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000522 printxval(whence, tcp->u_arg[4], "SEEK_???");
523 }
524 return 0;
525}
Roland McGrath186c5ac2002-12-15 23:58:23 +0000526
527int
528sys_readahead (tcp)
529struct tcb *tcp;
530{
531 if (entering(tcp)) {
532 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
533# if defined IA64 || defined X86_64 || defined ALPHA
534 (long long int) tcp->u_arg[1], tcp->u_arg[2]
535# else
Roland McGrath2fe2a3e2004-10-07 19:09:16 +0000536 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]
Roland McGrath186c5ac2002-12-15 23:58:23 +0000537# endif
538 );
539 }
540 return 0;
541}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000542#endif
543
John Hughes70623be2001-03-08 13:59:00 +0000544#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughesbdf48f52001-03-06 15:08:09 +0000545int
546sys_lseek64 (tcp)
547struct tcb *tcp;
548{
549 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000550 long long offset;
551 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
John Hughes0c79e012001-03-08 14:40:06 +0000552 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
John Hughesbdf48f52001-03-06 15:08:09 +0000553 if (tcp->u_arg[3] == SEEK_SET)
554 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
555 else
556 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
557 printxval(whence, tcp->u_arg[3], "SEEK_???");
558 }
559 return RVAL_LUDECIMAL;
560}
561#endif
562
John Hughes70623be2001-03-08 13:59:00 +0000563#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000564int
565sys_truncate(tcp)
566struct tcb *tcp;
567{
568 if (entering(tcp)) {
569 printpath(tcp, tcp->u_arg[0]);
570 tprintf(", %lu", tcp->u_arg[1]);
571 }
572 return 0;
573}
John Hughes5a826b82001-03-07 13:21:24 +0000574#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000575
John Hughes70623be2001-03-08 13:59:00 +0000576#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000577int
578sys_truncate64(tcp)
579struct tcb *tcp;
580{
581 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000582 ALIGN64 (tcp, 1);
John Hughes96f51472001-03-06 16:50:41 +0000583 printpath(tcp, tcp->u_arg[0]);
John Hughes0c79e012001-03-08 14:40:06 +0000584 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
John Hughes96f51472001-03-06 16:50:41 +0000585 }
586 return 0;
587}
588#endif
589
John Hughes70623be2001-03-08 13:59:00 +0000590#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000591int
592sys_ftruncate(tcp)
593struct tcb *tcp;
594{
595 if (entering(tcp)) {
596 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
597 }
598 return 0;
599}
John Hughes5a826b82001-03-07 13:21:24 +0000600#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000601
John Hughes70623be2001-03-08 13:59:00 +0000602#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000603int
604sys_ftruncate64(tcp)
605struct tcb *tcp;
606{
607 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000608 ALIGN64 (tcp, 1);
John Hughes96f51472001-03-06 16:50:41 +0000609 tprintf("%ld, %llu", tcp->u_arg[0],
John Hughes0c79e012001-03-08 14:40:06 +0000610 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
John Hughes96f51472001-03-06 16:50:41 +0000611 }
612 return 0;
613}
614#endif
615
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000616/* several stats */
617
Roland McGrathd9f816f2004-09-04 03:39:20 +0000618static const struct xlat modetypes[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000619 { S_IFREG, "S_IFREG" },
620 { S_IFSOCK, "S_IFSOCK" },
621 { S_IFIFO, "S_IFIFO" },
622 { S_IFLNK, "S_IFLNK" },
623 { S_IFDIR, "S_IFDIR" },
624 { S_IFBLK, "S_IFBLK" },
625 { S_IFCHR, "S_IFCHR" },
626 { 0, NULL },
627};
628
Roland McGrathf9c49b22004-10-06 22:11:54 +0000629static const char *
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000630sprintmode(mode)
631int mode;
632{
633 static char buf[64];
Roland McGrathf9c49b22004-10-06 22:11:54 +0000634 const char *s;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000635
636 if ((mode & S_IFMT) == 0)
637 s = "";
638 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
639 sprintf(buf, "%#o", mode);
640 return buf;
641 }
642 sprintf(buf, "%s%s%s%s", s,
643 (mode & S_ISUID) ? "|S_ISUID" : "",
644 (mode & S_ISGID) ? "|S_ISGID" : "",
645 (mode & S_ISVTX) ? "|S_ISVTX" : "");
646 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
647 if (mode)
648 sprintf(buf + strlen(buf), "|%#o", mode);
649 s = (*buf == '|') ? buf + 1 : buf;
650 return *s ? s : "0";
651}
652
653static char *
654sprinttime(t)
655time_t t;
656{
657 struct tm *tmp;
658 static char buf[32];
659
660 if (t == 0) {
661 sprintf(buf, "0");
662 return buf;
663 }
664 tmp = localtime(&t);
665 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
Wichert Akkerman3ed6dc22000-01-11 14:41:09 +0000666 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000667 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
668 return buf;
669}
670
671#ifdef LINUXSPARC
672typedef struct {
673 int tv_sec;
674 int tv_nsec;
675} timestruct_t;
676
677struct solstat {
678 unsigned st_dev;
679 int st_pad1[3]; /* network id */
680 unsigned st_ino;
681 unsigned st_mode;
682 unsigned st_nlink;
683 unsigned st_uid;
684 unsigned st_gid;
685 unsigned st_rdev;
686 int st_pad2[2];
687 int st_size;
688 int st_pad3; /* st_size, off_t expansion */
689 timestruct_t st_atime;
690 timestruct_t st_mtime;
691 timestruct_t st_ctime;
692 int st_blksize;
693 int st_blocks;
694 char st_fstype[16];
695 int st_pad4[8]; /* expansion area */
696};
697
698static void
699printstatsol(tcp, addr)
700struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000701long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000702{
703 struct solstat statbuf;
704
705 if (!addr) {
706 tprintf("NULL");
707 return;
708 }
709 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000710 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000711 return;
712 }
713 if (umove(tcp, addr, &statbuf) < 0) {
714 tprintf("{...}");
715 return;
716 }
717 if (!abbrev(tcp)) {
718 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
719 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
720 (unsigned long) (statbuf.st_dev & 0x3ffff),
721 (unsigned long) statbuf.st_ino,
722 sprintmode(statbuf.st_mode));
723 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
724 (unsigned long) statbuf.st_nlink,
725 (unsigned long) statbuf.st_uid,
726 (unsigned long) statbuf.st_gid);
727 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
728 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
729 }
730 else
731 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
732 switch (statbuf.st_mode & S_IFMT) {
733 case S_IFCHR: case S_IFBLK:
734 tprintf("st_rdev=makedev(%lu, %lu), ",
735 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
736 (unsigned long) (statbuf.st_rdev & 0x3ffff));
737 break;
738 default:
739 tprintf("st_size=%u, ", statbuf.st_size);
740 break;
741 }
742 if (!abbrev(tcp)) {
743 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
744 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
745 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
746 }
747 else
748 tprintf("...}");
749}
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000750
751#if defined (SPARC64)
752static void
753printstat_sparc64(tcp, addr)
754struct tcb *tcp;
755long addr;
756{
757 struct stat_sparc64 statbuf;
758
759 if (!addr) {
760 tprintf("NULL");
761 return;
762 }
763 if (syserror(tcp) || !verbose(tcp)) {
764 tprintf("%#lx", addr);
765 return;
766 }
767 if (umove(tcp, addr, &statbuf) < 0) {
768 tprintf("{...}");
769 return;
770 }
771
772 if (!abbrev(tcp)) {
773 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
774 (unsigned long) major(statbuf.st_dev),
775 (unsigned long) minor(statbuf.st_dev),
776 (unsigned long) statbuf.st_ino,
777 sprintmode(statbuf.st_mode));
778 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
779 (unsigned long) statbuf.st_nlink,
780 (unsigned long) statbuf.st_uid,
781 (unsigned long) statbuf.st_gid);
782 tprintf("st_blksize=%lu, ",
783 (unsigned long) statbuf.st_blksize);
784 tprintf("st_blocks=%lu, ",
785 (unsigned long) statbuf.st_blocks);
786 }
787 else
788 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
789 switch (statbuf.st_mode & S_IFMT) {
790 case S_IFCHR: case S_IFBLK:
791 tprintf("st_rdev=makedev(%lu, %lu), ",
792 (unsigned long) major(statbuf.st_rdev),
793 (unsigned long) minor(statbuf.st_rdev));
794 break;
795 default:
796 tprintf("st_size=%lu, ", statbuf.st_size);
797 break;
798 }
799 if (!abbrev(tcp)) {
800 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
801 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
802 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
803 tprintf("}");
804 }
805 else
806 tprintf("...}");
807}
808#endif /* SPARC64 */
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000809#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000810
Roland McGratha4d48532005-06-08 20:45:28 +0000811static const struct xlat fileflags[] = {
John Hughesc0fc3fd2001-03-08 16:10:40 +0000812#ifdef FREEBSD
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000813 { UF_NODUMP, "UF_NODUMP" },
814 { UF_IMMUTABLE, "UF_IMMUTABLE" },
815 { UF_APPEND, "UF_APPEND" },
816 { UF_OPAQUE, "UF_OPAQUE" },
817 { UF_NOUNLINK, "UF_NOUNLINK" },
818 { SF_ARCHIVED, "SF_ARCHIVED" },
819 { SF_IMMUTABLE, "SF_IMMUTABLE" },
820 { SF_APPEND, "SF_APPEND" },
821 { SF_NOUNLINK, "SF_NOUNLINK" },
John Hughesc0fc3fd2001-03-08 16:10:40 +0000822#elif UNIXWARE >= 2
823#ifdef _S_ISMLD
824 { _S_ISMLD, "_S_ISMLD" },
825#endif
826#ifdef _S_ISMOUNTED
827 { _S_ISMOUNTED, "_S_ISMOUNTED" },
828#endif
829#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000830 { 0, NULL },
831};
832
John Hughesc0fc3fd2001-03-08 16:10:40 +0000833#ifdef FREEBSD
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000834int
835sys_chflags(tcp)
836struct tcb *tcp;
837{
838 if (entering(tcp)) {
839 printpath(tcp, tcp->u_arg[0]);
840 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000841 printflags(fileflags, tcp->u_arg[1], "UF_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000842 }
843 return 0;
844}
845
846int
847sys_fchflags(tcp)
848struct tcb *tcp;
849{
850 if (entering(tcp)) {
851 tprintf("%ld, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000852 printflags(fileflags, tcp->u_arg[1], "UF_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000853 }
854 return 0;
855}
856#endif
857
John Hughes70623be2001-03-08 13:59:00 +0000858#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000859static void
860realprintstat(tcp, statbuf)
861struct tcb *tcp;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000862struct stat *statbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000863{
864 if (!abbrev(tcp)) {
865 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
866 (unsigned long) major(statbuf->st_dev),
867 (unsigned long) minor(statbuf->st_dev),
868 (unsigned long) statbuf->st_ino,
869 sprintmode(statbuf->st_mode));
870 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
871 (unsigned long) statbuf->st_nlink,
872 (unsigned long) statbuf->st_uid,
873 (unsigned long) statbuf->st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000874#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000875 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000876#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
877#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000878 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000879#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000880 }
881 else
882 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
883 switch (statbuf->st_mode & S_IFMT) {
884 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +0000885#ifdef HAVE_STRUCT_STAT_ST_RDEV
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000886 tprintf("st_rdev=makedev(%lu, %lu), ",
887 (unsigned long) major(statbuf->st_rdev),
888 (unsigned long) minor(statbuf->st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000889#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000890 tprintf("st_size=makedev(%lu, %lu), ",
891 (unsigned long) major(statbuf->st_size),
892 (unsigned long) minor(statbuf->st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000893#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000894 break;
895 default:
896 tprintf("st_size=%lu, ", statbuf->st_size);
897 break;
898 }
899 if (!abbrev(tcp)) {
900 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
901 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +0000902 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000903#if HAVE_STRUCT_STAT_ST_FLAGS
John Hughesc0fc3fd2001-03-08 16:10:40 +0000904 tprintf(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +0000905 printflags(fileflags, statbuf->st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +0000906#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000907#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +0000908 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
909#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000910#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +0000911 tprintf(", st_level=%ld", statbuf->st_level);
912#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000913#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +0000914 tprintf(", st_fstype=%.*s",
915 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
916#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000917#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +0000918 tprintf(", st_gen=%u", statbuf->st_gen);
919#endif
920 tprintf("}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000921 }
922 else
923 tprintf("...}");
924}
925
Nate Sammons771a6ff1999-04-05 22:39:31 +0000926
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000927static void
928printstat(tcp, addr)
929struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000930long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000931{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000932 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000933
934#ifdef LINUXSPARC
935 if (current_personality == 1) {
936 printstatsol(tcp, addr);
937 return;
938 }
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000939#ifdef SPARC64
940 else if (current_personality == 2) {
941 printstat_sparc64(tcp, addr);
942 return;
943 }
944#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000945#endif /* LINUXSPARC */
946
947 if (!addr) {
948 tprintf("NULL");
949 return;
950 }
951 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000952 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000953 return;
954 }
955 if (umove(tcp, addr, &statbuf) < 0) {
956 tprintf("{...}");
957 return;
958 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000959
960 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000961}
John Hughes70623be2001-03-08 13:59:00 +0000962#endif /* !HAVE_LONG_LONG_OFF_T */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000963
Wichert Akkermanc7926982000-04-10 22:22:31 +0000964#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000965static void
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000966printstat64(tcp, addr)
967struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000968long addr;
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000969{
970 struct stat64 statbuf;
971
972#ifdef LINUXSPARC
973 if (current_personality == 1) {
974 printstatsol(tcp, addr);
975 return;
976 }
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000977#ifdef SPARC64
978 else if (current_personality == 2) {
979 printstat_sparc64(tcp, addr);
980 return;
981 }
982#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000983#endif /* LINUXSPARC */
984
985 if (!addr) {
986 tprintf("NULL");
987 return;
988 }
989 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000990 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000991 return;
992 }
993 if (umove(tcp, addr, &statbuf) < 0) {
994 tprintf("{...}");
995 return;
996 }
997
998 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +0000999#ifdef HAVE_LONG_LONG
1000 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1001#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001002 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
Wichert Akkermand077c452000-08-10 18:16:15 +00001003#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001004 (unsigned long) major(statbuf.st_dev),
1005 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +00001006#ifdef HAVE_LONG_LONG
1007 (unsigned long long) statbuf.st_ino,
1008#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001009 (unsigned long) statbuf.st_ino,
Wichert Akkermand077c452000-08-10 18:16:15 +00001010#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001011 sprintmode(statbuf.st_mode));
1012 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1013 (unsigned long) statbuf.st_nlink,
1014 (unsigned long) statbuf.st_uid,
1015 (unsigned long) statbuf.st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001016#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001017 tprintf("st_blksize=%lu, ",
1018 (unsigned long) statbuf.st_blksize);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001019#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
1020#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001021 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001022#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001023 }
1024 else
1025 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1026 switch (statbuf.st_mode & S_IFMT) {
1027 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +00001028#ifdef HAVE_STRUCT_STAT_ST_RDEV
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001029 tprintf("st_rdev=makedev(%lu, %lu), ",
1030 (unsigned long) major(statbuf.st_rdev),
1031 (unsigned long) minor(statbuf.st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001032#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001033 tprintf("st_size=makedev(%lu, %lu), ",
1034 (unsigned long) major(statbuf.st_size),
1035 (unsigned long) minor(statbuf.st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001036#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001037 break;
1038 default:
1039 tprintf("st_size=%llu, ", statbuf.st_size);
1040 break;
1041 }
1042 if (!abbrev(tcp)) {
1043 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1044 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +00001045 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001046#if HAVE_STRUCT_STAT_ST_FLAGS
John Hughesc0fc3fd2001-03-08 16:10:40 +00001047 tprintf(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +00001048 printflags(fileflags, statbuf.st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +00001049#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001050#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +00001051 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1052#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001053#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +00001054 tprintf(", st_level=%ld", statbuf.st_level);
1055#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001056#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +00001057 tprintf(", st_fstype=%.*s",
1058 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1059#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001060#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +00001061 tprintf(", st_gen=%u", statbuf.st_gen);
1062#endif
1063 tprintf("}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001064 }
1065 else
1066 tprintf("...}");
1067}
Wichert Akkermanc7926982000-04-10 22:22:31 +00001068#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001069
Roland McGrath79db8af2003-06-27 21:20:09 +00001070#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001071static void
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001072convertoldstat(oldbuf, newbuf)
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +00001073const struct __old_kernel_stat *oldbuf;
1074struct stat *newbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001075{
1076 newbuf->st_dev=oldbuf->st_dev;
1077 newbuf->st_ino=oldbuf->st_ino;
1078 newbuf->st_mode=oldbuf->st_mode;
1079 newbuf->st_nlink=oldbuf->st_nlink;
1080 newbuf->st_uid=oldbuf->st_uid;
1081 newbuf->st_gid=oldbuf->st_gid;
1082 newbuf->st_rdev=oldbuf->st_rdev;
1083 newbuf->st_size=oldbuf->st_size;
1084 newbuf->st_atime=oldbuf->st_atime;
1085 newbuf->st_mtime=oldbuf->st_mtime;
1086 newbuf->st_ctime=oldbuf->st_ctime;
1087 newbuf->st_blksize=0; /* not supported in old_stat */
1088 newbuf->st_blocks=0; /* not supported in old_stat */
1089}
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001090
1091
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001092static void
1093printoldstat(tcp, addr)
1094struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001095long addr;
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001096{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +00001097 struct __old_kernel_stat statbuf;
1098 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001099
1100#ifdef LINUXSPARC
1101 if (current_personality == 1) {
1102 printstatsol(tcp, addr);
1103 return;
1104 }
1105#endif /* LINUXSPARC */
1106
1107 if (!addr) {
1108 tprintf("NULL");
1109 return;
1110 }
1111 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001112 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001113 return;
1114 }
1115 if (umove(tcp, addr, &statbuf) < 0) {
1116 tprintf("{...}");
1117 return;
1118 }
1119
1120 convertoldstat(&statbuf, &newstatbuf);
1121 realprintstat(tcp, &newstatbuf);
1122}
Michal Ludvig10a88d02002-10-07 14:31:00 +00001123#endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001124
John Hughes70623be2001-03-08 13:59:00 +00001125#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001126int
1127sys_stat(tcp)
1128struct tcb *tcp;
1129{
1130 if (entering(tcp)) {
1131 printpath(tcp, tcp->u_arg[0]);
1132 tprintf(", ");
1133 } else {
1134 printstat(tcp, tcp->u_arg[1]);
1135 }
1136 return 0;
1137}
John Hughesb8c9f772001-03-07 16:53:07 +00001138#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001139
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001140int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001141sys_stat64(tcp)
1142struct tcb *tcp;
1143{
1144#ifdef HAVE_STAT64
1145 if (entering(tcp)) {
1146 printpath(tcp, tcp->u_arg[0]);
1147 tprintf(", ");
1148 } else {
1149 printstat64(tcp, tcp->u_arg[1]);
1150 }
1151 return 0;
1152#else
1153 return printargs(tcp);
1154#endif
1155}
1156
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001157#ifdef LINUX
1158static const struct xlat fstatatflags[] = {
1159#ifndef AT_SYMLINK_NOFOLLOW
1160# define AT_SYMLINK_NOFOLLOW 0x100
1161#endif
1162 { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" },
1163 { 0, NULL },
1164};
1165
1166int
1167sys_newfstatat(struct tcb *tcp)
1168{
1169 if (entering(tcp)) {
1170 print_dirfd(tcp->u_arg[0]);
1171 printpath(tcp, tcp->u_arg[1]);
1172 tprintf(", ");
1173 } else {
1174#ifdef HAVE_STAT64
1175 printstat64(tcp, tcp->u_arg[2]);
1176#else
1177 printstat(tcp, tcp->u_arg[2]);
1178#endif
1179 tprintf(", ");
1180 printflags(fstatatflags, tcp->u_arg[3], "AT_???");
1181 }
1182 return 0;
1183}
1184#endif
1185
Roland McGrath79db8af2003-06-27 21:20:09 +00001186#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001187int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001188sys_oldstat(tcp)
1189struct tcb *tcp;
1190{
1191 if (entering(tcp)) {
1192 printpath(tcp, tcp->u_arg[0]);
1193 tprintf(", ");
1194 } else {
1195 printoldstat(tcp, tcp->u_arg[1]);
1196 }
1197 return 0;
1198}
Roland McGrath79db8af2003-06-27 21:20:09 +00001199#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001200
John Hughes70623be2001-03-08 13:59:00 +00001201#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001202int
1203sys_fstat(tcp)
1204struct tcb *tcp;
1205{
1206 if (entering(tcp))
1207 tprintf("%ld, ", tcp->u_arg[0]);
1208 else {
1209 printstat(tcp, tcp->u_arg[1]);
1210 }
1211 return 0;
1212}
John Hughesb8c9f772001-03-07 16:53:07 +00001213#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001214
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001215int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001216sys_fstat64(tcp)
1217struct tcb *tcp;
1218{
1219#ifdef HAVE_STAT64
1220 if (entering(tcp))
1221 tprintf("%ld, ", tcp->u_arg[0]);
1222 else {
1223 printstat64(tcp, tcp->u_arg[1]);
1224 }
1225 return 0;
1226#else
1227 return printargs(tcp);
1228#endif
1229}
1230
Roland McGrath79db8af2003-06-27 21:20:09 +00001231#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001232int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001233sys_oldfstat(tcp)
1234struct tcb *tcp;
1235{
1236 if (entering(tcp))
1237 tprintf("%ld, ", tcp->u_arg[0]);
1238 else {
1239 printoldstat(tcp, tcp->u_arg[1]);
1240 }
1241 return 0;
1242}
Roland McGrath79db8af2003-06-27 21:20:09 +00001243#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001244
John Hughes70623be2001-03-08 13:59:00 +00001245#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001246int
1247sys_lstat(tcp)
1248struct tcb *tcp;
1249{
1250 if (entering(tcp)) {
1251 printpath(tcp, tcp->u_arg[0]);
1252 tprintf(", ");
1253 } else {
1254 printstat(tcp, tcp->u_arg[1]);
1255 }
1256 return 0;
1257}
John Hughesb8c9f772001-03-07 16:53:07 +00001258#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001259
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001260int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001261sys_lstat64(tcp)
1262struct tcb *tcp;
1263{
1264#ifdef HAVE_STAT64
1265 if (entering(tcp)) {
1266 printpath(tcp, tcp->u_arg[0]);
1267 tprintf(", ");
1268 } else {
1269 printstat64(tcp, tcp->u_arg[1]);
1270 }
1271 return 0;
1272#else
1273 return printargs(tcp);
1274#endif
1275}
1276
Roland McGrath79db8af2003-06-27 21:20:09 +00001277#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001278int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001279sys_oldlstat(tcp)
1280struct tcb *tcp;
1281{
1282 if (entering(tcp)) {
1283 printpath(tcp, tcp->u_arg[0]);
1284 tprintf(", ");
1285 } else {
1286 printoldstat(tcp, tcp->u_arg[1]);
1287 }
1288 return 0;
1289}
Roland McGrath79db8af2003-06-27 21:20:09 +00001290#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001291
1292
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001293#if defined(SVR4) || defined(LINUXSPARC)
1294
1295int
1296sys_xstat(tcp)
1297struct tcb *tcp;
1298{
1299 if (entering(tcp)) {
1300 tprintf("%ld, ", tcp->u_arg[0]);
1301 printpath(tcp, tcp->u_arg[1]);
1302 tprintf(", ");
1303 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001304#ifdef _STAT64_VER
1305 if (tcp->u_arg[0] == _STAT64_VER)
1306 printstat64 (tcp, tcp->u_arg[2]);
1307 else
1308#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001309 printstat(tcp, tcp->u_arg[2]);
1310 }
1311 return 0;
1312}
1313
1314int
1315sys_fxstat(tcp)
1316struct tcb *tcp;
1317{
1318 if (entering(tcp))
1319 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1320 else {
John Hughes8fe2c982001-03-06 09:45:18 +00001321#ifdef _STAT64_VER
1322 if (tcp->u_arg[0] == _STAT64_VER)
1323 printstat64 (tcp, tcp->u_arg[2]);
1324 else
1325#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001326 printstat(tcp, tcp->u_arg[2]);
1327 }
1328 return 0;
1329}
1330
1331int
1332sys_lxstat(tcp)
1333struct tcb *tcp;
1334{
1335 if (entering(tcp)) {
1336 tprintf("%ld, ", tcp->u_arg[0]);
1337 printpath(tcp, tcp->u_arg[1]);
1338 tprintf(", ");
1339 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001340#ifdef _STAT64_VER
1341 if (tcp->u_arg[0] == _STAT64_VER)
1342 printstat64 (tcp, tcp->u_arg[2]);
1343 else
1344#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001345 printstat(tcp, tcp->u_arg[2]);
1346 }
1347 return 0;
1348}
1349
1350int
1351sys_xmknod(tcp)
1352struct tcb *tcp;
1353{
1354 int mode = tcp->u_arg[2];
1355
1356 if (entering(tcp)) {
1357 tprintf("%ld, ", tcp->u_arg[0]);
1358 printpath(tcp, tcp->u_arg[1]);
1359 tprintf(", %s", sprintmode(mode));
1360 switch (mode & S_IFMT) {
1361 case S_IFCHR: case S_IFBLK:
1362#ifdef LINUXSPARC
1363 tprintf(", makedev(%lu, %lu)",
1364 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1365 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
Roland McGrath186c5ac2002-12-15 23:58:23 +00001366#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001367 tprintf(", makedev(%lu, %lu)",
1368 (unsigned long) major(tcp->u_arg[3]),
1369 (unsigned long) minor(tcp->u_arg[3]));
Roland McGrath186c5ac2002-12-15 23:58:23 +00001370#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001371 break;
1372 default:
1373 break;
1374 }
1375 }
1376 return 0;
1377}
1378
Wichert Akkerman8829a551999-06-11 13:18:40 +00001379#ifdef HAVE_SYS_ACL_H
1380
1381#include <sys/acl.h>
1382
Roland McGratha4d48532005-06-08 20:45:28 +00001383static const struct xlat aclcmds[] = {
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001384#ifdef SETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001385 { SETACL, "SETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001386#endif
1387#ifdef GETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001388 { GETACL, "GETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001389#endif
1390#ifdef GETACLCNT
Wichert Akkerman8829a551999-06-11 13:18:40 +00001391 { GETACLCNT, "GETACLCNT" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001392#endif
1393#ifdef ACL_GET
1394 { ACL_GET, "ACL_GET" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001395#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001396#ifdef ACL_SET
1397 { ACL_SET, "ACL_SET" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001398#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001399#ifdef ACL_CNT
1400 { ACL_CNT, "ACL_CNT" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001401#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +00001402 { 0, NULL },
1403};
1404
1405int
1406sys_acl(tcp)
1407struct tcb *tcp;
1408{
1409 if (entering(tcp)) {
1410 printpath(tcp, tcp->u_arg[0]);
1411 tprintf(", ");
1412 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1413 tprintf(", %ld", tcp->u_arg[2]);
1414 /*
1415 * FIXME - dump out the list of aclent_t's pointed to
1416 * by "tcp->u_arg[3]" if it's not NULL.
1417 */
1418 if (tcp->u_arg[3])
1419 tprintf(", %#lx", tcp->u_arg[3]);
1420 else
1421 tprintf(", NULL");
1422 }
1423 return 0;
1424}
1425
1426
1427int
1428sys_facl(tcp)
1429struct tcb *tcp;
1430{
1431 if (entering(tcp)) {
1432 tprintf("%ld, ", tcp->u_arg[0]);
1433 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1434 tprintf(", %ld", tcp->u_arg[2]);
1435 /*
1436 * FIXME - dump out the list of aclent_t's pointed to
1437 * by "tcp->u_arg[3]" if it's not NULL.
1438 */
1439 if (tcp->u_arg[3])
1440 tprintf(", %#lx", tcp->u_arg[3]);
1441 else
1442 tprintf(", NULL");
1443 }
1444 return 0;
1445}
1446
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001447
Roland McGratha4d48532005-06-08 20:45:28 +00001448static const struct xlat aclipc[] = {
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001449#ifdef IPC_SHM
1450 { IPC_SHM, "IPC_SHM" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001451#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001452#ifdef IPC_SEM
1453 { IPC_SEM, "IPC_SEM" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001454#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001455#ifdef IPC_MSG
1456 { IPC_MSG, "IPC_MSG" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001457#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001458 { 0, NULL },
1459};
1460
1461
1462int
1463sys_aclipc(tcp)
1464struct tcb *tcp;
1465{
1466 if (entering(tcp)) {
1467 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1468 tprintf(", %#lx, ", tcp->u_arg[1]);
1469 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1470 tprintf(", %ld", tcp->u_arg[3]);
1471 /*
1472 * FIXME - dump out the list of aclent_t's pointed to
1473 * by "tcp->u_arg[4]" if it's not NULL.
1474 */
1475 if (tcp->u_arg[4])
1476 tprintf(", %#lx", tcp->u_arg[4]);
1477 else
1478 tprintf(", NULL");
1479 }
1480 return 0;
1481}
1482
1483
1484
Wichert Akkerman8829a551999-06-11 13:18:40 +00001485#endif /* HAVE_SYS_ACL_H */
1486
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001487#endif /* SVR4 || LINUXSPARC */
1488
Michal Ludvig53b320f2002-09-23 13:30:09 +00001489#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001490
Roland McGrathd9f816f2004-09-04 03:39:20 +00001491static const struct xlat fsmagic[] = {
Wichert Akkerman43a74822000-06-27 17:33:32 +00001492 { 0x73757245, "CODA_SUPER_MAGIC" },
1493 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1494 { 0x1373, "DEVFS_SUPER_MAGIC" },
1495 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1496 { 0x414A53, "EFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001497 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1498 { 0xef53, "EXT2_SUPER_MAGIC" },
1499 { 0x137d, "EXT_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001500 { 0xf995e849, "HPFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001501 { 0x9660, "ISOFS_SUPER_MAGIC" },
1502 { 0x137f, "MINIX_SUPER_MAGIC" },
1503 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001504 { 0x2468, "MINIX2_SUPER_MAGIC" },
1505 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001506 { 0x4d44, "MSDOS_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001507 { 0x564c, "NCP_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001508 { 0x6969, "NFS_SUPER_MAGIC" },
1509 { 0x9fa0, "PROC_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001510 { 0x002f, "QNX4_SUPER_MAGIC" },
1511 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1512 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1513 { 0x517b, "SMB_SUPER_MAGIC" },
1514 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1515 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1516 { 0x00011954, "UFS_MAGIC" },
1517 { 0x54190100, "UFS_CIGAM" },
1518 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001519 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
Roland McGrathc767ad82004-01-13 10:13:45 +00001520 { 0x62656572, "SYSFS_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001521 { 0, NULL },
1522};
1523
Michal Ludvig53b320f2002-09-23 13:30:09 +00001524#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001525
1526#ifndef SVR4
1527
Roland McGrathf9c49b22004-10-06 22:11:54 +00001528static const char *
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001529sprintfstype(magic)
1530int magic;
1531{
1532 static char buf[32];
Michal Ludvig53b320f2002-09-23 13:30:09 +00001533#ifdef LINUX
Roland McGrathf9c49b22004-10-06 22:11:54 +00001534 const char *s;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001535
1536 s = xlookup(fsmagic, magic);
1537 if (s) {
1538 sprintf(buf, "\"%s\"", s);
1539 return buf;
1540 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00001541#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001542 sprintf(buf, "%#x", magic);
1543 return buf;
1544}
1545
1546static void
1547printstatfs(tcp, addr)
1548struct tcb *tcp;
1549long addr;
1550{
1551 struct statfs statbuf;
1552
1553 if (syserror(tcp) || !verbose(tcp)) {
1554 tprintf("%#lx", addr);
1555 return;
1556 }
1557 if (umove(tcp, addr, &statbuf) < 0) {
1558 tprintf("{...}");
1559 return;
1560 }
1561#ifdef ALPHA
1562
1563 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1564 sprintfstype(statbuf.f_type),
1565 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Roland McGrathab147c52003-07-17 09:03:02 +00001566 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1567 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1568 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1569 statbuf.f_namelen);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001570#else /* !ALPHA */
1571 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1572 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +00001573 (unsigned long)statbuf.f_bsize,
1574 (unsigned long)statbuf.f_blocks,
1575 (unsigned long)statbuf.f_bfree);
Roland McGrathab147c52003-07-17 09:03:02 +00001576 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1577 (unsigned long)statbuf.f_bavail,
Nate Sammons5c74d201999-04-06 01:37:51 +00001578 (unsigned long)statbuf.f_files,
Roland McGrathab147c52003-07-17 09:03:02 +00001579 (unsigned long)statbuf.f_ffree,
1580 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
Michal Ludvig53b320f2002-09-23 13:30:09 +00001581#ifdef LINUX
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001582 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Michal Ludvig53b320f2002-09-23 13:30:09 +00001583#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001584#endif /* !ALPHA */
Roland McGrathab147c52003-07-17 09:03:02 +00001585#ifdef _STATFS_F_FRSIZE
1586 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1587#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001588 tprintf("}");
1589}
1590
1591int
1592sys_statfs(tcp)
1593struct tcb *tcp;
1594{
1595 if (entering(tcp)) {
1596 printpath(tcp, tcp->u_arg[0]);
1597 tprintf(", ");
1598 } else {
1599 printstatfs(tcp, tcp->u_arg[1]);
1600 }
1601 return 0;
1602}
1603
1604int
1605sys_fstatfs(tcp)
1606struct tcb *tcp;
1607{
1608 if (entering(tcp)) {
1609 tprintf("%lu, ", tcp->u_arg[0]);
1610 } else {
1611 printstatfs(tcp, tcp->u_arg[1]);
1612 }
1613 return 0;
1614}
1615
Roland McGrathab147c52003-07-17 09:03:02 +00001616#ifdef LINUX
1617static void
1618printstatfs64(tcp, addr)
1619struct tcb *tcp;
1620long addr;
1621{
1622 struct statfs64 statbuf;
1623
1624 if (syserror(tcp) || !verbose(tcp)) {
1625 tprintf("%#lx", addr);
1626 return;
1627 }
1628 if (umove(tcp, addr, &statbuf) < 0) {
1629 tprintf("{...}");
1630 return;
1631 }
Roland McGrath08738432005-06-03 02:40:39 +00001632 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
Roland McGrathab147c52003-07-17 09:03:02 +00001633 sprintfstype(statbuf.f_type),
Roland McGrath08738432005-06-03 02:40:39 +00001634 (unsigned long long)statbuf.f_bsize,
1635 (unsigned long long)statbuf.f_blocks,
1636 (unsigned long long)statbuf.f_bfree);
1637 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1638 (unsigned long long)statbuf.f_bavail,
1639 (unsigned long long)statbuf.f_files,
1640 (unsigned long long)statbuf.f_ffree,
Roland McGrathab147c52003-07-17 09:03:02 +00001641 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1642 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Roland McGrathab147c52003-07-17 09:03:02 +00001643#ifdef _STATFS_F_FRSIZE
Roland McGrath08738432005-06-03 02:40:39 +00001644 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
Roland McGrathab147c52003-07-17 09:03:02 +00001645#endif
1646 tprintf("}");
1647}
1648
1649int
1650sys_statfs64(tcp)
1651struct tcb *tcp;
1652{
1653 if (entering(tcp)) {
1654 printpath(tcp, tcp->u_arg[0]);
1655 tprintf(", %lu, ", tcp->u_arg[1]);
1656 } else {
1657 if (tcp->u_arg[1] == sizeof (struct statfs64))
1658 printstatfs64(tcp, tcp->u_arg[2]);
1659 else
1660 tprintf("{???}");
1661 }
1662 return 0;
1663}
1664
1665int
1666sys_fstatfs64(tcp)
1667struct tcb *tcp;
1668{
1669 if (entering(tcp)) {
1670 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1671 } else {
1672 if (tcp->u_arg[1] == sizeof (struct statfs64))
1673 printstatfs64(tcp, tcp->u_arg[2]);
1674 else
1675 tprintf("{???}");
1676 }
1677 return 0;
1678}
1679#endif
1680
Michal Ludvig53b320f2002-09-23 13:30:09 +00001681#if defined(LINUX) && defined(__alpha)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001682
1683int
1684osf_statfs(tcp)
1685struct tcb *tcp;
1686{
1687 if (entering(tcp)) {
1688 printpath(tcp, tcp->u_arg[0]);
1689 tprintf(", ");
1690 } else {
1691 printstatfs(tcp, tcp->u_arg[1]);
1692 tprintf(", %lu", tcp->u_arg[2]);
1693 }
1694 return 0;
1695}
1696
1697int
1698osf_fstatfs(tcp)
1699struct tcb *tcp;
1700{
1701 if (entering(tcp)) {
1702 tprintf("%lu, ", tcp->u_arg[0]);
1703 } else {
1704 printstatfs(tcp, tcp->u_arg[1]);
1705 tprintf(", %lu", tcp->u_arg[2]);
1706 }
1707 return 0;
1708}
Michal Ludvig53b320f2002-09-23 13:30:09 +00001709#endif /* LINUX && __alpha */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001710
1711#endif /* !SVR4 */
1712
1713#ifdef SUNOS4
1714
1715int
1716sys_ustat(tcp)
1717struct tcb *tcp;
1718{
1719 struct ustat statbuf;
1720
1721 if (entering(tcp)) {
1722 tprintf("makedev(%lu, %lu), ",
1723 (long) major(tcp->u_arg[0]),
1724 (long) minor(tcp->u_arg[0]));
1725 }
1726 else {
1727 if (syserror(tcp) || !verbose(tcp))
1728 tprintf("%#lx", tcp->u_arg[1]);
1729 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1730 tprintf("{...}");
1731 else {
1732 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1733 statbuf.f_tfree, statbuf.f_tinode);
1734 tprintf("f_fname=\"%.*s\", ",
1735 (int) sizeof(statbuf.f_fname),
1736 statbuf.f_fname);
1737 tprintf("f_fpack=\"%.*s\"}",
1738 (int) sizeof(statbuf.f_fpack),
1739 statbuf.f_fpack);
1740 }
1741 }
1742 return 0;
1743}
1744
1745#endif /* SUNOS4 */
1746
Wichert Akkermanc7926982000-04-10 22:22:31 +00001747int
1748sys_pivotroot(tcp)
1749struct tcb *tcp;
1750{
1751 if (entering(tcp)) {
1752 printpath(tcp, tcp->u_arg[0]);
1753 tprintf(", ");
1754 printpath(tcp, tcp->u_arg[1]);
1755 }
1756 return 0;
1757}
1758
1759
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001760/* directory */
1761int
1762sys_chdir(tcp)
1763struct tcb *tcp;
1764{
1765 if (entering(tcp)) {
1766 printpath(tcp, tcp->u_arg[0]);
1767 }
1768 return 0;
1769}
1770
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001771static int
1772decode_mkdir(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001773{
1774 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001775 printpath(tcp, tcp->u_arg[offset]);
1776 tprintf(", %#lo", tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001777 }
1778 return 0;
1779}
1780
1781int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001782sys_mkdir(struct tcb *tcp)
1783{
1784 return decode_mkdir(tcp, 0);
1785}
1786
1787#ifdef LINUX
1788int
1789sys_mkdirat(struct tcb *tcp)
1790{
1791 if (entering(tcp))
1792 print_dirfd(tcp->u_arg[0]);
1793 return decode_mkdir(tcp, 1);
1794}
1795#endif
1796
1797int
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001798sys_rmdir(tcp)
1799struct tcb *tcp;
1800{
1801 if (entering(tcp)) {
1802 printpath(tcp, tcp->u_arg[0]);
1803 }
1804 return 0;
1805}
1806
1807int
1808sys_fchdir(tcp)
1809struct tcb *tcp;
1810{
1811 if (entering(tcp)) {
1812 tprintf("%ld", tcp->u_arg[0]);
1813 }
1814 return 0;
1815}
1816
1817int
1818sys_chroot(tcp)
1819struct tcb *tcp;
1820{
1821 if (entering(tcp)) {
1822 printpath(tcp, tcp->u_arg[0]);
1823 }
1824 return 0;
1825}
1826
1827int
1828sys_fchroot(tcp)
1829struct tcb *tcp;
1830{
1831 if (entering(tcp)) {
1832 tprintf("%ld", tcp->u_arg[0]);
1833 }
1834 return 0;
1835}
1836
1837int
1838sys_link(tcp)
1839struct tcb *tcp;
1840{
1841 if (entering(tcp)) {
1842 printpath(tcp, tcp->u_arg[0]);
1843 tprintf(", ");
1844 printpath(tcp, tcp->u_arg[1]);
1845 }
1846 return 0;
1847}
1848
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001849#ifdef LINUX
1850int
1851sys_linkat(struct tcb *tcp)
1852{
1853 if (entering(tcp)) {
1854 print_dirfd(tcp->u_arg[0]);
1855 printpath(tcp, tcp->u_arg[1]);
1856 tprintf(", ");
1857 print_dirfd(tcp->u_arg[2]);
1858 printpath(tcp, tcp->u_arg[3]);
1859 tprintf(", %ld", tcp->u_arg[4]);
1860 }
1861 return 0;
1862}
1863#endif
1864
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001865int
1866sys_unlink(tcp)
1867struct tcb *tcp;
1868{
1869 if (entering(tcp)) {
1870 printpath(tcp, tcp->u_arg[0]);
1871 }
1872 return 0;
1873}
1874
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001875#ifdef LINUX
1876static const struct xlat unlinkatflags[] = {
1877#ifndef AT_REMOVEDIR
1878# define AT_REMOVEDIR 0x200
1879#endif
1880 { AT_REMOVEDIR, "AT_REMOVEDIR" },
1881 { 0, NULL },
1882};
1883
1884int
1885sys_unlinkat(struct tcb *tcp)
1886{
1887 if (entering(tcp)) {
1888 print_dirfd(tcp->u_arg[0]);
1889 printpath(tcp, tcp->u_arg[1]);
1890 tprintf(", ");
1891 printflags(unlinkatflags, tcp->u_arg[2], "AT_???");
1892 }
1893 return 0;
1894}
1895#endif
1896
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001897int
1898sys_symlink(tcp)
1899struct tcb *tcp;
1900{
1901 if (entering(tcp)) {
1902 printpath(tcp, tcp->u_arg[0]);
1903 tprintf(", ");
1904 printpath(tcp, tcp->u_arg[1]);
1905 }
1906 return 0;
1907}
1908
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001909#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001910int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001911sys_symlinkat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001912{
1913 if (entering(tcp)) {
1914 printpath(tcp, tcp->u_arg[0]);
1915 tprintf(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001916 print_dirfd(tcp->u_arg[1]);
1917 printpath(tcp, tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001918 }
1919 return 0;
1920}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001921#endif
1922
1923static int
1924decode_readlink(struct tcb *tcp, int offset)
1925{
1926 if (entering(tcp)) {
1927 printpath(tcp, tcp->u_arg[offset]);
1928 tprintf(", ");
1929 } else {
1930 if (syserror(tcp))
1931 tprintf("%#lx", tcp->u_arg[offset + 1]);
1932 else
1933 printpathn(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
1934 tprintf(", %lu", tcp->u_arg[offset + 2]);
1935 }
1936 return 0;
1937}
1938
1939int
1940sys_readlink(struct tcb *tcp)
1941{
1942 return decode_readlink(tcp, 0);
1943}
1944
1945#ifdef LINUX
1946int
1947sys_readlinkat(struct tcb *tcp)
1948{
1949 if (entering(tcp))
1950 print_dirfd(tcp->u_arg[0]);
1951 return decode_readlink(tcp, 1);
1952}
1953#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001954
1955int
1956sys_rename(tcp)
1957struct tcb *tcp;
1958{
1959 if (entering(tcp)) {
1960 printpath(tcp, tcp->u_arg[0]);
1961 tprintf(", ");
1962 printpath(tcp, tcp->u_arg[1]);
1963 }
1964 return 0;
1965}
1966
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001967#ifdef LINUX
1968int
1969sys_renameat(struct tcb *tcp)
1970{
1971 if (entering(tcp)) {
1972 print_dirfd(tcp->u_arg[0]);
1973 printpath(tcp, tcp->u_arg[1]);
1974 tprintf(", ");
1975 print_dirfd(tcp->u_arg[2]);
1976 printpath(tcp, tcp->u_arg[3]);
1977 }
1978 return 0;
1979}
1980#endif
1981
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001982int
1983sys_chown(tcp)
1984struct tcb *tcp;
1985{
1986 if (entering(tcp)) {
1987 printpath(tcp, tcp->u_arg[0]);
Roland McGrath6bc12202003-11-13 22:32:27 +00001988 printuid(", ", tcp->u_arg[1]);
1989 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001990 }
1991 return 0;
1992}
1993
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001994#ifdef LINUX
1995int
1996sys_fchownat(struct tcb *tcp)
1997{
1998 if (entering(tcp)) {
1999 print_dirfd(tcp->u_arg[0]);
2000 printpath(tcp, tcp->u_arg[1]);
2001 printuid(", ", tcp->u_arg[2]);
2002 printuid(", ", tcp->u_arg[3]);
2003 tprintf(", ");
2004 printflags(fstatatflags, tcp->u_arg[4], "AT_???");
2005 }
2006 return 0;
2007}
2008#endif
2009
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002010int
2011sys_fchown(tcp)
2012struct tcb *tcp;
2013{
2014 if (entering(tcp)) {
Roland McGrath6bc12202003-11-13 22:32:27 +00002015 tprintf("%ld", tcp->u_arg[0]);
2016 printuid(", ", tcp->u_arg[1]);
2017 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002018 }
2019 return 0;
2020}
2021
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002022static int
2023decode_chmod(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002024{
2025 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002026 printpath(tcp, tcp->u_arg[offset]);
2027 tprintf(", %#lo", tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002028 }
2029 return 0;
2030}
2031
2032int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002033sys_chmod(struct tcb *tcp)
2034{
2035 return decode_chmod(tcp, 0);
2036}
2037
2038#ifdef LINUX
2039int
2040sys_fchmodat(struct tcb *tcp)
2041{
2042 if (entering(tcp))
2043 print_dirfd(tcp->u_arg[0]);
2044 return decode_chmod(tcp, 1);
2045}
2046#endif
2047
2048int
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002049sys_fchmod(tcp)
2050struct tcb *tcp;
2051{
2052 if (entering(tcp)) {
2053 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
2054 }
2055 return 0;
2056}
2057
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002058#ifdef ALPHA
2059int
2060sys_osf_utimes(tcp)
2061struct tcb *tcp;
2062{
2063 if (entering(tcp)) {
2064 printpath(tcp, tcp->u_arg[0]);
2065 tprintf(", ");
2066 printtv32(tcp, tcp->u_arg[1]);
2067 }
2068 return 0;
2069}
2070#endif
2071
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002072static int
2073decode_utimes(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002074{
2075 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002076 printpath(tcp, tcp->u_arg[offset]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002077 tprintf(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002078 printtv(tcp, tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002079 }
2080 return 0;
2081}
2082
2083int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002084sys_utimes(struct tcb *tcp)
2085{
2086 return decode_utimes(tcp, 0);
2087}
2088
2089#ifdef LINUX
2090int
2091sys_futimesat(struct tcb *tcp)
2092{
2093 if (entering(tcp))
2094 print_dirfd(tcp->u_arg[0]);
2095 return decode_utimes(tcp, 1);
2096}
2097#endif
2098
2099int
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002100sys_utime(tcp)
2101struct tcb *tcp;
2102{
2103 long ut[2];
2104
2105 if (entering(tcp)) {
2106 printpath(tcp, tcp->u_arg[0]);
2107 tprintf(", ");
2108 if (!tcp->u_arg[1])
2109 tprintf("NULL");
2110 else if (!verbose(tcp))
2111 tprintf("%#lx", tcp->u_arg[1]);
2112 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
2113 (char *) ut) < 0)
2114 tprintf("[?, ?]");
2115 else {
2116 tprintf("[%s,", sprinttime(ut[0]));
2117 tprintf(" %s]", sprinttime(ut[1]));
2118 }
2119 }
2120 return 0;
2121}
2122
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002123static int
2124decode_mknod(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002125{
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002126 int mode = tcp->u_arg[offset + 1];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002127
2128 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002129 printpath(tcp, tcp->u_arg[offset]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002130 tprintf(", %s", sprintmode(mode));
2131 switch (mode & S_IFMT) {
2132 case S_IFCHR: case S_IFBLK:
2133#ifdef LINUXSPARC
2134 if (current_personality == 1)
2135 tprintf(", makedev(%lu, %lu)",
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002136 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
2137 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002138 else
Roland McGrath186c5ac2002-12-15 23:58:23 +00002139#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002140 tprintf(", makedev(%lu, %lu)",
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002141 (unsigned long) major(tcp->u_arg[offset + 2]),
2142 (unsigned long) minor(tcp->u_arg[offset + 2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002143 break;
2144 default:
2145 break;
2146 }
2147 }
2148 return 0;
2149}
2150
2151int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002152sys_mknod(struct tcb *tcp)
2153{
2154 return decode_mknod(tcp, 0);
2155}
2156
2157#ifdef LINUX
2158int
2159sys_mknodat(struct tcb *tcp)
2160{
2161 if (entering(tcp))
2162 print_dirfd(tcp->u_arg[0]);
2163 return decode_mknod(tcp, 1);
2164}
2165#endif
2166
2167int
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002168sys_mkfifo(tcp)
2169struct tcb *tcp;
2170{
2171 if (entering(tcp)) {
2172 printpath(tcp, tcp->u_arg[0]);
2173 tprintf(", %#lo", tcp->u_arg[1]);
2174 }
2175 return 0;
2176}
2177
2178int
2179sys_fsync(tcp)
2180struct tcb *tcp;
2181{
2182 if (entering(tcp)) {
2183 tprintf("%ld", tcp->u_arg[0]);
2184 }
2185 return 0;
2186}
2187
Michal Ludvig53b320f2002-09-23 13:30:09 +00002188#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002189
2190static void
2191printdir(tcp, addr)
2192struct tcb *tcp;
2193long addr;
2194{
2195 struct dirent d;
2196
2197 if (!verbose(tcp)) {
2198 tprintf("%#lx", addr);
2199 return;
2200 }
2201 if (umove(tcp, addr, &d) < 0) {
2202 tprintf("{...}");
2203 return;
2204 }
2205 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002206 tprintf("d_name=");
2207 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
2208 tprintf("}");
2209}
2210
2211int
2212sys_readdir(tcp)
2213struct tcb *tcp;
2214{
2215 if (entering(tcp)) {
2216 tprintf("%lu, ", tcp->u_arg[0]);
2217 } else {
2218 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
2219 tprintf("%#lx", tcp->u_arg[1]);
2220 else
2221 printdir(tcp, tcp->u_arg[1]);
2222 /* Not much point in printing this out, it is always 1. */
2223 if (tcp->u_arg[2] != 1)
2224 tprintf(", %lu", tcp->u_arg[2]);
2225 }
2226 return 0;
2227}
2228
Michal Ludvig53b320f2002-09-23 13:30:09 +00002229#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002230
Roland McGrath40542842004-01-13 09:47:49 +00002231#if defined FREEBSD || defined LINUX
Roland McGratha4d48532005-06-08 20:45:28 +00002232static const struct xlat direnttypes[] = {
Roland McGrath40542842004-01-13 09:47:49 +00002233 { DT_UNKNOWN, "DT_UNKNOWN" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002234 { DT_FIFO, "DT_FIFO" },
2235 { DT_CHR, "DT_CHR" },
2236 { DT_DIR, "DT_DIR" },
2237 { DT_BLK, "DT_BLK" },
2238 { DT_REG, "DT_REG" },
2239 { DT_LNK, "DT_LNK" },
2240 { DT_SOCK, "DT_SOCK" },
2241 { DT_WHT, "DT_WHT" },
2242 { 0, NULL },
2243};
2244
2245#endif
2246
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002247int
2248sys_getdents(tcp)
2249struct tcb *tcp;
2250{
2251 int i, len, dents = 0;
2252 char *buf;
2253
2254 if (entering(tcp)) {
2255 tprintf("%lu, ", tcp->u_arg[0]);
2256 return 0;
2257 }
2258 if (syserror(tcp) || !verbose(tcp)) {
2259 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2260 return 0;
2261 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002262 len = tcp->u_rval;
2263 if ((buf = malloc(len)) == NULL) {
Roland McGrath46100d02005-06-01 18:55:42 +00002264 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2265 fprintf(stderr, "out of memory\n");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002266 return 0;
2267 }
2268 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002269 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002270 free(buf);
2271 return 0;
2272 }
2273 if (!abbrev(tcp))
2274 tprintf("{");
2275 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00002276 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Michal Ludvig53b320f2002-09-23 13:30:09 +00002277#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002278 if (!abbrev(tcp)) {
2279 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2280 i ? " " : "", d->d_ino, d->d_off);
2281 tprintf("d_reclen=%u, d_name=\"%s\"}",
2282 d->d_reclen, d->d_name);
2283 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00002284#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002285#ifdef SVR4
2286 if (!abbrev(tcp)) {
2287 tprintf("%s{d_ino=%lu, d_off=%lu, ",
Roland McGrath186c5ac2002-12-15 23:58:23 +00002288 i ? " " : "",
2289 (unsigned long) d->d_ino,
2290 (unsigned long) d->d_off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002291 tprintf("d_reclen=%u, d_name=\"%s\"}",
2292 d->d_reclen, d->d_name);
2293 }
2294#endif /* SVR4 */
2295#ifdef SUNOS4
2296 if (!abbrev(tcp)) {
2297 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2298 i ? " " : "", d->d_off, d->d_fileno,
2299 d->d_reclen);
2300 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2301 d->d_namlen, d->d_namlen, d->d_name);
2302 }
2303#endif /* SUNOS4 */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002304#ifdef FREEBSD
2305 if (!abbrev(tcp)) {
2306 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2307 i ? " " : "", d->d_fileno, d->d_reclen);
2308 printxval(direnttypes, d->d_type, "DT_???");
2309 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2310 d->d_namlen, d->d_namlen, d->d_name);
2311 }
Roland McGrath186c5ac2002-12-15 23:58:23 +00002312#endif /* FREEBSD */
Pavel Machek9a9f10b2000-02-01 16:22:52 +00002313 if (!d->d_reclen) {
2314 tprintf("/* d_reclen == 0, problem here */");
2315 break;
2316 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002317 i += d->d_reclen;
2318 dents++;
2319 }
2320 if (!abbrev(tcp))
2321 tprintf("}");
2322 else
2323 tprintf("/* %u entries */", dents);
2324 tprintf(", %lu", tcp->u_arg[2]);
2325 free(buf);
2326 return 0;
2327}
2328
John Hughesbdf48f52001-03-06 15:08:09 +00002329
2330#if _LFS64_LARGEFILE
2331int
2332sys_getdents64(tcp)
2333struct tcb *tcp;
2334{
2335 int i, len, dents = 0;
2336 char *buf;
2337
2338 if (entering(tcp)) {
2339 tprintf("%lu, ", tcp->u_arg[0]);
2340 return 0;
2341 }
2342 if (syserror(tcp) || !verbose(tcp)) {
2343 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2344 return 0;
2345 }
2346 len = tcp->u_rval;
2347 if ((buf = malloc(len)) == NULL) {
Roland McGrath46100d02005-06-01 18:55:42 +00002348 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2349 fprintf(stderr, "out of memory\n");
John Hughesbdf48f52001-03-06 15:08:09 +00002350 return 0;
2351 }
2352 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002353 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
John Hughesbdf48f52001-03-06 15:08:09 +00002354 free(buf);
2355 return 0;
2356 }
2357 if (!abbrev(tcp))
2358 tprintf("{");
2359 for (i = 0; i < len;) {
2360 struct dirent64 *d = (struct dirent64 *) &buf[i];
Michal Ludvig53b320f2002-09-23 13:30:09 +00002361#if defined(LINUX) || defined(SVR4)
John Hughesbdf48f52001-03-06 15:08:09 +00002362 if (!abbrev(tcp)) {
Dmitry V. Levin1f336e52006-10-14 20:20:46 +00002363 tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ",
Roland McGrath186c5ac2002-12-15 23:58:23 +00002364 i ? " " : "",
Roland McGrath92053242004-01-13 10:16:47 +00002365 d->d_ino,
2366 d->d_off);
Roland McGrath40542842004-01-13 09:47:49 +00002367#ifdef LINUX
2368 tprintf("d_type=");
2369 printxval(direnttypes, d->d_type, "DT_???");
2370 tprintf(", ");
2371#endif
John Hughesbdf48f52001-03-06 15:08:09 +00002372 tprintf("d_reclen=%u, d_name=\"%s\"}",
2373 d->d_reclen, d->d_name);
2374 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00002375#endif /* LINUX || SVR4 */
John Hughesbdf48f52001-03-06 15:08:09 +00002376#ifdef SUNOS4
2377 if (!abbrev(tcp)) {
2378 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2379 i ? " " : "", d->d_off, d->d_fileno,
2380 d->d_reclen);
2381 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2382 d->d_namlen, d->d_namlen, d->d_name);
2383 }
2384#endif /* SUNOS4 */
2385 i += d->d_reclen;
2386 dents++;
2387 }
2388 if (!abbrev(tcp))
2389 tprintf("}");
2390 else
2391 tprintf("/* %u entries */", dents);
2392 tprintf(", %lu", tcp->u_arg[2]);
2393 free(buf);
2394 return 0;
2395}
2396#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +00002397
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002398#ifdef FREEBSD
2399int
2400sys_getdirentries(tcp)
2401struct tcb * tcp;
2402{
2403 int i, len, dents = 0;
2404 long basep;
2405 char *buf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002406
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002407 if (entering(tcp)) {
2408 tprintf("%lu, ", tcp->u_arg[0]);
2409 return 0;
2410 }
2411 if (syserror(tcp) || !verbose(tcp)) {
2412 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2413 return 0;
2414 }
2415 len = tcp->u_rval;
2416 if ((buf = malloc(len)) == NULL) {
Roland McGrath46100d02005-06-01 18:55:42 +00002417 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2418 fprintf(stderr, "out of memory\n");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002419 return 0;
2420 }
2421 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002422 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002423 free(buf);
2424 return 0;
2425 }
2426 if (!abbrev(tcp))
2427 tprintf("{");
2428 for (i = 0; i < len;) {
2429 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2430 if (!abbrev(tcp)) {
2431 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2432 i ? " " : "", d->d_fileno, d->d_reclen);
2433 printxval(direnttypes, d->d_type, "DT_???");
2434 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2435 d->d_namlen, d->d_namlen, d->d_name);
2436 }
2437 i += d->d_reclen;
2438 dents++;
2439 }
2440 if (!abbrev(tcp))
2441 tprintf("}");
2442 else
2443 tprintf("/* %u entries */", dents);
2444 free(buf);
2445 tprintf(", %lu", tcp->u_arg[2]);
2446 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2447 tprintf(", %#lx", tcp->u_arg[3]);
2448 else
2449 tprintf(", [%lu]", basep);
2450 return 0;
2451}
2452#endif
2453
Michal Ludvig53b320f2002-09-23 13:30:09 +00002454#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002455int
2456sys_getcwd(tcp)
2457struct tcb *tcp;
2458{
2459 if (exiting(tcp)) {
2460 if (syserror(tcp))
2461 tprintf("%#lx", tcp->u_arg[0]);
2462 else
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00002463 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002464 tprintf(", %lu", tcp->u_arg[1]);
2465 }
2466 return 0;
2467}
Michal Ludvig53b320f2002-09-23 13:30:09 +00002468#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002469
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002470#ifdef FREEBSD
2471int
2472sys___getcwd(tcp)
2473struct tcb *tcp;
2474{
2475 if (exiting(tcp)) {
2476 if (syserror(tcp))
2477 tprintf("%#lx", tcp->u_arg[0]);
2478 else
2479 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2480 tprintf(", %lu", tcp->u_arg[1]);
2481 }
2482 return 0;
2483}
2484#endif
2485
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002486#ifdef HAVE_SYS_ASYNCH_H
2487
2488int
2489sys_aioread(tcp)
2490struct tcb *tcp;
2491{
2492 struct aio_result_t res;
2493
2494 if (entering(tcp)) {
2495 tprintf("%lu, ", tcp->u_arg[0]);
2496 } else {
2497 if (syserror(tcp))
2498 tprintf("%#lx", tcp->u_arg[1]);
2499 else
2500 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2501 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2502 printxval(whence, tcp->u_arg[4], "L_???");
2503 if (syserror(tcp) || tcp->u_arg[5] == 0
2504 || umove(tcp, tcp->u_arg[5], &res) < 0)
2505 tprintf(", %#lx", tcp->u_arg[5]);
2506 else
2507 tprintf(", {aio_return %d aio_errno %d}",
2508 res.aio_return, res.aio_errno);
2509 }
2510 return 0;
2511}
2512
2513int
2514sys_aiowrite(tcp)
2515struct tcb *tcp;
2516{
2517 struct aio_result_t res;
2518
2519 if (entering(tcp)) {
2520 tprintf("%lu, ", tcp->u_arg[0]);
2521 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2522 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2523 printxval(whence, tcp->u_arg[4], "L_???");
2524 }
2525 else {
2526 if (tcp->u_arg[5] == 0)
2527 tprintf(", NULL");
2528 else if (syserror(tcp)
2529 || umove(tcp, tcp->u_arg[5], &res) < 0)
2530 tprintf(", %#lx", tcp->u_arg[5]);
2531 else
2532 tprintf(", {aio_return %d aio_errno %d}",
2533 res.aio_return, res.aio_errno);
2534 }
2535 return 0;
2536}
2537
2538int
2539sys_aiowait(tcp)
2540struct tcb *tcp;
2541{
2542 if (entering(tcp))
2543 printtv(tcp, tcp->u_arg[0]);
2544 return 0;
2545}
2546
2547int
2548sys_aiocancel(tcp)
2549struct tcb *tcp;
2550{
2551 struct aio_result_t res;
2552
2553 if (exiting(tcp)) {
2554 if (tcp->u_arg[0] == 0)
2555 tprintf("NULL");
2556 else if (syserror(tcp)
2557 || umove(tcp, tcp->u_arg[0], &res) < 0)
2558 tprintf("%#lx", tcp->u_arg[0]);
2559 else
2560 tprintf("{aio_return %d aio_errno %d}",
2561 res.aio_return, res.aio_errno);
2562 }
2563 return 0;
2564}
2565
2566#endif /* HAVE_SYS_ASYNCH_H */
Roland McGrath186c5ac2002-12-15 23:58:23 +00002567
Roland McGratha4d48532005-06-08 20:45:28 +00002568static const struct xlat xattrflags[] = {
Roland McGrath561c7992003-04-02 01:10:44 +00002569#ifdef XATTR_CREATE
Roland McGrath186c5ac2002-12-15 23:58:23 +00002570 { XATTR_CREATE, "XATTR_CREATE" },
2571 { XATTR_REPLACE, "XATTR_REPLACE" },
Roland McGrath561c7992003-04-02 01:10:44 +00002572#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +00002573 { 0, NULL }
2574};
2575
Roland McGrath3292e222004-08-31 06:30:48 +00002576static void
2577print_xattr_val(tcp, failed, arg, insize, size)
2578struct tcb *tcp;
2579int failed;
2580unsigned long arg;
Roland McGrathaa524c82005-06-01 19:22:06 +00002581unsigned long insize, size;
Roland McGrath3292e222004-08-31 06:30:48 +00002582{
Roland McGrath883567c2005-02-02 03:38:32 +00002583 if (!failed) {
Roland McGrathaa524c82005-06-01 19:22:06 +00002584 unsigned long capacity = 4 * size + 1;
2585 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
Roland McGrath883567c2005-02-02 03:38:32 +00002586 if (buf == NULL || /* probably a bogus size argument */
Roland McGrathf7746422005-03-01 23:02:32 +00002587 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
Roland McGrath883567c2005-02-02 03:38:32 +00002588 failed = 1;
2589 }
2590 else {
2591 unsigned char *out = buf;
2592 unsigned char *in = &buf[3 * size];
2593 size_t i;
2594 for (i = 0; i < size; ++i)
2595 if (isprint(in[i]))
2596 *out++ = in[i];
2597 else {
Roland McGrath3292e222004-08-31 06:30:48 +00002598#define tohex(n) "0123456789abcdef"[n]
Roland McGrath883567c2005-02-02 03:38:32 +00002599 *out++ = '\\';
2600 *out++ = 'x';
2601 *out++ = tohex(in[i] / 16);
2602 *out++ = tohex(in[i] % 16);
2603 }
2604 /* Don't print terminating NUL if there is one. */
Dmitry V. Levin504eb0b2006-10-11 22:58:31 +00002605 if (i > 0 && in[i - 1] == '\0')
Roland McGrath883567c2005-02-02 03:38:32 +00002606 out -= 4;
2607 *out = '\0';
2608 tprintf(", \"%s\", %ld", buf, insize);
2609 }
2610 free(buf);
2611 }
2612 if (failed)
2613 tprintf(", 0x%lx, %ld", arg, insize);
Roland McGrath3292e222004-08-31 06:30:48 +00002614}
2615
Roland McGrath186c5ac2002-12-15 23:58:23 +00002616int
2617sys_setxattr(tcp)
2618struct tcb *tcp;
2619{
2620 if (entering(tcp)) {
2621 printpath(tcp, tcp->u_arg[0]);
2622 tprintf(", ");
2623 printstr(tcp, tcp->u_arg[1], -1);
Roland McGrath3292e222004-08-31 06:30:48 +00002624 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2625 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00002626 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
Roland McGrath186c5ac2002-12-15 23:58:23 +00002627 }
2628 return 0;
2629}
2630
2631int
2632sys_fsetxattr(tcp)
2633struct tcb *tcp;
2634{
2635 if (entering(tcp)) {
2636 tprintf("%ld, ", tcp->u_arg[0]);
2637 printstr(tcp, tcp->u_arg[1], -1);
Roland McGrath3292e222004-08-31 06:30:48 +00002638 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2639 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00002640 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
Roland McGrath186c5ac2002-12-15 23:58:23 +00002641 }
2642 return 0;
2643}
2644
2645int
2646sys_getxattr(tcp)
2647struct tcb *tcp;
2648{
2649 if (entering(tcp)) {
2650 printpath(tcp, tcp->u_arg[0]);
2651 tprintf(", ");
2652 printstr(tcp, tcp->u_arg[1], -1);
2653 } else {
Roland McGrath3292e222004-08-31 06:30:48 +00002654 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2655 tcp->u_rval);
Roland McGrath186c5ac2002-12-15 23:58:23 +00002656 }
2657 return 0;
2658}
2659
2660int
2661sys_fgetxattr(tcp)
2662struct tcb *tcp;
2663{
2664 if (entering(tcp)) {
2665 tprintf("%ld, ", tcp->u_arg[0]);
2666 printstr(tcp, tcp->u_arg[1], -1);
2667 } else {
Roland McGrath3292e222004-08-31 06:30:48 +00002668 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2669 tcp->u_rval);
Roland McGrath186c5ac2002-12-15 23:58:23 +00002670 }
2671 return 0;
2672}
2673
2674int
2675sys_listxattr(tcp)
2676struct tcb *tcp;
2677{
2678 if (entering(tcp)) {
2679 printpath(tcp, tcp->u_arg[0]);
2680 } else {
2681 /* XXX Print value in format */
2682 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2683 }
2684 return 0;
2685}
2686
2687int
2688sys_flistxattr(tcp)
2689struct tcb *tcp;
2690{
2691 if (entering(tcp)) {
2692 tprintf("%ld", tcp->u_arg[0]);
2693 } else {
2694 /* XXX Print value in format */
2695 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2696 }
2697 return 0;
2698}
2699
2700int
2701sys_removexattr(tcp)
2702struct tcb *tcp;
2703{
2704 if (entering(tcp)) {
2705 printpath(tcp, tcp->u_arg[0]);
2706 tprintf(", ");
2707 printstr(tcp, tcp->u_arg[1], -1);
2708 }
2709 return 0;
2710}
2711
2712int
2713sys_fremovexattr(tcp)
2714struct tcb *tcp;
2715{
2716 if (entering(tcp)) {
2717 tprintf("%ld, ", tcp->u_arg[0]);
2718 printstr(tcp, tcp->u_arg[1], -1);
2719 }
2720 return 0;
2721}
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002722
2723
2724static const struct xlat advise[] = {
2725 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2726 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2727 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2728 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2729 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2730 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2731 { 0, NULL }
2732};
2733
2734
Roland McGrathe27ed342004-10-20 02:24:19 +00002735#ifdef LINUX
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002736int
2737sys_fadvise64(tcp)
2738struct tcb *tcp;
2739{
2740 if (entering(tcp)) {
2741 tprintf("%ld, %lld, %ld, ",
2742 tcp->u_arg[0],
2743# if defined IA64 || defined X86_64 || defined ALPHA
2744 (long long int) tcp->u_arg[1], tcp->u_arg[2]);
2745 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2746#else
Roland McGrath2fe2a3e2004-10-07 19:09:16 +00002747 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]);
2748 printxval(advise, tcp->u_arg[4], "POSIX_FADV_???");
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002749#endif
2750 }
2751 return 0;
2752}
2753#endif
2754
2755
2756int
2757sys_fadvise64_64(tcp)
2758struct tcb *tcp;
2759{
2760 if (entering(tcp)) {
2761 tprintf("%ld, %lld, %lld, ",
2762 tcp->u_arg[0],
2763# if defined IA64 || defined X86_64 || defined ALPHA
2764 (long long int) tcp->u_arg[1], (long long int) tcp->u_arg[2]);
2765 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2766#else
Roland McGrath2fe2a3e2004-10-07 19:09:16 +00002767 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]),
2768 LONG_LONG(tcp->u_arg[3], tcp->u_arg[4]));
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002769 printxval(advise, tcp->u_arg[5], "POSIX_FADV_???");
2770#endif
2771 }
2772 return 0;
2773}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002774
2775#ifdef LINUX
2776static const struct xlat inotify_modes[] = {
2777 { 0x00000001, "IN_ACCESS" },
2778 { 0x00000002, "IN_MODIFY" },
2779 { 0x00000004, "IN_ATTRIB" },
2780 { 0x00000008, "IN_CLOSE_WRITE" },
2781 { 0x00000010, "IN_CLOSE_NOWRITE" },
2782 { 0x00000020, "IN_OPEN" },
2783 { 0x00000040, "IN_MOVED_FROM" },
2784 { 0x00000080, "IN_MOVED_TO" },
2785 { 0x00000100, "IN_CREATE" },
2786 { 0x00000200, "IN_DELETE" },
2787 { 0x00000400, "IN_DELETE_SELF" },
2788 { 0x00000800, "IN_MOVE_SELF" },
2789 { 0x00002000, "IN_UNMOUNT" },
2790 { 0x00004000, "IN_Q_OVERFLOW" },
2791 { 0x00008000, "IN_IGNORED" },
2792 { 0x01000000, "IN_ONLYDIR" },
2793 { 0x02000000, "IN_DONT_FOLLOW" },
2794 { 0x20000000, "IN_MASK_ADD" },
2795 { 0x40000000, "IN_ISDIR" },
2796 { 0x80000000, "IN_ONESHOT" }
2797};
2798
2799int
2800sys_inotify_add_watch(struct tcb *tcp)
2801{
2802 if (entering(tcp)) {
2803 tprintf("%ld, ", tcp->u_arg[0]);
2804 printpath(tcp, tcp->u_arg[1]);
2805 tprintf(", ");
2806 printflags(inotify_modes, tcp->u_arg[2], "IN_???");
2807 }
2808 return 0;
2809}
2810
2811int
2812sys_inotify_rm_watch(struct tcb *tcp)
2813{
2814 if (entering(tcp)) {
2815 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
2816 }
2817 return 0;
2818}
2819#endif