blob: 1cd8d3c0b9aa6cad789605ca27e3d822a066a582 [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 Vlasenkod33e72a2012-05-18 02:03:24 +0200626 argn = printllval(tcp, ", %lld", 1);
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100627 tprintf(", %ld", tcp->u_arg[argn]);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000628 }
629 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +0000630}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000631
John Hughes70623be2001-03-08 13:59:00 +0000632#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000633int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000634sys_truncate(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000635{
636 if (entering(tcp)) {
637 printpath(tcp, tcp->u_arg[0]);
638 tprintf(", %lu", tcp->u_arg[1]);
639 }
640 return 0;
641}
John Hughes5a826b82001-03-07 13:21:24 +0000642#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000643
John Hughes70623be2001-03-08 13:59:00 +0000644#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000645int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000646sys_truncate64(struct tcb *tcp)
John Hughes96f51472001-03-06 16:50:41 +0000647{
648 if (entering(tcp)) {
649 printpath(tcp, tcp->u_arg[0]);
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100650 printllval(tcp, ", %llu", 1);
John Hughes96f51472001-03-06 16:50:41 +0000651 }
652 return 0;
653}
654#endif
655
John Hughes70623be2001-03-08 13:59:00 +0000656#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000657int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000658sys_ftruncate(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000659{
660 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300661 printfd(tcp, tcp->u_arg[0]);
662 tprintf(", %lu", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000663 }
664 return 0;
665}
John Hughes5a826b82001-03-07 13:21:24 +0000666#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000667
John Hughes70623be2001-03-08 13:59:00 +0000668#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000669int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000670sys_ftruncate64(struct tcb *tcp)
John Hughes96f51472001-03-06 16:50:41 +0000671{
672 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300673 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenkod33e72a2012-05-18 02:03:24 +0200674 printllval(tcp, ", %llu", 1);
John Hughes96f51472001-03-06 16:50:41 +0000675 }
676 return 0;
677}
678#endif
679
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000680/* several stats */
681
Roland McGrathd9f816f2004-09-04 03:39:20 +0000682static const struct xlat modetypes[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000683 { S_IFREG, "S_IFREG" },
684 { S_IFSOCK, "S_IFSOCK" },
685 { S_IFIFO, "S_IFIFO" },
686 { S_IFLNK, "S_IFLNK" },
687 { S_IFDIR, "S_IFDIR" },
688 { S_IFBLK, "S_IFBLK" },
689 { S_IFCHR, "S_IFCHR" },
690 { 0, NULL },
691};
692
Roland McGrathf9c49b22004-10-06 22:11:54 +0000693static const char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000694sprintmode(int mode)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000695{
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100696 static char buf[sizeof("S_IFSOCK|S_ISUID|S_ISGID|S_ISVTX|%o")
697 + sizeof(int)*3
698 + /*paranoia:*/ 8];
Roland McGrathf9c49b22004-10-06 22:11:54 +0000699 const char *s;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000700
701 if ((mode & S_IFMT) == 0)
702 s = "";
703 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
704 sprintf(buf, "%#o", mode);
705 return buf;
706 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100707 s = buf + sprintf(buf, "%s%s%s%s", s,
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000708 (mode & S_ISUID) ? "|S_ISUID" : "",
709 (mode & S_ISGID) ? "|S_ISGID" : "",
710 (mode & S_ISVTX) ? "|S_ISVTX" : "");
711 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
712 if (mode)
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100713 sprintf((char*)s, "|%#o", mode);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000714 s = (*buf == '|') ? buf + 1 : buf;
715 return *s ? s : "0";
716}
717
718static char *
Dmitry V. Levindc7715b2008-04-19 23:45:09 +0000719sprinttime(time_t t)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000720{
721 struct tm *tmp;
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100722 static char buf[sizeof("yyyy/mm/dd-hh:mm:ss")];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000723
724 if (t == 0) {
Dmitry V. Levindc7715b2008-04-19 23:45:09 +0000725 strcpy(buf, "0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000726 return buf;
727 }
Denys Vlasenko5d645812011-08-20 12:48:18 +0200728 tmp = localtime(&t);
729 if (tmp)
Dmitry V. Levindc7715b2008-04-19 23:45:09 +0000730 snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d",
731 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
732 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
733 else
734 snprintf(buf, sizeof buf, "%lu", (unsigned long) t);
735
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000736 return buf;
737}
738
739#ifdef LINUXSPARC
740typedef struct {
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000741 int tv_sec;
742 int tv_nsec;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000743} timestruct_t;
744
745struct solstat {
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000746 unsigned st_dev;
747 int st_pad1[3]; /* network id */
748 unsigned st_ino;
749 unsigned st_mode;
750 unsigned st_nlink;
751 unsigned st_uid;
752 unsigned st_gid;
753 unsigned st_rdev;
754 int st_pad2[2];
755 int st_size;
756 int st_pad3; /* st_size, off_t expansion */
757 timestruct_t st_atime;
758 timestruct_t st_mtime;
759 timestruct_t st_ctime;
760 int st_blksize;
761 int st_blocks;
762 char st_fstype[16];
763 int st_pad4[8]; /* expansion area */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000764};
765
766static void
Dmitry V. Levinb838b1e2008-04-19 23:47:47 +0000767printstatsol(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000768{
769 struct solstat statbuf;
770
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000771 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200772 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000773 return;
774 }
775 if (!abbrev(tcp)) {
776 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
777 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
778 (unsigned long) (statbuf.st_dev & 0x3ffff),
779 (unsigned long) statbuf.st_ino,
780 sprintmode(statbuf.st_mode));
781 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
782 (unsigned long) statbuf.st_nlink,
783 (unsigned long) statbuf.st_uid,
784 (unsigned long) statbuf.st_gid);
785 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
786 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
787 }
788 else
789 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
790 switch (statbuf.st_mode & S_IFMT) {
791 case S_IFCHR: case S_IFBLK:
792 tprintf("st_rdev=makedev(%lu, %lu), ",
793 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
794 (unsigned long) (statbuf.st_rdev & 0x3ffff));
795 break;
796 default:
797 tprintf("st_size=%u, ", statbuf.st_size);
798 break;
799 }
800 if (!abbrev(tcp)) {
Dmitry V. Levinb838b1e2008-04-19 23:47:47 +0000801 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
802 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
803 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000804 }
805 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200806 tprints("...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000807}
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000808
Denys Vlasenkoc36c3522012-02-25 02:47:15 +0100809#if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000810static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000811printstat_sparc64(struct tcb *tcp, long addr)
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000812{
813 struct stat_sparc64 statbuf;
814
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000815 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200816 tprints("{...}");
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000817 return;
818 }
819
820 if (!abbrev(tcp)) {
821 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
822 (unsigned long) major(statbuf.st_dev),
823 (unsigned long) minor(statbuf.st_dev),
824 (unsigned long) statbuf.st_ino,
825 sprintmode(statbuf.st_mode));
826 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
827 (unsigned long) statbuf.st_nlink,
828 (unsigned long) statbuf.st_uid,
829 (unsigned long) statbuf.st_gid);
830 tprintf("st_blksize=%lu, ",
831 (unsigned long) statbuf.st_blksize);
832 tprintf("st_blocks=%lu, ",
833 (unsigned long) statbuf.st_blocks);
834 }
835 else
836 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
837 switch (statbuf.st_mode & S_IFMT) {
838 case S_IFCHR: case S_IFBLK:
839 tprintf("st_rdev=makedev(%lu, %lu), ",
840 (unsigned long) major(statbuf.st_rdev),
841 (unsigned long) minor(statbuf.st_rdev));
842 break;
843 default:
844 tprintf("st_size=%lu, ", statbuf.st_size);
845 break;
846 }
847 if (!abbrev(tcp)) {
848 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
849 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100850 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000851 }
852 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200853 tprints("...}");
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000854}
855#endif /* SPARC64 */
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000856#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000857
Denys Vlasenko84703742012-02-25 02:38:52 +0100858#if defined POWERPC64
Andreas Schwabd69fa492010-07-12 21:39:57 +0200859struct stat_powerpc32 {
860 unsigned int st_dev;
861 unsigned int st_ino;
862 unsigned int st_mode;
863 unsigned short st_nlink;
864 unsigned int st_uid;
865 unsigned int st_gid;
866 unsigned int st_rdev;
867 unsigned int st_size;
868 unsigned int st_blksize;
869 unsigned int st_blocks;
870 unsigned int st_atime;
871 unsigned int st_atime_nsec;
872 unsigned int st_mtime;
873 unsigned int st_mtime_nsec;
874 unsigned int st_ctime;
875 unsigned int st_ctime_nsec;
876 unsigned int __unused4;
877 unsigned int __unused5;
878};
879
880static void
881printstat_powerpc32(struct tcb *tcp, long addr)
882{
883 struct stat_powerpc32 statbuf;
884
885 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200886 tprints("{...}");
Andreas Schwabd69fa492010-07-12 21:39:57 +0200887 return;
888 }
889
890 if (!abbrev(tcp)) {
891 tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ",
892 major(statbuf.st_dev), minor(statbuf.st_dev),
893 statbuf.st_ino,
894 sprintmode(statbuf.st_mode));
895 tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ",
896 statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid);
897 tprintf("st_blksize=%u, ", statbuf.st_blksize);
898 tprintf("st_blocks=%u, ", statbuf.st_blocks);
899 }
900 else
901 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
902 switch (statbuf.st_mode & S_IFMT) {
903 case S_IFCHR: case S_IFBLK:
904 tprintf("st_rdev=makedev(%lu, %lu), ",
905 (unsigned long) major(statbuf.st_rdev),
906 (unsigned long) minor(statbuf.st_rdev));
907 break;
908 default:
909 tprintf("st_size=%u, ", statbuf.st_size);
910 break;
911 }
912 if (!abbrev(tcp)) {
913 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
914 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100915 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
Andreas Schwabd69fa492010-07-12 21:39:57 +0200916 }
917 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200918 tprints("...}");
Andreas Schwabd69fa492010-07-12 21:39:57 +0200919}
Denys Vlasenko84703742012-02-25 02:38:52 +0100920#endif /* POWERPC64 */
Andreas Schwabd69fa492010-07-12 21:39:57 +0200921
Roland McGratha4d48532005-06-08 20:45:28 +0000922static const struct xlat fileflags[] = {
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000923 { 0, NULL },
924};
925
John Hughes70623be2001-03-08 13:59:00 +0000926#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000927static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000928realprintstat(struct tcb *tcp, struct stat *statbuf)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000929{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000930 if (!abbrev(tcp)) {
931 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
932 (unsigned long) major(statbuf->st_dev),
933 (unsigned long) minor(statbuf->st_dev),
934 (unsigned long) statbuf->st_ino,
935 sprintmode(statbuf->st_mode));
936 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
937 (unsigned long) statbuf->st_nlink,
938 (unsigned long) statbuf->st_uid,
939 (unsigned long) statbuf->st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000940#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Denys Vlasenko1d632462009-04-14 12:51:00 +0000941 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
942#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000943#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Denys Vlasenko1d632462009-04-14 12:51:00 +0000944 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
945#endif
946 }
947 else
948 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
949 switch (statbuf->st_mode & S_IFMT) {
950 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +0000951#ifdef HAVE_STRUCT_STAT_ST_RDEV
Denys Vlasenko1d632462009-04-14 12:51:00 +0000952 tprintf("st_rdev=makedev(%lu, %lu), ",
953 (unsigned long) major(statbuf->st_rdev),
954 (unsigned long) minor(statbuf->st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000955#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000956 tprintf("st_size=makedev(%lu, %lu), ",
957 (unsigned long) major(statbuf->st_size),
958 (unsigned long) minor(statbuf->st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000959#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000960 break;
961 default:
Dmitry V. Levine9a06b72011-02-23 16:16:50 +0000962 tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000963 break;
964 }
965 if (!abbrev(tcp)) {
966 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
967 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
968 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000969#if HAVE_STRUCT_STAT_ST_FLAGS
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200970 tprints(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +0000971 printflags(fileflags, statbuf->st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +0000972#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000973#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +0000974 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
975#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000976#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +0000977 tprintf(", st_level=%ld", statbuf->st_level);
978#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000979#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +0000980 tprintf(", st_fstype=%.*s",
981 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
982#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000983#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +0000984 tprintf(", st_gen=%u", statbuf->st_gen);
985#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200986 tprints("}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000987 }
988 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200989 tprints("...}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000990}
991
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000992static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000993printstat(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000994{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000995 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000996
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000997 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200998 tprints("NULL");
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000999 return;
1000 }
1001 if (syserror(tcp) || !verbose(tcp)) {
1002 tprintf("%#lx", addr);
1003 return;
1004 }
1005
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001006#ifdef LINUXSPARC
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00001007 if (current_personality == 1) {
1008 printstatsol(tcp, addr);
1009 return;
1010 }
Roland McGrath6d1a65c2004-07-12 07:44:08 +00001011#ifdef SPARC64
1012 else if (current_personality == 2) {
1013 printstat_sparc64(tcp, addr);
1014 return;
1015 }
1016#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001017#endif /* LINUXSPARC */
1018
Denys Vlasenko84703742012-02-25 02:38:52 +01001019#if defined POWERPC64
Andreas Schwabd69fa492010-07-12 21:39:57 +02001020 if (current_personality == 1) {
1021 printstat_powerpc32(tcp, addr);
1022 return;
1023 }
1024#endif
1025
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001026 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001027 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001028 return;
1029 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001030
1031 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001032}
John Hughes70623be2001-03-08 13:59:00 +00001033#endif /* !HAVE_LONG_LONG_OFF_T */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001034
Denys Vlasenko84703742012-02-25 02:38:52 +01001035#if !defined HAVE_STAT64 && defined X86_64
Roland McGrathe6d0f712007-08-07 01:22:49 +00001036/*
1037 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
1038 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
1039 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
1040 * __GNUC__ is needed for the required __attribute__ below.
1041 */
1042struct stat64 {
1043 unsigned long long st_dev;
1044 unsigned char __pad0[4];
1045 unsigned int __st_ino;
1046 unsigned int st_mode;
1047 unsigned int st_nlink;
1048 unsigned int st_uid;
1049 unsigned int st_gid;
1050 unsigned long long st_rdev;
1051 unsigned char __pad3[4];
1052 long long st_size;
1053 unsigned int st_blksize;
1054 unsigned long long st_blocks;
1055 unsigned int st_atime;
1056 unsigned int st_atime_nsec;
1057 unsigned int st_mtime;
1058 unsigned int st_mtime_nsec;
1059 unsigned int st_ctime;
1060 unsigned int st_ctime_nsec;
1061 unsigned long long st_ino;
1062} __attribute__((packed));
1063# define HAVE_STAT64 1
1064# define STAT64_SIZE 96
1065#endif
1066
Wichert Akkermanc7926982000-04-10 22:22:31 +00001067#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001068static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001069printstat64(struct tcb *tcp, long addr)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001070{
1071 struct stat64 statbuf;
1072
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001073#ifdef STAT64_SIZE
Roland McGrathe6d0f712007-08-07 01:22:49 +00001074 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
1075#endif
1076
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001077 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001078 tprints("NULL");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001079 return;
1080 }
1081 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001082 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001083 return;
1084 }
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001085
1086#ifdef LINUXSPARC
1087 if (current_personality == 1) {
1088 printstatsol(tcp, addr);
1089 return;
1090 }
1091# ifdef SPARC64
1092 else if (current_personality == 2) {
1093 printstat_sparc64(tcp, addr);
1094 return;
1095 }
1096# endif
1097#endif /* LINUXSPARC */
1098
Denys Vlasenko84703742012-02-25 02:38:52 +01001099#if defined X86_64
H.J. Lu35be5812012-04-16 13:00:01 +02001100 if (current_personality != 1) {
Andreas Schwab61b74352009-10-16 11:37:13 +02001101 printstat(tcp, addr);
1102 return;
1103 }
1104#endif
Dmitry V. Levinff896f72009-10-21 13:43:57 +00001105
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001106 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001107 tprints("{...}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001108 return;
1109 }
1110
1111 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +00001112#ifdef HAVE_LONG_LONG
1113 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1114#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001115 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
Wichert Akkermand077c452000-08-10 18:16:15 +00001116#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001117 (unsigned long) major(statbuf.st_dev),
1118 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +00001119#ifdef HAVE_LONG_LONG
1120 (unsigned long long) statbuf.st_ino,
1121#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001122 (unsigned long) statbuf.st_ino,
Wichert Akkermand077c452000-08-10 18:16:15 +00001123#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001124 sprintmode(statbuf.st_mode));
1125 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1126 (unsigned long) statbuf.st_nlink,
1127 (unsigned long) statbuf.st_uid,
1128 (unsigned long) statbuf.st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001129#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001130 tprintf("st_blksize=%lu, ",
1131 (unsigned long) statbuf.st_blksize);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001132#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
1133#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001134 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001135#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001136 }
1137 else
1138 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1139 switch (statbuf.st_mode & S_IFMT) {
1140 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +00001141#ifdef HAVE_STRUCT_STAT_ST_RDEV
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001142 tprintf("st_rdev=makedev(%lu, %lu), ",
1143 (unsigned long) major(statbuf.st_rdev),
1144 (unsigned long) minor(statbuf.st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001145#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001146 tprintf("st_size=makedev(%lu, %lu), ",
1147 (unsigned long) major(statbuf.st_size),
1148 (unsigned long) minor(statbuf.st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001149#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001150 break;
1151 default:
Roland McGrathc7bd4d32007-08-07 01:05:19 +00001152#ifdef HAVE_LONG_LONG
1153 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1154#else
1155 tprintf("st_size=%lu, ", (unsigned long) statbuf.st_size);
1156#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001157 break;
1158 }
1159 if (!abbrev(tcp)) {
1160 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1161 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +00001162 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001163#if HAVE_STRUCT_STAT_ST_FLAGS
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001164 tprints(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +00001165 printflags(fileflags, statbuf.st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +00001166#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001167#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +00001168 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1169#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001170#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +00001171 tprintf(", st_level=%ld", statbuf.st_level);
1172#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001173#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +00001174 tprintf(", st_fstype=%.*s",
1175 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1176#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001177#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +00001178 tprintf(", st_gen=%u", statbuf.st_gen);
1179#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001180 tprints("}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001181 }
1182 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001183 tprints("...}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001184}
Wichert Akkermanc7926982000-04-10 22:22:31 +00001185#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001186
Denys Vlasenko84703742012-02-25 02:38:52 +01001187#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001188static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001189convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001190{
Denys Vlasenko1d632462009-04-14 12:51:00 +00001191 newbuf->st_dev = oldbuf->st_dev;
1192 newbuf->st_ino = oldbuf->st_ino;
1193 newbuf->st_mode = oldbuf->st_mode;
1194 newbuf->st_nlink = oldbuf->st_nlink;
1195 newbuf->st_uid = oldbuf->st_uid;
1196 newbuf->st_gid = oldbuf->st_gid;
1197 newbuf->st_rdev = oldbuf->st_rdev;
1198 newbuf->st_size = oldbuf->st_size;
1199 newbuf->st_atime = oldbuf->st_atime;
1200 newbuf->st_mtime = oldbuf->st_mtime;
1201 newbuf->st_ctime = oldbuf->st_ctime;
1202 newbuf->st_blksize = 0; /* not supported in old_stat */
1203 newbuf->st_blocks = 0; /* not supported in old_stat */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001204}
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001205
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001206static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001207printoldstat(struct tcb *tcp, long addr)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001208{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +00001209 struct __old_kernel_stat statbuf;
1210 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001211
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001212 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001213 tprints("NULL");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001214 return;
1215 }
1216 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001217 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001218 return;
1219 }
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001220
Denys Vlasenko84703742012-02-25 02:38:52 +01001221# ifdef LINUXSPARC
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001222 if (current_personality == 1) {
1223 printstatsol(tcp, addr);
1224 return;
1225 }
Denys Vlasenko84703742012-02-25 02:38:52 +01001226# endif
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001227
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001228 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001229 tprints("{...}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001230 return;
1231 }
1232
1233 convertoldstat(&statbuf, &newstatbuf);
1234 realprintstat(tcp, &newstatbuf);
1235}
Denys Vlasenko84703742012-02-25 02:38:52 +01001236#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001237
John Hughes70623be2001-03-08 13:59:00 +00001238#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001239int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001240sys_stat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001241{
1242 if (entering(tcp)) {
1243 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001244 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001245 } else {
1246 printstat(tcp, tcp->u_arg[1]);
1247 }
1248 return 0;
1249}
John Hughesb8c9f772001-03-07 16:53:07 +00001250#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001251
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001252int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001253sys_stat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001254{
1255#ifdef HAVE_STAT64
1256 if (entering(tcp)) {
1257 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001258 tprints(", ");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001259 } else {
1260 printstat64(tcp, tcp->u_arg[1]);
1261 }
1262 return 0;
1263#else
1264 return printargs(tcp);
1265#endif
1266}
1267
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001268#ifndef AT_SYMLINK_NOFOLLOW
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001269# define AT_SYMLINK_NOFOLLOW 0x100
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001270#endif
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001271#ifndef AT_REMOVEDIR
1272# define AT_REMOVEDIR 0x200
1273#endif
1274#ifndef AT_SYMLINK_FOLLOW
1275# define AT_SYMLINK_FOLLOW 0x400
1276#endif
1277#ifndef AT_NO_AUTOMOUNT
1278# define AT_NO_AUTOMOUNT 0x800
1279#endif
1280#ifndef AT_EMPTY_PATH
1281# define AT_EMPTY_PATH 0x1000
1282#endif
1283
1284static const struct xlat at_flags[] = {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001285 { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" },
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001286 { AT_REMOVEDIR, "AT_REMOVEDIR" },
1287 { AT_SYMLINK_FOLLOW, "AT_SYMLINK_FOLLOW" },
1288 { AT_NO_AUTOMOUNT, "AT_NO_AUTOMOUNT" },
1289 { AT_EMPTY_PATH, "AT_EMPTY_PATH" },
1290 { 0, NULL }
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001291};
1292
1293int
1294sys_newfstatat(struct tcb *tcp)
1295{
1296 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001297 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001298 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001299 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001300 } else {
Andreas Schwabd69fa492010-07-12 21:39:57 +02001301#ifdef POWERPC64
1302 if (current_personality == 0)
1303 printstat(tcp, tcp->u_arg[2]);
1304 else
1305 printstat64(tcp, tcp->u_arg[2]);
1306#elif defined HAVE_STAT64
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001307 printstat64(tcp, tcp->u_arg[2]);
1308#else
1309 printstat(tcp, tcp->u_arg[2]);
1310#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001311 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001312 printflags(at_flags, tcp->u_arg[3], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001313 }
1314 return 0;
1315}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001316
Denys Vlasenko84703742012-02-25 02:38:52 +01001317#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001318int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001319sys_oldstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001320{
1321 if (entering(tcp)) {
1322 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001323 tprints(", ");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001324 } else {
1325 printoldstat(tcp, tcp->u_arg[1]);
1326 }
1327 return 0;
1328}
Denys Vlasenko84703742012-02-25 02:38:52 +01001329#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001330
John Hughes70623be2001-03-08 13:59:00 +00001331#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001332int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001333sys_fstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001334{
Dmitry V. Levin31382132011-03-04 05:08:02 +03001335 if (entering(tcp)) {
1336 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001337 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001338 } else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001339 printstat(tcp, tcp->u_arg[1]);
1340 }
1341 return 0;
1342}
John Hughesb8c9f772001-03-07 16:53:07 +00001343#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001344
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001345int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001346sys_fstat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001347{
1348#ifdef HAVE_STAT64
Dmitry V. Levin31382132011-03-04 05:08:02 +03001349 if (entering(tcp)) {
1350 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001351 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001352 } else {
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001353 printstat64(tcp, tcp->u_arg[1]);
1354 }
1355 return 0;
1356#else
1357 return printargs(tcp);
1358#endif
1359}
1360
Denys Vlasenko84703742012-02-25 02:38:52 +01001361#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001362int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001363sys_oldfstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001364{
Dmitry V. Levin31382132011-03-04 05:08:02 +03001365 if (entering(tcp)) {
1366 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001367 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001368 } else {
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001369 printoldstat(tcp, tcp->u_arg[1]);
1370 }
1371 return 0;
1372}
Denys Vlasenko84703742012-02-25 02:38:52 +01001373#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001374
John Hughes70623be2001-03-08 13:59:00 +00001375#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001376int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001377sys_lstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001378{
1379 if (entering(tcp)) {
1380 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001381 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001382 } else {
1383 printstat(tcp, tcp->u_arg[1]);
1384 }
1385 return 0;
1386}
John Hughesb8c9f772001-03-07 16:53:07 +00001387#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001388
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001389int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001390sys_lstat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001391{
1392#ifdef HAVE_STAT64
1393 if (entering(tcp)) {
1394 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001395 tprints(", ");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001396 } else {
1397 printstat64(tcp, tcp->u_arg[1]);
1398 }
1399 return 0;
1400#else
1401 return printargs(tcp);
1402#endif
1403}
1404
Denys Vlasenko84703742012-02-25 02:38:52 +01001405#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001406int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001407sys_oldlstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001408{
1409 if (entering(tcp)) {
1410 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001411 tprints(", ");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001412 } else {
1413 printoldstat(tcp, tcp->u_arg[1]);
1414 }
1415 return 0;
1416}
Denys Vlasenko84703742012-02-25 02:38:52 +01001417#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001418
Denys Vlasenko84703742012-02-25 02:38:52 +01001419#if defined(LINUXSPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001420
1421int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001422sys_xstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001423{
1424 if (entering(tcp)) {
1425 tprintf("%ld, ", tcp->u_arg[0]);
1426 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001427 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001428 } else {
Denys Vlasenko84703742012-02-25 02:38:52 +01001429# ifdef _STAT64_VER
John Hughes8fe2c982001-03-06 09:45:18 +00001430 if (tcp->u_arg[0] == _STAT64_VER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01001431 printstat64(tcp, tcp->u_arg[2]);
John Hughes8fe2c982001-03-06 09:45:18 +00001432 else
Denys Vlasenko84703742012-02-25 02:38:52 +01001433# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001434 printstat(tcp, tcp->u_arg[2]);
1435 }
1436 return 0;
1437}
1438
1439int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001440sys_fxstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001441{
1442 if (entering(tcp))
1443 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1444 else {
Denys Vlasenko84703742012-02-25 02:38:52 +01001445# ifdef _STAT64_VER
John Hughes8fe2c982001-03-06 09:45:18 +00001446 if (tcp->u_arg[0] == _STAT64_VER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01001447 printstat64(tcp, tcp->u_arg[2]);
John Hughes8fe2c982001-03-06 09:45:18 +00001448 else
Denys Vlasenko84703742012-02-25 02:38:52 +01001449# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001450 printstat(tcp, tcp->u_arg[2]);
1451 }
1452 return 0;
1453}
1454
1455int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001456sys_lxstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001457{
1458 if (entering(tcp)) {
1459 tprintf("%ld, ", tcp->u_arg[0]);
1460 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001461 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001462 } else {
Denys Vlasenko84703742012-02-25 02:38:52 +01001463# ifdef _STAT64_VER
John Hughes8fe2c982001-03-06 09:45:18 +00001464 if (tcp->u_arg[0] == _STAT64_VER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01001465 printstat64(tcp, tcp->u_arg[2]);
John Hughes8fe2c982001-03-06 09:45:18 +00001466 else
Denys Vlasenko84703742012-02-25 02:38:52 +01001467# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001468 printstat(tcp, tcp->u_arg[2]);
1469 }
1470 return 0;
1471}
1472
1473int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001474sys_xmknod(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001475{
1476 int mode = tcp->u_arg[2];
1477
1478 if (entering(tcp)) {
1479 tprintf("%ld, ", tcp->u_arg[0]);
1480 printpath(tcp, tcp->u_arg[1]);
1481 tprintf(", %s", sprintmode(mode));
1482 switch (mode & S_IFMT) {
1483 case S_IFCHR: case S_IFBLK:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001484 tprintf(", makedev(%lu, %lu)",
1485 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1486 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001487 break;
1488 default:
1489 break;
1490 }
1491 }
1492 return 0;
1493}
1494
Denys Vlasenko84703742012-02-25 02:38:52 +01001495# ifdef HAVE_SYS_ACL_H
Wichert Akkerman8829a551999-06-11 13:18:40 +00001496
Denys Vlasenko84703742012-02-25 02:38:52 +01001497# include <sys/acl.h>
Wichert Akkerman8829a551999-06-11 13:18:40 +00001498
Roland McGratha4d48532005-06-08 20:45:28 +00001499static const struct xlat aclcmds[] = {
Denys Vlasenko84703742012-02-25 02:38:52 +01001500# ifdef SETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001501 { SETACL, "SETACL" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001502# endif
1503# ifdef GETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001504 { GETACL, "GETACL" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001505# endif
1506# ifdef GETACLCNT
Wichert Akkerman8829a551999-06-11 13:18:40 +00001507 { GETACLCNT, "GETACLCNT" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001508# endif
1509# ifdef ACL_GET
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001510 { ACL_GET, "ACL_GET" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001511# endif
1512# ifdef ACL_SET
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001513 { ACL_SET, "ACL_SET" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001514# endif
1515# ifdef ACL_CNT
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001516 { ACL_CNT, "ACL_CNT" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001517# endif
Wichert Akkerman8829a551999-06-11 13:18:40 +00001518 { 0, NULL },
1519};
1520
1521int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001522sys_acl(struct tcb *tcp)
Wichert Akkerman8829a551999-06-11 13:18:40 +00001523{
1524 if (entering(tcp)) {
1525 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001526 tprints(", ");
Wichert Akkerman8829a551999-06-11 13:18:40 +00001527 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1528 tprintf(", %ld", tcp->u_arg[2]);
1529 /*
1530 * FIXME - dump out the list of aclent_t's pointed to
1531 * by "tcp->u_arg[3]" if it's not NULL.
1532 */
1533 if (tcp->u_arg[3])
1534 tprintf(", %#lx", tcp->u_arg[3]);
1535 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001536 tprints(", NULL");
Wichert Akkerman8829a551999-06-11 13:18:40 +00001537 }
1538 return 0;
1539}
1540
Wichert Akkerman8829a551999-06-11 13:18:40 +00001541int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001542sys_facl(struct tcb *tcp)
Wichert Akkerman8829a551999-06-11 13:18:40 +00001543{
1544 if (entering(tcp)) {
1545 tprintf("%ld, ", tcp->u_arg[0]);
1546 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1547 tprintf(", %ld", tcp->u_arg[2]);
1548 /*
1549 * FIXME - dump out the list of aclent_t's pointed to
1550 * by "tcp->u_arg[3]" if it's not NULL.
1551 */
1552 if (tcp->u_arg[3])
1553 tprintf(", %#lx", tcp->u_arg[3]);
1554 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001555 tprints(", NULL");
Wichert Akkerman8829a551999-06-11 13:18:40 +00001556 }
1557 return 0;
1558}
1559
Roland McGratha4d48532005-06-08 20:45:28 +00001560static const struct xlat aclipc[] = {
Denys Vlasenko84703742012-02-25 02:38:52 +01001561# ifdef IPC_SHM
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001562 { IPC_SHM, "IPC_SHM" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001563# endif
1564# ifdef IPC_SEM
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001565 { IPC_SEM, "IPC_SEM" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001566# endif
1567# ifdef IPC_MSG
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001568 { IPC_MSG, "IPC_MSG" },
Denys Vlasenko84703742012-02-25 02:38:52 +01001569# endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001570 { 0, NULL },
1571};
1572
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001573int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001574sys_aclipc(struct tcb *tcp)
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001575{
1576 if (entering(tcp)) {
1577 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1578 tprintf(", %#lx, ", tcp->u_arg[1]);
1579 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1580 tprintf(", %ld", tcp->u_arg[3]);
1581 /*
1582 * FIXME - dump out the list of aclent_t's pointed to
1583 * by "tcp->u_arg[4]" if it's not NULL.
1584 */
1585 if (tcp->u_arg[4])
1586 tprintf(", %#lx", tcp->u_arg[4]);
1587 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001588 tprints(", NULL");
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001589 }
1590 return 0;
1591}
1592
Denys Vlasenko84703742012-02-25 02:38:52 +01001593# endif /* HAVE_SYS_ACL_H */
Wichert Akkerman8829a551999-06-11 13:18:40 +00001594
Denys Vlasenko84703742012-02-25 02:38:52 +01001595#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001596
Roland McGrathd9f816f2004-09-04 03:39:20 +00001597static const struct xlat fsmagic[] = {
Wichert Akkerman43a74822000-06-27 17:33:32 +00001598 { 0x73757245, "CODA_SUPER_MAGIC" },
1599 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1600 { 0x1373, "DEVFS_SUPER_MAGIC" },
1601 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1602 { 0x414A53, "EFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001603 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1604 { 0xef53, "EXT2_SUPER_MAGIC" },
1605 { 0x137d, "EXT_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001606 { 0xf995e849, "HPFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001607 { 0x9660, "ISOFS_SUPER_MAGIC" },
1608 { 0x137f, "MINIX_SUPER_MAGIC" },
1609 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001610 { 0x2468, "MINIX2_SUPER_MAGIC" },
1611 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001612 { 0x4d44, "MSDOS_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001613 { 0x564c, "NCP_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001614 { 0x6969, "NFS_SUPER_MAGIC" },
1615 { 0x9fa0, "PROC_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001616 { 0x002f, "QNX4_SUPER_MAGIC" },
1617 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1618 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1619 { 0x517b, "SMB_SUPER_MAGIC" },
1620 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1621 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1622 { 0x00011954, "UFS_MAGIC" },
1623 { 0x54190100, "UFS_CIGAM" },
1624 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001625 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
Roland McGrathc767ad82004-01-13 10:13:45 +00001626 { 0x62656572, "SYSFS_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001627 { 0, NULL },
1628};
1629
Roland McGrathf9c49b22004-10-06 22:11:54 +00001630static const char *
Denys Vlasenko1d632462009-04-14 12:51:00 +00001631sprintfstype(int magic)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001632{
1633 static char buf[32];
Roland McGrathf9c49b22004-10-06 22:11:54 +00001634 const char *s;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001635
1636 s = xlookup(fsmagic, magic);
1637 if (s) {
1638 sprintf(buf, "\"%s\"", s);
1639 return buf;
1640 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001641 sprintf(buf, "%#x", magic);
1642 return buf;
1643}
1644
1645static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001646printstatfs(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001647{
1648 struct statfs statbuf;
1649
1650 if (syserror(tcp) || !verbose(tcp)) {
1651 tprintf("%#lx", addr);
1652 return;
1653 }
1654 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001655 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001656 return;
1657 }
1658#ifdef ALPHA
1659
1660 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1661 sprintfstype(statbuf.f_type),
1662 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Roland McGrathab147c52003-07-17 09:03:02 +00001663 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001664 statbuf.f_bavail, statbuf.f_files, statbuf.f_ffree,
Roland McGrathab147c52003-07-17 09:03:02 +00001665 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1666 statbuf.f_namelen);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001667#else /* !ALPHA */
1668 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1669 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +00001670 (unsigned long)statbuf.f_bsize,
1671 (unsigned long)statbuf.f_blocks,
1672 (unsigned long)statbuf.f_bfree);
Roland McGrathab147c52003-07-17 09:03:02 +00001673 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1674 (unsigned long)statbuf.f_bavail,
Nate Sammons5c74d201999-04-06 01:37:51 +00001675 (unsigned long)statbuf.f_files,
Roland McGrathab147c52003-07-17 09:03:02 +00001676 (unsigned long)statbuf.f_ffree,
1677 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001678 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001679#endif /* !ALPHA */
Roland McGrathab147c52003-07-17 09:03:02 +00001680#ifdef _STATFS_F_FRSIZE
1681 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1682#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001683 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001684}
1685
1686int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001687sys_statfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001688{
1689 if (entering(tcp)) {
1690 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001691 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001692 } else {
1693 printstatfs(tcp, tcp->u_arg[1]);
1694 }
1695 return 0;
1696}
1697
1698int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001699sys_fstatfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001700{
1701 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001702 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001703 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001704 } else {
1705 printstatfs(tcp, tcp->u_arg[1]);
1706 }
1707 return 0;
1708}
1709
Denys Vlasenko84703742012-02-25 02:38:52 +01001710#if defined HAVE_STATFS64
Roland McGrathab147c52003-07-17 09:03:02 +00001711static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001712printstatfs64(struct tcb *tcp, long addr)
Roland McGrathab147c52003-07-17 09:03:02 +00001713{
1714 struct statfs64 statbuf;
1715
1716 if (syserror(tcp) || !verbose(tcp)) {
1717 tprintf("%#lx", addr);
1718 return;
1719 }
1720 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001721 tprints("{...}");
Roland McGrathab147c52003-07-17 09:03:02 +00001722 return;
1723 }
Roland McGrath08738432005-06-03 02:40:39 +00001724 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
Roland McGrathab147c52003-07-17 09:03:02 +00001725 sprintfstype(statbuf.f_type),
Roland McGrath08738432005-06-03 02:40:39 +00001726 (unsigned long long)statbuf.f_bsize,
1727 (unsigned long long)statbuf.f_blocks,
1728 (unsigned long long)statbuf.f_bfree);
1729 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1730 (unsigned long long)statbuf.f_bavail,
1731 (unsigned long long)statbuf.f_files,
1732 (unsigned long long)statbuf.f_ffree,
Roland McGrathab147c52003-07-17 09:03:02 +00001733 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1734 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Roland McGrathab147c52003-07-17 09:03:02 +00001735#ifdef _STATFS_F_FRSIZE
Roland McGrath08738432005-06-03 02:40:39 +00001736 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
Roland McGrathab147c52003-07-17 09:03:02 +00001737#endif
Andreas Schwab000d66f2012-01-17 18:13:33 +01001738#ifdef _STATFS_F_FLAGS
1739 tprintf(", f_flags=%llu", (unsigned long long)statbuf.f_flags);
1740#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001741 tprints("}");
Roland McGrathab147c52003-07-17 09:03:02 +00001742}
1743
Andreas Schwab7d558012012-01-17 18:14:22 +01001744struct compat_statfs64 {
1745 uint32_t f_type;
1746 uint32_t f_bsize;
1747 uint64_t f_blocks;
1748 uint64_t f_bfree;
1749 uint64_t f_bavail;
1750 uint64_t f_files;
1751 uint64_t f_ffree;
1752 fsid_t f_fsid;
1753 uint32_t f_namelen;
1754 uint32_t f_frsize;
1755 uint32_t f_flags;
1756 uint32_t f_spare[4];
1757}
1758#if defined(X86_64) || defined(IA64)
1759 __attribute__ ((packed, aligned(4)))
1760#endif
1761;
1762
1763static void
1764printcompat_statfs64(struct tcb *tcp, long addr)
1765{
1766 struct compat_statfs64 statbuf;
1767
1768 if (syserror(tcp) || !verbose(tcp)) {
1769 tprintf("%#lx", addr);
1770 return;
1771 }
1772 if (umove(tcp, addr, &statbuf) < 0) {
1773 tprints("{...}");
1774 return;
1775 }
1776 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%llu, f_bfree=%llu, ",
1777 sprintfstype(statbuf.f_type),
1778 (unsigned long)statbuf.f_bsize,
1779 (unsigned long long)statbuf.f_blocks,
1780 (unsigned long long)statbuf.f_bfree);
1781 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1782 (unsigned long long)statbuf.f_bavail,
1783 (unsigned long long)statbuf.f_files,
1784 (unsigned long long)statbuf.f_ffree,
1785 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1786 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
1787 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001788 tprintf(", f_flags=%lu}", (unsigned long)statbuf.f_frsize);
Andreas Schwab7d558012012-01-17 18:14:22 +01001789}
1790
Roland McGrathab147c52003-07-17 09:03:02 +00001791int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001792sys_statfs64(struct tcb *tcp)
Roland McGrathab147c52003-07-17 09:03:02 +00001793{
1794 if (entering(tcp)) {
1795 printpath(tcp, tcp->u_arg[0]);
1796 tprintf(", %lu, ", tcp->u_arg[1]);
1797 } else {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001798 if (tcp->u_arg[1] == sizeof(struct statfs64))
Roland McGrathab147c52003-07-17 09:03:02 +00001799 printstatfs64(tcp, tcp->u_arg[2]);
Andreas Schwab7d558012012-01-17 18:14:22 +01001800 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
1801 printcompat_statfs64(tcp, tcp->u_arg[2]);
Roland McGrathab147c52003-07-17 09:03:02 +00001802 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001803 tprints("{???}");
Roland McGrathab147c52003-07-17 09:03:02 +00001804 }
1805 return 0;
1806}
1807
1808int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001809sys_fstatfs64(struct tcb *tcp)
Roland McGrathab147c52003-07-17 09:03:02 +00001810{
1811 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001812 printfd(tcp, tcp->u_arg[0]);
1813 tprintf(", %lu, ", tcp->u_arg[1]);
Roland McGrathab147c52003-07-17 09:03:02 +00001814 } else {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001815 if (tcp->u_arg[1] == sizeof(struct statfs64))
Roland McGrathab147c52003-07-17 09:03:02 +00001816 printstatfs64(tcp, tcp->u_arg[2]);
Andreas Schwab7d558012012-01-17 18:14:22 +01001817 else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
1818 printcompat_statfs64(tcp, tcp->u_arg[2]);
Roland McGrathab147c52003-07-17 09:03:02 +00001819 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001820 tprints("{???}");
Roland McGrathab147c52003-07-17 09:03:02 +00001821 }
1822 return 0;
1823}
1824#endif
1825
Denys Vlasenkoc36c3522012-02-25 02:47:15 +01001826#if defined(ALPHA)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001827int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001828osf_statfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001829{
1830 if (entering(tcp)) {
1831 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001832 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001833 } else {
1834 printstatfs(tcp, tcp->u_arg[1]);
1835 tprintf(", %lu", tcp->u_arg[2]);
1836 }
1837 return 0;
1838}
1839
1840int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001841osf_fstatfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001842{
1843 if (entering(tcp)) {
1844 tprintf("%lu, ", tcp->u_arg[0]);
1845 } else {
1846 printstatfs(tcp, tcp->u_arg[1]);
1847 tprintf(", %lu", tcp->u_arg[2]);
1848 }
1849 return 0;
1850}
Denys Vlasenko84703742012-02-25 02:38:52 +01001851#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001852
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001853/* directory */
1854int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001855sys_chdir(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001856{
1857 if (entering(tcp)) {
1858 printpath(tcp, tcp->u_arg[0]);
1859 }
1860 return 0;
1861}
1862
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001863static int
1864decode_mkdir(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001865{
1866 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001867 printpath(tcp, tcp->u_arg[offset]);
1868 tprintf(", %#lo", tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001869 }
1870 return 0;
1871}
1872
1873int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001874sys_mkdir(struct tcb *tcp)
1875{
1876 return decode_mkdir(tcp, 0);
1877}
1878
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001879int
1880sys_mkdirat(struct tcb *tcp)
1881{
1882 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03001883 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001884 return decode_mkdir(tcp, 1);
1885}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001886
1887int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001888sys_link(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001889{
1890 if (entering(tcp)) {
1891 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001892 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001893 printpath(tcp, tcp->u_arg[1]);
1894 }
1895 return 0;
1896}
1897
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001898int
1899sys_linkat(struct tcb *tcp)
1900{
1901 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001902 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001903 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001904 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001905 print_dirfd(tcp, tcp->u_arg[2]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001906 printpath(tcp, tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001907 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001908 printflags(at_flags, tcp->u_arg[4], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001909 }
1910 return 0;
1911}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001912
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001913int
1914sys_unlinkat(struct tcb *tcp)
1915{
1916 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001917 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001918 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001919 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00001920 printflags(at_flags, tcp->u_arg[2], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001921 }
1922 return 0;
1923}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001924
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001925int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001926sys_symlinkat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001927{
1928 if (entering(tcp)) {
1929 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001930 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001931 print_dirfd(tcp, tcp->u_arg[1]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001932 printpath(tcp, tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001933 }
1934 return 0;
1935}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001936
1937static int
1938decode_readlink(struct tcb *tcp, int offset)
1939{
1940 if (entering(tcp)) {
1941 printpath(tcp, tcp->u_arg[offset]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001942 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001943 } else {
1944 if (syserror(tcp))
1945 tprintf("%#lx", tcp->u_arg[offset + 1]);
1946 else
Denys Vlasenko3449ae82012-01-27 17:24:26 +01001947 /* Used to use printpathn(), but readlink
1948 * neither includes NUL in the returned count,
1949 * nor actually writes it into memory.
1950 * printpathn() would decide on printing
1951 * "..." continuation based on garbage
1952 * past return buffer's end.
1953 */
1954 printstr(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001955 tprintf(", %lu", tcp->u_arg[offset + 2]);
1956 }
1957 return 0;
1958}
1959
1960int
1961sys_readlink(struct tcb *tcp)
1962{
1963 return decode_readlink(tcp, 0);
1964}
1965
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001966int
1967sys_readlinkat(struct tcb *tcp)
1968{
1969 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03001970 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001971 return decode_readlink(tcp, 1);
1972}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001973
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001974int
1975sys_renameat(struct tcb *tcp)
1976{
1977 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001978 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001979 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001980 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001981 print_dirfd(tcp, tcp->u_arg[2]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001982 printpath(tcp, tcp->u_arg[3]);
1983 }
1984 return 0;
1985}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001986
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001987int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001988sys_chown(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001989{
1990 if (entering(tcp)) {
1991 printpath(tcp, tcp->u_arg[0]);
Roland McGrath6bc12202003-11-13 22:32:27 +00001992 printuid(", ", tcp->u_arg[1]);
1993 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001994 }
1995 return 0;
1996}
1997
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001998int
1999sys_fchownat(struct tcb *tcp)
2000{
2001 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002002 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002003 printpath(tcp, tcp->u_arg[1]);
2004 printuid(", ", tcp->u_arg[2]);
2005 printuid(", ", tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002006 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00002007 printflags(at_flags, tcp->u_arg[4], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002008 }
2009 return 0;
2010}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002011
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002012int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002013sys_fchown(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002014{
2015 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002016 printfd(tcp, tcp->u_arg[0]);
Roland McGrath6bc12202003-11-13 22:32:27 +00002017 printuid(", ", tcp->u_arg[1]);
2018 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002019 }
2020 return 0;
2021}
2022
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002023static int
2024decode_chmod(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002025{
2026 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002027 printpath(tcp, tcp->u_arg[offset]);
2028 tprintf(", %#lo", tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002029 }
2030 return 0;
2031}
2032
2033int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002034sys_chmod(struct tcb *tcp)
2035{
2036 return decode_chmod(tcp, 0);
2037}
2038
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002039int
2040sys_fchmodat(struct tcb *tcp)
2041{
2042 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03002043 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002044 return decode_chmod(tcp, 1);
2045}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002046
2047int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002048sys_fchmod(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002049{
2050 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002051 printfd(tcp, tcp->u_arg[0]);
2052 tprintf(", %#lo", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002053 }
2054 return 0;
2055}
2056
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002057#ifdef ALPHA
2058int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002059sys_osf_utimes(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002060{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002061 if (entering(tcp)) {
2062 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002063 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002064 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
2065 }
2066 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002067}
2068#endif
2069
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002070static int
Roland McGrath6afc5652007-07-24 01:57:11 +00002071decode_utimes(struct tcb *tcp, int offset, int special)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002072{
2073 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002074 printpath(tcp, tcp->u_arg[offset]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002075 tprints(", ");
Roland McGrath6afc5652007-07-24 01:57:11 +00002076 if (tcp->u_arg[offset + 1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002077 tprints("NULL");
Roland McGrath6afc5652007-07-24 01:57:11 +00002078 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002079 tprints("{");
Roland McGrath6afc5652007-07-24 01:57:11 +00002080 printtv_bitness(tcp, tcp->u_arg[offset + 1],
2081 BITNESS_CURRENT, special);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002082 tprints(", ");
Roland McGrathe6d0f712007-08-07 01:22:49 +00002083 printtv_bitness(tcp, tcp->u_arg[offset + 1]
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002084 + sizeof(struct timeval),
Roland McGrath6afc5652007-07-24 01:57:11 +00002085 BITNESS_CURRENT, special);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002086 tprints("}");
Roland McGrath6afc5652007-07-24 01:57:11 +00002087 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002088 }
2089 return 0;
2090}
2091
2092int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002093sys_utimes(struct tcb *tcp)
2094{
Roland McGrath6afc5652007-07-24 01:57:11 +00002095 return decode_utimes(tcp, 0, 0);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002096}
2097
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002098int
2099sys_futimesat(struct tcb *tcp)
2100{
2101 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03002102 print_dirfd(tcp, tcp->u_arg[0]);
Roland McGrath6afc5652007-07-24 01:57:11 +00002103 return decode_utimes(tcp, 1, 0);
2104}
2105
2106int
2107sys_utimensat(struct tcb *tcp)
2108{
2109 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002110 print_dirfd(tcp, tcp->u_arg[0]);
Roland McGrath6afc5652007-07-24 01:57:11 +00002111 decode_utimes(tcp, 1, 1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002112 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +00002113 printflags(at_flags, tcp->u_arg[3], "AT_???");
Roland McGrath6afc5652007-07-24 01:57:11 +00002114 }
2115 return 0;
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002116}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002117
2118int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002119sys_utime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002120{
Roland McGrath7e9817c2007-07-05 20:31:58 +00002121 union {
2122 long utl[2];
2123 int uti[2];
2124 } u;
Denys Vlasenko9fd4f962012-03-19 09:36:42 +01002125 unsigned wordsize = current_wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002126
2127 if (entering(tcp)) {
2128 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002129 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002130 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002131 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002132 else if (!verbose(tcp))
2133 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01002134 else if (umoven(tcp, tcp->u_arg[1], 2 * wordsize, (char *) &u) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002135 tprints("[?, ?]");
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01002136 else if (wordsize == sizeof u.utl[0]) {
Roland McGrath7e9817c2007-07-05 20:31:58 +00002137 tprintf("[%s,", sprinttime(u.utl[0]));
2138 tprintf(" %s]", sprinttime(u.utl[1]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002139 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01002140 else if (wordsize == sizeof u.uti[0]) {
Roland McGrath7e9817c2007-07-05 20:31:58 +00002141 tprintf("[%s,", sprinttime(u.uti[0]));
2142 tprintf(" %s]", sprinttime(u.uti[1]));
2143 }
2144 else
2145 abort();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002146 }
2147 return 0;
2148}
2149
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002150static int
2151decode_mknod(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002152{
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002153 int mode = tcp->u_arg[offset + 1];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002154
2155 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002156 printpath(tcp, tcp->u_arg[offset]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002157 tprintf(", %s", sprintmode(mode));
2158 switch (mode & S_IFMT) {
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002159 case S_IFCHR:
2160 case S_IFBLK:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002161#ifdef LINUXSPARC
2162 if (current_personality == 1)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002163 tprintf(", makedev(%lu, %lu)",
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002164 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
2165 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002166 else
Roland McGrath186c5ac2002-12-15 23:58:23 +00002167#endif
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002168 tprintf(", makedev(%lu, %lu)",
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002169 (unsigned long) major(tcp->u_arg[offset + 2]),
2170 (unsigned long) minor(tcp->u_arg[offset + 2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002171 break;
2172 default:
2173 break;
2174 }
2175 }
2176 return 0;
2177}
2178
2179int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002180sys_mknod(struct tcb *tcp)
2181{
2182 return decode_mknod(tcp, 0);
2183}
2184
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002185int
2186sys_mknodat(struct tcb *tcp)
2187{
2188 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03002189 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002190 return decode_mknod(tcp, 1);
2191}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002192
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002193static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002194printdir(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002195{
2196 struct dirent d;
2197
2198 if (!verbose(tcp)) {
2199 tprintf("%#lx", addr);
2200 return;
2201 }
2202 if (umove(tcp, addr, &d) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002203 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002204 return;
2205 }
2206 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002207 tprints("d_name=");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002208 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002209 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002210}
2211
2212int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002213sys_readdir(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002214{
2215 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002216 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002217 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002218 } else {
2219 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
2220 tprintf("%#lx", tcp->u_arg[1]);
2221 else
2222 printdir(tcp, tcp->u_arg[1]);
2223 /* Not much point in printing this out, it is always 1. */
2224 if (tcp->u_arg[2] != 1)
2225 tprintf(", %lu", tcp->u_arg[2]);
2226 }
2227 return 0;
2228}
2229
Roland McGratha4d48532005-06-08 20:45:28 +00002230static const struct xlat direnttypes[] = {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002231 { DT_UNKNOWN, "DT_UNKNOWN" },
2232 { DT_FIFO, "DT_FIFO" },
2233 { DT_CHR, "DT_CHR" },
2234 { DT_DIR, "DT_DIR" },
2235 { DT_BLK, "DT_BLK" },
2236 { DT_REG, "DT_REG" },
2237 { DT_LNK, "DT_LNK" },
2238 { DT_SOCK, "DT_SOCK" },
2239 { DT_WHT, "DT_WHT" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002240 { 0, NULL },
2241};
2242
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002243int
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002244sys_getdents(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002245{
2246 int i, len, dents = 0;
2247 char *buf;
2248
2249 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002250 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002251 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002252 return 0;
2253 }
2254 if (syserror(tcp) || !verbose(tcp)) {
2255 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2256 return 0;
2257 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002258 len = tcp->u_rval;
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002259 /* Beware of insanely large or negative values in tcp->u_rval */
2260 if (tcp->u_rval > 1024*1024)
2261 len = 1024*1024;
2262 if (tcp->u_rval < 0)
2263 len = 0;
Mike Frysinger229738c2009-10-07 20:41:56 -04002264 buf = len ? malloc(len) : NULL;
Denys Vlasenko1d46ba52011-08-31 14:00:02 +02002265 if (len && !buf)
2266 die_out_of_memory();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002267 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002268 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002269 free(buf);
2270 return 0;
2271 }
2272 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002273 tprints("{");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002274 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00002275 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002276 if (!abbrev(tcp)) {
2277 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2278 i ? " " : "", d->d_ino, d->d_off);
Dmitry V. Levinad232c62012-08-16 19:29:55 +00002279 tprintf("d_reclen=%u, d_name=\"%s\", d_type=",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002280 d->d_reclen, d->d_name);
Dmitry V. Levinad232c62012-08-16 19:29:55 +00002281 printxval(direnttypes, buf[i + d->d_reclen - 1], "DT_???");
2282 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002283 }
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{
Dmitry V. Levin1f215132012-12-07 21:38:52 +00002469 if (insize == 0)
2470 failed = 1;
Denys Vlasenko1d632462009-04-14 12:51:00 +00002471 if (!failed) {
2472 unsigned long capacity = 4 * size + 1;
2473 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
2474 if (buf == NULL || /* probably a bogus size argument */
2475 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2476 failed = 1;
Roland McGrath883567c2005-02-02 03:38:32 +00002477 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002478 else {
2479 unsigned char *out = buf;
2480 unsigned char *in = &buf[3 * size];
2481 size_t i;
2482 for (i = 0; i < size; ++i) {
2483 if (isprint(in[i]))
2484 *out++ = in[i];
2485 else {
2486#define tohex(n) "0123456789abcdef"[n]
2487 *out++ = '\\';
2488 *out++ = 'x';
2489 *out++ = tohex(in[i] / 16);
2490 *out++ = tohex(in[i] % 16);
2491 }
2492 }
2493 /* Don't print terminating NUL if there is one. */
2494 if (i > 0 && in[i - 1] == '\0')
2495 out -= 4;
2496 *out = '\0';
2497 tprintf(", \"%s\", %ld", buf, insize);
2498 }
2499 free(buf);
Roland McGrath883567c2005-02-02 03:38:32 +00002500 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002501 if (failed)
2502 tprintf(", 0x%lx, %ld", arg, insize);
Roland McGrath3292e222004-08-31 06:30:48 +00002503}
2504
Roland McGrath186c5ac2002-12-15 23:58:23 +00002505int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002506sys_setxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002507{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002508 if (entering(tcp)) {
2509 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002510 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002511 printstr(tcp, tcp->u_arg[1], -1);
2512 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002513 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002514 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2515 }
2516 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002517}
2518
2519int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002520sys_fsetxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002521{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002522 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002523 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002524 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002525 printstr(tcp, tcp->u_arg[1], -1);
2526 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002527 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002528 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2529 }
2530 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002531}
2532
2533int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002534sys_getxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002535{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002536 if (entering(tcp)) {
2537 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002538 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002539 printstr(tcp, tcp->u_arg[1], -1);
2540 } else {
2541 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2542 tcp->u_rval);
2543 }
2544 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002545}
2546
2547int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002548sys_fgetxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002549{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002550 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002551 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002552 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002553 printstr(tcp, tcp->u_arg[1], -1);
2554 } else {
2555 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2556 tcp->u_rval);
2557 }
2558 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002559}
2560
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002561static void
2562print_xattr_list(struct tcb *tcp, unsigned long addr, unsigned long size)
2563{
2564 if (syserror(tcp)) {
2565 tprintf("%#lx", addr);
2566 } else {
2567 if (!addr) {
2568 tprints("NULL");
2569 } else {
2570 unsigned long len =
2571 (size < tcp->u_rval) ? size : tcp->u_rval;
2572 printstr(tcp, addr, len);
2573 }
2574 }
2575 tprintf(", %lu", size);
2576}
2577
Roland McGrath186c5ac2002-12-15 23:58:23 +00002578int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002579sys_listxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002580{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002581 if (entering(tcp)) {
2582 printpath(tcp, tcp->u_arg[0]);
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002583 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002584 } else {
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002585 print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002586 }
2587 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002588}
2589
2590int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002591sys_flistxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002592{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002593 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002594 printfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002595 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002596 } else {
Dmitry V. Levin33d24762012-03-14 16:34:32 +00002597 print_xattr_list(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002598 }
2599 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002600}
2601
2602int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002603sys_removexattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002604{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002605 if (entering(tcp)) {
2606 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002607 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002608 printstr(tcp, tcp->u_arg[1], -1);
2609 }
2610 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002611}
2612
2613int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002614sys_fremovexattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002615{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002616 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002617 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002618 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002619 printstr(tcp, tcp->u_arg[1], -1);
2620 }
2621 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002622}
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002623
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002624static const struct xlat advise[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002625 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2626 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2627 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2628 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2629 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2630 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2631 { 0, NULL }
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002632};
2633
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002634int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002635sys_fadvise64(struct tcb *tcp)
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002636{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002637 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002638 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +03002639 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenkod33e72a2012-05-18 02:03:24 +02002640 argn = printllval(tcp, ", %lld", 1);
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002641 tprintf(", %ld, ", tcp->u_arg[argn++]);
2642 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002643 }
2644 return 0;
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002645}
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002646
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002647int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002648sys_fadvise64_64(struct tcb *tcp)
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002649{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002650 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002651 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +03002652 printfd(tcp, tcp->u_arg[0]);
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002653#if defined ARM || defined POWERPC
Denys Vlasenkod33e72a2012-05-18 02:03:24 +02002654 argn = printllval(tcp, ", %lld, ", 2);
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002655#else
Denys Vlasenkod33e72a2012-05-18 02:03:24 +02002656 argn = printllval(tcp, ", %lld, ", 1);
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002657#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 Vlasenkod33e72a2012-05-18 02:03:24 +02002735 tprintf(", %#lo, ", tcp->u_arg[1]); /* mode */
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002736 argn = printllval(tcp, "%llu, ", 2); /* offset */
2737 printllval(tcp, "%llu", argn); /* len */
Roland McGrath96a96612008-05-20 04:56:18 +00002738 }
2739 return 0;
2740}
Dmitry V. Levin88293652012-03-09 21:02:19 +00002741
Dmitry V. Levinad0c01e2012-03-15 00:52:22 +00002742#ifndef SWAP_FLAG_PREFER
2743# define SWAP_FLAG_PREFER 0x8000
2744#endif
2745#ifndef SWAP_FLAG_DISCARD
2746# define SWAP_FLAG_DISCARD 0x10000
2747#endif
Dmitry V. Levin88293652012-03-09 21:02:19 +00002748static const struct xlat swap_flags[] = {
2749 { SWAP_FLAG_PREFER, "SWAP_FLAG_PREFER" },
2750 { SWAP_FLAG_DISCARD, "SWAP_FLAG_DISCARD" },
2751 { 0, NULL }
2752};
2753
2754int
2755sys_swapon(struct tcb *tcp)
2756{
2757 if (entering(tcp)) {
2758 int flags = tcp->u_arg[1];
2759 printpath(tcp, tcp->u_arg[0]);
2760 tprints(", ");
2761 printflags(swap_flags, flags & ~SWAP_FLAG_PRIO_MASK,
2762 "SWAP_FLAG_???");
2763 if (flags & SWAP_FLAG_PREFER)
2764 tprintf("|%d", flags & SWAP_FLAG_PRIO_MASK);
2765 }
2766 return 0;
2767}
H.J. Lu085e4282012-04-17 11:05:04 -07002768
2769#ifdef X32
2770# undef stat64
2771# undef sys_fstat64
2772# undef sys_stat64
2773
2774static void
2775realprintstat64(struct tcb *tcp, long addr)
2776{
2777 struct stat64 statbuf;
2778
2779 if (!addr) {
2780 tprints("NULL");
2781 return;
2782 }
2783 if (syserror(tcp) || !verbose(tcp)) {
2784 tprintf("%#lx", addr);
2785 return;
2786 }
2787
2788 if (umove(tcp, addr, &statbuf) < 0) {
2789 tprints("{...}");
2790 return;
2791 }
2792
2793 if (!abbrev(tcp)) {
2794 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
2795 (unsigned long) major(statbuf.st_dev),
2796 (unsigned long) minor(statbuf.st_dev),
2797 (unsigned long long) statbuf.st_ino,
2798 sprintmode(statbuf.st_mode));
2799 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
2800 (unsigned long) statbuf.st_nlink,
2801 (unsigned long) statbuf.st_uid,
2802 (unsigned long) statbuf.st_gid);
2803 tprintf("st_blksize=%lu, ",
2804 (unsigned long) statbuf.st_blksize);
2805 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
2806 }
2807 else
2808 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
2809 switch (statbuf.st_mode & S_IFMT) {
2810 case S_IFCHR: case S_IFBLK:
2811 tprintf("st_rdev=makedev(%lu, %lu), ",
2812 (unsigned long) major(statbuf.st_rdev),
2813 (unsigned long) minor(statbuf.st_rdev));
2814 break;
2815 default:
2816 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
2817 break;
2818 }
2819 if (!abbrev(tcp)) {
2820 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
2821 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
2822 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
2823 tprints("}");
2824 }
2825 else
2826 tprints("...}");
2827}
2828
2829int
2830sys_fstat64(struct tcb *tcp)
2831{
2832 if (entering(tcp)) {
2833 printfd(tcp, tcp->u_arg[0]);
2834 tprints(", ");
2835 } else {
2836 realprintstat64(tcp, tcp->u_arg[1]);
2837 }
2838 return 0;
2839}
2840
2841int
2842sys_stat64(struct tcb *tcp)
2843{
2844 if (entering(tcp)) {
2845 printpath(tcp, tcp->u_arg[0]);
2846 tprints(", ");
2847 } else {
2848 realprintstat64(tcp, tcp->u_arg[1]);
2849 }
2850 return 0;
2851}
2852#endif