blob: 0cda7e127b71342674c316d23c93eefd5437febb [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 Vlasenko84703742012-02-25 02:38:52 +010035#ifdef LINUXSPARC
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};
Denys Vlasenko84703742012-02-25 02:38:52 +0100121#else
122# undef dev_t
123# undef ino_t
124# undef mode_t
125# undef nlink_t
126# undef uid_t
127# undef gid_t
128# undef off_t
129# undef loff_t
Denys Vlasenko84703742012-02-25 02:38:52 +0100130# define dev_t __kernel_dev_t
131# define ino_t __kernel_ino_t
132# define mode_t __kernel_mode_t
133# define nlink_t __kernel_nlink_t
134# define uid_t __kernel_uid_t
135# define gid_t __kernel_gid_t
136# define off_t __kernel_off_t
137# define loff_t __kernel_loff_t
Wichert Akkermana6013701999-07-08 14:00:58 +0000138
Denys Vlasenko84703742012-02-25 02:38:52 +0100139# include <asm/stat.h>
Wichert Akkermana6013701999-07-08 14:00:58 +0000140
Denys Vlasenko84703742012-02-25 02:38:52 +0100141# undef dev_t
142# undef ino_t
143# undef mode_t
144# undef nlink_t
145# undef uid_t
146# undef gid_t
147# undef off_t
148# undef loff_t
Denys Vlasenko84703742012-02-25 02:38:52 +0100149# define dev_t dev_t
150# define ino_t ino_t
151# define mode_t mode_t
152# define nlink_t nlink_t
153# define uid_t uid_t
154# define gid_t gid_t
155# define off_t off_t
156# define loff_t loff_t
157#endif
158
159#ifdef HPPA /* asm-parisc/stat.h defines stat64 */
160# undef stat64
161#endif
162#define stat libc_stat
163#define stat64 libc_stat64
164#include <sys/stat.h>
165#undef stat
166#undef stat64
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100167/* These might be macros. */
Denys Vlasenko84703742012-02-25 02:38:52 +0100168#undef st_atime
169#undef st_mtime
170#undef st_ctime
171#ifdef HPPA
172# define stat64 hpux_stat64
173#endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000174
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000175#include <fcntl.h>
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000176#ifdef HAVE_SYS_VFS_H
Denys Vlasenko84703742012-02-25 02:38:52 +0100177# include <sys/vfs.h>
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000178#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +0000179#ifdef HAVE_LINUX_XATTR_H
Denys Vlasenko84703742012-02-25 02:38:52 +0100180# include <linux/xattr.h>
Denys Vlasenkoed720fd2012-02-25 02:24:03 +0100181#else
Denys Vlasenko84703742012-02-25 02:38:52 +0100182# define XATTR_CREATE 1
183# define XATTR_REPLACE 2
Roland McGrath186c5ac2002-12-15 23:58:23 +0000184#endif
185
John Hughes70623be2001-03-08 13:59:00 +0000186#if HAVE_LONG_LONG_OFF_T
187/*
188 * Ugly hacks for systems that have typedef long long off_t
189 */
Denys Vlasenko84703742012-02-25 02:38:52 +0100190# define stat64 stat
191# define HAVE_STAT64 1 /* Ugly hack */
Denys Vlasenko84703742012-02-25 02:38:52 +0100192# define sys_stat64 sys_stat
193# define sys_fstat64 sys_fstat
194# define sys_lstat64 sys_lstat
Denys Vlasenko84703742012-02-25 02:38:52 +0100195# define sys_truncate64 sys_truncate
196# define sys_ftruncate64 sys_ftruncate
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000197#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000198
199#ifdef MAJOR_IN_SYSMACROS
Denys Vlasenko84703742012-02-25 02:38:52 +0100200# include <sys/sysmacros.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000201#endif
202
203#ifdef MAJOR_IN_MKDEV
Denys Vlasenko84703742012-02-25 02:38:52 +0100204# include <sys/mkdev.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000205#endif
206
207#ifdef HAVE_SYS_ASYNCH_H
Denys Vlasenko84703742012-02-25 02:38:52 +0100208# include <sys/asynch.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000209#endif
210
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100211struct kernel_dirent {
212 unsigned long d_ino;
213 unsigned long d_off;
214 unsigned short d_reclen;
215 char d_name[1];
216};
217
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000218const struct xlat open_access_modes[] = {
219 { O_RDONLY, "O_RDONLY" },
220 { O_WRONLY, "O_WRONLY" },
221 { O_RDWR, "O_RDWR" },
222#ifdef O_ACCMODE
223 { O_ACCMODE, "O_ACCMODE" },
224#endif
225 { 0, NULL },
226};
227
228const struct xlat open_mode_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000229 { O_CREAT, "O_CREAT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000230 { O_EXCL, "O_EXCL" },
231 { O_NOCTTY, "O_NOCTTY" },
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000232 { O_TRUNC, "O_TRUNC" },
233 { O_APPEND, "O_APPEND" },
234 { O_NONBLOCK, "O_NONBLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000235#ifdef O_SYNC
236 { O_SYNC, "O_SYNC" },
237#endif
238#ifdef O_ASYNC
239 { O_ASYNC, "O_ASYNC" },
240#endif
241#ifdef O_DSYNC
242 { O_DSYNC, "O_DSYNC" },
243#endif
244#ifdef O_RSYNC
245 { O_RSYNC, "O_RSYNC" },
246#endif
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000247#if defined(O_NDELAY) && (O_NDELAY != O_NONBLOCK)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000248 { O_NDELAY, "O_NDELAY" },
249#endif
250#ifdef O_PRIV
251 { O_PRIV, "O_PRIV" },
252#endif
253#ifdef O_DIRECT
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000254 { O_DIRECT, "O_DIRECT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000255#endif
256#ifdef O_LARGEFILE
Roland McGrathfee836e2005-02-02 22:11:32 +0000257# if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
258# undef O_LARGEFILE
259# ifdef SPARC64
260# define O_LARGEFILE 0x40000
261# elif defined X86_64 || defined S390X
262# define O_LARGEFILE 0100000
263# endif
264# endif
Roland McGrath663a8a02005-02-04 09:49:56 +0000265# ifdef O_LARGEFILE
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200266 { O_LARGEFILE, "O_LARGEFILE" },
Roland McGrath663a8a02005-02-04 09:49:56 +0000267# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000268#endif
269#ifdef O_DIRECTORY
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200270 { O_DIRECTORY, "O_DIRECTORY" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000271#endif
272#ifdef O_NOFOLLOW
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200273 { O_NOFOLLOW, "O_NOFOLLOW" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000274#endif
Roland McGrath1025c3e2005-05-09 07:40:35 +0000275#ifdef O_NOATIME
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200276 { O_NOATIME, "O_NOATIME" },
Roland McGrath1025c3e2005-05-09 07:40:35 +0000277#endif
Roland McGrath71d3d662007-08-07 01:00:26 +0000278#ifdef O_CLOEXEC
279 { O_CLOEXEC, "O_CLOEXEC" },
280#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000281#ifdef FNDELAY
282 { FNDELAY, "FNDELAY" },
283#endif
284#ifdef FAPPEND
285 { FAPPEND, "FAPPEND" },
286#endif
287#ifdef FMARK
288 { FMARK, "FMARK" },
289#endif
290#ifdef FDEFER
291 { FDEFER, "FDEFER" },
292#endif
293#ifdef FASYNC
294 { FASYNC, "FASYNC" },
295#endif
296#ifdef FSHLOCK
297 { FSHLOCK, "FSHLOCK" },
298#endif
299#ifdef FEXLOCK
300 { FEXLOCK, "FEXLOCK" },
301#endif
302#ifdef FCREAT
303 { FCREAT, "FCREAT" },
304#endif
305#ifdef FTRUNC
306 { FTRUNC, "FTRUNC" },
307#endif
308#ifdef FEXCL
309 { FEXCL, "FEXCL" },
310#endif
311#ifdef FNBIO
312 { FNBIO, "FNBIO" },
313#endif
314#ifdef FSYNC
315 { FSYNC, "FSYNC" },
316#endif
317#ifdef FNOCTTY
318 { FNOCTTY, "FNOCTTY" },
Roland McGrath186c5ac2002-12-15 23:58:23 +0000319#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000320#ifdef O_SHLOCK
321 { O_SHLOCK, "O_SHLOCK" },
322#endif
323#ifdef O_EXLOCK
324 { O_EXLOCK, "O_EXLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000325#endif
326 { 0, NULL },
327};
328
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000329#ifndef AT_FDCWD
330# define AT_FDCWD -100
331#endif
332
Denys Vlasenkoe740fd32009-04-16 12:06:16 +0000333/* The fd is an "int", so when decoding x86 on x86_64, we need to force sign
334 * extension to get the right value. We do this by declaring fd as int here.
335 */
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000336static void
Dmitry V. Levin31382132011-03-04 05:08:02 +0300337print_dirfd(struct tcb *tcp, int fd)
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000338{
339 if (fd == AT_FDCWD)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200340 tprints("AT_FDCWD, ");
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200341 else {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300342 printfd(tcp, fd);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200343 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +0300344 }
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000345}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000346
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000347/*
348 * low bits of the open(2) flags define access mode,
349 * other bits are real flags.
350 */
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000351const char *
352sprint_open_modes(mode_t flags)
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000353{
Denys Vlasenko4f3df072012-01-29 22:38:35 +0100354 static char outstr[(1 + ARRAY_SIZE(open_mode_flags)) * sizeof("O_LARGEFILE")];
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000355 char *p;
Denys Vlasenko4f3df072012-01-29 22:38:35 +0100356 char sep;
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000357 const char *str;
358 const struct xlat *x;
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000359
Denys Vlasenko4f3df072012-01-29 22:38:35 +0100360 sep = ' ';
361 p = stpcpy(outstr, "flags");
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000362 str = xlookup(open_access_modes, flags & 3);
363 if (str) {
Denys Vlasenko4f3df072012-01-29 22:38:35 +0100364 *p++ = sep;
Denys Vlasenko52845572011-08-31 12:07:38 +0200365 p = stpcpy(p, str);
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000366 flags &= ~3;
367 if (!flags)
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000368 return outstr;
369 sep = '|';
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000370 }
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000371
372 for (x = open_mode_flags; x->str; x++) {
373 if ((flags & x->val) == x->val) {
Denys Vlasenko4f3df072012-01-29 22:38:35 +0100374 *p++ = sep;
Denys Vlasenko52845572011-08-31 12:07:38 +0200375 p = stpcpy(p, x->str);
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000376 flags &= ~x->val;
377 if (!flags)
378 return outstr;
379 sep = '|';
380 }
381 }
382 /* flags is still nonzero */
Denys Vlasenko4f3df072012-01-29 22:38:35 +0100383 *p++ = sep;
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000384 sprintf(p, "%#x", flags);
385 return outstr;
386}
387
388void
389tprint_open_modes(mode_t flags)
390{
Denys Vlasenko5940e652011-09-01 09:55:05 +0200391 tprints(sprint_open_modes(flags) + sizeof("flags"));
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000392}
393
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000394static int
395decode_open(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000396{
397 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000398 printpath(tcp, tcp->u_arg[offset]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200399 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000400 /* flags */
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000401 tprint_open_modes(tcp->u_arg[offset + 1]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000402 if (tcp->u_arg[offset + 1] & O_CREAT) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000403 /* mode */
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000404 tprintf(", %#lo", tcp->u_arg[offset + 2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000405 }
406 }
407 return 0;
408}
409
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000410int
411sys_open(struct tcb *tcp)
412{
413 return decode_open(tcp, 0);
414}
415
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000416int
417sys_openat(struct tcb *tcp)
418{
419 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +0300420 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000421 return decode_open(tcp, 1);
422}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000423
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000424#ifdef LINUXSPARC
Roland McGratha4d48532005-06-08 20:45:28 +0000425static const struct xlat openmodessol[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000426 { 0, "O_RDWR" },
427 { 1, "O_RDONLY" },
428 { 2, "O_WRONLY" },
429 { 0x80, "O_NONBLOCK" },
430 { 8, "O_APPEND" },
431 { 0x100, "O_CREAT" },
432 { 0x200, "O_TRUNC" },
433 { 0x400, "O_EXCL" },
434 { 0x800, "O_NOCTTY" },
435 { 0x10, "O_SYNC" },
436 { 0x40, "O_DSYNC" },
437 { 0x8000, "O_RSYNC" },
438 { 4, "O_NDELAY" },
439 { 0x1000, "O_PRIV" },
440 { 0, NULL },
441};
442
443int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000444solaris_open(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000445{
446 if (entering(tcp)) {
447 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200448 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000449 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000450 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000451 if (tcp->u_arg[1] & 0x100) {
452 /* mode */
453 tprintf(", %#lo", tcp->u_arg[2]);
454 }
455 }
456 return 0;
457}
458
459#endif
460
461int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000462sys_creat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000463{
464 if (entering(tcp)) {
465 printpath(tcp, tcp->u_arg[0]);
466 tprintf(", %#lo", tcp->u_arg[1]);
467 }
468 return 0;
469}
470
Roland McGrathd9f816f2004-09-04 03:39:20 +0000471static const struct xlat access_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000472 { F_OK, "F_OK", },
473 { R_OK, "R_OK" },
474 { W_OK, "W_OK" },
475 { X_OK, "X_OK" },
476#ifdef EFF_ONLY_OK
477 { EFF_ONLY_OK, "EFF_ONLY_OK" },
478#endif
479#ifdef EX_OK
480 { EX_OK, "EX_OK" },
481#endif
482 { 0, NULL },
483};
484
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000485static int
486decode_access(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000487{
488 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000489 printpath(tcp, tcp->u_arg[offset]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200490 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000491 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000492 }
493 return 0;
494}
495
496int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000497sys_access(struct tcb *tcp)
498{
499 return decode_access(tcp, 0);
500}
501
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000502int
503sys_faccessat(struct tcb *tcp)
504{
505 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +0300506 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000507 return decode_access(tcp, 1);
508}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000509
510int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000511sys_umask(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000512{
513 if (entering(tcp)) {
514 tprintf("%#lo", tcp->u_arg[0]);
515 }
516 return RVAL_OCTAL;
517}
518
Roland McGrathd9f816f2004-09-04 03:39:20 +0000519static const struct xlat whence[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000520 { SEEK_SET, "SEEK_SET" },
521 { SEEK_CUR, "SEEK_CUR" },
522 { SEEK_END, "SEEK_END" },
523 { 0, NULL },
524};
525
H.J. Luc933f272012-04-16 17:41:13 +0200526#if defined(LINUX_MIPSN32) || defined(X32)
Roland McGrath542c2c62008-05-20 01:11:56 +0000527int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000528sys_lseek(struct tcb *tcp)
Roland McGrath542c2c62008-05-20 01:11:56 +0000529{
530 long long offset;
531 int _whence;
532
533 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300534 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200535 tprints(", ");
Roland McGrath542c2c62008-05-20 01:11:56 +0000536 offset = tcp->ext_arg[1];
537 _whence = tcp->u_arg[2];
538 if (_whence == SEEK_SET)
539 tprintf("%llu, ", offset);
540 else
541 tprintf("%lld, ", offset);
542 printxval(whence, _whence, "SEEK_???");
543 }
H.J. Ludd0130b2012-04-16 12:16:45 +0200544 return RVAL_LUDECIMAL;
Roland McGrath542c2c62008-05-20 01:11:56 +0000545}
H.J. Lu085e4282012-04-17 11:05:04 -0700546
547# if defined(X32)
548int
549sys_lseek32(struct tcb *tcp)
550{
551 long offset;
552 int _whence;
553
554 if (entering(tcp)) {
555 printfd(tcp, tcp->u_arg[0]);
556 tprints(", ");
557 offset = tcp->u_arg[1];
558 _whence = tcp->u_arg[2];
559 if (_whence == SEEK_SET)
560 tprintf("%lu, ", offset);
561 else
562 tprintf("%ld, ", offset);
563 printxval(whence, _whence, "SEEK_???");
564 }
565 return RVAL_UDECIMAL;
566}
567# endif
H.J. Ludd0130b2012-04-16 12:16:45 +0200568#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000569int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000570sys_lseek(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000571{
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000572 off_t offset;
573 int _whence;
574
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000575 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300576 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200577 tprints(", ");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000578 offset = tcp->u_arg[1];
579 _whence = tcp->u_arg[2];
580 if (_whence == SEEK_SET)
581 tprintf("%lu, ", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000582 else
Roland McGrath186c5ac2002-12-15 23:58:23 +0000583 tprintf("%ld, ", offset);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000584 printxval(whence, _whence, "SEEK_???");
Roland McGrath186c5ac2002-12-15 23:58:23 +0000585 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000586 return RVAL_UDECIMAL;
587}
John Hughes5a826b82001-03-07 13:21:24 +0000588#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000589
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000590int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000591sys_llseek(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000592{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000593 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300594 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000595 /*
596 * This one call takes explicitly two 32-bit arguments hi, lo,
597 * rather than one 64-bit argument for which LONG_LONG works
598 * appropriate for the native byte order.
599 */
600 if (tcp->u_arg[4] == SEEK_SET)
Dmitry V. Levin31382132011-03-04 05:08:02 +0300601 tprintf(", %llu, ",
602 ((long long int) tcp->u_arg[1]) << 32 |
603 (unsigned long long) (unsigned) tcp->u_arg[2]);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000604 else
Dmitry V. Levin31382132011-03-04 05:08:02 +0300605 tprintf(", %lld, ",
606 ((long long int) tcp->u_arg[1]) << 32 |
607 (unsigned long long) (unsigned) tcp->u_arg[2]);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000608 }
609 else {
610 long long int off;
611 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
612 tprintf("%#lx, ", tcp->u_arg[3]);
613 else
614 tprintf("[%llu], ", off);
615 printxval(whence, tcp->u_arg[4], "SEEK_???");
616 }
617 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000618}
Roland McGrath186c5ac2002-12-15 23:58:23 +0000619
620int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000621sys_readahead(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +0000622{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000623 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100624 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +0300625 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200626 tprints(", ");
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100627 argn = printllval(tcp, "%lld", 1);
628 tprintf(", %ld", tcp->u_arg[argn]);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000629 }
630 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +0000631}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000632
John Hughes70623be2001-03-08 13:59:00 +0000633#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000634int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000635sys_truncate(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000636{
637 if (entering(tcp)) {
638 printpath(tcp, tcp->u_arg[0]);
639 tprintf(", %lu", tcp->u_arg[1]);
640 }
641 return 0;
642}
John Hughes5a826b82001-03-07 13:21:24 +0000643#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000644
John Hughes70623be2001-03-08 13:59:00 +0000645#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000646int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000647sys_truncate64(struct tcb *tcp)
John Hughes96f51472001-03-06 16:50:41 +0000648{
649 if (entering(tcp)) {
650 printpath(tcp, tcp->u_arg[0]);
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100651 printllval(tcp, ", %llu", 1);
John Hughes96f51472001-03-06 16:50:41 +0000652 }
653 return 0;
654}
655#endif
656
John Hughes70623be2001-03-08 13:59:00 +0000657#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000658int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000659sys_ftruncate(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000660{
661 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300662 printfd(tcp, tcp->u_arg[0]);
663 tprintf(", %lu", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000664 }
665 return 0;
666}
John Hughes5a826b82001-03-07 13:21:24 +0000667#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000668
John Hughes70623be2001-03-08 13:59:00 +0000669#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000670int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000671sys_ftruncate64(struct tcb *tcp)
John Hughes96f51472001-03-06 16:50:41 +0000672{
673 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300674 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200675 tprints(", ");
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100676 printllval(tcp, "%llu", 1);
John Hughes96f51472001-03-06 16:50:41 +0000677 }
678 return 0;
679}
680#endif
681
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000682/* several stats */
683
Roland McGrathd9f816f2004-09-04 03:39:20 +0000684static const struct xlat modetypes[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000685 { S_IFREG, "S_IFREG" },
686 { S_IFSOCK, "S_IFSOCK" },
687 { S_IFIFO, "S_IFIFO" },
688 { S_IFLNK, "S_IFLNK" },
689 { S_IFDIR, "S_IFDIR" },
690 { S_IFBLK, "S_IFBLK" },
691 { S_IFCHR, "S_IFCHR" },
692 { 0, NULL },
693};
694
Roland McGrathf9c49b22004-10-06 22:11:54 +0000695static const char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000696sprintmode(int mode)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000697{
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100698 static char buf[sizeof("S_IFSOCK|S_ISUID|S_ISGID|S_ISVTX|%o")
699 + sizeof(int)*3
700 + /*paranoia:*/ 8];
Roland McGrathf9c49b22004-10-06 22:11:54 +0000701 const char *s;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000702
703 if ((mode & S_IFMT) == 0)
704 s = "";
705 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
706 sprintf(buf, "%#o", mode);
707 return buf;
708 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100709 s = buf + sprintf(buf, "%s%s%s%s", s,
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000710 (mode & S_ISUID) ? "|S_ISUID" : "",
711 (mode & S_ISGID) ? "|S_ISGID" : "",
712 (mode & S_ISVTX) ? "|S_ISVTX" : "");
713 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
714 if (mode)
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100715 sprintf((char*)s, "|%#o", mode);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000716 s = (*buf == '|') ? buf + 1 : buf;
717 return *s ? s : "0";
718}
719
720static char *
Dmitry V. Levindc7715b2008-04-19 23:45:09 +0000721sprinttime(time_t t)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000722{
723 struct tm *tmp;
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100724 static char buf[sizeof("yyyy/mm/dd-hh:mm:ss")];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000725
726 if (t == 0) {
Dmitry V. Levindc7715b2008-04-19 23:45:09 +0000727 strcpy(buf, "0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000728 return buf;
729 }
Denys Vlasenko5d645812011-08-20 12:48:18 +0200730 tmp = localtime(&t);
731 if (tmp)
Dmitry V. Levindc7715b2008-04-19 23:45:09 +0000732 snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d",
733 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
734 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
735 else
736 snprintf(buf, sizeof buf, "%lu", (unsigned long) t);
737
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000738 return buf;
739}
740
741#ifdef LINUXSPARC
742typedef struct {
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000743 int tv_sec;
744 int tv_nsec;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000745} timestruct_t;
746
747struct solstat {
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000748 unsigned st_dev;
749 int st_pad1[3]; /* network id */
750 unsigned st_ino;
751 unsigned st_mode;
752 unsigned st_nlink;
753 unsigned st_uid;
754 unsigned st_gid;
755 unsigned st_rdev;
756 int st_pad2[2];
757 int st_size;
758 int st_pad3; /* st_size, off_t expansion */
759 timestruct_t st_atime;
760 timestruct_t st_mtime;
761 timestruct_t st_ctime;
762 int st_blksize;
763 int st_blocks;
764 char st_fstype[16];
765 int st_pad4[8]; /* expansion area */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000766};
767
768static void
Dmitry V. Levinb838b1e2008-04-19 23:47:47 +0000769printstatsol(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000770{
771 struct solstat statbuf;
772
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000773 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200774 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000775 return;
776 }
777 if (!abbrev(tcp)) {
778 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
779 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
780 (unsigned long) (statbuf.st_dev & 0x3ffff),
781 (unsigned long) statbuf.st_ino,
782 sprintmode(statbuf.st_mode));
783 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
784 (unsigned long) statbuf.st_nlink,
785 (unsigned long) statbuf.st_uid,
786 (unsigned long) statbuf.st_gid);
787 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
788 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
789 }
790 else
791 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
792 switch (statbuf.st_mode & S_IFMT) {
793 case S_IFCHR: case S_IFBLK:
794 tprintf("st_rdev=makedev(%lu, %lu), ",
795 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
796 (unsigned long) (statbuf.st_rdev & 0x3ffff));
797 break;
798 default:
799 tprintf("st_size=%u, ", statbuf.st_size);
800 break;
801 }
802 if (!abbrev(tcp)) {
Dmitry V. Levinb838b1e2008-04-19 23:47:47 +0000803 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
804 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
805 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000806 }
807 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200808 tprints("...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000809}
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000810
Denys Vlasenkoc36c3522012-02-25 02:47:15 +0100811#if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000812static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000813printstat_sparc64(struct tcb *tcp, long addr)
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000814{
815 struct stat_sparc64 statbuf;
816
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000817 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200818 tprints("{...}");
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000819 return;
820 }
821
822 if (!abbrev(tcp)) {
823 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
824 (unsigned long) major(statbuf.st_dev),
825 (unsigned long) minor(statbuf.st_dev),
826 (unsigned long) statbuf.st_ino,
827 sprintmode(statbuf.st_mode));
828 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
829 (unsigned long) statbuf.st_nlink,
830 (unsigned long) statbuf.st_uid,
831 (unsigned long) statbuf.st_gid);
832 tprintf("st_blksize=%lu, ",
833 (unsigned long) statbuf.st_blksize);
834 tprintf("st_blocks=%lu, ",
835 (unsigned long) statbuf.st_blocks);
836 }
837 else
838 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
839 switch (statbuf.st_mode & S_IFMT) {
840 case S_IFCHR: case S_IFBLK:
841 tprintf("st_rdev=makedev(%lu, %lu), ",
842 (unsigned long) major(statbuf.st_rdev),
843 (unsigned long) minor(statbuf.st_rdev));
844 break;
845 default:
846 tprintf("st_size=%lu, ", statbuf.st_size);
847 break;
848 }
849 if (!abbrev(tcp)) {
850 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
851 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100852 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000853 }
854 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200855 tprints("...}");
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000856}
857#endif /* SPARC64 */
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000858#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000859
Denys Vlasenko84703742012-02-25 02:38:52 +0100860#if defined POWERPC64
Andreas Schwabd69fa492010-07-12 21:39:57 +0200861struct stat_powerpc32 {
862 unsigned int st_dev;
863 unsigned int st_ino;
864 unsigned int st_mode;
865 unsigned short st_nlink;
866 unsigned int st_uid;
867 unsigned int st_gid;
868 unsigned int st_rdev;
869 unsigned int st_size;
870 unsigned int st_blksize;
871 unsigned int st_blocks;
872 unsigned int st_atime;
873 unsigned int st_atime_nsec;
874 unsigned int st_mtime;
875 unsigned int st_mtime_nsec;
876 unsigned int st_ctime;
877 unsigned int st_ctime_nsec;
878 unsigned int __unused4;
879 unsigned int __unused5;
880};
881
882static void
883printstat_powerpc32(struct tcb *tcp, long addr)
884{
885 struct stat_powerpc32 statbuf;
886
887 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200888 tprints("{...}");
Andreas Schwabd69fa492010-07-12 21:39:57 +0200889 return;
890 }
891
892 if (!abbrev(tcp)) {
893 tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ",
894 major(statbuf.st_dev), minor(statbuf.st_dev),
895 statbuf.st_ino,
896 sprintmode(statbuf.st_mode));
897 tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ",
898 statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid);
899 tprintf("st_blksize=%u, ", statbuf.st_blksize);
900 tprintf("st_blocks=%u, ", statbuf.st_blocks);
901 }
902 else
903 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
904 switch (statbuf.st_mode & S_IFMT) {
905 case S_IFCHR: case S_IFBLK:
906 tprintf("st_rdev=makedev(%lu, %lu), ",
907 (unsigned long) major(statbuf.st_rdev),
908 (unsigned long) minor(statbuf.st_rdev));
909 break;
910 default:
911 tprintf("st_size=%u, ", statbuf.st_size);
912 break;
913 }
914 if (!abbrev(tcp)) {
915 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
916 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100917 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
Andreas Schwabd69fa492010-07-12 21:39:57 +0200918 }
919 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200920 tprints("...}");
Andreas Schwabd69fa492010-07-12 21:39:57 +0200921}
Denys Vlasenko84703742012-02-25 02:38:52 +0100922#endif /* POWERPC64 */
Andreas Schwabd69fa492010-07-12 21:39:57 +0200923
Roland McGratha4d48532005-06-08 20:45:28 +0000924static const struct xlat fileflags[] = {
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000925 { 0, NULL },
926};
927
John Hughes70623be2001-03-08 13:59:00 +0000928#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000929static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000930realprintstat(struct tcb *tcp, struct stat *statbuf)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000931{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000932 if (!abbrev(tcp)) {
933 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
934 (unsigned long) major(statbuf->st_dev),
935 (unsigned long) minor(statbuf->st_dev),
936 (unsigned long) statbuf->st_ino,
937 sprintmode(statbuf->st_mode));
938 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
939 (unsigned long) statbuf->st_nlink,
940 (unsigned long) statbuf->st_uid,
941 (unsigned long) statbuf->st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000942#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Denys Vlasenko1d632462009-04-14 12:51:00 +0000943 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
944#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000945#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Denys Vlasenko1d632462009-04-14 12:51:00 +0000946 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
947#endif
948 }
949 else
950 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
951 switch (statbuf->st_mode & S_IFMT) {
952 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +0000953#ifdef HAVE_STRUCT_STAT_ST_RDEV
Denys Vlasenko1d632462009-04-14 12:51:00 +0000954 tprintf("st_rdev=makedev(%lu, %lu), ",
955 (unsigned long) major(statbuf->st_rdev),
956 (unsigned long) minor(statbuf->st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000957#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000958 tprintf("st_size=makedev(%lu, %lu), ",
959 (unsigned long) major(statbuf->st_size),
960 (unsigned long) minor(statbuf->st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000961#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000962 break;
963 default:
Dmitry V. Levine9a06b72011-02-23 16:16:50 +0000964 tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000965 break;
966 }
967 if (!abbrev(tcp)) {
968 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
969 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
970 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000971#if HAVE_STRUCT_STAT_ST_FLAGS
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200972 tprints(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +0000973 printflags(fileflags, statbuf->st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +0000974#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000975#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +0000976 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
977#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000978#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +0000979 tprintf(", st_level=%ld", statbuf->st_level);
980#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000981#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +0000982 tprintf(", st_fstype=%.*s",
983 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
984#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000985#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +0000986 tprintf(", st_gen=%u", statbuf->st_gen);
987#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200988 tprints("}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000989 }
990 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200991 tprints("...}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000992}
993
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000994static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000995printstat(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000996{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000997 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000998
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000999 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001000 tprints("NULL");
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001001 return;
1002 }
1003 if (syserror(tcp) || !verbose(tcp)) {
1004 tprintf("%#lx", addr);
1005 return;
1006 }
1007
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001008#ifdef LINUXSPARC
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00001009 if (current_personality == 1) {
1010 printstatsol(tcp, addr);
1011 return;
1012 }
Roland McGrath6d1a65c2004-07-12 07:44:08 +00001013#ifdef SPARC64
1014 else if (current_personality == 2) {
1015 printstat_sparc64(tcp, addr);
1016 return;
1017 }
1018#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001019#endif /* LINUXSPARC */
1020
Denys Vlasenko84703742012-02-25 02:38:52 +01001021#if defined POWERPC64
Andreas Schwabd69fa492010-07-12 21:39:57 +02001022 if (current_personality == 1) {
1023 printstat_powerpc32(tcp, addr);
1024 return;
1025 }
1026#endif
1027
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001028 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001029 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001030 return;
1031 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001032
1033 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001034}
John Hughes70623be2001-03-08 13:59:00 +00001035#endif /* !HAVE_LONG_LONG_OFF_T */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001036
Denys Vlasenko84703742012-02-25 02:38:52 +01001037#if !defined HAVE_STAT64 && defined X86_64
Roland McGrathe6d0f712007-08-07 01:22:49 +00001038/*
1039 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
1040 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
1041 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
1042 * __GNUC__ is needed for the required __attribute__ below.
1043 */
1044struct stat64 {
1045 unsigned long long st_dev;
1046 unsigned char __pad0[4];
1047 unsigned int __st_ino;
1048 unsigned int st_mode;
1049 unsigned int st_nlink;
1050 unsigned int st_uid;
1051 unsigned int st_gid;
1052 unsigned long long st_rdev;
1053 unsigned char __pad3[4];
1054 long long st_size;
1055 unsigned int st_blksize;
1056 unsigned long long st_blocks;
1057 unsigned int st_atime;
1058 unsigned int st_atime_nsec;
1059 unsigned int st_mtime;
1060 unsigned int st_mtime_nsec;
1061 unsigned int st_ctime;
1062 unsigned int st_ctime_nsec;
1063 unsigned long long st_ino;
1064} __attribute__((packed));
1065# define HAVE_STAT64 1
1066# define STAT64_SIZE 96
1067#endif
1068
Wichert Akkermanc7926982000-04-10 22:22:31 +00001069#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001070static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001071printstat64(struct tcb *tcp, long addr)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001072{
1073 struct stat64 statbuf;
1074
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001075#ifdef STAT64_SIZE
Roland McGrathe6d0f712007-08-07 01:22:49 +00001076 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
1077#endif
1078
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001079 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001080 tprints("NULL");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001081 return;
1082 }
1083 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001084 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001085 return;
1086 }
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001087
1088#ifdef LINUXSPARC
1089 if (current_personality == 1) {
1090 printstatsol(tcp, addr);
1091 return;
1092 }
1093# ifdef SPARC64
1094 else if (current_personality == 2) {
1095 printstat_sparc64(tcp, addr);
1096 return;
1097 }
1098# endif
1099#endif /* LINUXSPARC */
1100
Denys Vlasenko84703742012-02-25 02:38:52 +01001101#if defined X86_64
H.J. Lu35be5812012-04-16 13:00:01 +02001102 if (current_personality != 1) {
Andreas Schwab61b74352009-10-16 11:37:13 +02001103 printstat(tcp, addr);
1104 return;
1105 }
1106#endif
Dmitry V. Levinff896f72009-10-21 13:43:57 +00001107
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001108 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001109 tprints("{...}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001110 return;
1111 }
1112
1113 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +00001114#ifdef HAVE_LONG_LONG
1115 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1116#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001117 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
Wichert Akkermand077c452000-08-10 18:16:15 +00001118#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001119 (unsigned long) major(statbuf.st_dev),
1120 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +00001121#ifdef HAVE_LONG_LONG
1122 (unsigned long long) statbuf.st_ino,
1123#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001124 (unsigned long) statbuf.st_ino,
Wichert Akkermand077c452000-08-10 18:16:15 +00001125#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001126 sprintmode(statbuf.st_mode));
1127 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1128 (unsigned long) statbuf.st_nlink,
1129 (unsigned long) statbuf.st_uid,
1130 (unsigned long) statbuf.st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001131#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001132 tprintf("st_blksize=%lu, ",
1133 (unsigned long) statbuf.st_blksize);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001134#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
1135#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001136 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001137#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001138 }
1139 else
1140 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1141 switch (statbuf.st_mode & S_IFMT) {
1142 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +00001143#ifdef HAVE_STRUCT_STAT_ST_RDEV
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001144 tprintf("st_rdev=makedev(%lu, %lu), ",
1145 (unsigned long) major(statbuf.st_rdev),
1146 (unsigned long) minor(statbuf.st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001147#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001148 tprintf("st_size=makedev(%lu, %lu), ",
1149 (unsigned long) major(statbuf.st_size),
1150 (unsigned long) minor(statbuf.st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001151#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001152 break;
1153 default:
Roland McGrathc7bd4d32007-08-07 01:05:19 +00001154#ifdef HAVE_LONG_LONG
1155 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1156#else
1157 tprintf("st_size=%lu, ", (unsigned long) statbuf.st_size);
1158#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001159 break;
1160 }
1161 if (!abbrev(tcp)) {
1162 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1163 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +00001164 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001165#if HAVE_STRUCT_STAT_ST_FLAGS
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001166 tprints(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +00001167 printflags(fileflags, statbuf.st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +00001168#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001169#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +00001170 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1171#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001172#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +00001173 tprintf(", st_level=%ld", statbuf.st_level);
1174#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001175#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +00001176 tprintf(", st_fstype=%.*s",
1177 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1178#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001179#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +00001180 tprintf(", st_gen=%u", statbuf.st_gen);
1181#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001182 tprints("}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001183 }
1184 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001185 tprints("...}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001186}
Wichert Akkermanc7926982000-04-10 22:22:31 +00001187#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001188
Denys Vlasenko84703742012-02-25 02:38:52 +01001189#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001190static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001191convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001192{
Denys Vlasenko1d632462009-04-14 12:51:00 +00001193 newbuf->st_dev = oldbuf->st_dev;
1194 newbuf->st_ino = oldbuf->st_ino;
1195 newbuf->st_mode = oldbuf->st_mode;
1196 newbuf->st_nlink = oldbuf->st_nlink;
1197 newbuf->st_uid = oldbuf->st_uid;
1198 newbuf->st_gid = oldbuf->st_gid;
1199 newbuf->st_rdev = oldbuf->st_rdev;
1200 newbuf->st_size = oldbuf->st_size;
1201 newbuf->st_atime = oldbuf->st_atime;
1202 newbuf->st_mtime = oldbuf->st_mtime;
1203 newbuf->st_ctime = oldbuf->st_ctime;
1204 newbuf->st_blksize = 0; /* not supported in old_stat */
1205 newbuf->st_blocks = 0; /* not supported in old_stat */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001206}
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001207
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001208static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001209printoldstat(struct tcb *tcp, long addr)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001210{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +00001211 struct __old_kernel_stat statbuf;
1212 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001213
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001214 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001215 tprints("NULL");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001216 return;
1217 }
1218 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001219 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001220 return;
1221 }
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001222
Denys Vlasenko84703742012-02-25 02:38:52 +01001223# ifdef LINUXSPARC
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001224 if (current_personality == 1) {
1225 printstatsol(tcp, addr);
1226 return;
1227 }
Denys Vlasenko84703742012-02-25 02:38:52 +01001228# endif
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001229
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001230 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001231 tprints("{...}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001232 return;
1233 }
1234
1235 convertoldstat(&statbuf, &newstatbuf);
1236 realprintstat(tcp, &newstatbuf);
1237}
Denys Vlasenko84703742012-02-25 02:38:52 +01001238#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001239
John Hughes70623be2001-03-08 13:59:00 +00001240#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001241int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001242sys_stat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001243{
1244 if (entering(tcp)) {
1245 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001246 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001247 } else {
1248 printstat(tcp, tcp->u_arg[1]);
1249 }
1250 return 0;
1251}
John Hughesb8c9f772001-03-07 16:53:07 +00001252#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001253
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001254int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001255sys_stat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001256{
1257#ifdef HAVE_STAT64
1258 if (entering(tcp)) {
1259 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001260 tprints(", ");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001261 } else {
1262 printstat64(tcp, tcp->u_arg[1]);
1263 }
1264 return 0;
1265#else
1266 return printargs(tcp);
1267#endif
1268}
1269
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001270#ifndef AT_SYMLINK_NOFOLLOW
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001271# define AT_SYMLINK_NOFOLLOW 0x100
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001272#endif
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001273#ifndef AT_REMOVEDIR
1274# define AT_REMOVEDIR 0x200
1275#endif
1276#ifndef AT_SYMLINK_FOLLOW
1277# define AT_SYMLINK_FOLLOW 0x400
1278#endif
1279#ifndef AT_NO_AUTOMOUNT
1280# define AT_NO_AUTOMOUNT 0x800
1281#endif
1282#ifndef AT_EMPTY_PATH
1283# define AT_EMPTY_PATH 0x1000
1284#endif
1285
1286static const struct xlat at_flags[] = {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001287 { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" },
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001288 { AT_REMOVEDIR, "AT_REMOVEDIR" },
1289 { AT_SYMLINK_FOLLOW, "AT_SYMLINK_FOLLOW" },
1290 { AT_NO_AUTOMOUNT, "AT_NO_AUTOMOUNT" },
1291 { AT_EMPTY_PATH, "AT_EMPTY_PATH" },
1292 { 0, NULL }
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001293};
1294
1295int
1296sys_newfstatat(struct tcb *tcp)
1297{
1298 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001299 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001300 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001301 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001302 } else {
Andreas Schwabd69fa492010-07-12 21:39:57 +02001303#ifdef POWERPC64
1304 if (current_personality == 0)
1305 printstat(tcp, tcp->u_arg[2]);
1306 else
1307 printstat64(tcp, tcp->u_arg[2]);
1308#elif defined HAVE_STAT64
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001309 printstat64(tcp, tcp->u_arg[2]);
1310#else
1311 printstat(tcp, tcp->u_arg[2]);
1312#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001313 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001314 printflags(at_flags, tcp->u_arg[3], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001315 }
1316 return 0;
1317}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001318
Denys Vlasenko84703742012-02-25 02:38:52 +01001319#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001320int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001321sys_oldstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001322{
1323 if (entering(tcp)) {
1324 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001325 tprints(", ");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001326 } else {
1327 printoldstat(tcp, tcp->u_arg[1]);
1328 }
1329 return 0;
1330}
Denys Vlasenko84703742012-02-25 02:38:52 +01001331#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001332
John Hughes70623be2001-03-08 13:59:00 +00001333#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001334int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001335sys_fstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001336{
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 {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001341 printstat(tcp, tcp->u_arg[1]);
1342 }
1343 return 0;
1344}
John Hughesb8c9f772001-03-07 16:53:07 +00001345#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001346
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001347int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001348sys_fstat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001349{
1350#ifdef HAVE_STAT64
Dmitry V. Levin31382132011-03-04 05:08:02 +03001351 if (entering(tcp)) {
1352 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001353 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001354 } else {
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001355 printstat64(tcp, tcp->u_arg[1]);
1356 }
1357 return 0;
1358#else
1359 return printargs(tcp);
1360#endif
1361}
1362
Denys Vlasenko84703742012-02-25 02:38:52 +01001363#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001364int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001365sys_oldfstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001366{
Dmitry V. Levin31382132011-03-04 05:08:02 +03001367 if (entering(tcp)) {
1368 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001369 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001370 } else {
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001371 printoldstat(tcp, tcp->u_arg[1]);
1372 }
1373 return 0;
1374}
Denys Vlasenko84703742012-02-25 02:38:52 +01001375#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001376
John Hughes70623be2001-03-08 13:59:00 +00001377#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001378int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001379sys_lstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001380{
1381 if (entering(tcp)) {
1382 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001383 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001384 } else {
1385 printstat(tcp, tcp->u_arg[1]);
1386 }
1387 return 0;
1388}
John Hughesb8c9f772001-03-07 16:53:07 +00001389#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001390
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001391int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001392sys_lstat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001393{
1394#ifdef HAVE_STAT64
1395 if (entering(tcp)) {
1396 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001397 tprints(", ");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001398 } else {
1399 printstat64(tcp, tcp->u_arg[1]);
1400 }
1401 return 0;
1402#else
1403 return printargs(tcp);
1404#endif
1405}
1406
Denys Vlasenko84703742012-02-25 02:38:52 +01001407#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001408int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001409sys_oldlstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001410{
1411 if (entering(tcp)) {
1412 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001413 tprints(", ");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001414 } else {
1415 printoldstat(tcp, tcp->u_arg[1]);
1416 }
1417 return 0;
1418}
Denys Vlasenko84703742012-02-25 02:38:52 +01001419#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001420
Denys Vlasenko84703742012-02-25 02:38:52 +01001421#if defined(LINUXSPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001422
1423int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001424sys_xstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001425{
1426 if (entering(tcp)) {
1427 tprintf("%ld, ", tcp->u_arg[0]);
1428 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001429 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001430 } else {
Denys Vlasenko84703742012-02-25 02:38:52 +01001431# ifdef _STAT64_VER
John Hughes8fe2c982001-03-06 09:45:18 +00001432 if (tcp->u_arg[0] == _STAT64_VER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01001433 printstat64(tcp, tcp->u_arg[2]);
John Hughes8fe2c982001-03-06 09:45:18 +00001434 else
Denys Vlasenko84703742012-02-25 02:38:52 +01001435# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001436 printstat(tcp, tcp->u_arg[2]);
1437 }
1438 return 0;
1439}
1440
1441int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001442sys_fxstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001443{
1444 if (entering(tcp))
1445 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1446 else {
Denys Vlasenko84703742012-02-25 02:38:52 +01001447# ifdef _STAT64_VER
John Hughes8fe2c982001-03-06 09:45:18 +00001448 if (tcp->u_arg[0] == _STAT64_VER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01001449 printstat64(tcp, tcp->u_arg[2]);
John Hughes8fe2c982001-03-06 09:45:18 +00001450 else
Denys Vlasenko84703742012-02-25 02:38:52 +01001451# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001452 printstat(tcp, tcp->u_arg[2]);
1453 }
1454 return 0;
1455}
1456
1457int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001458sys_lxstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001459{
1460 if (entering(tcp)) {
1461 tprintf("%ld, ", tcp->u_arg[0]);
1462 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001463 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001464 } else {
Denys Vlasenko84703742012-02-25 02:38:52 +01001465# ifdef _STAT64_VER
John Hughes8fe2c982001-03-06 09:45:18 +00001466 if (tcp->u_arg[0] == _STAT64_VER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01001467 printstat64(tcp, tcp->u_arg[2]);
John Hughes8fe2c982001-03-06 09:45:18 +00001468 else
Denys Vlasenko84703742012-02-25 02:38:52 +01001469# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001470 printstat(tcp, tcp->u_arg[2]);
1471 }
1472 return 0;
1473}
1474
1475int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001476sys_xmknod(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001477{
1478 int mode = tcp->u_arg[2];
1479
1480 if (entering(tcp)) {
1481 tprintf("%ld, ", tcp->u_arg[0]);
1482 printpath(tcp, tcp->u_arg[1]);
1483 tprintf(", %s", sprintmode(mode));
1484 switch (mode & S_IFMT) {
1485 case S_IFCHR: case S_IFBLK:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001486 tprintf(", makedev(%lu, %lu)",
1487 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1488 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001489 break;
1490 default:
1491 break;
1492 }
1493 }
1494 return 0;
1495}
1496
Denys Vlasenko84703742012-02-25 02:38:52 +01001497# ifdef HAVE_SYS_ACL_H
Wichert Akkerman8829a551999-06-11 13:18:40 +00001498
Denys Vlasenko84703742012-02-25 02:38:52 +01001499# include <sys/acl.h>
Wichert Akkerman8829a551999-06-11 13:18:40 +00001500
Roland McGratha4d48532005-06-08 20:45:28 +00001501static const struct xlat aclcmds[] = {
Denys Vlasenko84703742012-02-25 02:38:52 +01001502# ifdef SETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001503 { SETACL, "SETACL" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001504# endif
1505# ifdef GETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001506 { GETACL, "GETACL" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001507# endif
1508# ifdef GETACLCNT
Wichert Akkerman8829a551999-06-11 13:18:40 +00001509 { GETACLCNT, "GETACLCNT" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001510# endif
1511# ifdef ACL_GET
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001512 { ACL_GET, "ACL_GET" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001513# endif
1514# ifdef ACL_SET
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001515 { ACL_SET, "ACL_SET" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001516# endif
1517# ifdef ACL_CNT
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001518 { ACL_CNT, "ACL_CNT" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001519# endif
Wichert Akkerman8829a551999-06-11 13:18:40 +00001520 { 0, NULL },
1521};
1522
1523int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001524sys_acl(struct tcb *tcp)
Wichert Akkerman8829a551999-06-11 13:18:40 +00001525{
1526 if (entering(tcp)) {
1527 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001528 tprints(", ");
Wichert Akkerman8829a551999-06-11 13:18:40 +00001529 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1530 tprintf(", %ld", tcp->u_arg[2]);
1531 /*
1532 * FIXME - dump out the list of aclent_t's pointed to
1533 * by "tcp->u_arg[3]" if it's not NULL.
1534 */
1535 if (tcp->u_arg[3])
1536 tprintf(", %#lx", tcp->u_arg[3]);
1537 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001538 tprints(", NULL");
Wichert Akkerman8829a551999-06-11 13:18:40 +00001539 }
1540 return 0;
1541}
1542
Wichert Akkerman8829a551999-06-11 13:18:40 +00001543int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001544sys_facl(struct tcb *tcp)
Wichert Akkerman8829a551999-06-11 13:18:40 +00001545{
1546 if (entering(tcp)) {
1547 tprintf("%ld, ", tcp->u_arg[0]);
1548 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1549 tprintf(", %ld", tcp->u_arg[2]);
1550 /*
1551 * FIXME - dump out the list of aclent_t's pointed to
1552 * by "tcp->u_arg[3]" if it's not NULL.
1553 */
1554 if (tcp->u_arg[3])
1555 tprintf(", %#lx", tcp->u_arg[3]);
1556 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001557 tprints(", NULL");
Wichert Akkerman8829a551999-06-11 13:18:40 +00001558 }
1559 return 0;
1560}
1561
Roland McGratha4d48532005-06-08 20:45:28 +00001562static const struct xlat aclipc[] = {
Denys Vlasenko84703742012-02-25 02:38:52 +01001563# ifdef IPC_SHM
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001564 { IPC_SHM, "IPC_SHM" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001565# endif
1566# ifdef IPC_SEM
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001567 { IPC_SEM, "IPC_SEM" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001568# endif
1569# ifdef IPC_MSG
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001570 { IPC_MSG, "IPC_MSG" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001571# endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001572 { 0, NULL },
1573};
1574
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001575int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001576sys_aclipc(struct tcb *tcp)
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001577{
1578 if (entering(tcp)) {
1579 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1580 tprintf(", %#lx, ", tcp->u_arg[1]);
1581 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1582 tprintf(", %ld", tcp->u_arg[3]);
1583 /*
1584 * FIXME - dump out the list of aclent_t's pointed to
1585 * by "tcp->u_arg[4]" if it's not NULL.
1586 */
1587 if (tcp->u_arg[4])
1588 tprintf(", %#lx", tcp->u_arg[4]);
1589 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001590 tprints(", NULL");
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001591 }
1592 return 0;
1593}
1594
Denys Vlasenko84703742012-02-25 02:38:52 +01001595# endif /* HAVE_SYS_ACL_H */
Wichert Akkerman8829a551999-06-11 13:18:40 +00001596
Denys Vlasenko84703742012-02-25 02:38:52 +01001597#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001598
Roland McGrathd9f816f2004-09-04 03:39:20 +00001599static const struct xlat fsmagic[] = {
Wichert Akkerman43a74822000-06-27 17:33:32 +00001600 { 0x73757245, "CODA_SUPER_MAGIC" },
1601 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1602 { 0x1373, "DEVFS_SUPER_MAGIC" },
1603 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1604 { 0x414A53, "EFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001605 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1606 { 0xef53, "EXT2_SUPER_MAGIC" },
1607 { 0x137d, "EXT_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001608 { 0xf995e849, "HPFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001609 { 0x9660, "ISOFS_SUPER_MAGIC" },
1610 { 0x137f, "MINIX_SUPER_MAGIC" },
1611 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001612 { 0x2468, "MINIX2_SUPER_MAGIC" },
1613 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001614 { 0x4d44, "MSDOS_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001615 { 0x564c, "NCP_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001616 { 0x6969, "NFS_SUPER_MAGIC" },
1617 { 0x9fa0, "PROC_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001618 { 0x002f, "QNX4_SUPER_MAGIC" },
1619 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1620 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1621 { 0x517b, "SMB_SUPER_MAGIC" },
1622 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1623 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1624 { 0x00011954, "UFS_MAGIC" },
1625 { 0x54190100, "UFS_CIGAM" },
1626 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001627 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
Roland McGrathc767ad82004-01-13 10:13:45 +00001628 { 0x62656572, "SYSFS_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001629 { 0, NULL },
1630};
1631
Roland McGrathf9c49b22004-10-06 22:11:54 +00001632static const char *
Denys Vlasenko1d632462009-04-14 12:51:00 +00001633sprintfstype(int magic)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001634{
1635 static char buf[32];
Roland McGrathf9c49b22004-10-06 22:11:54 +00001636 const char *s;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001637
1638 s = xlookup(fsmagic, magic);
1639 if (s) {
1640 sprintf(buf, "\"%s\"", s);
1641 return buf;
1642 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001643 sprintf(buf, "%#x", magic);
1644 return buf;
1645}
1646
1647static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001648printstatfs(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001649{
1650 struct statfs statbuf;
1651
1652 if (syserror(tcp) || !verbose(tcp)) {
1653 tprintf("%#lx", addr);
1654 return;
1655 }
1656 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001657 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001658 return;
1659 }
1660#ifdef ALPHA
1661
1662 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1663 sprintfstype(statbuf.f_type),
1664 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Roland McGrathab147c52003-07-17 09:03:02 +00001665 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001666 statbuf.f_bavail, statbuf.f_files, statbuf.f_ffree,
Roland McGrathab147c52003-07-17 09:03:02 +00001667 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1668 statbuf.f_namelen);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001669#else /* !ALPHA */
1670 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1671 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +00001672 (unsigned long)statbuf.f_bsize,
1673 (unsigned long)statbuf.f_blocks,
1674 (unsigned long)statbuf.f_bfree);
Roland McGrathab147c52003-07-17 09:03:02 +00001675 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1676 (unsigned long)statbuf.f_bavail,
Nate Sammons5c74d201999-04-06 01:37:51 +00001677 (unsigned long)statbuf.f_files,
Roland McGrathab147c52003-07-17 09:03:02 +00001678 (unsigned long)statbuf.f_ffree,
1679 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001680 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001681#endif /* !ALPHA */
Roland McGrathab147c52003-07-17 09:03:02 +00001682#ifdef _STATFS_F_FRSIZE
1683 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1684#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001685 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001686}
1687
1688int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001689sys_statfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001690{
1691 if (entering(tcp)) {
1692 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001693 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001694 } else {
1695 printstatfs(tcp, tcp->u_arg[1]);
1696 }
1697 return 0;
1698}
1699
1700int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001701sys_fstatfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001702{
1703 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001704 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001705 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001706 } else {
1707 printstatfs(tcp, tcp->u_arg[1]);
1708 }
1709 return 0;
1710}
1711
Denys Vlasenko84703742012-02-25 02:38:52 +01001712#if defined HAVE_STATFS64
Roland McGrathab147c52003-07-17 09:03:02 +00001713static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001714printstatfs64(struct tcb *tcp, long addr)
Roland McGrathab147c52003-07-17 09:03:02 +00001715{
1716 struct statfs64 statbuf;
1717
1718 if (syserror(tcp) || !verbose(tcp)) {
1719 tprintf("%#lx", addr);
1720 return;
1721 }
1722 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001723 tprints("{...}");
Roland McGrathab147c52003-07-17 09:03:02 +00001724 return;
1725 }
Roland McGrath08738432005-06-03 02:40:39 +00001726 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
Roland McGrathab147c52003-07-17 09:03:02 +00001727 sprintfstype(statbuf.f_type),
Roland McGrath08738432005-06-03 02:40:39 +00001728 (unsigned long long)statbuf.f_bsize,
1729 (unsigned long long)statbuf.f_blocks,
1730 (unsigned long long)statbuf.f_bfree);
1731 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1732 (unsigned long long)statbuf.f_bavail,
1733 (unsigned long long)statbuf.f_files,
1734 (unsigned long long)statbuf.f_ffree,
Roland McGrathab147c52003-07-17 09:03:02 +00001735 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1736 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Roland McGrathab147c52003-07-17 09:03:02 +00001737#ifdef _STATFS_F_FRSIZE
Roland McGrath08738432005-06-03 02:40:39 +00001738 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
Roland McGrathab147c52003-07-17 09:03:02 +00001739#endif
Andreas Schwab000d66f2012-01-17 18:13:33 +01001740#ifdef _STATFS_F_FLAGS
1741 tprintf(", f_flags=%llu", (unsigned long long)statbuf.f_flags);
1742#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001743 tprints("}");
Roland McGrathab147c52003-07-17 09:03:02 +00001744}
1745
Andreas Schwab7d558012012-01-17 18:14:22 +01001746struct compat_statfs64 {
1747 uint32_t f_type;
1748 uint32_t f_bsize;
1749 uint64_t f_blocks;
1750 uint64_t f_bfree;
1751 uint64_t f_bavail;
1752 uint64_t f_files;
1753 uint64_t f_ffree;
1754 fsid_t f_fsid;
1755 uint32_t f_namelen;
1756 uint32_t f_frsize;
1757 uint32_t f_flags;
1758 uint32_t f_spare[4];
1759}
1760#if defined(X86_64) || defined(IA64)
1761 __attribute__ ((packed, aligned(4)))
1762#endif
1763;
1764
1765static void
1766printcompat_statfs64(struct tcb *tcp, long addr)
1767{
1768 struct compat_statfs64 statbuf;
1769
1770 if (syserror(tcp) || !verbose(tcp)) {
1771 tprintf("%#lx", addr);
1772 return;
1773 }
1774 if (umove(tcp, addr, &statbuf) < 0) {
1775 tprints("{...}");
1776 return;
1777 }
1778 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%llu, f_bfree=%llu, ",
1779 sprintfstype(statbuf.f_type),
1780 (unsigned long)statbuf.f_bsize,
1781 (unsigned long long)statbuf.f_blocks,
1782 (unsigned long long)statbuf.f_bfree);
1783 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1784 (unsigned long long)statbuf.f_bavail,
1785 (unsigned long long)statbuf.f_files,
1786 (unsigned long long)statbuf.f_ffree,
1787 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1788 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1789 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001790 tprintf(", f_flags=%lu}", (unsigned long)statbuf.f_frsize);
Andreas Schwab7d558012012-01-17 18:14:22 +01001791}
1792
Roland McGrathab147c52003-07-17 09:03:02 +00001793int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001794sys_statfs64(struct tcb *tcp)
Roland McGrathab147c52003-07-17 09:03:02 +00001795{
1796 if (entering(tcp)) {
1797 printpath(tcp, tcp->u_arg[0]);
1798 tprintf(", %lu, ", tcp->u_arg[1]);
1799 } else {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001800 if (tcp->u_arg[1] == sizeof(struct statfs64))
Roland McGrathab147c52003-07-17 09:03:02 +00001801 printstatfs64(tcp, tcp->u_arg[2]);
Andreas Schwab7d558012012-01-17 18:14:22 +01001802 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
1803 printcompat_statfs64(tcp, tcp->u_arg[2]);
Roland McGrathab147c52003-07-17 09:03:02 +00001804 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001805 tprints("{???}");
Roland McGrathab147c52003-07-17 09:03:02 +00001806 }
1807 return 0;
1808}
1809
1810int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001811sys_fstatfs64(struct tcb *tcp)
Roland McGrathab147c52003-07-17 09:03:02 +00001812{
1813 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001814 printfd(tcp, tcp->u_arg[0]);
1815 tprintf(", %lu, ", tcp->u_arg[1]);
Roland McGrathab147c52003-07-17 09:03:02 +00001816 } else {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001817 if (tcp->u_arg[1] == sizeof(struct statfs64))
Roland McGrathab147c52003-07-17 09:03:02 +00001818 printstatfs64(tcp, tcp->u_arg[2]);
Andreas Schwab7d558012012-01-17 18:14:22 +01001819 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
1820 printcompat_statfs64(tcp, tcp->u_arg[2]);
Roland McGrathab147c52003-07-17 09:03:02 +00001821 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001822 tprints("{???}");
Roland McGrathab147c52003-07-17 09:03:02 +00001823 }
1824 return 0;
1825}
1826#endif
1827
Denys Vlasenkoc36c3522012-02-25 02:47:15 +01001828#if defined(ALPHA)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001829int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001830osf_statfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001831{
1832 if (entering(tcp)) {
1833 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001834 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001835 } else {
1836 printstatfs(tcp, tcp->u_arg[1]);
1837 tprintf(", %lu", tcp->u_arg[2]);
1838 }
1839 return 0;
1840}
1841
1842int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001843osf_fstatfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001844{
1845 if (entering(tcp)) {
1846 tprintf("%lu, ", tcp->u_arg[0]);
1847 } else {
1848 printstatfs(tcp, tcp->u_arg[1]);
1849 tprintf(", %lu", tcp->u_arg[2]);
1850 }
1851 return 0;
1852}
Denys Vlasenko84703742012-02-25 02:38:52 +01001853#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001854
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001855/* directory */
1856int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001857sys_chdir(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001858{
1859 if (entering(tcp)) {
1860 printpath(tcp, tcp->u_arg[0]);
1861 }
1862 return 0;
1863}
1864
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001865static int
1866decode_mkdir(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001867{
1868 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001869 printpath(tcp, tcp->u_arg[offset]);
1870 tprintf(", %#lo", tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001871 }
1872 return 0;
1873}
1874
1875int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001876sys_mkdir(struct tcb *tcp)
1877{
1878 return decode_mkdir(tcp, 0);
1879}
1880
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001881int
1882sys_mkdirat(struct tcb *tcp)
1883{
1884 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03001885 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001886 return decode_mkdir(tcp, 1);
1887}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001888
1889int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001890sys_link(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001891{
1892 if (entering(tcp)) {
1893 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001894 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001895 printpath(tcp, tcp->u_arg[1]);
1896 }
1897 return 0;
1898}
1899
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001900int
1901sys_linkat(struct tcb *tcp)
1902{
1903 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001904 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001905 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001906 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001907 print_dirfd(tcp, tcp->u_arg[2]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001908 printpath(tcp, tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001909 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001910 printflags(at_flags, tcp->u_arg[4], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001911 }
1912 return 0;
1913}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001914
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001915int
1916sys_unlinkat(struct tcb *tcp)
1917{
1918 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001919 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001920 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001921 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001922 printflags(at_flags, tcp->u_arg[2], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001923 }
1924 return 0;
1925}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001926
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001927int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001928sys_symlinkat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001929{
1930 if (entering(tcp)) {
1931 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001932 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001933 print_dirfd(tcp, tcp->u_arg[1]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001934 printpath(tcp, tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001935 }
1936 return 0;
1937}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001938
1939static int
1940decode_readlink(struct tcb *tcp, int offset)
1941{
1942 if (entering(tcp)) {
1943 printpath(tcp, tcp->u_arg[offset]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001944 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001945 } else {
1946 if (syserror(tcp))
1947 tprintf("%#lx", tcp->u_arg[offset + 1]);
1948 else
Denys Vlasenko3449ae82012-01-27 17:24:26 +01001949 /* Used to use printpathn(), but readlink
1950 * neither includes NUL in the returned count,
1951 * nor actually writes it into memory.
1952 * printpathn() would decide on printing
1953 * "..." continuation based on garbage
1954 * past return buffer's end.
1955 */
1956 printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001957 tprintf(", %lu", tcp->u_arg[offset + 2]);
1958 }
1959 return 0;
1960}
1961
1962int
1963sys_readlink(struct tcb *tcp)
1964{
1965 return decode_readlink(tcp, 0);
1966}
1967
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001968int
1969sys_readlinkat(struct tcb *tcp)
1970{
1971 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03001972 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001973 return decode_readlink(tcp, 1);
1974}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001975
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001976int
1977sys_renameat(struct tcb *tcp)
1978{
1979 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001980 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001981 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001982 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001983 print_dirfd(tcp, tcp->u_arg[2]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001984 printpath(tcp, tcp->u_arg[3]);
1985 }
1986 return 0;
1987}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001988
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001989int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001990sys_chown(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001991{
1992 if (entering(tcp)) {
1993 printpath(tcp, tcp->u_arg[0]);
Roland McGrath6bc12202003-11-13 22:32:27 +00001994 printuid(", ", tcp->u_arg[1]);
1995 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001996 }
1997 return 0;
1998}
1999
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002000int
2001sys_fchownat(struct tcb *tcp)
2002{
2003 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002004 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002005 printpath(tcp, tcp->u_arg[1]);
2006 printuid(", ", tcp->u_arg[2]);
2007 printuid(", ", tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002008 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00002009 printflags(at_flags, tcp->u_arg[4], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002010 }
2011 return 0;
2012}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002013
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002014int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002015sys_fchown(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002016{
2017 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002018 printfd(tcp, tcp->u_arg[0]);
Roland McGrath6bc12202003-11-13 22:32:27 +00002019 printuid(", ", tcp->u_arg[1]);
2020 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002021 }
2022 return 0;
2023}
2024
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002025static int
2026decode_chmod(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002027{
2028 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002029 printpath(tcp, tcp->u_arg[offset]);
2030 tprintf(", %#lo", tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002031 }
2032 return 0;
2033}
2034
2035int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002036sys_chmod(struct tcb *tcp)
2037{
2038 return decode_chmod(tcp, 0);
2039}
2040
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002041int
2042sys_fchmodat(struct tcb *tcp)
2043{
2044 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03002045 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002046 return decode_chmod(tcp, 1);
2047}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002048
2049int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002050sys_fchmod(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002051{
2052 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002053 printfd(tcp, tcp->u_arg[0]);
2054 tprintf(", %#lo", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002055 }
2056 return 0;
2057}
2058
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002059#ifdef ALPHA
2060int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002061sys_osf_utimes(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002062{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002063 if (entering(tcp)) {
2064 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002065 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002066 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
2067 }
2068 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002069}
2070#endif
2071
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002072static int
Roland McGrath6afc5652007-07-24 01:57:11 +00002073decode_utimes(struct tcb *tcp, int offset, int special)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002074{
2075 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002076 printpath(tcp, tcp->u_arg[offset]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002077 tprints(", ");
Roland McGrath6afc5652007-07-24 01:57:11 +00002078 if (tcp->u_arg[offset + 1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002079 tprints("NULL");
Roland McGrath6afc5652007-07-24 01:57:11 +00002080 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002081 tprints("{");
Roland McGrath6afc5652007-07-24 01:57:11 +00002082 printtv_bitness(tcp, tcp->u_arg[offset + 1],
2083 BITNESS_CURRENT, special);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002084 tprints(", ");
Roland McGrathe6d0f712007-08-07 01:22:49 +00002085 printtv_bitness(tcp, tcp->u_arg[offset + 1]
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002086 + sizeof(struct timeval),
Roland McGrath6afc5652007-07-24 01:57:11 +00002087 BITNESS_CURRENT, special);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002088 tprints("}");
Roland McGrath6afc5652007-07-24 01:57:11 +00002089 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002090 }
2091 return 0;
2092}
2093
2094int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002095sys_utimes(struct tcb *tcp)
2096{
Roland McGrath6afc5652007-07-24 01:57:11 +00002097 return decode_utimes(tcp, 0, 0);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002098}
2099
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002100int
2101sys_futimesat(struct tcb *tcp)
2102{
2103 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03002104 print_dirfd(tcp, tcp->u_arg[0]);
Roland McGrath6afc5652007-07-24 01:57:11 +00002105 return decode_utimes(tcp, 1, 0);
2106}
2107
2108int
2109sys_utimensat(struct tcb *tcp)
2110{
2111 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002112 print_dirfd(tcp, tcp->u_arg[0]);
Roland McGrath6afc5652007-07-24 01:57:11 +00002113 decode_utimes(tcp, 1, 1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002114 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00002115 printflags(at_flags, tcp->u_arg[3], "AT_???");
Roland McGrath6afc5652007-07-24 01:57:11 +00002116 }
2117 return 0;
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002118}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002119
2120int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002121sys_utime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002122{
Roland McGrath7e9817c2007-07-05 20:31:58 +00002123 union {
2124 long utl[2];
2125 int uti[2];
2126 } u;
Denys Vlasenko9fd4f962012-03-19 09:36:42 +01002127 unsigned wordsize = current_wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002128
2129 if (entering(tcp)) {
2130 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002131 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002132 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002133 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002134 else if (!verbose(tcp))
2135 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01002136 else if (umoven(tcp, tcp->u_arg[1], 2 * wordsize, (char *) &u) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002137 tprints("[?, ?]");
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01002138 else if (wordsize == sizeof u.utl[0]) {
Roland McGrath7e9817c2007-07-05 20:31:58 +00002139 tprintf("[%s,", sprinttime(u.utl[0]));
2140 tprintf(" %s]", sprinttime(u.utl[1]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002141 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01002142 else if (wordsize == sizeof u.uti[0]) {
Roland McGrath7e9817c2007-07-05 20:31:58 +00002143 tprintf("[%s,", sprinttime(u.uti[0]));
2144 tprintf(" %s]", sprinttime(u.uti[1]));
2145 }
2146 else
2147 abort();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002148 }
2149 return 0;
2150}
2151
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002152static int
2153decode_mknod(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002154{
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002155 int mode = tcp->u_arg[offset + 1];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002156
2157 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002158 printpath(tcp, tcp->u_arg[offset]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002159 tprintf(", %s", sprintmode(mode));
2160 switch (mode & S_IFMT) {
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002161 case S_IFCHR:
2162 case S_IFBLK:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002163#ifdef LINUXSPARC
2164 if (current_personality == 1)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002165 tprintf(", makedev(%lu, %lu)",
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002166 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
2167 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002168 else
Roland McGrath186c5ac2002-12-15 23:58:23 +00002169#endif
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002170 tprintf(", makedev(%lu, %lu)",
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002171 (unsigned long) major(tcp->u_arg[offset + 2]),
2172 (unsigned long) minor(tcp->u_arg[offset + 2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002173 break;
2174 default:
2175 break;
2176 }
2177 }
2178 return 0;
2179}
2180
2181int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002182sys_mknod(struct tcb *tcp)
2183{
2184 return decode_mknod(tcp, 0);
2185}
2186
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002187int
2188sys_mknodat(struct tcb *tcp)
2189{
2190 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03002191 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002192 return decode_mknod(tcp, 1);
2193}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002194
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002195static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002196printdir(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002197{
2198 struct dirent d;
2199
2200 if (!verbose(tcp)) {
2201 tprintf("%#lx", addr);
2202 return;
2203 }
2204 if (umove(tcp, addr, &d) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002205 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002206 return;
2207 }
2208 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002209 tprints("d_name=");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002210 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002211 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002212}
2213
2214int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002215sys_readdir(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002216{
2217 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002218 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002219 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002220 } else {
2221 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
2222 tprintf("%#lx", tcp->u_arg[1]);
2223 else
2224 printdir(tcp, tcp->u_arg[1]);
2225 /* Not much point in printing this out, it is always 1. */
2226 if (tcp->u_arg[2] != 1)
2227 tprintf(", %lu", tcp->u_arg[2]);
2228 }
2229 return 0;
2230}
2231
Roland McGratha4d48532005-06-08 20:45:28 +00002232static const struct xlat direnttypes[] = {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002233 { DT_UNKNOWN, "DT_UNKNOWN" },
2234 { DT_FIFO, "DT_FIFO" },
2235 { DT_CHR, "DT_CHR" },
2236 { DT_DIR, "DT_DIR" },
2237 { DT_BLK, "DT_BLK" },
2238 { DT_REG, "DT_REG" },
2239 { DT_LNK, "DT_LNK" },
2240 { DT_SOCK, "DT_SOCK" },
2241 { DT_WHT, "DT_WHT" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002242 { 0, NULL },
2243};
2244
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002245int
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002246sys_getdents(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002247{
2248 int i, len, dents = 0;
2249 char *buf;
2250
2251 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002252 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002253 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002254 return 0;
2255 }
2256 if (syserror(tcp) || !verbose(tcp)) {
2257 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2258 return 0;
2259 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002260 len = tcp->u_rval;
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002261 /* Beware of insanely large or negative values in tcp->u_rval */
2262 if (tcp->u_rval > 1024*1024)
2263 len = 1024*1024;
2264 if (tcp->u_rval < 0)
2265 len = 0;
Mike Frysinger229738c2009-10-07 20:41:56 -04002266 buf = len ? malloc(len) : NULL;
Denys Vlasenko1d46ba52011-08-31 14:00:02 +02002267 if (len && !buf)
2268 die_out_of_memory();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002269 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002270 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002271 free(buf);
2272 return 0;
2273 }
2274 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002275 tprints("{");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002276 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00002277 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002278 if (!abbrev(tcp)) {
2279 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2280 i ? " " : "", d->d_ino, d->d_off);
2281 tprintf("d_reclen=%u, d_name=\"%s\"}",
2282 d->d_reclen, d->d_name);
2283 }
Pavel Machek9a9f10b2000-02-01 16:22:52 +00002284 if (!d->d_reclen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002285 tprints("/* d_reclen == 0, problem here */");
Pavel Machek9a9f10b2000-02-01 16:22:52 +00002286 break;
2287 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002288 i += d->d_reclen;
2289 dents++;
2290 }
2291 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002292 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002293 else
2294 tprintf("/* %u entries */", dents);
2295 tprintf(", %lu", tcp->u_arg[2]);
2296 free(buf);
2297 return 0;
2298}
2299
John Hughesbdf48f52001-03-06 15:08:09 +00002300#if _LFS64_LARGEFILE
2301int
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002302sys_getdents64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +00002303{
2304 int i, len, dents = 0;
2305 char *buf;
2306
2307 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002308 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002309 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +00002310 return 0;
2311 }
2312 if (syserror(tcp) || !verbose(tcp)) {
2313 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2314 return 0;
2315 }
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002316
John Hughesbdf48f52001-03-06 15:08:09 +00002317 len = tcp->u_rval;
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002318 /* Beware of insanely large or negative tcp->u_rval */
2319 if (tcp->u_rval > 1024*1024)
2320 len = 1024*1024;
2321 if (tcp->u_rval < 0)
2322 len = 0;
Mike Frysinger229738c2009-10-07 20:41:56 -04002323 buf = len ? malloc(len) : NULL;
Denys Vlasenko1d46ba52011-08-31 14:00:02 +02002324 if (len && !buf)
2325 die_out_of_memory();
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002326
John Hughesbdf48f52001-03-06 15:08:09 +00002327 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002328 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
John Hughesbdf48f52001-03-06 15:08:09 +00002329 free(buf);
2330 return 0;
2331 }
2332 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002333 tprints("{");
John Hughesbdf48f52001-03-06 15:08:09 +00002334 for (i = 0; i < len;) {
2335 struct dirent64 *d = (struct dirent64 *) &buf[i];
John Hughesbdf48f52001-03-06 15:08:09 +00002336 if (!abbrev(tcp)) {
Dmitry V. Levin1f336e52006-10-14 20:20:46 +00002337 tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ",
Roland McGrath186c5ac2002-12-15 23:58:23 +00002338 i ? " " : "",
Roland McGrath92053242004-01-13 10:16:47 +00002339 d->d_ino,
2340 d->d_off);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002341 tprints("d_type=");
Roland McGrath40542842004-01-13 09:47:49 +00002342 printxval(direnttypes, d->d_type, "DT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002343 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +00002344 tprintf("d_reclen=%u, d_name=\"%s\"}",
2345 d->d_reclen, d->d_name);
2346 }
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002347 if (!d->d_reclen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002348 tprints("/* d_reclen == 0, problem here */");
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002349 break;
2350 }
John Hughesbdf48f52001-03-06 15:08:09 +00002351 i += d->d_reclen;
2352 dents++;
2353 }
2354 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002355 tprints("}");
John Hughesbdf48f52001-03-06 15:08:09 +00002356 else
2357 tprintf("/* %u entries */", dents);
2358 tprintf(", %lu", tcp->u_arg[2]);
2359 free(buf);
2360 return 0;
2361}
2362#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +00002363
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002364int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002365sys_getcwd(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002366{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002367 if (exiting(tcp)) {
2368 if (syserror(tcp))
2369 tprintf("%#lx", tcp->u_arg[0]);
2370 else
2371 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2372 tprintf(", %lu", tcp->u_arg[1]);
2373 }
2374 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002375}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002376
2377#ifdef HAVE_SYS_ASYNCH_H
2378
2379int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002380sys_aioread(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002381{
2382 struct aio_result_t res;
2383
2384 if (entering(tcp)) {
2385 tprintf("%lu, ", tcp->u_arg[0]);
2386 } else {
2387 if (syserror(tcp))
2388 tprintf("%#lx", tcp->u_arg[1]);
2389 else
2390 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2391 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2392 printxval(whence, tcp->u_arg[4], "L_???");
2393 if (syserror(tcp) || tcp->u_arg[5] == 0
2394 || umove(tcp, tcp->u_arg[5], &res) < 0)
2395 tprintf(", %#lx", tcp->u_arg[5]);
2396 else
2397 tprintf(", {aio_return %d aio_errno %d}",
2398 res.aio_return, res.aio_errno);
2399 }
2400 return 0;
2401}
2402
2403int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002404sys_aiowrite(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002405{
2406 struct aio_result_t res;
2407
2408 if (entering(tcp)) {
2409 tprintf("%lu, ", tcp->u_arg[0]);
2410 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2411 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2412 printxval(whence, tcp->u_arg[4], "L_???");
2413 }
2414 else {
2415 if (tcp->u_arg[5] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002416 tprints(", NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002417 else if (syserror(tcp)
2418 || umove(tcp, tcp->u_arg[5], &res) < 0)
2419 tprintf(", %#lx", tcp->u_arg[5]);
2420 else
2421 tprintf(", {aio_return %d aio_errno %d}",
2422 res.aio_return, res.aio_errno);
2423 }
2424 return 0;
2425}
2426
2427int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002428sys_aiowait(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002429{
2430 if (entering(tcp))
2431 printtv(tcp, tcp->u_arg[0]);
2432 return 0;
2433}
2434
2435int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002436sys_aiocancel(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002437{
2438 struct aio_result_t res;
2439
2440 if (exiting(tcp)) {
2441 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002442 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002443 else if (syserror(tcp)
2444 || umove(tcp, tcp->u_arg[0], &res) < 0)
2445 tprintf("%#lx", tcp->u_arg[0]);
2446 else
2447 tprintf("{aio_return %d aio_errno %d}",
2448 res.aio_return, res.aio_errno);
2449 }
2450 return 0;
2451}
2452
2453#endif /* HAVE_SYS_ASYNCH_H */
Roland McGrath186c5ac2002-12-15 23:58:23 +00002454
Roland McGratha4d48532005-06-08 20:45:28 +00002455static const struct xlat xattrflags[] = {
Roland McGrath561c7992003-04-02 01:10:44 +00002456#ifdef XATTR_CREATE
Roland McGrath186c5ac2002-12-15 23:58:23 +00002457 { XATTR_CREATE, "XATTR_CREATE" },
2458 { XATTR_REPLACE, "XATTR_REPLACE" },
Roland McGrath561c7992003-04-02 01:10:44 +00002459#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +00002460 { 0, NULL }
2461};
2462
Roland McGrath3292e222004-08-31 06:30:48 +00002463static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002464print_xattr_val(struct tcb *tcp, int failed,
2465 unsigned long arg,
2466 unsigned long insize,
2467 unsigned long size)
Roland McGrath3292e222004-08-31 06:30:48 +00002468{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002469 if (!failed) {
2470 unsigned long capacity = 4 * size + 1;
2471 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
2472 if (buf == NULL || /* probably a bogus size argument */
2473 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2474 failed = 1;
Roland McGrath883567c2005-02-02 03:38:32 +00002475 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002476 else {
2477 unsigned char *out = buf;
2478 unsigned char *in = &buf[3 * size];
2479 size_t i;
2480 for (i = 0; i < size; ++i) {
2481 if (isprint(in[i]))
2482 *out++ = in[i];
2483 else {
2484#define tohex(n) "0123456789abcdef"[n]
2485 *out++ = '\\';
2486 *out++ = 'x';
2487 *out++ = tohex(in[i] / 16);
2488 *out++ = tohex(in[i] % 16);
2489 }
2490 }
2491 /* Don't print terminating NUL if there is one. */
2492 if (i > 0 && in[i - 1] == '\0')
2493 out -= 4;
2494 *out = '\0';
2495 tprintf(", \"%s\", %ld", buf, insize);
2496 }
2497 free(buf);
Roland McGrath883567c2005-02-02 03:38:32 +00002498 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002499 if (failed)
2500 tprintf(", 0x%lx, %ld", arg, insize);
Roland McGrath3292e222004-08-31 06:30:48 +00002501}
2502
Roland McGrath186c5ac2002-12-15 23:58:23 +00002503int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002504sys_setxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002505{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002506 if (entering(tcp)) {
2507 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002508 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002509 printstr(tcp, tcp->u_arg[1], -1);
2510 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002511 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002512 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2513 }
2514 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002515}
2516
2517int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002518sys_fsetxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002519{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002520 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002521 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002522 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002523 printstr(tcp, tcp->u_arg[1], -1);
2524 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002525 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002526 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2527 }
2528 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002529}
2530
2531int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002532sys_getxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002533{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002534 if (entering(tcp)) {
2535 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002536 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002537 printstr(tcp, tcp->u_arg[1], -1);
2538 } else {
2539 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2540 tcp->u_rval);
2541 }
2542 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002543}
2544
2545int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002546sys_fgetxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002547{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002548 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002549 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002550 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002551 printstr(tcp, tcp->u_arg[1], -1);
2552 } else {
2553 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2554 tcp->u_rval);
2555 }
2556 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002557}
2558
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002559static void
2560print_xattr_list(struct tcb *tcp, unsigned long addr, unsigned long size)
2561{
2562 if (syserror(tcp)) {
2563 tprintf("%#lx", addr);
2564 } else {
2565 if (!addr) {
2566 tprints("NULL");
2567 } else {
2568 unsigned long len =
2569 (size < tcp->u_rval) ? size : tcp->u_rval;
2570 printstr(tcp, addr, len);
2571 }
2572 }
2573 tprintf(", %lu", size);
2574}
2575
Roland McGrath186c5ac2002-12-15 23:58:23 +00002576int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002577sys_listxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002578{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002579 if (entering(tcp)) {
2580 printpath(tcp, tcp->u_arg[0]);
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002581 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002582 } else {
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002583 print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002584 }
2585 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002586}
2587
2588int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002589sys_flistxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002590{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002591 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002592 printfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002593 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002594 } else {
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002595 print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002596 }
2597 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002598}
2599
2600int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002601sys_removexattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002602{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002603 if (entering(tcp)) {
2604 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002605 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002606 printstr(tcp, tcp->u_arg[1], -1);
2607 }
2608 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002609}
2610
2611int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002612sys_fremovexattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002613{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002614 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002615 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002616 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002617 printstr(tcp, tcp->u_arg[1], -1);
2618 }
2619 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002620}
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002621
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002622static const struct xlat advise[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002623 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2624 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2625 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2626 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2627 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2628 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2629 { 0, NULL }
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002630};
2631
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002632int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002633sys_fadvise64(struct tcb *tcp)
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002634{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002635 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002636 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +03002637 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002638 tprints(", ");
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002639 argn = printllval(tcp, "%lld", 1);
2640 tprintf(", %ld, ", tcp->u_arg[argn++]);
2641 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002642 }
2643 return 0;
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002644}
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002645
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002646int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002647sys_fadvise64_64(struct tcb *tcp)
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002648{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002649 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002650 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +03002651 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002652 tprints(", ");
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002653#if defined ARM || defined POWERPC
2654 argn = printllval(tcp, "%lld, ", 2);
2655#else
2656 argn = printllval(tcp, "%lld, ", 1);
2657#endif
2658 argn = printllval(tcp, "%lld, ", argn);
2659#if defined ARM || defined POWERPC
Kirill A. Shutemov896db212009-09-19 03:21:33 +03002660 printxval(advise, tcp->u_arg[1], "POSIX_FADV_???");
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002661#else
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002662 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002663#endif
Denys Vlasenko1d632462009-04-14 12:51:00 +00002664 }
2665 return 0;
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002666}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002667
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002668static const struct xlat inotify_modes[] = {
Dmitry V. Levind475c062011-03-03 01:02:41 +00002669 { 0x00000001, "IN_ACCESS" },
2670 { 0x00000002, "IN_MODIFY" },
2671 { 0x00000004, "IN_ATTRIB" },
2672 { 0x00000008, "IN_CLOSE_WRITE"},
2673 { 0x00000010, "IN_CLOSE_NOWRITE"},
2674 { 0x00000020, "IN_OPEN" },
2675 { 0x00000040, "IN_MOVED_FROM" },
2676 { 0x00000080, "IN_MOVED_TO" },
2677 { 0x00000100, "IN_CREATE" },
2678 { 0x00000200, "IN_DELETE" },
2679 { 0x00000400, "IN_DELETE_SELF"},
2680 { 0x00000800, "IN_MOVE_SELF" },
2681 { 0x00002000, "IN_UNMOUNT" },
2682 { 0x00004000, "IN_Q_OVERFLOW" },
2683 { 0x00008000, "IN_IGNORED" },
2684 { 0x01000000, "IN_ONLYDIR" },
2685 { 0x02000000, "IN_DONT_FOLLOW"},
2686 { 0x20000000, "IN_MASK_ADD" },
2687 { 0x40000000, "IN_ISDIR" },
2688 { 0x80000000, "IN_ONESHOT" },
2689 { 0, NULL }
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002690};
2691
Sebastian Pipping1e1405a2011-03-03 00:50:55 +01002692static const struct xlat inotify_init_flags[] = {
2693 { 0x00000800, "IN_NONBLOCK" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002694 { 0x00080000, "IN_CLOEXEC" },
2695 { 0, NULL }
Sebastian Pipping1e1405a2011-03-03 00:50:55 +01002696};
2697
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002698int
2699sys_inotify_add_watch(struct tcb *tcp)
2700{
2701 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002702 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002703 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002704 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002705 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002706 printflags(inotify_modes, tcp->u_arg[2], "IN_???");
2707 }
2708 return 0;
2709}
2710
2711int
2712sys_inotify_rm_watch(struct tcb *tcp)
2713{
2714 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002715 printfd(tcp, tcp->u_arg[0]);
Dmitry V. Levinab1a70c2012-03-11 15:33:34 +00002716 tprintf(", %d", (int) tcp->u_arg[1]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002717 }
2718 return 0;
2719}
Roland McGrath96a96612008-05-20 04:56:18 +00002720
2721int
Mark Wielaardbab89402010-03-21 14:41:26 +01002722sys_inotify_init1(struct tcb *tcp)
2723{
2724 if (entering(tcp))
Sebastian Pipping1e1405a2011-03-03 00:50:55 +01002725 printflags(inotify_init_flags, tcp->u_arg[0], "IN_???");
Mark Wielaardbab89402010-03-21 14:41:26 +01002726 return 0;
2727}
2728
2729int
Roland McGrath96a96612008-05-20 04:56:18 +00002730sys_fallocate(struct tcb *tcp)
2731{
2732 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002733 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +03002734 printfd(tcp, tcp->u_arg[0]); /* fd */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002735 tprints(", ");
Roland McGrath96a96612008-05-20 04:56:18 +00002736 tprintf("%#lo, ", tcp->u_arg[1]); /* mode */
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002737 argn = printllval(tcp, "%llu, ", 2); /* offset */
2738 printllval(tcp, "%llu", argn); /* len */
Roland McGrath96a96612008-05-20 04:56:18 +00002739 }
2740 return 0;
2741}
Dmitry V. Levin88293652012-03-09 21:02:19 +00002742
Dmitry V. Levinad0c01e2012-03-15 00:52:22 +00002743#ifndef SWAP_FLAG_PREFER
2744# define SWAP_FLAG_PREFER 0x8000
2745#endif
2746#ifndef SWAP_FLAG_DISCARD
2747# define SWAP_FLAG_DISCARD 0x10000
2748#endif
Dmitry V. Levin88293652012-03-09 21:02:19 +00002749static const struct xlat swap_flags[] = {
2750 { SWAP_FLAG_PREFER, "SWAP_FLAG_PREFER" },
2751 { SWAP_FLAG_DISCARD, "SWAP_FLAG_DISCARD" },
2752 { 0, NULL }
2753};
2754
2755int
2756sys_swapon(struct tcb *tcp)
2757{
2758 if (entering(tcp)) {
2759 int flags = tcp->u_arg[1];
2760 printpath(tcp, tcp->u_arg[0]);
2761 tprints(", ");
2762 printflags(swap_flags, flags & ~SWAP_FLAG_PRIO_MASK,
2763 "SWAP_FLAG_???");
2764 if (flags & SWAP_FLAG_PREFER)
2765 tprintf("|%d", flags & SWAP_FLAG_PRIO_MASK);
2766 }
2767 return 0;
2768}
H.J. Lu085e4282012-04-17 11:05:04 -07002769
2770#ifdef X32
2771# undef stat64
2772# undef sys_fstat64
2773# undef sys_stat64
2774
2775static void
2776realprintstat64(struct tcb *tcp, long addr)
2777{
2778 struct stat64 statbuf;
2779
2780 if (!addr) {
2781 tprints("NULL");
2782 return;
2783 }
2784 if (syserror(tcp) || !verbose(tcp)) {
2785 tprintf("%#lx", addr);
2786 return;
2787 }
2788
2789 if (umove(tcp, addr, &statbuf) < 0) {
2790 tprints("{...}");
2791 return;
2792 }
2793
2794 if (!abbrev(tcp)) {
2795 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
2796 (unsigned long) major(statbuf.st_dev),
2797 (unsigned long) minor(statbuf.st_dev),
2798 (unsigned long long) statbuf.st_ino,
2799 sprintmode(statbuf.st_mode));
2800 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
2801 (unsigned long) statbuf.st_nlink,
2802 (unsigned long) statbuf.st_uid,
2803 (unsigned long) statbuf.st_gid);
2804 tprintf("st_blksize=%lu, ",
2805 (unsigned long) statbuf.st_blksize);
2806 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
2807 }
2808 else
2809 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
2810 switch (statbuf.st_mode & S_IFMT) {
2811 case S_IFCHR: case S_IFBLK:
2812 tprintf("st_rdev=makedev(%lu, %lu), ",
2813 (unsigned long) major(statbuf.st_rdev),
2814 (unsigned long) minor(statbuf.st_rdev));
2815 break;
2816 default:
2817 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
2818 break;
2819 }
2820 if (!abbrev(tcp)) {
2821 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
2822 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
2823 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
2824 tprints("}");
2825 }
2826 else
2827 tprints("...}");
2828}
2829
2830int
2831sys_fstat64(struct tcb *tcp)
2832{
2833 if (entering(tcp)) {
2834 printfd(tcp, tcp->u_arg[0]);
2835 tprints(", ");
2836 } else {
2837 realprintstat64(tcp, tcp->u_arg[1]);
2838 }
2839 return 0;
2840}
2841
2842int
2843sys_stat64(struct tcb *tcp)
2844{
2845 if (entering(tcp)) {
2846 printpath(tcp, tcp->u_arg[0]);
2847 tprints(", ");
2848 } else {
2849 realprintstat64(tcp, tcp->u_arg[1]);
2850 }
2851 return 0;
2852}
2853#endif