blob: 837bfed6c2d04d55242f86406817a90b5bf7aef8 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00006 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000029 */
30
31#include "defs.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000032#include <dirent.h>
Dmitry V. Levin88293652012-03-09 21:02:19 +000033#include <sys/swap.h>
Roland McGrathc531e572008-08-01 01:13:10 +000034
Denys Vlasenko9472a272013-02-12 11:43:46 +010035#if defined(SPARC) || defined(SPARC64)
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000036struct stat {
37 unsigned short st_dev;
38 unsigned int st_ino;
39 unsigned short st_mode;
40 short st_nlink;
41 unsigned short st_uid;
42 unsigned short st_gid;
43 unsigned short st_rdev;
44 unsigned int st_size;
45 int st_atime;
46 unsigned int __unused1;
47 int st_mtime;
48 unsigned int __unused2;
49 int st_ctime;
50 unsigned int __unused3;
51 int st_blksize;
52 int st_blocks;
53 unsigned int __unused4[2];
54};
Denys Vlasenko84703742012-02-25 02:38:52 +010055# if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +000056struct stat_sparc64 {
57 unsigned int st_dev;
58 unsigned long st_ino;
59 unsigned int st_mode;
60 unsigned int st_nlink;
61 unsigned int st_uid;
62 unsigned int st_gid;
63 unsigned int st_rdev;
64 long st_size;
65 long st_atime;
66 long st_mtime;
67 long st_ctime;
68 long st_blksize;
69 long st_blocks;
70 unsigned long __unused4[2];
71};
Denys Vlasenko84703742012-02-25 02:38:52 +010072# endif /* SPARC64 */
73# define stat kernel_stat
74# include <asm/stat.h>
75# undef stat
H.J. Lu35be5812012-04-16 13:00:01 +020076#elif defined(X32)
77struct stat {
78 unsigned long long st_dev;
79 unsigned long long st_ino;
80 unsigned long long st_nlink;
81
82 unsigned int st_mode;
83 unsigned int st_uid;
84 unsigned int st_gid;
85 unsigned int __pad0;
86 unsigned long long st_rdev;
87 long long st_size;
88 long long st_blksize;
89 long long st_blocks;
90
91 unsigned long long st_atime;
92 unsigned long long st_atime_nsec;
93 unsigned long long st_mtime;
94 unsigned long long st_mtime_nsec;
95 unsigned long long st_ctime;
96 unsigned long long st_ctime_nsec;
97 long long __unused[3];
98};
H.J. Lu085e4282012-04-17 11:05:04 -070099
100struct stat64 {
101 unsigned long long st_dev;
102 unsigned char __pad0[4];
103 unsigned long __st_ino;
104 unsigned int st_mode;
105 unsigned int st_nlink;
106 unsigned long st_uid;
107 unsigned long st_gid;
108 unsigned long long st_rdev;
109 unsigned char __pad3[4];
110 long long st_size;
111 unsigned long st_blksize;
112 unsigned long long st_blocks;
113 unsigned long st_atime;
114 unsigned long st_atime_nsec;
115 unsigned long st_mtime;
116 unsigned int st_mtime_nsec;
117 unsigned long st_ctime;
118 unsigned long st_ctime_nsec;
119 unsigned long long st_ino;
120};
Dmitry V. Levinbd2e28a2013-05-01 15:14:25 +0000121
122struct __old_kernel_stat {
123 unsigned short st_dev;
124 unsigned short st_ino;
125 unsigned short st_mode;
126 unsigned short st_nlink;
127 unsigned short st_uid;
128 unsigned short st_gid;
129 unsigned short st_rdev;
130 unsigned int st_size;
131 unsigned int st_atime;
132 unsigned int st_mtime;
133 unsigned int st_ctime;
134};
Denys Vlasenko84703742012-02-25 02:38:52 +0100135#else
136# undef dev_t
137# undef ino_t
138# undef mode_t
139# undef nlink_t
140# undef uid_t
141# undef gid_t
142# undef off_t
143# undef loff_t
Denys Vlasenko84703742012-02-25 02:38:52 +0100144# define dev_t __kernel_dev_t
145# define ino_t __kernel_ino_t
146# define mode_t __kernel_mode_t
147# define nlink_t __kernel_nlink_t
148# define uid_t __kernel_uid_t
149# define gid_t __kernel_gid_t
150# define off_t __kernel_off_t
151# define loff_t __kernel_loff_t
Wichert Akkermana6013701999-07-08 14:00:58 +0000152
Denys Vlasenko84703742012-02-25 02:38:52 +0100153# include <asm/stat.h>
Wichert Akkermana6013701999-07-08 14:00:58 +0000154
Denys Vlasenko84703742012-02-25 02:38:52 +0100155# undef dev_t
156# undef ino_t
157# undef mode_t
158# undef nlink_t
159# undef uid_t
160# undef gid_t
161# undef off_t
162# undef loff_t
Denys Vlasenko84703742012-02-25 02:38:52 +0100163# define dev_t dev_t
164# define ino_t ino_t
165# define mode_t mode_t
166# define nlink_t nlink_t
167# define uid_t uid_t
168# define gid_t gid_t
169# define off_t off_t
170# define loff_t loff_t
171#endif
172
173#ifdef HPPA /* asm-parisc/stat.h defines stat64 */
174# undef stat64
175#endif
176#define stat libc_stat
177#define stat64 libc_stat64
178#include <sys/stat.h>
179#undef stat
180#undef stat64
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100181/* These might be macros. */
Denys Vlasenko84703742012-02-25 02:38:52 +0100182#undef st_atime
183#undef st_mtime
184#undef st_ctime
185#ifdef HPPA
186# define stat64 hpux_stat64
187#endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000188
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000189#include <fcntl.h>
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000190#ifdef HAVE_SYS_VFS_H
Denys Vlasenko84703742012-02-25 02:38:52 +0100191# include <sys/vfs.h>
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000192#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +0000193#ifdef HAVE_LINUX_XATTR_H
Denys Vlasenko84703742012-02-25 02:38:52 +0100194# include <linux/xattr.h>
Denys Vlasenkoed720fd2012-02-25 02:24:03 +0100195#else
Denys Vlasenko84703742012-02-25 02:38:52 +0100196# define XATTR_CREATE 1
197# define XATTR_REPLACE 2
Roland McGrath186c5ac2002-12-15 23:58:23 +0000198#endif
199
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000200#ifdef MAJOR_IN_SYSMACROS
Denys Vlasenko84703742012-02-25 02:38:52 +0100201# include <sys/sysmacros.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000202#endif
203
204#ifdef MAJOR_IN_MKDEV
Denys Vlasenko84703742012-02-25 02:38:52 +0100205# include <sys/mkdev.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000206#endif
207
208#ifdef HAVE_SYS_ASYNCH_H
Denys Vlasenko84703742012-02-25 02:38:52 +0100209# include <sys/asynch.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000210#endif
211
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100212struct kernel_dirent {
213 unsigned long d_ino;
214 unsigned long d_off;
215 unsigned short d_reclen;
216 char d_name[1];
217};
218
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000219const struct xlat open_access_modes[] = {
220 { O_RDONLY, "O_RDONLY" },
221 { O_WRONLY, "O_WRONLY" },
222 { O_RDWR, "O_RDWR" },
223#ifdef O_ACCMODE
224 { O_ACCMODE, "O_ACCMODE" },
225#endif
226 { 0, NULL },
227};
228
229const struct xlat open_mode_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000230 { O_CREAT, "O_CREAT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000231 { O_EXCL, "O_EXCL" },
232 { O_NOCTTY, "O_NOCTTY" },
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000233 { O_TRUNC, "O_TRUNC" },
234 { O_APPEND, "O_APPEND" },
235 { O_NONBLOCK, "O_NONBLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000236#ifdef O_SYNC
237 { O_SYNC, "O_SYNC" },
238#endif
239#ifdef O_ASYNC
240 { O_ASYNC, "O_ASYNC" },
241#endif
242#ifdef O_DSYNC
243 { O_DSYNC, "O_DSYNC" },
244#endif
245#ifdef O_RSYNC
246 { O_RSYNC, "O_RSYNC" },
247#endif
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000248#if defined(O_NDELAY) && (O_NDELAY != O_NONBLOCK)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000249 { O_NDELAY, "O_NDELAY" },
250#endif
251#ifdef O_PRIV
252 { O_PRIV, "O_PRIV" },
253#endif
254#ifdef O_DIRECT
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000255 { O_DIRECT, "O_DIRECT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000256#endif
257#ifdef O_LARGEFILE
Roland McGrathfee836e2005-02-02 22:11:32 +0000258# if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
259# undef O_LARGEFILE
260# ifdef SPARC64
261# define O_LARGEFILE 0x40000
262# elif defined X86_64 || defined S390X
263# define O_LARGEFILE 0100000
264# endif
265# endif
Roland McGrath663a8a02005-02-04 09:49:56 +0000266# ifdef O_LARGEFILE
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200267 { O_LARGEFILE, "O_LARGEFILE" },
Roland McGrath663a8a02005-02-04 09:49:56 +0000268# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000269#endif
270#ifdef O_DIRECTORY
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200271 { O_DIRECTORY, "O_DIRECTORY" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000272#endif
273#ifdef O_NOFOLLOW
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200274 { O_NOFOLLOW, "O_NOFOLLOW" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000275#endif
Roland McGrath1025c3e2005-05-09 07:40:35 +0000276#ifdef O_NOATIME
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200277 { O_NOATIME, "O_NOATIME" },
Roland McGrath1025c3e2005-05-09 07:40:35 +0000278#endif
Roland McGrath71d3d662007-08-07 01:00:26 +0000279#ifdef O_CLOEXEC
280 { O_CLOEXEC, "O_CLOEXEC" },
281#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000282#ifdef FNDELAY
283 { FNDELAY, "FNDELAY" },
284#endif
285#ifdef FAPPEND
286 { FAPPEND, "FAPPEND" },
287#endif
288#ifdef FMARK
289 { FMARK, "FMARK" },
290#endif
291#ifdef FDEFER
292 { FDEFER, "FDEFER" },
293#endif
294#ifdef FASYNC
295 { FASYNC, "FASYNC" },
296#endif
297#ifdef FSHLOCK
298 { FSHLOCK, "FSHLOCK" },
299#endif
300#ifdef FEXLOCK
301 { FEXLOCK, "FEXLOCK" },
302#endif
303#ifdef FCREAT
304 { FCREAT, "FCREAT" },
305#endif
306#ifdef FTRUNC
307 { FTRUNC, "FTRUNC" },
308#endif
309#ifdef FEXCL
310 { FEXCL, "FEXCL" },
311#endif
312#ifdef FNBIO
313 { FNBIO, "FNBIO" },
314#endif
315#ifdef FSYNC
316 { FSYNC, "FSYNC" },
317#endif
318#ifdef FNOCTTY
319 { FNOCTTY, "FNOCTTY" },
Roland McGrath186c5ac2002-12-15 23:58:23 +0000320#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000321#ifdef O_SHLOCK
322 { O_SHLOCK, "O_SHLOCK" },
323#endif
324#ifdef O_EXLOCK
325 { O_EXLOCK, "O_EXLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000326#endif
327 { 0, NULL },
328};
329
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000330#ifndef AT_FDCWD
331# define AT_FDCWD -100
332#endif
333
Denys Vlasenkoe740fd32009-04-16 12:06:16 +0000334/* The fd is an "int", so when decoding x86 on x86_64, we need to force sign
335 * extension to get the right value. We do this by declaring fd as int here.
336 */
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000337static void
Dmitry V. Levin31382132011-03-04 05:08:02 +0300338print_dirfd(struct tcb *tcp, int fd)
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000339{
340 if (fd == AT_FDCWD)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200341 tprints("AT_FDCWD, ");
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200342 else {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300343 printfd(tcp, fd);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200344 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +0300345 }
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000346}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000347
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000348/*
349 * low bits of the open(2) flags define access mode,
350 * other bits are real flags.
351 */
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000352const char *
353sprint_open_modes(mode_t flags)
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000354{
Denys Vlasenko4f3df072012-01-29 22:38:35 +0100355 static char outstr[(1 + ARRAY_SIZE(open_mode_flags)) * sizeof("O_LARGEFILE")];
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000356 char *p;
Denys Vlasenko4f3df072012-01-29 22:38:35 +0100357 char sep;
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000358 const char *str;
359 const struct xlat *x;
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000360
Denys Vlasenko4f3df072012-01-29 22:38:35 +0100361 sep = ' ';
362 p = stpcpy(outstr, "flags");
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000363 str = xlookup(open_access_modes, flags & 3);
364 if (str) {
Denys Vlasenko4f3df072012-01-29 22:38:35 +0100365 *p++ = sep;
Denys Vlasenko52845572011-08-31 12:07:38 +0200366 p = stpcpy(p, str);
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000367 flags &= ~3;
368 if (!flags)
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000369 return outstr;
370 sep = '|';
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000371 }
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000372
373 for (x = open_mode_flags; x->str; x++) {
374 if ((flags & x->val) == x->val) {
Denys Vlasenko4f3df072012-01-29 22:38:35 +0100375 *p++ = sep;
Denys Vlasenko52845572011-08-31 12:07:38 +0200376 p = stpcpy(p, x->str);
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000377 flags &= ~x->val;
378 if (!flags)
379 return outstr;
380 sep = '|';
381 }
382 }
383 /* flags is still nonzero */
Denys Vlasenko4f3df072012-01-29 22:38:35 +0100384 *p++ = sep;
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000385 sprintf(p, "%#x", flags);
386 return outstr;
387}
388
389void
390tprint_open_modes(mode_t flags)
391{
Denys Vlasenko5940e652011-09-01 09:55:05 +0200392 tprints(sprint_open_modes(flags) + sizeof("flags"));
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000393}
394
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000395static int
396decode_open(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000397{
398 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000399 printpath(tcp, tcp->u_arg[offset]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200400 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000401 /* flags */
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000402 tprint_open_modes(tcp->u_arg[offset + 1]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000403 if (tcp->u_arg[offset + 1] & O_CREAT) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000404 /* mode */
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000405 tprintf(", %#lo", tcp->u_arg[offset + 2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000406 }
407 }
408 return 0;
409}
410
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000411int
412sys_open(struct tcb *tcp)
413{
414 return decode_open(tcp, 0);
415}
416
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000417int
418sys_openat(struct tcb *tcp)
419{
420 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +0300421 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000422 return decode_open(tcp, 1);
423}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000424
Denys Vlasenko9472a272013-02-12 11:43:46 +0100425#if defined(SPARC) || defined(SPARC64)
Roland McGratha4d48532005-06-08 20:45:28 +0000426static const struct xlat openmodessol[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000427 { 0, "O_RDWR" },
428 { 1, "O_RDONLY" },
429 { 2, "O_WRONLY" },
430 { 0x80, "O_NONBLOCK" },
431 { 8, "O_APPEND" },
432 { 0x100, "O_CREAT" },
433 { 0x200, "O_TRUNC" },
434 { 0x400, "O_EXCL" },
435 { 0x800, "O_NOCTTY" },
436 { 0x10, "O_SYNC" },
437 { 0x40, "O_DSYNC" },
438 { 0x8000, "O_RSYNC" },
439 { 4, "O_NDELAY" },
440 { 0x1000, "O_PRIV" },
441 { 0, NULL },
442};
443
444int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000445solaris_open(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000446{
447 if (entering(tcp)) {
448 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200449 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000450 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000451 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000452 if (tcp->u_arg[1] & 0x100) {
453 /* mode */
454 tprintf(", %#lo", tcp->u_arg[2]);
455 }
456 }
457 return 0;
458}
459
460#endif
461
462int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000463sys_creat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000464{
465 if (entering(tcp)) {
466 printpath(tcp, tcp->u_arg[0]);
467 tprintf(", %#lo", tcp->u_arg[1]);
468 }
469 return 0;
470}
471
Roland McGrathd9f816f2004-09-04 03:39:20 +0000472static const struct xlat access_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000473 { F_OK, "F_OK", },
474 { R_OK, "R_OK" },
475 { W_OK, "W_OK" },
476 { X_OK, "X_OK" },
477#ifdef EFF_ONLY_OK
478 { EFF_ONLY_OK, "EFF_ONLY_OK" },
479#endif
480#ifdef EX_OK
481 { EX_OK, "EX_OK" },
482#endif
483 { 0, NULL },
484};
485
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000486static int
487decode_access(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000488{
489 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000490 printpath(tcp, tcp->u_arg[offset]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200491 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000492 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000493 }
494 return 0;
495}
496
497int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000498sys_access(struct tcb *tcp)
499{
500 return decode_access(tcp, 0);
501}
502
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000503int
504sys_faccessat(struct tcb *tcp)
505{
506 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +0300507 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000508 return decode_access(tcp, 1);
509}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000510
511int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000512sys_umask(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000513{
514 if (entering(tcp)) {
515 tprintf("%#lo", tcp->u_arg[0]);
516 }
517 return RVAL_OCTAL;
518}
519
Denys Vlasenko86738a22013-02-17 14:31:55 +0100520const struct xlat whence_codes[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000521 { SEEK_SET, "SEEK_SET" },
522 { SEEK_CUR, "SEEK_CUR" },
523 { SEEK_END, "SEEK_END" },
Denys Vlasenko86738a22013-02-17 14:31:55 +0100524#ifdef SEEK_DATA
525 { SEEK_DATA, "SEEK_DATA" },
526#endif
527#ifdef SEEK_HOLE
528 { SEEK_HOLE, "SEEK_HOLE" },
529#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000530 { 0, NULL },
531};
532
Denys Vlasenko386b8712013-02-17 01:38:14 +0100533/* Linux kernel has exactly one version of lseek:
534 * fs/read_write.c::SYSCALL_DEFINE3(lseek, unsigned, fd, off_t, offset, unsigned, origin)
535 * In kernel, off_t is always the same as (kernel's) long
536 * (see include/uapi/asm-generic/posix_types.h),
537 * which means that on x32 we need to use tcp->ext_arg[N] to get offset argument.
Denys Vlasenko09a87ae2013-02-17 13:17:49 +0100538 * Use test/x32_lseek.c to test lseek decoding.
Denys Vlasenko386b8712013-02-17 01:38:14 +0100539 */
H.J. Luc933f272012-04-16 17:41:13 +0200540#if defined(LINUX_MIPSN32) || defined(X32)
Roland McGrath542c2c62008-05-20 01:11:56 +0000541int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000542sys_lseek(struct tcb *tcp)
Roland McGrath542c2c62008-05-20 01:11:56 +0000543{
544 long long offset;
Denys Vlasenko386b8712013-02-17 01:38:14 +0100545 int whence;
Roland McGrath542c2c62008-05-20 01:11:56 +0000546
547 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300548 printfd(tcp, tcp->u_arg[0]);
Roland McGrath542c2c62008-05-20 01:11:56 +0000549 offset = tcp->ext_arg[1];
Denys Vlasenko386b8712013-02-17 01:38:14 +0100550 whence = tcp->u_arg[2];
551 if (whence == SEEK_SET)
552 tprintf(", %llu, ", offset);
Roland McGrath542c2c62008-05-20 01:11:56 +0000553 else
Denys Vlasenko386b8712013-02-17 01:38:14 +0100554 tprintf(", %lld, ", offset);
Denys Vlasenko782d90f2013-02-17 12:47:44 +0100555 printxval(whence_codes, whence, "SEEK_???");
Roland McGrath542c2c62008-05-20 01:11:56 +0000556 }
H.J. Ludd0130b2012-04-16 12:16:45 +0200557 return RVAL_LUDECIMAL;
Roland McGrath542c2c62008-05-20 01:11:56 +0000558}
H.J. Ludd0130b2012-04-16 12:16:45 +0200559#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000560int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000561sys_lseek(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000562{
Denys Vlasenko06121762013-02-17 20:08:50 +0100563 long offset;
Denys Vlasenko386b8712013-02-17 01:38:14 +0100564 int whence;
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000565
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000566 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300567 printfd(tcp, tcp->u_arg[0]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000568 offset = tcp->u_arg[1];
Denys Vlasenko386b8712013-02-17 01:38:14 +0100569 whence = tcp->u_arg[2];
570 if (whence == SEEK_SET)
571 tprintf(", %lu, ", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000572 else
Denys Vlasenko386b8712013-02-17 01:38:14 +0100573 tprintf(", %ld, ", offset);
Denys Vlasenko782d90f2013-02-17 12:47:44 +0100574 printxval(whence_codes, whence, "SEEK_???");
Roland McGrath186c5ac2002-12-15 23:58:23 +0000575 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000576 return RVAL_UDECIMAL;
577}
John Hughes5a826b82001-03-07 13:21:24 +0000578#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000579
Denys Vlasenko386b8712013-02-17 01:38:14 +0100580/* llseek syscall takes explicitly two ulong arguments hi, lo,
581 * rather than one 64-bit argument for which LONG_LONG works
582 * appropriate for the native byte order.
583 *
584 * See kernel's fs/read_write.c::SYSCALL_DEFINE5(llseek, ...)
585 *
586 * hi,lo are "unsigned longs" and combined exactly this way in kernel:
587 * ((loff_t) hi << 32) | lo
Denys Vlasenko09a87ae2013-02-17 13:17:49 +0100588 * Note that for architectures with kernel's long wider than userspace long
Denys Vlasenko386b8712013-02-17 01:38:14 +0100589 * (such as x32), combining code will use *kernel's*, i.e. *wide* longs
Denys Vlasenko06121762013-02-17 20:08:50 +0100590 * for hi and lo. We would need to use tcp->ext_arg[N] on x32...
591 * ...however, x32 (and x86_64) does not _have_ llseek syscall as such.
Denys Vlasenko386b8712013-02-17 01:38:14 +0100592 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000593int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000594sys_llseek(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000595{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000596 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300597 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000598 if (tcp->u_arg[4] == SEEK_SET)
Dmitry V. Levin31382132011-03-04 05:08:02 +0300599 tprintf(", %llu, ",
Denys Vlasenko386b8712013-02-17 01:38:14 +0100600 ((long long) tcp->u_arg[1]) << 32 |
Dmitry V. Levin31382132011-03-04 05:08:02 +0300601 (unsigned long long) (unsigned) tcp->u_arg[2]);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000602 else
Dmitry V. Levin31382132011-03-04 05:08:02 +0300603 tprintf(", %lld, ",
Denys Vlasenko386b8712013-02-17 01:38:14 +0100604 ((long long) tcp->u_arg[1]) << 32 |
Dmitry V. Levin31382132011-03-04 05:08:02 +0300605 (unsigned long long) (unsigned) tcp->u_arg[2]);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000606 }
607 else {
Denys Vlasenko386b8712013-02-17 01:38:14 +0100608 long long off;
Denys Vlasenko1d632462009-04-14 12:51:00 +0000609 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
610 tprintf("%#lx, ", tcp->u_arg[3]);
611 else
612 tprintf("[%llu], ", off);
Denys Vlasenko782d90f2013-02-17 12:47:44 +0100613 printxval(whence_codes, tcp->u_arg[4], "SEEK_???");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000614 }
615 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000616}
Roland McGrath186c5ac2002-12-15 23:58:23 +0000617
618int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000619sys_readahead(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +0000620{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000621 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100622 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +0300623 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenkod33e72a2012-05-18 02:03:24 +0200624 argn = printllval(tcp, ", %lld", 1);
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100625 tprintf(", %ld", tcp->u_arg[argn]);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000626 }
627 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +0000628}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000629
630int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000631sys_truncate(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000632{
633 if (entering(tcp)) {
634 printpath(tcp, tcp->u_arg[0]);
635 tprintf(", %lu", tcp->u_arg[1]);
636 }
637 return 0;
638}
639
Denys Vlasenko8435d672013-02-18 15:47:57 +0100640#if _LFS64_LARGEFILE
John Hughes96f51472001-03-06 16:50:41 +0000641int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000642sys_truncate64(struct tcb *tcp)
John Hughes96f51472001-03-06 16:50:41 +0000643{
644 if (entering(tcp)) {
645 printpath(tcp, tcp->u_arg[0]);
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100646 printllval(tcp, ", %llu", 1);
John Hughes96f51472001-03-06 16:50:41 +0000647 }
648 return 0;
649}
650#endif
651
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000652int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000653sys_ftruncate(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000654{
655 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300656 printfd(tcp, tcp->u_arg[0]);
657 tprintf(", %lu", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000658 }
659 return 0;
660}
661
Denys Vlasenko8435d672013-02-18 15:47:57 +0100662#if _LFS64_LARGEFILE
John Hughes96f51472001-03-06 16:50:41 +0000663int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000664sys_ftruncate64(struct tcb *tcp)
John Hughes96f51472001-03-06 16:50:41 +0000665{
666 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300667 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenkod33e72a2012-05-18 02:03:24 +0200668 printllval(tcp, ", %llu", 1);
John Hughes96f51472001-03-06 16:50:41 +0000669 }
670 return 0;
671}
672#endif
673
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000674/* several stats */
675
Roland McGrathd9f816f2004-09-04 03:39:20 +0000676static const struct xlat modetypes[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000677 { S_IFREG, "S_IFREG" },
678 { S_IFSOCK, "S_IFSOCK" },
679 { S_IFIFO, "S_IFIFO" },
680 { S_IFLNK, "S_IFLNK" },
681 { S_IFDIR, "S_IFDIR" },
682 { S_IFBLK, "S_IFBLK" },
683 { S_IFCHR, "S_IFCHR" },
684 { 0, NULL },
685};
686
Roland McGrathf9c49b22004-10-06 22:11:54 +0000687static const char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000688sprintmode(int mode)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000689{
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100690 static char buf[sizeof("S_IFSOCK|S_ISUID|S_ISGID|S_ISVTX|%o")
691 + sizeof(int)*3
692 + /*paranoia:*/ 8];
Roland McGrathf9c49b22004-10-06 22:11:54 +0000693 const char *s;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000694
695 if ((mode & S_IFMT) == 0)
696 s = "";
697 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
698 sprintf(buf, "%#o", mode);
699 return buf;
700 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100701 s = buf + sprintf(buf, "%s%s%s%s", s,
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000702 (mode & S_ISUID) ? "|S_ISUID" : "",
703 (mode & S_ISGID) ? "|S_ISGID" : "",
704 (mode & S_ISVTX) ? "|S_ISVTX" : "");
705 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
706 if (mode)
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100707 sprintf((char*)s, "|%#o", mode);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000708 s = (*buf == '|') ? buf + 1 : buf;
709 return *s ? s : "0";
710}
711
712static char *
Dmitry V. Levindc7715b2008-04-19 23:45:09 +0000713sprinttime(time_t t)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000714{
715 struct tm *tmp;
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100716 static char buf[sizeof("yyyy/mm/dd-hh:mm:ss")];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000717
718 if (t == 0) {
Dmitry V. Levindc7715b2008-04-19 23:45:09 +0000719 strcpy(buf, "0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000720 return buf;
721 }
Denys Vlasenko5d645812011-08-20 12:48:18 +0200722 tmp = localtime(&t);
723 if (tmp)
Dmitry V. Levindc7715b2008-04-19 23:45:09 +0000724 snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d",
725 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
726 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
727 else
728 snprintf(buf, sizeof buf, "%lu", (unsigned long) t);
729
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000730 return buf;
731}
732
Denys Vlasenko9472a272013-02-12 11:43:46 +0100733#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000734typedef struct {
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000735 int tv_sec;
736 int tv_nsec;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000737} timestruct_t;
738
739struct solstat {
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000740 unsigned st_dev;
741 int st_pad1[3]; /* network id */
742 unsigned st_ino;
743 unsigned st_mode;
744 unsigned st_nlink;
745 unsigned st_uid;
746 unsigned st_gid;
747 unsigned st_rdev;
748 int st_pad2[2];
749 int st_size;
750 int st_pad3; /* st_size, off_t expansion */
751 timestruct_t st_atime;
752 timestruct_t st_mtime;
753 timestruct_t st_ctime;
754 int st_blksize;
755 int st_blocks;
756 char st_fstype[16];
757 int st_pad4[8]; /* expansion area */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000758};
759
760static void
Dmitry V. Levinb838b1e2008-04-19 23:47:47 +0000761printstatsol(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000762{
763 struct solstat statbuf;
764
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000765 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200766 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000767 return;
768 }
769 if (!abbrev(tcp)) {
770 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
771 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
772 (unsigned long) (statbuf.st_dev & 0x3ffff),
773 (unsigned long) statbuf.st_ino,
774 sprintmode(statbuf.st_mode));
775 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
776 (unsigned long) statbuf.st_nlink,
777 (unsigned long) statbuf.st_uid,
778 (unsigned long) statbuf.st_gid);
779 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
780 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
781 }
782 else
783 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
784 switch (statbuf.st_mode & S_IFMT) {
785 case S_IFCHR: case S_IFBLK:
786 tprintf("st_rdev=makedev(%lu, %lu), ",
787 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
788 (unsigned long) (statbuf.st_rdev & 0x3ffff));
789 break;
790 default:
791 tprintf("st_size=%u, ", statbuf.st_size);
792 break;
793 }
794 if (!abbrev(tcp)) {
Dmitry V. Levinb838b1e2008-04-19 23:47:47 +0000795 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
796 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
797 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000798 }
799 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200800 tprints("...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000801}
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000802
Denys Vlasenko9472a272013-02-12 11:43:46 +0100803# if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000804static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000805printstat_sparc64(struct tcb *tcp, long addr)
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000806{
807 struct stat_sparc64 statbuf;
808
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000809 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200810 tprints("{...}");
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000811 return;
812 }
813
814 if (!abbrev(tcp)) {
815 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
816 (unsigned long) major(statbuf.st_dev),
817 (unsigned long) minor(statbuf.st_dev),
818 (unsigned long) statbuf.st_ino,
819 sprintmode(statbuf.st_mode));
820 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
821 (unsigned long) statbuf.st_nlink,
822 (unsigned long) statbuf.st_uid,
823 (unsigned long) statbuf.st_gid);
824 tprintf("st_blksize=%lu, ",
825 (unsigned long) statbuf.st_blksize);
826 tprintf("st_blocks=%lu, ",
827 (unsigned long) statbuf.st_blocks);
828 }
829 else
830 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
831 switch (statbuf.st_mode & S_IFMT) {
832 case S_IFCHR: case S_IFBLK:
833 tprintf("st_rdev=makedev(%lu, %lu), ",
834 (unsigned long) major(statbuf.st_rdev),
835 (unsigned long) minor(statbuf.st_rdev));
836 break;
837 default:
838 tprintf("st_size=%lu, ", statbuf.st_size);
839 break;
840 }
841 if (!abbrev(tcp)) {
842 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
843 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100844 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000845 }
846 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200847 tprints("...}");
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000848}
Denys Vlasenko9472a272013-02-12 11:43:46 +0100849# endif /* SPARC64 */
850#endif /* SPARC[64] */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000851
Denys Vlasenko84703742012-02-25 02:38:52 +0100852#if defined POWERPC64
Andreas Schwabd69fa492010-07-12 21:39:57 +0200853struct stat_powerpc32 {
854 unsigned int st_dev;
855 unsigned int st_ino;
856 unsigned int st_mode;
857 unsigned short st_nlink;
858 unsigned int st_uid;
859 unsigned int st_gid;
860 unsigned int st_rdev;
861 unsigned int st_size;
862 unsigned int st_blksize;
863 unsigned int st_blocks;
864 unsigned int st_atime;
865 unsigned int st_atime_nsec;
866 unsigned int st_mtime;
867 unsigned int st_mtime_nsec;
868 unsigned int st_ctime;
869 unsigned int st_ctime_nsec;
870 unsigned int __unused4;
871 unsigned int __unused5;
872};
873
874static void
875printstat_powerpc32(struct tcb *tcp, long addr)
876{
877 struct stat_powerpc32 statbuf;
878
879 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200880 tprints("{...}");
Andreas Schwabd69fa492010-07-12 21:39:57 +0200881 return;
882 }
883
884 if (!abbrev(tcp)) {
885 tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ",
886 major(statbuf.st_dev), minor(statbuf.st_dev),
887 statbuf.st_ino,
888 sprintmode(statbuf.st_mode));
889 tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ",
890 statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid);
891 tprintf("st_blksize=%u, ", statbuf.st_blksize);
892 tprintf("st_blocks=%u, ", statbuf.st_blocks);
893 }
894 else
895 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
896 switch (statbuf.st_mode & S_IFMT) {
897 case S_IFCHR: case S_IFBLK:
898 tprintf("st_rdev=makedev(%lu, %lu), ",
899 (unsigned long) major(statbuf.st_rdev),
900 (unsigned long) minor(statbuf.st_rdev));
901 break;
902 default:
903 tprintf("st_size=%u, ", statbuf.st_size);
904 break;
905 }
906 if (!abbrev(tcp)) {
907 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
908 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100909 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
Andreas Schwabd69fa492010-07-12 21:39:57 +0200910 }
911 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200912 tprints("...}");
Andreas Schwabd69fa492010-07-12 21:39:57 +0200913}
Denys Vlasenko84703742012-02-25 02:38:52 +0100914#endif /* POWERPC64 */
Andreas Schwabd69fa492010-07-12 21:39:57 +0200915
Roland McGratha4d48532005-06-08 20:45:28 +0000916static const struct xlat fileflags[] = {
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000917 { 0, NULL },
918};
919
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000920static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000921realprintstat(struct tcb *tcp, struct stat *statbuf)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000922{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000923 if (!abbrev(tcp)) {
924 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
925 (unsigned long) major(statbuf->st_dev),
926 (unsigned long) minor(statbuf->st_dev),
927 (unsigned long) statbuf->st_ino,
928 sprintmode(statbuf->st_mode));
929 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
930 (unsigned long) statbuf->st_nlink,
931 (unsigned long) statbuf->st_uid,
932 (unsigned long) statbuf->st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000933#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Denys Vlasenko1d632462009-04-14 12:51:00 +0000934 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
935#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000936#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Denys Vlasenko1d632462009-04-14 12:51:00 +0000937 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
938#endif
939 }
940 else
941 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
942 switch (statbuf->st_mode & S_IFMT) {
943 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +0000944#ifdef HAVE_STRUCT_STAT_ST_RDEV
Denys Vlasenko1d632462009-04-14 12:51:00 +0000945 tprintf("st_rdev=makedev(%lu, %lu), ",
946 (unsigned long) major(statbuf->st_rdev),
947 (unsigned long) minor(statbuf->st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000948#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000949 tprintf("st_size=makedev(%lu, %lu), ",
950 (unsigned long) major(statbuf->st_size),
951 (unsigned long) minor(statbuf->st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000952#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000953 break;
954 default:
Dmitry V. Levine9a06b72011-02-23 16:16:50 +0000955 tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000956 break;
957 }
958 if (!abbrev(tcp)) {
959 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
960 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
961 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000962#if HAVE_STRUCT_STAT_ST_FLAGS
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200963 tprints(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +0000964 printflags(fileflags, statbuf->st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +0000965#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000966#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +0000967 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
968#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000969#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +0000970 tprintf(", st_level=%ld", statbuf->st_level);
971#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000972#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +0000973 tprintf(", st_fstype=%.*s",
974 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
975#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000976#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +0000977 tprintf(", st_gen=%u", statbuf->st_gen);
978#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200979 tprints("}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000980 }
981 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200982 tprints("...}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000983}
984
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000985static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000986printstat(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000987{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000988 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000989
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000990 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200991 tprints("NULL");
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000992 return;
993 }
994 if (syserror(tcp) || !verbose(tcp)) {
995 tprintf("%#lx", addr);
996 return;
997 }
998
Denys Vlasenko9472a272013-02-12 11:43:46 +0100999#if defined(SPARC) || defined(SPARC64)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00001000 if (current_personality == 1) {
1001 printstatsol(tcp, addr);
1002 return;
1003 }
Roland McGrath6d1a65c2004-07-12 07:44:08 +00001004#ifdef SPARC64
1005 else if (current_personality == 2) {
1006 printstat_sparc64(tcp, addr);
1007 return;
1008 }
1009#endif
Denys Vlasenko9472a272013-02-12 11:43:46 +01001010#endif /* SPARC[64] */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001011
Denys Vlasenko84703742012-02-25 02:38:52 +01001012#if defined POWERPC64
Andreas Schwabd69fa492010-07-12 21:39:57 +02001013 if (current_personality == 1) {
1014 printstat_powerpc32(tcp, addr);
1015 return;
1016 }
1017#endif
1018
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001019 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001020 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001021 return;
1022 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001023
1024 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001025}
1026
Denys Vlasenko84703742012-02-25 02:38:52 +01001027#if !defined HAVE_STAT64 && defined X86_64
Roland McGrathe6d0f712007-08-07 01:22:49 +00001028/*
1029 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
1030 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
1031 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
1032 * __GNUC__ is needed for the required __attribute__ below.
1033 */
1034struct stat64 {
1035 unsigned long long st_dev;
1036 unsigned char __pad0[4];
1037 unsigned int __st_ino;
1038 unsigned int st_mode;
1039 unsigned int st_nlink;
1040 unsigned int st_uid;
1041 unsigned int st_gid;
1042 unsigned long long st_rdev;
1043 unsigned char __pad3[4];
1044 long long st_size;
1045 unsigned int st_blksize;
1046 unsigned long long st_blocks;
1047 unsigned int st_atime;
1048 unsigned int st_atime_nsec;
1049 unsigned int st_mtime;
1050 unsigned int st_mtime_nsec;
1051 unsigned int st_ctime;
1052 unsigned int st_ctime_nsec;
1053 unsigned long long st_ino;
1054} __attribute__((packed));
1055# define HAVE_STAT64 1
1056# define STAT64_SIZE 96
1057#endif
1058
Wichert Akkermanc7926982000-04-10 22:22:31 +00001059#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001060static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001061printstat64(struct tcb *tcp, long addr)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001062{
1063 struct stat64 statbuf;
1064
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001065#ifdef STAT64_SIZE
Roland McGrathe6d0f712007-08-07 01:22:49 +00001066 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
1067#endif
1068
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001069 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001070 tprints("NULL");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001071 return;
1072 }
1073 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001074 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001075 return;
1076 }
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001077
Denys Vlasenko9472a272013-02-12 11:43:46 +01001078#if defined(SPARC) || defined(SPARC64)
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001079 if (current_personality == 1) {
1080 printstatsol(tcp, addr);
1081 return;
1082 }
1083# ifdef SPARC64
1084 else if (current_personality == 2) {
1085 printstat_sparc64(tcp, addr);
1086 return;
1087 }
1088# endif
Denys Vlasenko9472a272013-02-12 11:43:46 +01001089#endif /* SPARC[64] */
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001090
Denys Vlasenko84703742012-02-25 02:38:52 +01001091#if defined X86_64
H.J. Lu35be5812012-04-16 13:00:01 +02001092 if (current_personality != 1) {
Andreas Schwab61b74352009-10-16 11:37:13 +02001093 printstat(tcp, addr);
1094 return;
1095 }
1096#endif
Dmitry V. Levinff896f72009-10-21 13:43:57 +00001097
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001098 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001099 tprints("{...}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001100 return;
1101 }
1102
1103 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +00001104#ifdef HAVE_LONG_LONG
1105 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1106#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001107 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
Wichert Akkermand077c452000-08-10 18:16:15 +00001108#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001109 (unsigned long) major(statbuf.st_dev),
1110 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +00001111#ifdef HAVE_LONG_LONG
1112 (unsigned long long) statbuf.st_ino,
1113#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001114 (unsigned long) statbuf.st_ino,
Wichert Akkermand077c452000-08-10 18:16:15 +00001115#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001116 sprintmode(statbuf.st_mode));
1117 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1118 (unsigned long) statbuf.st_nlink,
1119 (unsigned long) statbuf.st_uid,
1120 (unsigned long) statbuf.st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001121#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001122 tprintf("st_blksize=%lu, ",
1123 (unsigned long) statbuf.st_blksize);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001124#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
1125#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001126 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001127#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001128 }
1129 else
1130 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1131 switch (statbuf.st_mode & S_IFMT) {
1132 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +00001133#ifdef HAVE_STRUCT_STAT_ST_RDEV
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001134 tprintf("st_rdev=makedev(%lu, %lu), ",
1135 (unsigned long) major(statbuf.st_rdev),
1136 (unsigned long) minor(statbuf.st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001137#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001138 tprintf("st_size=makedev(%lu, %lu), ",
1139 (unsigned long) major(statbuf.st_size),
1140 (unsigned long) minor(statbuf.st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001141#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001142 break;
1143 default:
Roland McGrathc7bd4d32007-08-07 01:05:19 +00001144#ifdef HAVE_LONG_LONG
1145 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1146#else
1147 tprintf("st_size=%lu, ", (unsigned long) statbuf.st_size);
1148#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001149 break;
1150 }
1151 if (!abbrev(tcp)) {
1152 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1153 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +00001154 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001155#if HAVE_STRUCT_STAT_ST_FLAGS
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001156 tprints(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +00001157 printflags(fileflags, statbuf.st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +00001158#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001159#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +00001160 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1161#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001162#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +00001163 tprintf(", st_level=%ld", statbuf.st_level);
1164#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001165#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +00001166 tprintf(", st_fstype=%.*s",
1167 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1168#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001169#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +00001170 tprintf(", st_gen=%u", statbuf.st_gen);
1171#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001172 tprints("}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001173 }
1174 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001175 tprints("...}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001176}
Wichert Akkermanc7926982000-04-10 22:22:31 +00001177#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001178
Denys Vlasenko8435d672013-02-18 15:47:57 +01001179#if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001180static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001181convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001182{
Denys Vlasenko1d632462009-04-14 12:51:00 +00001183 newbuf->st_dev = oldbuf->st_dev;
1184 newbuf->st_ino = oldbuf->st_ino;
1185 newbuf->st_mode = oldbuf->st_mode;
1186 newbuf->st_nlink = oldbuf->st_nlink;
1187 newbuf->st_uid = oldbuf->st_uid;
1188 newbuf->st_gid = oldbuf->st_gid;
1189 newbuf->st_rdev = oldbuf->st_rdev;
1190 newbuf->st_size = oldbuf->st_size;
1191 newbuf->st_atime = oldbuf->st_atime;
1192 newbuf->st_mtime = oldbuf->st_mtime;
1193 newbuf->st_ctime = oldbuf->st_ctime;
1194 newbuf->st_blksize = 0; /* not supported in old_stat */
1195 newbuf->st_blocks = 0; /* not supported in old_stat */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001196}
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001197
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001198static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001199printoldstat(struct tcb *tcp, long addr)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001200{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +00001201 struct __old_kernel_stat statbuf;
1202 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001203
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001204 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001205 tprints("NULL");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001206 return;
1207 }
1208 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001209 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001210 return;
1211 }
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001212
Denys Vlasenko9472a272013-02-12 11:43:46 +01001213# if defined(SPARC) || defined(SPARC64)
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001214 if (current_personality == 1) {
1215 printstatsol(tcp, addr);
1216 return;
1217 }
Denys Vlasenko84703742012-02-25 02:38:52 +01001218# endif
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001219
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001220 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001221 tprints("{...}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001222 return;
1223 }
1224
1225 convertoldstat(&statbuf, &newstatbuf);
1226 realprintstat(tcp, &newstatbuf);
1227}
Denys Vlasenko84703742012-02-25 02:38:52 +01001228#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001229
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001230int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001231sys_stat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001232{
1233 if (entering(tcp)) {
1234 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001235 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001236 } else {
1237 printstat(tcp, tcp->u_arg[1]);
1238 }
1239 return 0;
1240}
1241
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001242int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001243sys_stat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001244{
1245#ifdef HAVE_STAT64
1246 if (entering(tcp)) {
1247 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001248 tprints(", ");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001249 } else {
1250 printstat64(tcp, tcp->u_arg[1]);
1251 }
1252 return 0;
1253#else
1254 return printargs(tcp);
1255#endif
1256}
1257
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001258#ifndef AT_SYMLINK_NOFOLLOW
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001259# define AT_SYMLINK_NOFOLLOW 0x100
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001260#endif
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001261#ifndef AT_REMOVEDIR
1262# define AT_REMOVEDIR 0x200
1263#endif
1264#ifndef AT_SYMLINK_FOLLOW
1265# define AT_SYMLINK_FOLLOW 0x400
1266#endif
1267#ifndef AT_NO_AUTOMOUNT
1268# define AT_NO_AUTOMOUNT 0x800
1269#endif
1270#ifndef AT_EMPTY_PATH
1271# define AT_EMPTY_PATH 0x1000
1272#endif
1273
1274static const struct xlat at_flags[] = {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001275 { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" },
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001276 { AT_REMOVEDIR, "AT_REMOVEDIR" },
1277 { AT_SYMLINK_FOLLOW, "AT_SYMLINK_FOLLOW" },
1278 { AT_NO_AUTOMOUNT, "AT_NO_AUTOMOUNT" },
1279 { AT_EMPTY_PATH, "AT_EMPTY_PATH" },
1280 { 0, NULL }
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001281};
1282
1283int
1284sys_newfstatat(struct tcb *tcp)
1285{
1286 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001287 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001288 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001289 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001290 } else {
Andreas Schwabd69fa492010-07-12 21:39:57 +02001291#ifdef POWERPC64
1292 if (current_personality == 0)
1293 printstat(tcp, tcp->u_arg[2]);
1294 else
1295 printstat64(tcp, tcp->u_arg[2]);
1296#elif defined HAVE_STAT64
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001297 printstat64(tcp, tcp->u_arg[2]);
1298#else
1299 printstat(tcp, tcp->u_arg[2]);
1300#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001301 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001302 printflags(at_flags, tcp->u_arg[3], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001303 }
1304 return 0;
1305}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001306
Denys Vlasenko8435d672013-02-18 15:47:57 +01001307#if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001308int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001309sys_oldstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001310{
1311 if (entering(tcp)) {
1312 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001313 tprints(", ");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001314 } else {
1315 printoldstat(tcp, tcp->u_arg[1]);
1316 }
1317 return 0;
1318}
Denys Vlasenko84703742012-02-25 02:38:52 +01001319#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001320
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001321int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001322sys_fstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001323{
Dmitry V. Levin31382132011-03-04 05:08:02 +03001324 if (entering(tcp)) {
1325 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001326 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001327 } else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001328 printstat(tcp, tcp->u_arg[1]);
1329 }
1330 return 0;
1331}
1332
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001333int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001334sys_fstat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001335{
1336#ifdef HAVE_STAT64
Dmitry V. Levin31382132011-03-04 05:08:02 +03001337 if (entering(tcp)) {
1338 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001339 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001340 } else {
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001341 printstat64(tcp, tcp->u_arg[1]);
1342 }
1343 return 0;
1344#else
1345 return printargs(tcp);
1346#endif
1347}
1348
Denys Vlasenko8435d672013-02-18 15:47:57 +01001349#if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001350int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001351sys_oldfstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001352{
Dmitry V. Levin31382132011-03-04 05:08:02 +03001353 if (entering(tcp)) {
1354 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001355 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001356 } else {
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001357 printoldstat(tcp, tcp->u_arg[1]);
1358 }
1359 return 0;
1360}
Denys Vlasenko84703742012-02-25 02:38:52 +01001361#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001362
Denys Vlasenko9472a272013-02-12 11:43:46 +01001363#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001364
1365int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001366sys_xstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001367{
1368 if (entering(tcp)) {
1369 tprintf("%ld, ", tcp->u_arg[0]);
1370 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001371 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001372 } else {
Denys Vlasenko84703742012-02-25 02:38:52 +01001373# ifdef _STAT64_VER
John Hughes8fe2c982001-03-06 09:45:18 +00001374 if (tcp->u_arg[0] == _STAT64_VER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01001375 printstat64(tcp, tcp->u_arg[2]);
John Hughes8fe2c982001-03-06 09:45:18 +00001376 else
Denys Vlasenko84703742012-02-25 02:38:52 +01001377# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001378 printstat(tcp, tcp->u_arg[2]);
1379 }
1380 return 0;
1381}
1382
1383int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001384sys_fxstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001385{
1386 if (entering(tcp))
1387 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1388 else {
Denys Vlasenko84703742012-02-25 02:38:52 +01001389# ifdef _STAT64_VER
John Hughes8fe2c982001-03-06 09:45:18 +00001390 if (tcp->u_arg[0] == _STAT64_VER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01001391 printstat64(tcp, tcp->u_arg[2]);
John Hughes8fe2c982001-03-06 09:45:18 +00001392 else
Denys Vlasenko84703742012-02-25 02:38:52 +01001393# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001394 printstat(tcp, tcp->u_arg[2]);
1395 }
1396 return 0;
1397}
1398
1399int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001400sys_lxstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001401{
1402 if (entering(tcp)) {
1403 tprintf("%ld, ", tcp->u_arg[0]);
1404 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001405 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001406 } else {
Denys Vlasenko84703742012-02-25 02:38:52 +01001407# ifdef _STAT64_VER
John Hughes8fe2c982001-03-06 09:45:18 +00001408 if (tcp->u_arg[0] == _STAT64_VER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01001409 printstat64(tcp, tcp->u_arg[2]);
John Hughes8fe2c982001-03-06 09:45:18 +00001410 else
Denys Vlasenko84703742012-02-25 02:38:52 +01001411# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001412 printstat(tcp, tcp->u_arg[2]);
1413 }
1414 return 0;
1415}
1416
1417int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001418sys_xmknod(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001419{
1420 int mode = tcp->u_arg[2];
1421
1422 if (entering(tcp)) {
1423 tprintf("%ld, ", tcp->u_arg[0]);
1424 printpath(tcp, tcp->u_arg[1]);
1425 tprintf(", %s", sprintmode(mode));
1426 switch (mode & S_IFMT) {
1427 case S_IFCHR: case S_IFBLK:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001428 tprintf(", makedev(%lu, %lu)",
1429 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1430 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001431 break;
1432 default:
1433 break;
1434 }
1435 }
1436 return 0;
1437}
1438
Denys Vlasenko84703742012-02-25 02:38:52 +01001439# ifdef HAVE_SYS_ACL_H
Wichert Akkerman8829a551999-06-11 13:18:40 +00001440
Denys Vlasenko84703742012-02-25 02:38:52 +01001441# include <sys/acl.h>
Wichert Akkerman8829a551999-06-11 13:18:40 +00001442
Roland McGratha4d48532005-06-08 20:45:28 +00001443static const struct xlat aclcmds[] = {
Denys Vlasenko84703742012-02-25 02:38:52 +01001444# ifdef SETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001445 { SETACL, "SETACL" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001446# endif
1447# ifdef GETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001448 { GETACL, "GETACL" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001449# endif
1450# ifdef GETACLCNT
Wichert Akkerman8829a551999-06-11 13:18:40 +00001451 { GETACLCNT, "GETACLCNT" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001452# endif
1453# ifdef ACL_GET
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001454 { ACL_GET, "ACL_GET" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001455# endif
1456# ifdef ACL_SET
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001457 { ACL_SET, "ACL_SET" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001458# endif
1459# ifdef ACL_CNT
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001460 { ACL_CNT, "ACL_CNT" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001461# endif
Wichert Akkerman8829a551999-06-11 13:18:40 +00001462 { 0, NULL },
1463};
1464
1465int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001466sys_acl(struct tcb *tcp)
Wichert Akkerman8829a551999-06-11 13:18:40 +00001467{
1468 if (entering(tcp)) {
1469 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001470 tprints(", ");
Wichert Akkerman8829a551999-06-11 13:18:40 +00001471 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1472 tprintf(", %ld", tcp->u_arg[2]);
1473 /*
1474 * FIXME - dump out the list of aclent_t's pointed to
1475 * by "tcp->u_arg[3]" if it's not NULL.
1476 */
1477 if (tcp->u_arg[3])
1478 tprintf(", %#lx", tcp->u_arg[3]);
1479 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001480 tprints(", NULL");
Wichert Akkerman8829a551999-06-11 13:18:40 +00001481 }
1482 return 0;
1483}
1484
Wichert Akkerman8829a551999-06-11 13:18:40 +00001485int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001486sys_facl(struct tcb *tcp)
Wichert Akkerman8829a551999-06-11 13:18:40 +00001487{
1488 if (entering(tcp)) {
1489 tprintf("%ld, ", tcp->u_arg[0]);
1490 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1491 tprintf(", %ld", tcp->u_arg[2]);
1492 /*
1493 * FIXME - dump out the list of aclent_t's pointed to
1494 * by "tcp->u_arg[3]" if it's not NULL.
1495 */
1496 if (tcp->u_arg[3])
1497 tprintf(", %#lx", tcp->u_arg[3]);
1498 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001499 tprints(", NULL");
Wichert Akkerman8829a551999-06-11 13:18:40 +00001500 }
1501 return 0;
1502}
1503
Roland McGratha4d48532005-06-08 20:45:28 +00001504static const struct xlat aclipc[] = {
Denys Vlasenko84703742012-02-25 02:38:52 +01001505# ifdef IPC_SHM
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001506 { IPC_SHM, "IPC_SHM" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001507# endif
1508# ifdef IPC_SEM
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001509 { IPC_SEM, "IPC_SEM" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001510# endif
1511# ifdef IPC_MSG
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001512 { IPC_MSG, "IPC_MSG" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001513# endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001514 { 0, NULL },
1515};
1516
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001517int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001518sys_aclipc(struct tcb *tcp)
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001519{
1520 if (entering(tcp)) {
1521 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1522 tprintf(", %#lx, ", tcp->u_arg[1]);
1523 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1524 tprintf(", %ld", tcp->u_arg[3]);
1525 /*
1526 * FIXME - dump out the list of aclent_t's pointed to
1527 * by "tcp->u_arg[4]" if it's not NULL.
1528 */
1529 if (tcp->u_arg[4])
1530 tprintf(", %#lx", tcp->u_arg[4]);
1531 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001532 tprints(", NULL");
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001533 }
1534 return 0;
1535}
1536
Denys Vlasenko84703742012-02-25 02:38:52 +01001537# endif /* HAVE_SYS_ACL_H */
Wichert Akkerman8829a551999-06-11 13:18:40 +00001538
Denys Vlasenko9472a272013-02-12 11:43:46 +01001539#endif /* SPARC[64] */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001540
Roland McGrathd9f816f2004-09-04 03:39:20 +00001541static const struct xlat fsmagic[] = {
Wichert Akkerman43a74822000-06-27 17:33:32 +00001542 { 0x73757245, "CODA_SUPER_MAGIC" },
1543 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1544 { 0x1373, "DEVFS_SUPER_MAGIC" },
1545 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1546 { 0x414A53, "EFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001547 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1548 { 0xef53, "EXT2_SUPER_MAGIC" },
1549 { 0x137d, "EXT_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001550 { 0xf995e849, "HPFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001551 { 0x9660, "ISOFS_SUPER_MAGIC" },
1552 { 0x137f, "MINIX_SUPER_MAGIC" },
1553 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001554 { 0x2468, "MINIX2_SUPER_MAGIC" },
1555 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001556 { 0x4d44, "MSDOS_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001557 { 0x564c, "NCP_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001558 { 0x6969, "NFS_SUPER_MAGIC" },
1559 { 0x9fa0, "PROC_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001560 { 0x002f, "QNX4_SUPER_MAGIC" },
1561 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1562 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1563 { 0x517b, "SMB_SUPER_MAGIC" },
1564 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1565 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1566 { 0x00011954, "UFS_MAGIC" },
1567 { 0x54190100, "UFS_CIGAM" },
1568 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001569 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
Roland McGrathc767ad82004-01-13 10:13:45 +00001570 { 0x62656572, "SYSFS_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001571 { 0, NULL },
1572};
1573
Roland McGrathf9c49b22004-10-06 22:11:54 +00001574static const char *
Denys Vlasenko1d632462009-04-14 12:51:00 +00001575sprintfstype(int magic)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001576{
1577 static char buf[32];
Roland McGrathf9c49b22004-10-06 22:11:54 +00001578 const char *s;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001579
1580 s = xlookup(fsmagic, magic);
1581 if (s) {
1582 sprintf(buf, "\"%s\"", s);
1583 return buf;
1584 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001585 sprintf(buf, "%#x", magic);
1586 return buf;
1587}
1588
1589static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001590printstatfs(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001591{
1592 struct statfs statbuf;
1593
1594 if (syserror(tcp) || !verbose(tcp)) {
1595 tprintf("%#lx", addr);
1596 return;
1597 }
1598 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001599 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001600 return;
1601 }
1602#ifdef ALPHA
1603
1604 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1605 sprintfstype(statbuf.f_type),
1606 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Roland McGrathab147c52003-07-17 09:03:02 +00001607 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001608 statbuf.f_bavail, statbuf.f_files, statbuf.f_ffree,
Roland McGrathab147c52003-07-17 09:03:02 +00001609 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1610 statbuf.f_namelen);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001611#else /* !ALPHA */
1612 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1613 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +00001614 (unsigned long)statbuf.f_bsize,
1615 (unsigned long)statbuf.f_blocks,
1616 (unsigned long)statbuf.f_bfree);
Roland McGrathab147c52003-07-17 09:03:02 +00001617 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1618 (unsigned long)statbuf.f_bavail,
Nate Sammons5c74d201999-04-06 01:37:51 +00001619 (unsigned long)statbuf.f_files,
Roland McGrathab147c52003-07-17 09:03:02 +00001620 (unsigned long)statbuf.f_ffree,
1621 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001622 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001623#endif /* !ALPHA */
Roland McGrathab147c52003-07-17 09:03:02 +00001624#ifdef _STATFS_F_FRSIZE
1625 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1626#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001627 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001628}
1629
1630int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001631sys_statfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001632{
1633 if (entering(tcp)) {
1634 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001635 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001636 } else {
1637 printstatfs(tcp, tcp->u_arg[1]);
1638 }
1639 return 0;
1640}
1641
1642int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001643sys_fstatfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001644{
1645 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001646 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001647 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001648 } else {
1649 printstatfs(tcp, tcp->u_arg[1]);
1650 }
1651 return 0;
1652}
1653
Denys Vlasenko84703742012-02-25 02:38:52 +01001654#if defined HAVE_STATFS64
Roland McGrathab147c52003-07-17 09:03:02 +00001655static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001656printstatfs64(struct tcb *tcp, long addr)
Roland McGrathab147c52003-07-17 09:03:02 +00001657{
1658 struct statfs64 statbuf;
1659
1660 if (syserror(tcp) || !verbose(tcp)) {
1661 tprintf("%#lx", addr);
1662 return;
1663 }
1664 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001665 tprints("{...}");
Roland McGrathab147c52003-07-17 09:03:02 +00001666 return;
1667 }
Roland McGrath08738432005-06-03 02:40:39 +00001668 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
Roland McGrathab147c52003-07-17 09:03:02 +00001669 sprintfstype(statbuf.f_type),
Roland McGrath08738432005-06-03 02:40:39 +00001670 (unsigned long long)statbuf.f_bsize,
1671 (unsigned long long)statbuf.f_blocks,
1672 (unsigned long long)statbuf.f_bfree);
1673 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1674 (unsigned long long)statbuf.f_bavail,
1675 (unsigned long long)statbuf.f_files,
1676 (unsigned long long)statbuf.f_ffree,
Roland McGrathab147c52003-07-17 09:03:02 +00001677 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1678 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Roland McGrathab147c52003-07-17 09:03:02 +00001679#ifdef _STATFS_F_FRSIZE
Roland McGrath08738432005-06-03 02:40:39 +00001680 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
Roland McGrathab147c52003-07-17 09:03:02 +00001681#endif
Andreas Schwab000d66f2012-01-17 18:13:33 +01001682#ifdef _STATFS_F_FLAGS
1683 tprintf(", f_flags=%llu", (unsigned long long)statbuf.f_flags);
1684#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001685 tprints("}");
Roland McGrathab147c52003-07-17 09:03:02 +00001686}
1687
Andreas Schwab7d558012012-01-17 18:14:22 +01001688struct compat_statfs64 {
1689 uint32_t f_type;
1690 uint32_t f_bsize;
1691 uint64_t f_blocks;
1692 uint64_t f_bfree;
1693 uint64_t f_bavail;
1694 uint64_t f_files;
1695 uint64_t f_ffree;
1696 fsid_t f_fsid;
1697 uint32_t f_namelen;
1698 uint32_t f_frsize;
1699 uint32_t f_flags;
1700 uint32_t f_spare[4];
1701}
1702#if defined(X86_64) || defined(IA64)
1703 __attribute__ ((packed, aligned(4)))
1704#endif
1705;
1706
1707static void
1708printcompat_statfs64(struct tcb *tcp, long addr)
1709{
1710 struct compat_statfs64 statbuf;
1711
1712 if (syserror(tcp) || !verbose(tcp)) {
1713 tprintf("%#lx", addr);
1714 return;
1715 }
1716 if (umove(tcp, addr, &statbuf) < 0) {
1717 tprints("{...}");
1718 return;
1719 }
1720 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%llu, f_bfree=%llu, ",
1721 sprintfstype(statbuf.f_type),
1722 (unsigned long)statbuf.f_bsize,
1723 (unsigned long long)statbuf.f_blocks,
1724 (unsigned long long)statbuf.f_bfree);
1725 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1726 (unsigned long long)statbuf.f_bavail,
1727 (unsigned long long)statbuf.f_files,
1728 (unsigned long long)statbuf.f_ffree,
1729 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1730 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1731 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001732 tprintf(", f_flags=%lu}", (unsigned long)statbuf.f_frsize);
Andreas Schwab7d558012012-01-17 18:14:22 +01001733}
1734
Roland McGrathab147c52003-07-17 09:03:02 +00001735int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001736sys_statfs64(struct tcb *tcp)
Roland McGrathab147c52003-07-17 09:03:02 +00001737{
1738 if (entering(tcp)) {
1739 printpath(tcp, tcp->u_arg[0]);
1740 tprintf(", %lu, ", tcp->u_arg[1]);
1741 } else {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001742 if (tcp->u_arg[1] == sizeof(struct statfs64))
Roland McGrathab147c52003-07-17 09:03:02 +00001743 printstatfs64(tcp, tcp->u_arg[2]);
Andreas Schwab7d558012012-01-17 18:14:22 +01001744 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
1745 printcompat_statfs64(tcp, tcp->u_arg[2]);
Roland McGrathab147c52003-07-17 09:03:02 +00001746 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001747 tprints("{???}");
Roland McGrathab147c52003-07-17 09:03:02 +00001748 }
1749 return 0;
1750}
1751
1752int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001753sys_fstatfs64(struct tcb *tcp)
Roland McGrathab147c52003-07-17 09:03:02 +00001754{
1755 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001756 printfd(tcp, tcp->u_arg[0]);
1757 tprintf(", %lu, ", tcp->u_arg[1]);
Roland McGrathab147c52003-07-17 09:03:02 +00001758 } else {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001759 if (tcp->u_arg[1] == sizeof(struct statfs64))
Roland McGrathab147c52003-07-17 09:03:02 +00001760 printstatfs64(tcp, tcp->u_arg[2]);
Andreas Schwab7d558012012-01-17 18:14:22 +01001761 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
1762 printcompat_statfs64(tcp, tcp->u_arg[2]);
Roland McGrathab147c52003-07-17 09:03:02 +00001763 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001764 tprints("{???}");
Roland McGrathab147c52003-07-17 09:03:02 +00001765 }
1766 return 0;
1767}
1768#endif
1769
Denys Vlasenkoc36c3522012-02-25 02:47:15 +01001770#if defined(ALPHA)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001771int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001772osf_statfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001773{
1774 if (entering(tcp)) {
1775 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001776 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001777 } else {
1778 printstatfs(tcp, tcp->u_arg[1]);
1779 tprintf(", %lu", tcp->u_arg[2]);
1780 }
1781 return 0;
1782}
1783
1784int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001785osf_fstatfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001786{
1787 if (entering(tcp)) {
1788 tprintf("%lu, ", tcp->u_arg[0]);
1789 } else {
1790 printstatfs(tcp, tcp->u_arg[1]);
1791 tprintf(", %lu", tcp->u_arg[2]);
1792 }
1793 return 0;
1794}
Denys Vlasenko84703742012-02-25 02:38:52 +01001795#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001796
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001797/* directory */
1798int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001799sys_chdir(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001800{
1801 if (entering(tcp)) {
1802 printpath(tcp, tcp->u_arg[0]);
1803 }
1804 return 0;
1805}
1806
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001807static int
1808decode_mkdir(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001809{
1810 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001811 printpath(tcp, tcp->u_arg[offset]);
1812 tprintf(", %#lo", tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001813 }
1814 return 0;
1815}
1816
1817int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001818sys_mkdir(struct tcb *tcp)
1819{
1820 return decode_mkdir(tcp, 0);
1821}
1822
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001823int
1824sys_mkdirat(struct tcb *tcp)
1825{
1826 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03001827 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001828 return decode_mkdir(tcp, 1);
1829}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001830
1831int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001832sys_link(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001833{
1834 if (entering(tcp)) {
1835 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001836 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001837 printpath(tcp, tcp->u_arg[1]);
1838 }
1839 return 0;
1840}
1841
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001842int
1843sys_linkat(struct tcb *tcp)
1844{
1845 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001846 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001847 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001848 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001849 print_dirfd(tcp, tcp->u_arg[2]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001850 printpath(tcp, tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001851 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001852 printflags(at_flags, tcp->u_arg[4], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001853 }
1854 return 0;
1855}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001856
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001857int
1858sys_unlinkat(struct tcb *tcp)
1859{
1860 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001861 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001862 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001863 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001864 printflags(at_flags, tcp->u_arg[2], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001865 }
1866 return 0;
1867}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001868
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001869int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001870sys_symlinkat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001871{
1872 if (entering(tcp)) {
1873 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001874 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001875 print_dirfd(tcp, tcp->u_arg[1]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001876 printpath(tcp, tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001877 }
1878 return 0;
1879}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001880
1881static int
1882decode_readlink(struct tcb *tcp, int offset)
1883{
1884 if (entering(tcp)) {
1885 printpath(tcp, tcp->u_arg[offset]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001886 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001887 } else {
1888 if (syserror(tcp))
1889 tprintf("%#lx", tcp->u_arg[offset + 1]);
1890 else
Denys Vlasenko3449ae82012-01-27 17:24:26 +01001891 /* Used to use printpathn(), but readlink
1892 * neither includes NUL in the returned count,
1893 * nor actually writes it into memory.
1894 * printpathn() would decide on printing
1895 * "..." continuation based on garbage
1896 * past return buffer's end.
1897 */
1898 printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001899 tprintf(", %lu", tcp->u_arg[offset + 2]);
1900 }
1901 return 0;
1902}
1903
1904int
1905sys_readlink(struct tcb *tcp)
1906{
1907 return decode_readlink(tcp, 0);
1908}
1909
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001910int
1911sys_readlinkat(struct tcb *tcp)
1912{
1913 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03001914 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001915 return decode_readlink(tcp, 1);
1916}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001917
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001918int
1919sys_renameat(struct tcb *tcp)
1920{
1921 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001922 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001923 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001924 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001925 print_dirfd(tcp, tcp->u_arg[2]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001926 printpath(tcp, tcp->u_arg[3]);
1927 }
1928 return 0;
1929}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001930
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001931int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001932sys_chown(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001933{
1934 if (entering(tcp)) {
1935 printpath(tcp, tcp->u_arg[0]);
Roland McGrath6bc12202003-11-13 22:32:27 +00001936 printuid(", ", tcp->u_arg[1]);
1937 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001938 }
1939 return 0;
1940}
1941
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001942int
1943sys_fchownat(struct tcb *tcp)
1944{
1945 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001946 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001947 printpath(tcp, tcp->u_arg[1]);
1948 printuid(", ", tcp->u_arg[2]);
1949 printuid(", ", tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001950 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001951 printflags(at_flags, tcp->u_arg[4], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001952 }
1953 return 0;
1954}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001955
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001956int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001957sys_fchown(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001958{
1959 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001960 printfd(tcp, tcp->u_arg[0]);
Roland McGrath6bc12202003-11-13 22:32:27 +00001961 printuid(", ", tcp->u_arg[1]);
1962 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001963 }
1964 return 0;
1965}
1966
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001967static int
1968decode_chmod(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001969{
1970 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001971 printpath(tcp, tcp->u_arg[offset]);
1972 tprintf(", %#lo", tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001973 }
1974 return 0;
1975}
1976
1977int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001978sys_chmod(struct tcb *tcp)
1979{
1980 return decode_chmod(tcp, 0);
1981}
1982
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001983int
1984sys_fchmodat(struct tcb *tcp)
1985{
1986 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03001987 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001988 return decode_chmod(tcp, 1);
1989}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001990
1991int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001992sys_fchmod(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001993{
1994 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001995 printfd(tcp, tcp->u_arg[0]);
1996 tprintf(", %#lo", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001997 }
1998 return 0;
1999}
2000
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002001#ifdef ALPHA
2002int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002003sys_osf_utimes(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002004{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002005 if (entering(tcp)) {
2006 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002007 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002008 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
2009 }
2010 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002011}
2012#endif
2013
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002014static int
Roland McGrath6afc5652007-07-24 01:57:11 +00002015decode_utimes(struct tcb *tcp, int offset, int special)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002016{
2017 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002018 printpath(tcp, tcp->u_arg[offset]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002019 tprints(", ");
Roland McGrath6afc5652007-07-24 01:57:11 +00002020 if (tcp->u_arg[offset + 1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002021 tprints("NULL");
Roland McGrath6afc5652007-07-24 01:57:11 +00002022 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002023 tprints("{");
Roland McGrath6afc5652007-07-24 01:57:11 +00002024 printtv_bitness(tcp, tcp->u_arg[offset + 1],
2025 BITNESS_CURRENT, special);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002026 tprints(", ");
Roland McGrathe6d0f712007-08-07 01:22:49 +00002027 printtv_bitness(tcp, tcp->u_arg[offset + 1]
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002028 + sizeof(struct timeval),
Roland McGrath6afc5652007-07-24 01:57:11 +00002029 BITNESS_CURRENT, special);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002030 tprints("}");
Roland McGrath6afc5652007-07-24 01:57:11 +00002031 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002032 }
2033 return 0;
2034}
2035
2036int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002037sys_utimes(struct tcb *tcp)
2038{
Roland McGrath6afc5652007-07-24 01:57:11 +00002039 return decode_utimes(tcp, 0, 0);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002040}
2041
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002042int
2043sys_futimesat(struct tcb *tcp)
2044{
2045 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03002046 print_dirfd(tcp, tcp->u_arg[0]);
Roland McGrath6afc5652007-07-24 01:57:11 +00002047 return decode_utimes(tcp, 1, 0);
2048}
2049
2050int
2051sys_utimensat(struct tcb *tcp)
2052{
2053 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002054 print_dirfd(tcp, tcp->u_arg[0]);
Roland McGrath6afc5652007-07-24 01:57:11 +00002055 decode_utimes(tcp, 1, 1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002056 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00002057 printflags(at_flags, tcp->u_arg[3], "AT_???");
Roland McGrath6afc5652007-07-24 01:57:11 +00002058 }
2059 return 0;
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002060}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002061
2062int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002063sys_utime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002064{
Roland McGrath7e9817c2007-07-05 20:31:58 +00002065 union {
2066 long utl[2];
2067 int uti[2];
Denys Vlasenko751acb32013-02-08 15:34:46 +01002068 long paranoia_for_huge_wordsize[4];
Roland McGrath7e9817c2007-07-05 20:31:58 +00002069 } u;
Denys Vlasenko751acb32013-02-08 15:34:46 +01002070 unsigned wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002071
2072 if (entering(tcp)) {
2073 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002074 tprints(", ");
Denys Vlasenko751acb32013-02-08 15:34:46 +01002075
2076 wordsize = current_wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002077 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002078 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002079 else if (!verbose(tcp))
2080 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01002081 else if (umoven(tcp, tcp->u_arg[1], 2 * wordsize, (char *) &u) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002082 tprints("[?, ?]");
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01002083 else if (wordsize == sizeof u.utl[0]) {
Roland McGrath7e9817c2007-07-05 20:31:58 +00002084 tprintf("[%s,", sprinttime(u.utl[0]));
2085 tprintf(" %s]", sprinttime(u.utl[1]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002086 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01002087 else if (wordsize == sizeof u.uti[0]) {
Roland McGrath7e9817c2007-07-05 20:31:58 +00002088 tprintf("[%s,", sprinttime(u.uti[0]));
2089 tprintf(" %s]", sprinttime(u.uti[1]));
2090 }
2091 else
Denys Vlasenko751acb32013-02-08 15:34:46 +01002092 tprintf("<decode error: unsupported wordsize %d>",
2093 wordsize);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002094 }
2095 return 0;
2096}
2097
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002098static int
2099decode_mknod(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002100{
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002101 int mode = tcp->u_arg[offset + 1];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002102
2103 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002104 printpath(tcp, tcp->u_arg[offset]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002105 tprintf(", %s", sprintmode(mode));
2106 switch (mode & S_IFMT) {
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002107 case S_IFCHR:
2108 case S_IFBLK:
Denys Vlasenko9472a272013-02-12 11:43:46 +01002109#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002110 if (current_personality == 1)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002111 tprintf(", makedev(%lu, %lu)",
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002112 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
2113 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002114 else
Roland McGrath186c5ac2002-12-15 23:58:23 +00002115#endif
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002116 tprintf(", makedev(%lu, %lu)",
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002117 (unsigned long) major(tcp->u_arg[offset + 2]),
2118 (unsigned long) minor(tcp->u_arg[offset + 2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002119 break;
2120 default:
2121 break;
2122 }
2123 }
2124 return 0;
2125}
2126
2127int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002128sys_mknod(struct tcb *tcp)
2129{
2130 return decode_mknod(tcp, 0);
2131}
2132
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002133int
2134sys_mknodat(struct tcb *tcp)
2135{
2136 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03002137 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002138 return decode_mknod(tcp, 1);
2139}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002140
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002141static void
Dmitry V. Levin68f80e62013-03-20 12:45:05 +00002142print_old_dirent(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002143{
Dmitry V. Levin68f80e62013-03-20 12:45:05 +00002144#ifdef SH64
2145 typedef struct kernel_dirent old_dirent_t;
2146#else
2147 typedef struct {
2148 uint32_t d_ino;
2149 uint32_t d_off;
2150 unsigned short d_reclen;
2151 char d_name[1];
2152 } old_dirent_t;
2153#endif
2154 old_dirent_t d;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002155
Dmitry V. Levin68f80e62013-03-20 12:45:05 +00002156 if (!verbose(tcp) || umove(tcp, addr, &d) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002157 tprintf("%#lx", addr);
2158 return;
2159 }
Dmitry V. Levin68f80e62013-03-20 12:45:05 +00002160
2161 tprintf("{d_ino=%lu, d_off=%lu, d_reclen=%u, d_name=\"",
2162 (unsigned long) d.d_ino, (unsigned long) d.d_off, d.d_reclen);
2163 if (d.d_reclen > 256)
2164 d.d_reclen = 256;
2165 printpathn(tcp, addr + offsetof(old_dirent_t, d_name), d.d_reclen);
2166 tprints("\"}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002167}
2168
2169int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002170sys_readdir(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002171{
2172 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002173 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002174 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002175 } else {
2176 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
2177 tprintf("%#lx", tcp->u_arg[1]);
2178 else
Dmitry V. Levin68f80e62013-03-20 12:45:05 +00002179 print_old_dirent(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002180 /* Not much point in printing this out, it is always 1. */
2181 if (tcp->u_arg[2] != 1)
2182 tprintf(", %lu", tcp->u_arg[2]);
2183 }
2184 return 0;
2185}
2186
Roland McGratha4d48532005-06-08 20:45:28 +00002187static const struct xlat direnttypes[] = {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002188 { DT_UNKNOWN, "DT_UNKNOWN" },
2189 { DT_FIFO, "DT_FIFO" },
2190 { DT_CHR, "DT_CHR" },
2191 { DT_DIR, "DT_DIR" },
2192 { DT_BLK, "DT_BLK" },
2193 { DT_REG, "DT_REG" },
2194 { DT_LNK, "DT_LNK" },
2195 { DT_SOCK, "DT_SOCK" },
2196 { DT_WHT, "DT_WHT" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002197 { 0, NULL },
2198};
2199
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002200int
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002201sys_getdents(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002202{
2203 int i, len, dents = 0;
2204 char *buf;
2205
2206 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002207 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002208 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002209 return 0;
2210 }
2211 if (syserror(tcp) || !verbose(tcp)) {
2212 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2213 return 0;
2214 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002215 len = tcp->u_rval;
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002216 /* Beware of insanely large or negative values in tcp->u_rval */
2217 if (tcp->u_rval > 1024*1024)
2218 len = 1024*1024;
2219 if (tcp->u_rval < 0)
2220 len = 0;
Mike Frysinger229738c2009-10-07 20:41:56 -04002221 buf = len ? malloc(len) : NULL;
Denys Vlasenko1d46ba52011-08-31 14:00:02 +02002222 if (len && !buf)
2223 die_out_of_memory();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002224 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002225 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002226 free(buf);
2227 return 0;
2228 }
2229 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002230 tprints("{");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002231 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00002232 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002233 if (!abbrev(tcp)) {
2234 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2235 i ? " " : "", d->d_ino, d->d_off);
Dmitry V. Levinad232c62012-08-16 19:29:55 +00002236 tprintf("d_reclen=%u, d_name=\"%s\", d_type=",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002237 d->d_reclen, d->d_name);
Dmitry V. Levinad232c62012-08-16 19:29:55 +00002238 printxval(direnttypes, buf[i + d->d_reclen - 1], "DT_???");
2239 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002240 }
Pavel Machek9a9f10b2000-02-01 16:22:52 +00002241 if (!d->d_reclen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002242 tprints("/* d_reclen == 0, problem here */");
Pavel Machek9a9f10b2000-02-01 16:22:52 +00002243 break;
2244 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002245 i += d->d_reclen;
2246 dents++;
2247 }
2248 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002249 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002250 else
2251 tprintf("/* %u entries */", dents);
2252 tprintf(", %lu", tcp->u_arg[2]);
2253 free(buf);
2254 return 0;
2255}
2256
John Hughesbdf48f52001-03-06 15:08:09 +00002257#if _LFS64_LARGEFILE
2258int
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002259sys_getdents64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +00002260{
2261 int i, len, dents = 0;
2262 char *buf;
2263
2264 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002265 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002266 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +00002267 return 0;
2268 }
2269 if (syserror(tcp) || !verbose(tcp)) {
2270 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2271 return 0;
2272 }
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002273
John Hughesbdf48f52001-03-06 15:08:09 +00002274 len = tcp->u_rval;
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002275 /* Beware of insanely large or negative tcp->u_rval */
2276 if (tcp->u_rval > 1024*1024)
2277 len = 1024*1024;
2278 if (tcp->u_rval < 0)
2279 len = 0;
Mike Frysinger229738c2009-10-07 20:41:56 -04002280 buf = len ? malloc(len) : NULL;
Denys Vlasenko1d46ba52011-08-31 14:00:02 +02002281 if (len && !buf)
2282 die_out_of_memory();
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002283
John Hughesbdf48f52001-03-06 15:08:09 +00002284 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002285 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
John Hughesbdf48f52001-03-06 15:08:09 +00002286 free(buf);
2287 return 0;
2288 }
2289 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002290 tprints("{");
John Hughesbdf48f52001-03-06 15:08:09 +00002291 for (i = 0; i < len;) {
2292 struct dirent64 *d = (struct dirent64 *) &buf[i];
John Hughesbdf48f52001-03-06 15:08:09 +00002293 if (!abbrev(tcp)) {
Dmitry V. Levin1f336e52006-10-14 20:20:46 +00002294 tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ",
Roland McGrath186c5ac2002-12-15 23:58:23 +00002295 i ? " " : "",
Roland McGrath92053242004-01-13 10:16:47 +00002296 d->d_ino,
2297 d->d_off);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002298 tprints("d_type=");
Roland McGrath40542842004-01-13 09:47:49 +00002299 printxval(direnttypes, d->d_type, "DT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002300 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +00002301 tprintf("d_reclen=%u, d_name=\"%s\"}",
2302 d->d_reclen, d->d_name);
2303 }
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002304 if (!d->d_reclen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002305 tprints("/* d_reclen == 0, problem here */");
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002306 break;
2307 }
John Hughesbdf48f52001-03-06 15:08:09 +00002308 i += d->d_reclen;
2309 dents++;
2310 }
2311 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002312 tprints("}");
John Hughesbdf48f52001-03-06 15:08:09 +00002313 else
2314 tprintf("/* %u entries */", dents);
2315 tprintf(", %lu", tcp->u_arg[2]);
2316 free(buf);
2317 return 0;
2318}
2319#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +00002320
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002321int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002322sys_getcwd(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002323{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002324 if (exiting(tcp)) {
2325 if (syserror(tcp))
2326 tprintf("%#lx", tcp->u_arg[0]);
2327 else
2328 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2329 tprintf(", %lu", tcp->u_arg[1]);
2330 }
2331 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002332}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002333
2334#ifdef HAVE_SYS_ASYNCH_H
2335
2336int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002337sys_aioread(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002338{
2339 struct aio_result_t res;
2340
2341 if (entering(tcp)) {
2342 tprintf("%lu, ", tcp->u_arg[0]);
2343 } else {
2344 if (syserror(tcp))
2345 tprintf("%#lx", tcp->u_arg[1]);
2346 else
2347 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2348 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2349 printxval(whence, tcp->u_arg[4], "L_???");
2350 if (syserror(tcp) || tcp->u_arg[5] == 0
2351 || umove(tcp, tcp->u_arg[5], &res) < 0)
2352 tprintf(", %#lx", tcp->u_arg[5]);
2353 else
2354 tprintf(", {aio_return %d aio_errno %d}",
2355 res.aio_return, res.aio_errno);
2356 }
2357 return 0;
2358}
2359
2360int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002361sys_aiowrite(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002362{
2363 struct aio_result_t res;
2364
2365 if (entering(tcp)) {
2366 tprintf("%lu, ", tcp->u_arg[0]);
2367 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2368 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2369 printxval(whence, tcp->u_arg[4], "L_???");
2370 }
2371 else {
2372 if (tcp->u_arg[5] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002373 tprints(", NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002374 else if (syserror(tcp)
2375 || umove(tcp, tcp->u_arg[5], &res) < 0)
2376 tprintf(", %#lx", tcp->u_arg[5]);
2377 else
2378 tprintf(", {aio_return %d aio_errno %d}",
2379 res.aio_return, res.aio_errno);
2380 }
2381 return 0;
2382}
2383
2384int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002385sys_aiowait(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002386{
2387 if (entering(tcp))
2388 printtv(tcp, tcp->u_arg[0]);
2389 return 0;
2390}
2391
2392int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002393sys_aiocancel(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002394{
2395 struct aio_result_t res;
2396
2397 if (exiting(tcp)) {
2398 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002399 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002400 else if (syserror(tcp)
2401 || umove(tcp, tcp->u_arg[0], &res) < 0)
2402 tprintf("%#lx", tcp->u_arg[0]);
2403 else
2404 tprintf("{aio_return %d aio_errno %d}",
2405 res.aio_return, res.aio_errno);
2406 }
2407 return 0;
2408}
2409
2410#endif /* HAVE_SYS_ASYNCH_H */
Roland McGrath186c5ac2002-12-15 23:58:23 +00002411
Roland McGratha4d48532005-06-08 20:45:28 +00002412static const struct xlat xattrflags[] = {
Roland McGrath561c7992003-04-02 01:10:44 +00002413#ifdef XATTR_CREATE
Roland McGrath186c5ac2002-12-15 23:58:23 +00002414 { XATTR_CREATE, "XATTR_CREATE" },
2415 { XATTR_REPLACE, "XATTR_REPLACE" },
Roland McGrath561c7992003-04-02 01:10:44 +00002416#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +00002417 { 0, NULL }
2418};
2419
Roland McGrath3292e222004-08-31 06:30:48 +00002420static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002421print_xattr_val(struct tcb *tcp, int failed,
2422 unsigned long arg,
2423 unsigned long insize,
2424 unsigned long size)
Roland McGrath3292e222004-08-31 06:30:48 +00002425{
Dmitry V. Levin1f215132012-12-07 21:38:52 +00002426 if (insize == 0)
2427 failed = 1;
Denys Vlasenko1d632462009-04-14 12:51:00 +00002428 if (!failed) {
2429 unsigned long capacity = 4 * size + 1;
2430 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
2431 if (buf == NULL || /* probably a bogus size argument */
2432 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2433 failed = 1;
Roland McGrath883567c2005-02-02 03:38:32 +00002434 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002435 else {
2436 unsigned char *out = buf;
2437 unsigned char *in = &buf[3 * size];
2438 size_t i;
2439 for (i = 0; i < size; ++i) {
Denys Vlasenko5198ed42013-03-06 23:44:23 +01002440 if (in[i] >= ' ' && in[i] <= 0x7e)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002441 *out++ = in[i];
2442 else {
2443#define tohex(n) "0123456789abcdef"[n]
2444 *out++ = '\\';
2445 *out++ = 'x';
2446 *out++ = tohex(in[i] / 16);
2447 *out++ = tohex(in[i] % 16);
2448 }
2449 }
2450 /* Don't print terminating NUL if there is one. */
2451 if (i > 0 && in[i - 1] == '\0')
2452 out -= 4;
2453 *out = '\0';
2454 tprintf(", \"%s\", %ld", buf, insize);
2455 }
2456 free(buf);
Roland McGrath883567c2005-02-02 03:38:32 +00002457 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002458 if (failed)
2459 tprintf(", 0x%lx, %ld", arg, insize);
Roland McGrath3292e222004-08-31 06:30:48 +00002460}
2461
Roland McGrath186c5ac2002-12-15 23:58:23 +00002462int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002463sys_setxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002464{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002465 if (entering(tcp)) {
2466 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002467 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002468 printstr(tcp, tcp->u_arg[1], -1);
2469 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002470 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002471 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2472 }
2473 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002474}
2475
2476int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002477sys_fsetxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002478{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002479 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002480 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002481 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002482 printstr(tcp, tcp->u_arg[1], -1);
2483 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002484 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002485 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2486 }
2487 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002488}
2489
2490int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002491sys_getxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002492{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002493 if (entering(tcp)) {
2494 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002495 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002496 printstr(tcp, tcp->u_arg[1], -1);
2497 } else {
2498 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2499 tcp->u_rval);
2500 }
2501 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002502}
2503
2504int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002505sys_fgetxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002506{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002507 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002508 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002509 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002510 printstr(tcp, tcp->u_arg[1], -1);
2511 } else {
2512 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2513 tcp->u_rval);
2514 }
2515 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002516}
2517
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002518static void
2519print_xattr_list(struct tcb *tcp, unsigned long addr, unsigned long size)
2520{
2521 if (syserror(tcp)) {
2522 tprintf("%#lx", addr);
2523 } else {
2524 if (!addr) {
2525 tprints("NULL");
2526 } else {
2527 unsigned long len =
2528 (size < tcp->u_rval) ? size : tcp->u_rval;
2529 printstr(tcp, addr, len);
2530 }
2531 }
2532 tprintf(", %lu", size);
2533}
2534
Roland McGrath186c5ac2002-12-15 23:58:23 +00002535int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002536sys_listxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002537{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002538 if (entering(tcp)) {
2539 printpath(tcp, tcp->u_arg[0]);
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002540 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002541 } else {
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002542 print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002543 }
2544 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002545}
2546
2547int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002548sys_flistxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002549{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002550 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002551 printfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002552 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002553 } else {
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002554 print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002555 }
2556 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002557}
2558
2559int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002560sys_removexattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002561{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002562 if (entering(tcp)) {
2563 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002564 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002565 printstr(tcp, tcp->u_arg[1], -1);
2566 }
2567 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002568}
2569
2570int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002571sys_fremovexattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002572{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002573 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002574 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002575 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002576 printstr(tcp, tcp->u_arg[1], -1);
2577 }
2578 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002579}
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002580
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002581static const struct xlat advise[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002582 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2583 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2584 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2585 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2586 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2587 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2588 { 0, NULL }
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002589};
2590
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002591int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002592sys_fadvise64(struct tcb *tcp)
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002593{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002594 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002595 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +03002596 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenkod33e72a2012-05-18 02:03:24 +02002597 argn = printllval(tcp, ", %lld", 1);
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002598 tprintf(", %ld, ", tcp->u_arg[argn++]);
2599 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002600 }
2601 return 0;
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002602}
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002603
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002604int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002605sys_fadvise64_64(struct tcb *tcp)
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002606{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002607 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002608 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +03002609 printfd(tcp, tcp->u_arg[0]);
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002610#if defined ARM || defined POWERPC
Denys Vlasenkod33e72a2012-05-18 02:03:24 +02002611 argn = printllval(tcp, ", %lld, ", 2);
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002612#else
Denys Vlasenkod33e72a2012-05-18 02:03:24 +02002613 argn = printllval(tcp, ", %lld, ", 1);
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002614#endif
2615 argn = printllval(tcp, "%lld, ", argn);
2616#if defined ARM || defined POWERPC
Kirill A. Shutemov896db212009-09-19 03:21:33 +03002617 printxval(advise, tcp->u_arg[1], "POSIX_FADV_???");
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002618#else
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002619 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002620#endif
Denys Vlasenko1d632462009-04-14 12:51:00 +00002621 }
2622 return 0;
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002623}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002624
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002625static const struct xlat inotify_modes[] = {
Dmitry V. Levind475c062011-03-03 01:02:41 +00002626 { 0x00000001, "IN_ACCESS" },
2627 { 0x00000002, "IN_MODIFY" },
2628 { 0x00000004, "IN_ATTRIB" },
2629 { 0x00000008, "IN_CLOSE_WRITE"},
2630 { 0x00000010, "IN_CLOSE_NOWRITE"},
2631 { 0x00000020, "IN_OPEN" },
2632 { 0x00000040, "IN_MOVED_FROM" },
2633 { 0x00000080, "IN_MOVED_TO" },
2634 { 0x00000100, "IN_CREATE" },
2635 { 0x00000200, "IN_DELETE" },
2636 { 0x00000400, "IN_DELETE_SELF"},
2637 { 0x00000800, "IN_MOVE_SELF" },
2638 { 0x00002000, "IN_UNMOUNT" },
2639 { 0x00004000, "IN_Q_OVERFLOW" },
2640 { 0x00008000, "IN_IGNORED" },
2641 { 0x01000000, "IN_ONLYDIR" },
2642 { 0x02000000, "IN_DONT_FOLLOW"},
2643 { 0x20000000, "IN_MASK_ADD" },
2644 { 0x40000000, "IN_ISDIR" },
2645 { 0x80000000, "IN_ONESHOT" },
2646 { 0, NULL }
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002647};
2648
Sebastian Pipping1e1405a2011-03-03 00:50:55 +01002649static const struct xlat inotify_init_flags[] = {
2650 { 0x00000800, "IN_NONBLOCK" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002651 { 0x00080000, "IN_CLOEXEC" },
2652 { 0, NULL }
Sebastian Pipping1e1405a2011-03-03 00:50:55 +01002653};
2654
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002655int
2656sys_inotify_add_watch(struct tcb *tcp)
2657{
2658 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002659 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002660 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002661 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002662 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002663 printflags(inotify_modes, tcp->u_arg[2], "IN_???");
2664 }
2665 return 0;
2666}
2667
2668int
2669sys_inotify_rm_watch(struct tcb *tcp)
2670{
2671 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002672 printfd(tcp, tcp->u_arg[0]);
Dmitry V. Levinab1a70c2012-03-11 15:33:34 +00002673 tprintf(", %d", (int) tcp->u_arg[1]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002674 }
2675 return 0;
2676}
Roland McGrath96a96612008-05-20 04:56:18 +00002677
2678int
Mark Wielaardbab89402010-03-21 14:41:26 +01002679sys_inotify_init1(struct tcb *tcp)
2680{
2681 if (entering(tcp))
Sebastian Pipping1e1405a2011-03-03 00:50:55 +01002682 printflags(inotify_init_flags, tcp->u_arg[0], "IN_???");
Mark Wielaardbab89402010-03-21 14:41:26 +01002683 return 0;
2684}
2685
2686int
Roland McGrath96a96612008-05-20 04:56:18 +00002687sys_fallocate(struct tcb *tcp)
2688{
2689 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002690 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +03002691 printfd(tcp, tcp->u_arg[0]); /* fd */
Denys Vlasenkod33e72a2012-05-18 02:03:24 +02002692 tprintf(", %#lo, ", tcp->u_arg[1]); /* mode */
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002693 argn = printllval(tcp, "%llu, ", 2); /* offset */
2694 printllval(tcp, "%llu", argn); /* len */
Roland McGrath96a96612008-05-20 04:56:18 +00002695 }
2696 return 0;
2697}
Dmitry V. Levin88293652012-03-09 21:02:19 +00002698
Dmitry V. Levinad0c01e2012-03-15 00:52:22 +00002699#ifndef SWAP_FLAG_PREFER
2700# define SWAP_FLAG_PREFER 0x8000
2701#endif
2702#ifndef SWAP_FLAG_DISCARD
2703# define SWAP_FLAG_DISCARD 0x10000
2704#endif
Dmitry V. Levin88293652012-03-09 21:02:19 +00002705static const struct xlat swap_flags[] = {
2706 { SWAP_FLAG_PREFER, "SWAP_FLAG_PREFER" },
2707 { SWAP_FLAG_DISCARD, "SWAP_FLAG_DISCARD" },
2708 { 0, NULL }
2709};
2710
2711int
2712sys_swapon(struct tcb *tcp)
2713{
2714 if (entering(tcp)) {
2715 int flags = tcp->u_arg[1];
2716 printpath(tcp, tcp->u_arg[0]);
2717 tprints(", ");
2718 printflags(swap_flags, flags & ~SWAP_FLAG_PRIO_MASK,
2719 "SWAP_FLAG_???");
2720 if (flags & SWAP_FLAG_PREFER)
2721 tprintf("|%d", flags & SWAP_FLAG_PRIO_MASK);
2722 }
2723 return 0;
2724}
H.J. Lu085e4282012-04-17 11:05:04 -07002725
2726#ifdef X32
2727# undef stat64
2728# undef sys_fstat64
2729# undef sys_stat64
2730
2731static void
2732realprintstat64(struct tcb *tcp, long addr)
2733{
2734 struct stat64 statbuf;
2735
2736 if (!addr) {
2737 tprints("NULL");
2738 return;
2739 }
2740 if (syserror(tcp) || !verbose(tcp)) {
2741 tprintf("%#lx", addr);
2742 return;
2743 }
2744
2745 if (umove(tcp, addr, &statbuf) < 0) {
2746 tprints("{...}");
2747 return;
2748 }
2749
2750 if (!abbrev(tcp)) {
2751 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
2752 (unsigned long) major(statbuf.st_dev),
2753 (unsigned long) minor(statbuf.st_dev),
2754 (unsigned long long) statbuf.st_ino,
2755 sprintmode(statbuf.st_mode));
2756 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
2757 (unsigned long) statbuf.st_nlink,
2758 (unsigned long) statbuf.st_uid,
2759 (unsigned long) statbuf.st_gid);
2760 tprintf("st_blksize=%lu, ",
2761 (unsigned long) statbuf.st_blksize);
2762 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
2763 }
2764 else
2765 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
2766 switch (statbuf.st_mode & S_IFMT) {
2767 case S_IFCHR: case S_IFBLK:
2768 tprintf("st_rdev=makedev(%lu, %lu), ",
2769 (unsigned long) major(statbuf.st_rdev),
2770 (unsigned long) minor(statbuf.st_rdev));
2771 break;
2772 default:
2773 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
2774 break;
2775 }
2776 if (!abbrev(tcp)) {
2777 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
2778 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
2779 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
2780 tprints("}");
2781 }
2782 else
2783 tprints("...}");
2784}
2785
2786int
2787sys_fstat64(struct tcb *tcp)
2788{
2789 if (entering(tcp)) {
2790 printfd(tcp, tcp->u_arg[0]);
2791 tprints(", ");
2792 } else {
2793 realprintstat64(tcp, tcp->u_arg[1]);
2794 }
2795 return 0;
2796}
2797
2798int
2799sys_stat64(struct tcb *tcp)
2800{
2801 if (entering(tcp)) {
2802 printpath(tcp, tcp->u_arg[0]);
2803 tprints(", ");
2804 } else {
2805 realprintstat64(tcp, tcp->u_arg[1]);
2806 }
2807 return 0;
2808}
2809#endif