blob: 473e6fda16366a920b9968454c8ef28f5fe5194a [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.
29 *
30 * $Id$
31 */
32
33#include "defs.h"
34
35#include <dirent.h>
Roland McGrathc531e572008-08-01 01:13:10 +000036
Michal Ludvig53b320f2002-09-23 13:30:09 +000037#ifdef LINUX
Roland McGrathc531e572008-08-01 01:13:10 +000038struct kernel_dirent {
39 unsigned long d_ino;
40 unsigned long d_off;
41 unsigned short d_reclen;
42 char d_name[1];
43};
Wichert Akkerman9524bb91999-05-25 23:11:18 +000044#else
Roland McGrathc531e572008-08-01 01:13:10 +000045# define kernel_dirent dirent
Wichert Akkerman9524bb91999-05-25 23:11:18 +000046#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000047
Michal Ludvig53b320f2002-09-23 13:30:09 +000048#ifdef LINUX
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000049# ifdef LINUXSPARC
50struct stat {
51 unsigned short st_dev;
52 unsigned int st_ino;
53 unsigned short st_mode;
54 short st_nlink;
55 unsigned short st_uid;
56 unsigned short st_gid;
57 unsigned short st_rdev;
58 unsigned int st_size;
59 int st_atime;
60 unsigned int __unused1;
61 int st_mtime;
62 unsigned int __unused2;
63 int st_ctime;
64 unsigned int __unused3;
65 int st_blksize;
66 int st_blocks;
67 unsigned int __unused4[2];
68};
Roland McGrath6d1a65c2004-07-12 07:44:08 +000069#if defined(SPARC64)
70struct stat_sparc64 {
71 unsigned int st_dev;
72 unsigned long st_ino;
73 unsigned int st_mode;
74 unsigned int st_nlink;
75 unsigned int st_uid;
76 unsigned int st_gid;
77 unsigned int st_rdev;
78 long st_size;
79 long st_atime;
80 long st_mtime;
81 long st_ctime;
82 long st_blksize;
83 long st_blocks;
84 unsigned long __unused4[2];
85};
86#endif /* SPARC64 */
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000087# define stat kernel_stat
88# include <asm/stat.h>
89# undef stat
90# else
Wichert Akkerman5b4d1281999-07-09 00:32:54 +000091# undef dev_t
92# undef ino_t
93# undef mode_t
94# undef nlink_t
95# undef uid_t
96# undef gid_t
97# undef off_t
98# undef loff_t
99
Wichert Akkermana6013701999-07-08 14:00:58 +0000100# define dev_t __kernel_dev_t
101# define ino_t __kernel_ino_t
102# define mode_t __kernel_mode_t
103# define nlink_t __kernel_nlink_t
104# define uid_t __kernel_uid_t
105# define gid_t __kernel_gid_t
106# define off_t __kernel_off_t
107# define loff_t __kernel_loff_t
108
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000109# include <asm/stat.h>
Wichert Akkermana6013701999-07-08 14:00:58 +0000110
111# undef dev_t
112# undef ino_t
113# undef mode_t
114# undef nlink_t
115# undef uid_t
116# undef gid_t
117# undef off_t
118# undef loff_t
Wichert Akkerman5b4d1281999-07-09 00:32:54 +0000119
120# define dev_t dev_t
121# define ino_t ino_t
122# define mode_t mode_t
123# define nlink_t nlink_t
124# define uid_t uid_t
125# define gid_t gid_t
126# define off_t off_t
127# define loff_t loff_t
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000128# endif
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000129# ifdef HPPA /* asm-parisc/stat.h defines stat64 */
130# undef stat64
131# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000132# define stat libc_stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000133# define stat64 libc_stat64
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000134# include <sys/stat.h>
135# undef stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000136# undef stat64
Roland McGrathca16a402003-01-09 06:53:22 +0000137 /* These might be macros. */
138# undef st_atime
139# undef st_mtime
140# undef st_ctime
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000141# ifdef HPPA
142# define stat64 hpux_stat64
143# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000144#else
145# include <sys/stat.h>
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000146#endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000147
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000148#include <fcntl.h>
149
150#ifdef SVR4
151# include <sys/cred.h>
152#endif /* SVR4 */
153
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000154#ifdef HAVE_SYS_VFS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000155#include <sys/vfs.h>
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000156#endif
157
Roland McGrath186c5ac2002-12-15 23:58:23 +0000158#ifdef HAVE_LINUX_XATTR_H
159#include <linux/xattr.h>
160#elif defined linux
161#define XATTR_CREATE 1
162#define XATTR_REPLACE 2
163#endif
164
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000165#ifdef FREEBSD
166#include <sys/param.h>
167#include <sys/mount.h>
168#include <sys/stat.h>
John Hughes70623be2001-03-08 13:59:00 +0000169#endif
170
Dmitry V. Levin1f336e52006-10-14 20:20:46 +0000171#if _LFS64_LARGEFILE && (defined(LINUX) || defined(SVR4))
172# ifdef HAVE_INTTYPES_H
173# include <inttypes.h>
174# else
175# define PRId64 "lld"
176# define PRIu64 "llu"
177# endif
178#endif
179
John Hughes70623be2001-03-08 13:59:00 +0000180#if HAVE_LONG_LONG_OFF_T
181/*
182 * Ugly hacks for systems that have typedef long long off_t
183 */
John Hughesb8c9f772001-03-07 16:53:07 +0000184
185#define stat64 stat
186#define HAVE_STAT64 1 /* Ugly hack */
John Hughes70623be2001-03-08 13:59:00 +0000187
188#define sys_stat64 sys_stat
189#define sys_fstat64 sys_fstat
190#define sys_lstat64 sys_lstat
191#define sys_lseek64 sys_lseek
192#define sys_truncate64 sys_truncate
193#define sys_ftruncate64 sys_ftruncate
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000194#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000195
196#ifdef MAJOR_IN_SYSMACROS
197#include <sys/sysmacros.h>
198#endif
199
200#ifdef MAJOR_IN_MKDEV
201#include <sys/mkdev.h>
202#endif
203
204#ifdef HAVE_SYS_ASYNCH_H
205#include <sys/asynch.h>
206#endif
207
208#ifdef SUNOS4
209#include <ustat.h>
210#endif
211
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000212const struct xlat open_access_modes[] = {
213 { O_RDONLY, "O_RDONLY" },
214 { O_WRONLY, "O_WRONLY" },
215 { O_RDWR, "O_RDWR" },
216#ifdef O_ACCMODE
217 { O_ACCMODE, "O_ACCMODE" },
218#endif
219 { 0, NULL },
220};
221
222const struct xlat open_mode_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000223 { O_CREAT, "O_CREAT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000224 { O_EXCL, "O_EXCL" },
225 { O_NOCTTY, "O_NOCTTY" },
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000226 { O_TRUNC, "O_TRUNC" },
227 { O_APPEND, "O_APPEND" },
228 { O_NONBLOCK, "O_NONBLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000229#ifdef O_SYNC
230 { O_SYNC, "O_SYNC" },
231#endif
232#ifdef O_ASYNC
233 { O_ASYNC, "O_ASYNC" },
234#endif
235#ifdef O_DSYNC
236 { O_DSYNC, "O_DSYNC" },
237#endif
238#ifdef O_RSYNC
239 { O_RSYNC, "O_RSYNC" },
240#endif
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000241#if defined(O_NDELAY) && (O_NDELAY != O_NONBLOCK)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000242 { O_NDELAY, "O_NDELAY" },
243#endif
244#ifdef O_PRIV
245 { O_PRIV, "O_PRIV" },
246#endif
247#ifdef O_DIRECT
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000248 { O_DIRECT, "O_DIRECT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000249#endif
250#ifdef O_LARGEFILE
Roland McGrathfee836e2005-02-02 22:11:32 +0000251# if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
252# undef O_LARGEFILE
253# ifdef SPARC64
254# define O_LARGEFILE 0x40000
255# elif defined X86_64 || defined S390X
256# define O_LARGEFILE 0100000
257# endif
258# endif
Roland McGrath663a8a02005-02-04 09:49:56 +0000259# ifdef O_LARGEFILE
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200260 { O_LARGEFILE, "O_LARGEFILE" },
Roland McGrath663a8a02005-02-04 09:49:56 +0000261# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000262#endif
263#ifdef O_DIRECTORY
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200264 { O_DIRECTORY, "O_DIRECTORY" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000265#endif
266#ifdef O_NOFOLLOW
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200267 { O_NOFOLLOW, "O_NOFOLLOW" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000268#endif
Roland McGrath1025c3e2005-05-09 07:40:35 +0000269#ifdef O_NOATIME
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200270 { O_NOATIME, "O_NOATIME" },
Roland McGrath1025c3e2005-05-09 07:40:35 +0000271#endif
Roland McGrath71d3d662007-08-07 01:00:26 +0000272#ifdef O_CLOEXEC
273 { O_CLOEXEC, "O_CLOEXEC" },
274#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000275
276#ifdef FNDELAY
277 { FNDELAY, "FNDELAY" },
278#endif
279#ifdef FAPPEND
280 { FAPPEND, "FAPPEND" },
281#endif
282#ifdef FMARK
283 { FMARK, "FMARK" },
284#endif
285#ifdef FDEFER
286 { FDEFER, "FDEFER" },
287#endif
288#ifdef FASYNC
289 { FASYNC, "FASYNC" },
290#endif
291#ifdef FSHLOCK
292 { FSHLOCK, "FSHLOCK" },
293#endif
294#ifdef FEXLOCK
295 { FEXLOCK, "FEXLOCK" },
296#endif
297#ifdef FCREAT
298 { FCREAT, "FCREAT" },
299#endif
300#ifdef FTRUNC
301 { FTRUNC, "FTRUNC" },
302#endif
303#ifdef FEXCL
304 { FEXCL, "FEXCL" },
305#endif
306#ifdef FNBIO
307 { FNBIO, "FNBIO" },
308#endif
309#ifdef FSYNC
310 { FSYNC, "FSYNC" },
311#endif
312#ifdef FNOCTTY
313 { FNOCTTY, "FNOCTTY" },
Roland McGrath186c5ac2002-12-15 23:58:23 +0000314#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000315#ifdef O_SHLOCK
316 { O_SHLOCK, "O_SHLOCK" },
317#endif
318#ifdef O_EXLOCK
319 { O_EXLOCK, "O_EXLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000320#endif
321 { 0, NULL },
322};
323
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000324#ifdef LINUX
325
326#ifndef AT_FDCWD
327# define AT_FDCWD -100
328#endif
329
Denys Vlasenkoe740fd32009-04-16 12:06:16 +0000330/* The fd is an "int", so when decoding x86 on x86_64, we need to force sign
331 * extension to get the right value. We do this by declaring fd as int here.
332 */
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000333static void
Dmitry V. Levin31382132011-03-04 05:08:02 +0300334print_dirfd(struct tcb *tcp, int fd)
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000335{
336 if (fd == AT_FDCWD)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200337 tprints("AT_FDCWD, ");
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200338 else {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300339 printfd(tcp, fd);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200340 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +0300341 }
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000342}
343#endif
344
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000345/*
346 * low bits of the open(2) flags define access mode,
347 * other bits are real flags.
348 */
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000349const char *
350sprint_open_modes(mode_t flags)
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000351{
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000352 static char outstr[1024];
353 char *p;
354 char sep = 0;
355 const char *str;
356 const struct xlat *x;
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000357
Denys Vlasenko52845572011-08-31 12:07:38 +0200358 p = stpcpy(outstr, "flags ");
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000359 str = xlookup(open_access_modes, flags & 3);
360 if (str) {
Denys Vlasenko52845572011-08-31 12:07:38 +0200361 p = stpcpy(p, str);
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000362 flags &= ~3;
363 if (!flags)
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000364 return outstr;
365 sep = '|';
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000366 }
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000367
368 for (x = open_mode_flags; x->str; x++) {
369 if ((flags & x->val) == x->val) {
370 if (sep)
371 *p++ = sep;
Denys Vlasenko52845572011-08-31 12:07:38 +0200372 p = stpcpy(p, x->str);
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000373 flags &= ~x->val;
374 if (!flags)
375 return outstr;
376 sep = '|';
377 }
378 }
379 /* flags is still nonzero */
380 if (sep)
381 *p++ = sep;
382 sprintf(p, "%#x", flags);
383 return outstr;
384}
385
386void
387tprint_open_modes(mode_t flags)
388{
Denys Vlasenko5940e652011-09-01 09:55:05 +0200389 tprints(sprint_open_modes(flags) + sizeof("flags"));
Dmitry V. Levin9b5b67e2007-01-11 23:19:55 +0000390}
391
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000392static int
393decode_open(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000394{
395 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000396 printpath(tcp, tcp->u_arg[offset]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200397 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000398 /* flags */
Denys Vlasenkoeedaac72009-03-10 20:41:58 +0000399 tprint_open_modes(tcp->u_arg[offset + 1]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000400 if (tcp->u_arg[offset + 1] & O_CREAT) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000401 /* mode */
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000402 tprintf(", %#lo", tcp->u_arg[offset + 2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000403 }
404 }
405 return 0;
406}
407
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000408int
409sys_open(struct tcb *tcp)
410{
411 return decode_open(tcp, 0);
412}
413
414#ifdef LINUX
415int
416sys_openat(struct tcb *tcp)
417{
418 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +0300419 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000420 return decode_open(tcp, 1);
421}
422#endif
423
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
502#ifdef LINUX
503int
504sys_faccessat(struct tcb *tcp)
505{
506 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +0300507 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000508 return decode_access(tcp, 1);
509}
510#endif
511
512int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000513sys_umask(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000514{
515 if (entering(tcp)) {
516 tprintf("%#lo", tcp->u_arg[0]);
517 }
518 return RVAL_OCTAL;
519}
520
Roland McGrathd9f816f2004-09-04 03:39:20 +0000521static const struct xlat whence[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000522 { SEEK_SET, "SEEK_SET" },
523 { SEEK_CUR, "SEEK_CUR" },
524 { SEEK_END, "SEEK_END" },
525 { 0, NULL },
526};
527
John Hughes70623be2001-03-08 13:59:00 +0000528#ifndef HAVE_LONG_LONG_OFF_T
Roland McGrath542c2c62008-05-20 01:11:56 +0000529#if defined (LINUX_MIPSN32)
530int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000531sys_lseek(struct tcb *tcp)
Roland McGrath542c2c62008-05-20 01:11:56 +0000532{
533 long long offset;
534 int _whence;
535
536 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300537 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200538 tprints(", ");
Roland McGrath542c2c62008-05-20 01:11:56 +0000539 offset = tcp->ext_arg[1];
540 _whence = tcp->u_arg[2];
541 if (_whence == SEEK_SET)
542 tprintf("%llu, ", offset);
543 else
544 tprintf("%lld, ", offset);
545 printxval(whence, _whence, "SEEK_???");
546 }
547 return RVAL_UDECIMAL;
548}
549#else /* !LINUX_MIPSN32 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000550int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000551sys_lseek(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000552{
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000553 off_t offset;
554 int _whence;
555
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000556 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300557 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200558 tprints(", ");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000559 offset = tcp->u_arg[1];
560 _whence = tcp->u_arg[2];
561 if (_whence == SEEK_SET)
562 tprintf("%lu, ", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000563 else
Roland McGrath186c5ac2002-12-15 23:58:23 +0000564 tprintf("%ld, ", offset);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000565 printxval(whence, _whence, "SEEK_???");
Roland McGrath186c5ac2002-12-15 23:58:23 +0000566 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000567 return RVAL_UDECIMAL;
568}
Roland McGrath542c2c62008-05-20 01:11:56 +0000569#endif /* LINUX_MIPSN32 */
John Hughes5a826b82001-03-07 13:21:24 +0000570#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000571
Michal Ludvig53b320f2002-09-23 13:30:09 +0000572#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000573int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000574sys_llseek(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000575{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000576 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300577 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000578 /*
579 * This one call takes explicitly two 32-bit arguments hi, lo,
580 * rather than one 64-bit argument for which LONG_LONG works
581 * appropriate for the native byte order.
582 */
583 if (tcp->u_arg[4] == SEEK_SET)
Dmitry V. Levin31382132011-03-04 05:08:02 +0300584 tprintf(", %llu, ",
585 ((long long int) tcp->u_arg[1]) << 32 |
586 (unsigned long long) (unsigned) tcp->u_arg[2]);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000587 else
Dmitry V. Levin31382132011-03-04 05:08:02 +0300588 tprintf(", %lld, ",
589 ((long long int) tcp->u_arg[1]) << 32 |
590 (unsigned long long) (unsigned) tcp->u_arg[2]);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000591 }
592 else {
593 long long int off;
594 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
595 tprintf("%#lx, ", tcp->u_arg[3]);
596 else
597 tprintf("[%llu], ", off);
598 printxval(whence, tcp->u_arg[4], "SEEK_???");
599 }
600 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000601}
Roland McGrath186c5ac2002-12-15 23:58:23 +0000602
603int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000604sys_readahead(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +0000605{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000606 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100607 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +0300608 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200609 tprints(", ");
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100610 argn = printllval(tcp, "%lld", 1);
611 tprintf(", %ld", tcp->u_arg[argn]);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000612 }
613 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +0000614}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000615#endif
616
John Hughes70623be2001-03-08 13:59:00 +0000617#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughesbdf48f52001-03-06 15:08:09 +0000618int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000619sys_lseek64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000620{
621 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100622 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +0300623 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200624 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +0000625 if (tcp->u_arg[3] == SEEK_SET)
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100626 argn = printllval(tcp, "%llu, ", 1);
John Hughesbdf48f52001-03-06 15:08:09 +0000627 else
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100628 argn = printllval(tcp, "%lld, ", 1);
629 printxval(whence, tcp->u_arg[argn], "SEEK_???");
John Hughesbdf48f52001-03-06 15:08:09 +0000630 }
631 return RVAL_LUDECIMAL;
632}
633#endif
634
John Hughes70623be2001-03-08 13:59:00 +0000635#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000636int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000637sys_truncate(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000638{
639 if (entering(tcp)) {
640 printpath(tcp, tcp->u_arg[0]);
641 tprintf(", %lu", tcp->u_arg[1]);
642 }
643 return 0;
644}
John Hughes5a826b82001-03-07 13:21:24 +0000645#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000646
John Hughes70623be2001-03-08 13:59:00 +0000647#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000648int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000649sys_truncate64(struct tcb *tcp)
John Hughes96f51472001-03-06 16:50:41 +0000650{
651 if (entering(tcp)) {
652 printpath(tcp, tcp->u_arg[0]);
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100653 printllval(tcp, ", %llu", 1);
John Hughes96f51472001-03-06 16:50:41 +0000654 }
655 return 0;
656}
657#endif
658
John Hughes70623be2001-03-08 13:59:00 +0000659#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000660int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000661sys_ftruncate(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000662{
663 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300664 printfd(tcp, tcp->u_arg[0]);
665 tprintf(", %lu", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000666 }
667 return 0;
668}
John Hughes5a826b82001-03-07 13:21:24 +0000669#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000670
John Hughes70623be2001-03-08 13:59:00 +0000671#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000672int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000673sys_ftruncate64(struct tcb *tcp)
John Hughes96f51472001-03-06 16:50:41 +0000674{
675 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300676 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200677 tprints(", ");
Andreas Schwabb5600fc2009-11-04 17:08:34 +0100678 printllval(tcp, "%llu", 1);
John Hughes96f51472001-03-06 16:50:41 +0000679 }
680 return 0;
681}
682#endif
683
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000684/* several stats */
685
Roland McGrathd9f816f2004-09-04 03:39:20 +0000686static const struct xlat modetypes[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000687 { S_IFREG, "S_IFREG" },
688 { S_IFSOCK, "S_IFSOCK" },
689 { S_IFIFO, "S_IFIFO" },
690 { S_IFLNK, "S_IFLNK" },
691 { S_IFDIR, "S_IFDIR" },
692 { S_IFBLK, "S_IFBLK" },
693 { S_IFCHR, "S_IFCHR" },
694 { 0, NULL },
695};
696
Roland McGrathf9c49b22004-10-06 22:11:54 +0000697static const char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000698sprintmode(int mode)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000699{
700 static char buf[64];
Roland McGrathf9c49b22004-10-06 22:11:54 +0000701 const char *s;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000702
703 if ((mode & S_IFMT) == 0)
704 s = "";
705 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
706 sprintf(buf, "%#o", mode);
707 return buf;
708 }
709 sprintf(buf, "%s%s%s%s", s,
710 (mode & S_ISUID) ? "|S_ISUID" : "",
711 (mode & S_ISGID) ? "|S_ISGID" : "",
712 (mode & S_ISVTX) ? "|S_ISVTX" : "");
713 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
714 if (mode)
715 sprintf(buf + strlen(buf), "|%#o", mode);
716 s = (*buf == '|') ? buf + 1 : buf;
717 return *s ? s : "0";
718}
719
720static char *
Dmitry V. Levindc7715b2008-04-19 23:45:09 +0000721sprinttime(time_t t)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000722{
723 struct tm *tmp;
724 static char buf[32];
725
726 if (t == 0) {
Dmitry V. Levindc7715b2008-04-19 23:45:09 +0000727 strcpy(buf, "0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000728 return buf;
729 }
Denys Vlasenko5d645812011-08-20 12:48:18 +0200730 tmp = localtime(&t);
731 if (tmp)
Dmitry V. Levindc7715b2008-04-19 23:45:09 +0000732 snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d",
733 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
734 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
735 else
736 snprintf(buf, sizeof buf, "%lu", (unsigned long) t);
737
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000738 return buf;
739}
740
741#ifdef LINUXSPARC
742typedef struct {
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000743 int tv_sec;
744 int tv_nsec;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000745} timestruct_t;
746
747struct solstat {
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000748 unsigned st_dev;
749 int st_pad1[3]; /* network id */
750 unsigned st_ino;
751 unsigned st_mode;
752 unsigned st_nlink;
753 unsigned st_uid;
754 unsigned st_gid;
755 unsigned st_rdev;
756 int st_pad2[2];
757 int st_size;
758 int st_pad3; /* st_size, off_t expansion */
759 timestruct_t st_atime;
760 timestruct_t st_mtime;
761 timestruct_t st_ctime;
762 int st_blksize;
763 int st_blocks;
764 char st_fstype[16];
765 int st_pad4[8]; /* expansion area */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000766};
767
768static void
Dmitry V. Levinb838b1e2008-04-19 23:47:47 +0000769printstatsol(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000770{
771 struct solstat statbuf;
772
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000773 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200774 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000775 return;
776 }
777 if (!abbrev(tcp)) {
778 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
779 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
780 (unsigned long) (statbuf.st_dev & 0x3ffff),
781 (unsigned long) statbuf.st_ino,
782 sprintmode(statbuf.st_mode));
783 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
784 (unsigned long) statbuf.st_nlink,
785 (unsigned long) statbuf.st_uid,
786 (unsigned long) statbuf.st_gid);
787 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
788 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
789 }
790 else
791 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
792 switch (statbuf.st_mode & S_IFMT) {
793 case S_IFCHR: case S_IFBLK:
794 tprintf("st_rdev=makedev(%lu, %lu), ",
795 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
796 (unsigned long) (statbuf.st_rdev & 0x3ffff));
797 break;
798 default:
799 tprintf("st_size=%u, ", statbuf.st_size);
800 break;
801 }
802 if (!abbrev(tcp)) {
Dmitry V. Levinb838b1e2008-04-19 23:47:47 +0000803 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
804 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
805 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000806 }
807 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200808 tprints("...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000809}
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000810
811#if defined (SPARC64)
812static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000813printstat_sparc64(struct tcb *tcp, long addr)
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000814{
815 struct stat_sparc64 statbuf;
816
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000817 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200818 tprints("{...}");
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000819 return;
820 }
821
822 if (!abbrev(tcp)) {
823 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
824 (unsigned long) major(statbuf.st_dev),
825 (unsigned long) minor(statbuf.st_dev),
826 (unsigned long) statbuf.st_ino,
827 sprintmode(statbuf.st_mode));
828 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
829 (unsigned long) statbuf.st_nlink,
830 (unsigned long) statbuf.st_uid,
831 (unsigned long) statbuf.st_gid);
832 tprintf("st_blksize=%lu, ",
833 (unsigned long) statbuf.st_blksize);
834 tprintf("st_blocks=%lu, ",
835 (unsigned long) statbuf.st_blocks);
836 }
837 else
838 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
839 switch (statbuf.st_mode & S_IFMT) {
840 case S_IFCHR: case S_IFBLK:
841 tprintf("st_rdev=makedev(%lu, %lu), ",
842 (unsigned long) major(statbuf.st_rdev),
843 (unsigned long) minor(statbuf.st_rdev));
844 break;
845 default:
846 tprintf("st_size=%lu, ", statbuf.st_size);
847 break;
848 }
849 if (!abbrev(tcp)) {
850 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
851 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
852 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200853 tprints("}");
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000854 }
855 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200856 tprints("...}");
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000857}
858#endif /* SPARC64 */
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000859#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000860
Andreas Schwabd69fa492010-07-12 21:39:57 +0200861#if defined LINUX && defined POWERPC64
862struct stat_powerpc32 {
863 unsigned int st_dev;
864 unsigned int st_ino;
865 unsigned int st_mode;
866 unsigned short st_nlink;
867 unsigned int st_uid;
868 unsigned int st_gid;
869 unsigned int st_rdev;
870 unsigned int st_size;
871 unsigned int st_blksize;
872 unsigned int st_blocks;
873 unsigned int st_atime;
874 unsigned int st_atime_nsec;
875 unsigned int st_mtime;
876 unsigned int st_mtime_nsec;
877 unsigned int st_ctime;
878 unsigned int st_ctime_nsec;
879 unsigned int __unused4;
880 unsigned int __unused5;
881};
882
883static void
884printstat_powerpc32(struct tcb *tcp, long addr)
885{
886 struct stat_powerpc32 statbuf;
887
888 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200889 tprints("{...}");
Andreas Schwabd69fa492010-07-12 21:39:57 +0200890 return;
891 }
892
893 if (!abbrev(tcp)) {
894 tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ",
895 major(statbuf.st_dev), minor(statbuf.st_dev),
896 statbuf.st_ino,
897 sprintmode(statbuf.st_mode));
898 tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ",
899 statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid);
900 tprintf("st_blksize=%u, ", statbuf.st_blksize);
901 tprintf("st_blocks=%u, ", statbuf.st_blocks);
902 }
903 else
904 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
905 switch (statbuf.st_mode & S_IFMT) {
906 case S_IFCHR: case S_IFBLK:
907 tprintf("st_rdev=makedev(%lu, %lu), ",
908 (unsigned long) major(statbuf.st_rdev),
909 (unsigned long) minor(statbuf.st_rdev));
910 break;
911 default:
912 tprintf("st_size=%u, ", statbuf.st_size);
913 break;
914 }
915 if (!abbrev(tcp)) {
916 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
917 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
918 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200919 tprints("}");
Andreas Schwabd69fa492010-07-12 21:39:57 +0200920 }
921 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200922 tprints("...}");
Andreas Schwabd69fa492010-07-12 21:39:57 +0200923}
924#endif /* LINUX && POWERPC64 */
925
Roland McGratha4d48532005-06-08 20:45:28 +0000926static const struct xlat fileflags[] = {
John Hughesc0fc3fd2001-03-08 16:10:40 +0000927#ifdef FREEBSD
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000928 { UF_NODUMP, "UF_NODUMP" },
929 { UF_IMMUTABLE, "UF_IMMUTABLE" },
930 { UF_APPEND, "UF_APPEND" },
931 { UF_OPAQUE, "UF_OPAQUE" },
932 { UF_NOUNLINK, "UF_NOUNLINK" },
933 { SF_ARCHIVED, "SF_ARCHIVED" },
934 { SF_IMMUTABLE, "SF_IMMUTABLE" },
935 { SF_APPEND, "SF_APPEND" },
936 { SF_NOUNLINK, "SF_NOUNLINK" },
John Hughesc0fc3fd2001-03-08 16:10:40 +0000937#elif UNIXWARE >= 2
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200938#ifdef _S_ISMLD
939 { _S_ISMLD, "_S_ISMLD" },
John Hughesc0fc3fd2001-03-08 16:10:40 +0000940#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200941#ifdef _S_ISMOUNTED
942 { _S_ISMOUNTED, "_S_ISMOUNTED" },
John Hughesc0fc3fd2001-03-08 16:10:40 +0000943#endif
944#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000945 { 0, NULL },
946};
947
John Hughesc0fc3fd2001-03-08 16:10:40 +0000948#ifdef FREEBSD
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000949int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000950sys_chflags(struct tcb *tcp)
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000951{
952 if (entering(tcp)) {
953 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200954 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000955 printflags(fileflags, tcp->u_arg[1], "UF_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000956 }
957 return 0;
958}
959
960int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000961sys_fchflags(struct tcb *tcp)
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000962{
963 if (entering(tcp)) {
964 tprintf("%ld, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000965 printflags(fileflags, tcp->u_arg[1], "UF_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000966 }
967 return 0;
968}
969#endif
970
John Hughes70623be2001-03-08 13:59:00 +0000971#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000972static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000973realprintstat(struct tcb *tcp, struct stat *statbuf)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000974{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000975 if (!abbrev(tcp)) {
976 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
977 (unsigned long) major(statbuf->st_dev),
978 (unsigned long) minor(statbuf->st_dev),
979 (unsigned long) statbuf->st_ino,
980 sprintmode(statbuf->st_mode));
981 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
982 (unsigned long) statbuf->st_nlink,
983 (unsigned long) statbuf->st_uid,
984 (unsigned long) statbuf->st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000985#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Denys Vlasenko1d632462009-04-14 12:51:00 +0000986 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
987#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000988#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Denys Vlasenko1d632462009-04-14 12:51:00 +0000989 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
990#endif
991 }
992 else
993 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
994 switch (statbuf->st_mode & S_IFMT) {
995 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +0000996#ifdef HAVE_STRUCT_STAT_ST_RDEV
Denys Vlasenko1d632462009-04-14 12:51:00 +0000997 tprintf("st_rdev=makedev(%lu, %lu), ",
998 (unsigned long) major(statbuf->st_rdev),
999 (unsigned long) minor(statbuf->st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001000#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Denys Vlasenko1d632462009-04-14 12:51:00 +00001001 tprintf("st_size=makedev(%lu, %lu), ",
1002 (unsigned long) major(statbuf->st_size),
1003 (unsigned long) minor(statbuf->st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001004#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Denys Vlasenko1d632462009-04-14 12:51:00 +00001005 break;
1006 default:
Dmitry V. Levine9a06b72011-02-23 16:16:50 +00001007 tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size);
Denys Vlasenko1d632462009-04-14 12:51:00 +00001008 break;
1009 }
1010 if (!abbrev(tcp)) {
1011 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
1012 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
1013 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001014#if HAVE_STRUCT_STAT_ST_FLAGS
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001015 tprints(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +00001016 printflags(fileflags, statbuf->st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +00001017#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001018#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +00001019 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
1020#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001021#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +00001022 tprintf(", st_level=%ld", statbuf->st_level);
1023#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001024#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +00001025 tprintf(", st_fstype=%.*s",
1026 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
1027#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001028#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +00001029 tprintf(", st_gen=%u", statbuf->st_gen);
1030#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001031 tprints("}");
Denys Vlasenko1d632462009-04-14 12:51:00 +00001032 }
1033 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001034 tprints("...}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001035}
1036
Nate Sammons771a6ff1999-04-05 22:39:31 +00001037
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001038static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001039printstat(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001040{
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001041 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001042
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001043 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001044 tprints("NULL");
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001045 return;
1046 }
1047 if (syserror(tcp) || !verbose(tcp)) {
1048 tprintf("%#lx", addr);
1049 return;
1050 }
1051
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001052#ifdef LINUXSPARC
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00001053 if (current_personality == 1) {
1054 printstatsol(tcp, addr);
1055 return;
1056 }
Roland McGrath6d1a65c2004-07-12 07:44:08 +00001057#ifdef SPARC64
1058 else if (current_personality == 2) {
1059 printstat_sparc64(tcp, addr);
1060 return;
1061 }
1062#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001063#endif /* LINUXSPARC */
1064
Andreas Schwabd69fa492010-07-12 21:39:57 +02001065#if defined LINUX && defined POWERPC64
1066 if (current_personality == 1) {
1067 printstat_powerpc32(tcp, addr);
1068 return;
1069 }
1070#endif
1071
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001072 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001073 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001074 return;
1075 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001076
1077 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001078}
John Hughes70623be2001-03-08 13:59:00 +00001079#endif /* !HAVE_LONG_LONG_OFF_T */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001080
Roland McGrathe6d0f712007-08-07 01:22:49 +00001081#if !defined HAVE_STAT64 && defined LINUX && defined X86_64
1082/*
1083 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
1084 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
1085 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
1086 * __GNUC__ is needed for the required __attribute__ below.
1087 */
1088struct stat64 {
1089 unsigned long long st_dev;
1090 unsigned char __pad0[4];
1091 unsigned int __st_ino;
1092 unsigned int st_mode;
1093 unsigned int st_nlink;
1094 unsigned int st_uid;
1095 unsigned int st_gid;
1096 unsigned long long st_rdev;
1097 unsigned char __pad3[4];
1098 long long st_size;
1099 unsigned int st_blksize;
1100 unsigned long long st_blocks;
1101 unsigned int st_atime;
1102 unsigned int st_atime_nsec;
1103 unsigned int st_mtime;
1104 unsigned int st_mtime_nsec;
1105 unsigned int st_ctime;
1106 unsigned int st_ctime_nsec;
1107 unsigned long long st_ino;
1108} __attribute__((packed));
1109# define HAVE_STAT64 1
1110# define STAT64_SIZE 96
1111#endif
1112
Wichert Akkermanc7926982000-04-10 22:22:31 +00001113#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001114static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001115printstat64(struct tcb *tcp, long addr)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001116{
1117 struct stat64 statbuf;
1118
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001119#ifdef STAT64_SIZE
Roland McGrathe6d0f712007-08-07 01:22:49 +00001120 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
1121#endif
1122
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001123 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001124 tprints("NULL");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001125 return;
1126 }
1127 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001128 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001129 return;
1130 }
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001131
1132#ifdef LINUXSPARC
1133 if (current_personality == 1) {
1134 printstatsol(tcp, addr);
1135 return;
1136 }
1137# ifdef SPARC64
1138 else if (current_personality == 2) {
1139 printstat_sparc64(tcp, addr);
1140 return;
1141 }
1142# endif
1143#endif /* LINUXSPARC */
1144
Andreas Schwab61b74352009-10-16 11:37:13 +02001145#if defined LINUX && defined X86_64
1146 if (current_personality == 0) {
1147 printstat(tcp, addr);
1148 return;
1149 }
1150#endif
Dmitry V. Levinff896f72009-10-21 13:43:57 +00001151
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001152 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001153 tprints("{...}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001154 return;
1155 }
1156
1157 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +00001158#ifdef HAVE_LONG_LONG
1159 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
1160#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001161 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
Wichert Akkermand077c452000-08-10 18:16:15 +00001162#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001163 (unsigned long) major(statbuf.st_dev),
1164 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +00001165#ifdef HAVE_LONG_LONG
1166 (unsigned long long) statbuf.st_ino,
1167#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001168 (unsigned long) statbuf.st_ino,
Wichert Akkermand077c452000-08-10 18:16:15 +00001169#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001170 sprintmode(statbuf.st_mode));
1171 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1172 (unsigned long) statbuf.st_nlink,
1173 (unsigned long) statbuf.st_uid,
1174 (unsigned long) statbuf.st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001175#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001176 tprintf("st_blksize=%lu, ",
1177 (unsigned long) statbuf.st_blksize);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001178#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
1179#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001180 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001181#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001182 }
1183 else
1184 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1185 switch (statbuf.st_mode & S_IFMT) {
1186 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +00001187#ifdef HAVE_STRUCT_STAT_ST_RDEV
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001188 tprintf("st_rdev=makedev(%lu, %lu), ",
1189 (unsigned long) major(statbuf.st_rdev),
1190 (unsigned long) minor(statbuf.st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001191#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001192 tprintf("st_size=makedev(%lu, %lu), ",
1193 (unsigned long) major(statbuf.st_size),
1194 (unsigned long) minor(statbuf.st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001195#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001196 break;
1197 default:
Roland McGrathc7bd4d32007-08-07 01:05:19 +00001198#ifdef HAVE_LONG_LONG
1199 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
1200#else
1201 tprintf("st_size=%lu, ", (unsigned long) statbuf.st_size);
1202#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001203 break;
1204 }
1205 if (!abbrev(tcp)) {
1206 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1207 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +00001208 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001209#if HAVE_STRUCT_STAT_ST_FLAGS
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001210 tprints(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +00001211 printflags(fileflags, statbuf.st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +00001212#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001213#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +00001214 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1215#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001216#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +00001217 tprintf(", st_level=%ld", statbuf.st_level);
1218#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001219#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +00001220 tprintf(", st_fstype=%.*s",
1221 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1222#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001223#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +00001224 tprintf(", st_gen=%u", statbuf.st_gen);
1225#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001226 tprints("}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001227 }
1228 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001229 tprints("...}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001230}
Wichert Akkermanc7926982000-04-10 22:22:31 +00001231#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001232
Roland McGrath79db8af2003-06-27 21:20:09 +00001233#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001234static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001235convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001236{
Denys Vlasenko1d632462009-04-14 12:51:00 +00001237 newbuf->st_dev = oldbuf->st_dev;
1238 newbuf->st_ino = oldbuf->st_ino;
1239 newbuf->st_mode = oldbuf->st_mode;
1240 newbuf->st_nlink = oldbuf->st_nlink;
1241 newbuf->st_uid = oldbuf->st_uid;
1242 newbuf->st_gid = oldbuf->st_gid;
1243 newbuf->st_rdev = oldbuf->st_rdev;
1244 newbuf->st_size = oldbuf->st_size;
1245 newbuf->st_atime = oldbuf->st_atime;
1246 newbuf->st_mtime = oldbuf->st_mtime;
1247 newbuf->st_ctime = oldbuf->st_ctime;
1248 newbuf->st_blksize = 0; /* not supported in old_stat */
1249 newbuf->st_blocks = 0; /* not supported in old_stat */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001250}
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001251
1252
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001253static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001254printoldstat(struct tcb *tcp, long addr)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001255{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +00001256 struct __old_kernel_stat statbuf;
1257 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001258
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001259 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001260 tprints("NULL");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001261 return;
1262 }
1263 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001264 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001265 return;
1266 }
Denys Vlasenko4e718b52009-04-20 18:30:13 +00001267
1268#ifdef LINUXSPARC
1269 if (current_personality == 1) {
1270 printstatsol(tcp, addr);
1271 return;
1272 }
1273#endif /* LINUXSPARC */
1274
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001275 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001276 tprints("{...}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001277 return;
1278 }
1279
1280 convertoldstat(&statbuf, &newstatbuf);
1281 realprintstat(tcp, &newstatbuf);
1282}
Michal Ludvig10a88d02002-10-07 14:31:00 +00001283#endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001284
John Hughes70623be2001-03-08 13:59:00 +00001285#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001286int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001287sys_stat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001288{
1289 if (entering(tcp)) {
1290 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001291 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001292 } else {
1293 printstat(tcp, tcp->u_arg[1]);
1294 }
1295 return 0;
1296}
John Hughesb8c9f772001-03-07 16:53:07 +00001297#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001298
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001299int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001300sys_stat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001301{
1302#ifdef HAVE_STAT64
1303 if (entering(tcp)) {
1304 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001305 tprints(", ");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001306 } else {
1307 printstat64(tcp, tcp->u_arg[1]);
1308 }
1309 return 0;
1310#else
1311 return printargs(tcp);
1312#endif
1313}
1314
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001315#ifdef LINUX
1316static const struct xlat fstatatflags[] = {
1317#ifndef AT_SYMLINK_NOFOLLOW
1318# define AT_SYMLINK_NOFOLLOW 0x100
1319#endif
1320 { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" },
1321 { 0, NULL },
1322};
Roland McGrath6afc5652007-07-24 01:57:11 +00001323#define utimensatflags fstatatflags
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001324
1325int
1326sys_newfstatat(struct tcb *tcp)
1327{
1328 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001329 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001330 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001331 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001332 } else {
Andreas Schwabd69fa492010-07-12 21:39:57 +02001333#ifdef POWERPC64
1334 if (current_personality == 0)
1335 printstat(tcp, tcp->u_arg[2]);
1336 else
1337 printstat64(tcp, tcp->u_arg[2]);
1338#elif defined HAVE_STAT64
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001339 printstat64(tcp, tcp->u_arg[2]);
1340#else
1341 printstat(tcp, tcp->u_arg[2]);
1342#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001343 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001344 printflags(fstatatflags, tcp->u_arg[3], "AT_???");
1345 }
1346 return 0;
1347}
1348#endif
1349
Roland McGrath79db8af2003-06-27 21:20:09 +00001350#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001351int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001352sys_oldstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001353{
1354 if (entering(tcp)) {
1355 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001356 tprints(", ");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001357 } else {
1358 printoldstat(tcp, tcp->u_arg[1]);
1359 }
1360 return 0;
1361}
Roland McGrath79db8af2003-06-27 21:20:09 +00001362#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001363
John Hughes70623be2001-03-08 13:59:00 +00001364#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001365int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001366sys_fstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001367{
Dmitry V. Levin31382132011-03-04 05:08:02 +03001368 if (entering(tcp)) {
1369 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001370 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001371 } else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001372 printstat(tcp, tcp->u_arg[1]);
1373 }
1374 return 0;
1375}
John Hughesb8c9f772001-03-07 16:53:07 +00001376#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001377
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001378int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001379sys_fstat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001380{
1381#ifdef HAVE_STAT64
Dmitry V. Levin31382132011-03-04 05:08:02 +03001382 if (entering(tcp)) {
1383 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001384 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001385 } else {
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001386 printstat64(tcp, tcp->u_arg[1]);
1387 }
1388 return 0;
1389#else
1390 return printargs(tcp);
1391#endif
1392}
1393
Roland McGrath79db8af2003-06-27 21:20:09 +00001394#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001395int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001396sys_oldfstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001397{
Dmitry V. Levin31382132011-03-04 05:08:02 +03001398 if (entering(tcp)) {
1399 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001400 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001401 } else {
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001402 printoldstat(tcp, tcp->u_arg[1]);
1403 }
1404 return 0;
1405}
Roland McGrath79db8af2003-06-27 21:20:09 +00001406#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001407
John Hughes70623be2001-03-08 13:59:00 +00001408#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001409int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001410sys_lstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001411{
1412 if (entering(tcp)) {
1413 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001414 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001415 } else {
1416 printstat(tcp, tcp->u_arg[1]);
1417 }
1418 return 0;
1419}
John Hughesb8c9f772001-03-07 16:53:07 +00001420#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001421
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001422int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001423sys_lstat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001424{
1425#ifdef HAVE_STAT64
1426 if (entering(tcp)) {
1427 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001428 tprints(", ");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001429 } else {
1430 printstat64(tcp, tcp->u_arg[1]);
1431 }
1432 return 0;
1433#else
1434 return printargs(tcp);
1435#endif
1436}
1437
Roland McGrath79db8af2003-06-27 21:20:09 +00001438#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001439int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001440sys_oldlstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001441{
1442 if (entering(tcp)) {
1443 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001444 tprints(", ");
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001445 } else {
1446 printoldstat(tcp, tcp->u_arg[1]);
1447 }
1448 return 0;
1449}
Roland McGrath79db8af2003-06-27 21:20:09 +00001450#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001451
1452
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001453#if defined(SVR4) || defined(LINUXSPARC)
1454
1455int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001456sys_xstat(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 {
John Hughes8fe2c982001-03-06 09:45:18 +00001463#ifdef _STAT64_VER
1464 if (tcp->u_arg[0] == _STAT64_VER)
1465 printstat64 (tcp, tcp->u_arg[2]);
1466 else
1467#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_fxstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001475{
1476 if (entering(tcp))
1477 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1478 else {
John Hughes8fe2c982001-03-06 09:45:18 +00001479#ifdef _STAT64_VER
1480 if (tcp->u_arg[0] == _STAT64_VER)
1481 printstat64 (tcp, tcp->u_arg[2]);
1482 else
1483#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001484 printstat(tcp, tcp->u_arg[2]);
1485 }
1486 return 0;
1487}
1488
1489int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001490sys_lxstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001491{
1492 if (entering(tcp)) {
1493 tprintf("%ld, ", tcp->u_arg[0]);
1494 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001495 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001496 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001497#ifdef _STAT64_VER
1498 if (tcp->u_arg[0] == _STAT64_VER)
1499 printstat64 (tcp, tcp->u_arg[2]);
1500 else
1501#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001502 printstat(tcp, tcp->u_arg[2]);
1503 }
1504 return 0;
1505}
1506
1507int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001508sys_xmknod(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001509{
1510 int mode = tcp->u_arg[2];
1511
1512 if (entering(tcp)) {
1513 tprintf("%ld, ", tcp->u_arg[0]);
1514 printpath(tcp, tcp->u_arg[1]);
1515 tprintf(", %s", sprintmode(mode));
1516 switch (mode & S_IFMT) {
1517 case S_IFCHR: case S_IFBLK:
1518#ifdef LINUXSPARC
1519 tprintf(", makedev(%lu, %lu)",
1520 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1521 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
Roland McGrath186c5ac2002-12-15 23:58:23 +00001522#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001523 tprintf(", makedev(%lu, %lu)",
1524 (unsigned long) major(tcp->u_arg[3]),
1525 (unsigned long) minor(tcp->u_arg[3]));
Roland McGrath186c5ac2002-12-15 23:58:23 +00001526#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001527 break;
1528 default:
1529 break;
1530 }
1531 }
1532 return 0;
1533}
1534
Wichert Akkerman8829a551999-06-11 13:18:40 +00001535#ifdef HAVE_SYS_ACL_H
1536
1537#include <sys/acl.h>
1538
Roland McGratha4d48532005-06-08 20:45:28 +00001539static const struct xlat aclcmds[] = {
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001540#ifdef SETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001541 { SETACL, "SETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001542#endif
1543#ifdef GETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001544 { GETACL, "GETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001545#endif
1546#ifdef GETACLCNT
Wichert Akkerman8829a551999-06-11 13:18:40 +00001547 { GETACLCNT, "GETACLCNT" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001548#endif
1549#ifdef ACL_GET
1550 { ACL_GET, "ACL_GET" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001551#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001552#ifdef ACL_SET
1553 { ACL_SET, "ACL_SET" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001554#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001555#ifdef ACL_CNT
1556 { ACL_CNT, "ACL_CNT" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001557#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +00001558 { 0, NULL },
1559};
1560
1561int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001562sys_acl(struct tcb *tcp)
Wichert Akkerman8829a551999-06-11 13:18:40 +00001563{
1564 if (entering(tcp)) {
1565 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001566 tprints(", ");
Wichert Akkerman8829a551999-06-11 13:18:40 +00001567 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1568 tprintf(", %ld", tcp->u_arg[2]);
1569 /*
1570 * FIXME - dump out the list of aclent_t's pointed to
1571 * by "tcp->u_arg[3]" if it's not NULL.
1572 */
1573 if (tcp->u_arg[3])
1574 tprintf(", %#lx", tcp->u_arg[3]);
1575 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001576 tprints(", NULL");
Wichert Akkerman8829a551999-06-11 13:18:40 +00001577 }
1578 return 0;
1579}
1580
1581
1582int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001583sys_facl(struct tcb *tcp)
Wichert Akkerman8829a551999-06-11 13:18:40 +00001584{
1585 if (entering(tcp)) {
1586 tprintf("%ld, ", tcp->u_arg[0]);
1587 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1588 tprintf(", %ld", tcp->u_arg[2]);
1589 /*
1590 * FIXME - dump out the list of aclent_t's pointed to
1591 * by "tcp->u_arg[3]" if it's not NULL.
1592 */
1593 if (tcp->u_arg[3])
1594 tprintf(", %#lx", tcp->u_arg[3]);
1595 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001596 tprints(", NULL");
Wichert Akkerman8829a551999-06-11 13:18:40 +00001597 }
1598 return 0;
1599}
1600
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001601
Roland McGratha4d48532005-06-08 20:45:28 +00001602static const struct xlat aclipc[] = {
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001603#ifdef IPC_SHM
1604 { IPC_SHM, "IPC_SHM" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001605#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001606#ifdef IPC_SEM
1607 { IPC_SEM, "IPC_SEM" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001608#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001609#ifdef IPC_MSG
1610 { IPC_MSG, "IPC_MSG" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001611#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001612 { 0, NULL },
1613};
1614
1615
1616int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001617sys_aclipc(struct tcb *tcp)
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001618{
1619 if (entering(tcp)) {
1620 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1621 tprintf(", %#lx, ", tcp->u_arg[1]);
1622 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1623 tprintf(", %ld", tcp->u_arg[3]);
1624 /*
1625 * FIXME - dump out the list of aclent_t's pointed to
1626 * by "tcp->u_arg[4]" if it's not NULL.
1627 */
1628 if (tcp->u_arg[4])
1629 tprintf(", %#lx", tcp->u_arg[4]);
1630 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001631 tprints(", NULL");
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001632 }
1633 return 0;
1634}
1635
Wichert Akkerman8829a551999-06-11 13:18:40 +00001636#endif /* HAVE_SYS_ACL_H */
1637
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001638#endif /* SVR4 || LINUXSPARC */
1639
Michal Ludvig53b320f2002-09-23 13:30:09 +00001640#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001641
Roland McGrathd9f816f2004-09-04 03:39:20 +00001642static const struct xlat fsmagic[] = {
Wichert Akkerman43a74822000-06-27 17:33:32 +00001643 { 0x73757245, "CODA_SUPER_MAGIC" },
1644 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1645 { 0x1373, "DEVFS_SUPER_MAGIC" },
1646 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1647 { 0x414A53, "EFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001648 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1649 { 0xef53, "EXT2_SUPER_MAGIC" },
1650 { 0x137d, "EXT_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001651 { 0xf995e849, "HPFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001652 { 0x9660, "ISOFS_SUPER_MAGIC" },
1653 { 0x137f, "MINIX_SUPER_MAGIC" },
1654 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001655 { 0x2468, "MINIX2_SUPER_MAGIC" },
1656 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001657 { 0x4d44, "MSDOS_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001658 { 0x564c, "NCP_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001659 { 0x6969, "NFS_SUPER_MAGIC" },
1660 { 0x9fa0, "PROC_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001661 { 0x002f, "QNX4_SUPER_MAGIC" },
1662 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1663 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1664 { 0x517b, "SMB_SUPER_MAGIC" },
1665 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1666 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1667 { 0x00011954, "UFS_MAGIC" },
1668 { 0x54190100, "UFS_CIGAM" },
1669 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001670 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
Roland McGrathc767ad82004-01-13 10:13:45 +00001671 { 0x62656572, "SYSFS_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001672 { 0, NULL },
1673};
1674
Michal Ludvig53b320f2002-09-23 13:30:09 +00001675#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001676
1677#ifndef SVR4
1678
Roland McGrathf9c49b22004-10-06 22:11:54 +00001679static const char *
Denys Vlasenko1d632462009-04-14 12:51:00 +00001680sprintfstype(int magic)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001681{
1682 static char buf[32];
Michal Ludvig53b320f2002-09-23 13:30:09 +00001683#ifdef LINUX
Roland McGrathf9c49b22004-10-06 22:11:54 +00001684 const char *s;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001685
1686 s = xlookup(fsmagic, magic);
1687 if (s) {
1688 sprintf(buf, "\"%s\"", s);
1689 return buf;
1690 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00001691#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001692 sprintf(buf, "%#x", magic);
1693 return buf;
1694}
1695
1696static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001697printstatfs(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001698{
1699 struct statfs statbuf;
1700
1701 if (syserror(tcp) || !verbose(tcp)) {
1702 tprintf("%#lx", addr);
1703 return;
1704 }
1705 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001706 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001707 return;
1708 }
1709#ifdef ALPHA
1710
1711 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1712 sprintfstype(statbuf.f_type),
1713 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Roland McGrathab147c52003-07-17 09:03:02 +00001714 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001715 statbuf.f_bavail, statbuf.f_files, statbuf.f_ffree,
Roland McGrathab147c52003-07-17 09:03:02 +00001716 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1717 statbuf.f_namelen);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001718#else /* !ALPHA */
1719 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1720 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +00001721 (unsigned long)statbuf.f_bsize,
1722 (unsigned long)statbuf.f_blocks,
1723 (unsigned long)statbuf.f_bfree);
Roland McGrathab147c52003-07-17 09:03:02 +00001724 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1725 (unsigned long)statbuf.f_bavail,
Nate Sammons5c74d201999-04-06 01:37:51 +00001726 (unsigned long)statbuf.f_files,
Roland McGrathab147c52003-07-17 09:03:02 +00001727 (unsigned long)statbuf.f_ffree,
1728 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
Michal Ludvig53b320f2002-09-23 13:30:09 +00001729#ifdef LINUX
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001730 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Michal Ludvig53b320f2002-09-23 13:30:09 +00001731#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001732#endif /* !ALPHA */
Roland McGrathab147c52003-07-17 09:03:02 +00001733#ifdef _STATFS_F_FRSIZE
1734 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1735#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001736 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001737}
1738
1739int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001740sys_statfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001741{
1742 if (entering(tcp)) {
1743 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001744 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001745 } else {
1746 printstatfs(tcp, tcp->u_arg[1]);
1747 }
1748 return 0;
1749}
1750
1751int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001752sys_fstatfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001753{
1754 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001755 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001756 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001757 } else {
1758 printstatfs(tcp, tcp->u_arg[1]);
1759 }
1760 return 0;
1761}
1762
Bernhard Reutner-Fischer9906e6d2009-10-14 16:33:58 +02001763#if defined LINUX && defined HAVE_STATFS64
Roland McGrathab147c52003-07-17 09:03:02 +00001764static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00001765printstatfs64(struct tcb *tcp, long addr)
Roland McGrathab147c52003-07-17 09:03:02 +00001766{
1767 struct statfs64 statbuf;
1768
1769 if (syserror(tcp) || !verbose(tcp)) {
1770 tprintf("%#lx", addr);
1771 return;
1772 }
1773 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001774 tprints("{...}");
Roland McGrathab147c52003-07-17 09:03:02 +00001775 return;
1776 }
Roland McGrath08738432005-06-03 02:40:39 +00001777 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
Roland McGrathab147c52003-07-17 09:03:02 +00001778 sprintfstype(statbuf.f_type),
Roland McGrath08738432005-06-03 02:40:39 +00001779 (unsigned long long)statbuf.f_bsize,
1780 (unsigned long long)statbuf.f_blocks,
1781 (unsigned long long)statbuf.f_bfree);
1782 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1783 (unsigned long long)statbuf.f_bavail,
1784 (unsigned long long)statbuf.f_files,
1785 (unsigned long long)statbuf.f_ffree,
Roland McGrathab147c52003-07-17 09:03:02 +00001786 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1787 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Roland McGrathab147c52003-07-17 09:03:02 +00001788#ifdef _STATFS_F_FRSIZE
Roland McGrath08738432005-06-03 02:40:39 +00001789 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
Roland McGrathab147c52003-07-17 09:03:02 +00001790#endif
Andreas Schwab000d66f2012-01-17 18:13:33 +01001791#ifdef _STATFS_F_FLAGS
1792 tprintf(", f_flags=%llu", (unsigned long long)statbuf.f_flags);
1793#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001794 tprints("}");
Roland McGrathab147c52003-07-17 09:03:02 +00001795}
1796
1797int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001798sys_statfs64(struct tcb *tcp)
Roland McGrathab147c52003-07-17 09:03:02 +00001799{
1800 if (entering(tcp)) {
1801 printpath(tcp, tcp->u_arg[0]);
1802 tprintf(", %lu, ", tcp->u_arg[1]);
1803 } else {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001804 if (tcp->u_arg[1] == sizeof(struct statfs64))
Roland McGrathab147c52003-07-17 09:03:02 +00001805 printstatfs64(tcp, tcp->u_arg[2]);
1806 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001807 tprints("{???}");
Roland McGrathab147c52003-07-17 09:03:02 +00001808 }
1809 return 0;
1810}
1811
1812int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001813sys_fstatfs64(struct tcb *tcp)
Roland McGrathab147c52003-07-17 09:03:02 +00001814{
1815 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001816 printfd(tcp, tcp->u_arg[0]);
1817 tprintf(", %lu, ", tcp->u_arg[1]);
Roland McGrathab147c52003-07-17 09:03:02 +00001818 } else {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001819 if (tcp->u_arg[1] == sizeof(struct statfs64))
Roland McGrathab147c52003-07-17 09:03:02 +00001820 printstatfs64(tcp, tcp->u_arg[2]);
1821 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001822 tprints("{???}");
Roland McGrathab147c52003-07-17 09:03:02 +00001823 }
1824 return 0;
1825}
1826#endif
1827
Michal Ludvig53b320f2002-09-23 13:30:09 +00001828#if defined(LINUX) && defined(__alpha)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001829
1830int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001831osf_statfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001832{
1833 if (entering(tcp)) {
1834 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001835 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001836 } else {
1837 printstatfs(tcp, tcp->u_arg[1]);
1838 tprintf(", %lu", tcp->u_arg[2]);
1839 }
1840 return 0;
1841}
1842
1843int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001844osf_fstatfs(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001845{
1846 if (entering(tcp)) {
1847 tprintf("%lu, ", tcp->u_arg[0]);
1848 } else {
1849 printstatfs(tcp, tcp->u_arg[1]);
1850 tprintf(", %lu", tcp->u_arg[2]);
1851 }
1852 return 0;
1853}
Michal Ludvig53b320f2002-09-23 13:30:09 +00001854#endif /* LINUX && __alpha */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001855
1856#endif /* !SVR4 */
1857
1858#ifdef SUNOS4
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001859int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001860sys_ustat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001861{
1862 struct ustat statbuf;
1863
1864 if (entering(tcp)) {
1865 tprintf("makedev(%lu, %lu), ",
1866 (long) major(tcp->u_arg[0]),
1867 (long) minor(tcp->u_arg[0]));
1868 }
1869 else {
1870 if (syserror(tcp) || !verbose(tcp))
1871 tprintf("%#lx", tcp->u_arg[1]);
1872 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001873 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001874 else {
1875 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1876 statbuf.f_tfree, statbuf.f_tinode);
1877 tprintf("f_fname=\"%.*s\", ",
1878 (int) sizeof(statbuf.f_fname),
1879 statbuf.f_fname);
1880 tprintf("f_fpack=\"%.*s\"}",
1881 (int) sizeof(statbuf.f_fpack),
1882 statbuf.f_fpack);
1883 }
1884 }
1885 return 0;
1886}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001887#endif /* SUNOS4 */
1888
1889/* directory */
1890int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001891sys_chdir(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001892{
1893 if (entering(tcp)) {
1894 printpath(tcp, tcp->u_arg[0]);
1895 }
1896 return 0;
1897}
1898
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001899static int
1900decode_mkdir(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001901{
1902 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001903 printpath(tcp, tcp->u_arg[offset]);
1904 tprintf(", %#lo", tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001905 }
1906 return 0;
1907}
1908
1909int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001910sys_mkdir(struct tcb *tcp)
1911{
1912 return decode_mkdir(tcp, 0);
1913}
1914
1915#ifdef LINUX
1916int
1917sys_mkdirat(struct tcb *tcp)
1918{
1919 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03001920 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001921 return decode_mkdir(tcp, 1);
1922}
1923#endif
1924
1925int
Denys Vlasenko1d632462009-04-14 12:51:00 +00001926sys_link(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(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001931 printpath(tcp, tcp->u_arg[1]);
1932 }
1933 return 0;
1934}
1935
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001936#ifdef LINUX
1937int
1938sys_linkat(struct tcb *tcp)
1939{
1940 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001941 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001942 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001943 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001944 print_dirfd(tcp, tcp->u_arg[2]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001945 printpath(tcp, tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001946 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001947 printfd(tcp, tcp->u_arg[4]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001948 }
1949 return 0;
1950}
1951#endif
1952
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001953#ifdef LINUX
1954static const struct xlat unlinkatflags[] = {
1955#ifndef AT_REMOVEDIR
1956# define AT_REMOVEDIR 0x200
1957#endif
1958 { AT_REMOVEDIR, "AT_REMOVEDIR" },
1959 { 0, NULL },
1960};
1961
1962int
1963sys_unlinkat(struct tcb *tcp)
1964{
1965 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03001966 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001967 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001968 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001969 printflags(unlinkatflags, tcp->u_arg[2], "AT_???");
1970 }
1971 return 0;
1972}
1973#endif
1974
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001975#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001976int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001977sys_symlinkat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001978{
1979 if (entering(tcp)) {
1980 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001981 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03001982 print_dirfd(tcp, tcp->u_arg[1]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001983 printpath(tcp, tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001984 }
1985 return 0;
1986}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001987#endif
1988
1989static int
1990decode_readlink(struct tcb *tcp, int offset)
1991{
1992 if (entering(tcp)) {
1993 printpath(tcp, tcp->u_arg[offset]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001994 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001995 } else {
1996 if (syserror(tcp))
1997 tprintf("%#lx", tcp->u_arg[offset + 1]);
1998 else
1999 printpathn(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
2000 tprintf(", %lu", tcp->u_arg[offset + 2]);
2001 }
2002 return 0;
2003}
2004
2005int
2006sys_readlink(struct tcb *tcp)
2007{
2008 return decode_readlink(tcp, 0);
2009}
2010
2011#ifdef LINUX
2012int
2013sys_readlinkat(struct tcb *tcp)
2014{
2015 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03002016 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002017 return decode_readlink(tcp, 1);
2018}
2019#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002020
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002021#ifdef LINUX
2022int
2023sys_renameat(struct tcb *tcp)
2024{
2025 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002026 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002027 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002028 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +03002029 print_dirfd(tcp, tcp->u_arg[2]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002030 printpath(tcp, tcp->u_arg[3]);
2031 }
2032 return 0;
2033}
2034#endif
2035
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002036int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002037sys_chown(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002038{
2039 if (entering(tcp)) {
2040 printpath(tcp, tcp->u_arg[0]);
Roland McGrath6bc12202003-11-13 22:32:27 +00002041 printuid(", ", tcp->u_arg[1]);
2042 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002043 }
2044 return 0;
2045}
2046
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002047#ifdef LINUX
2048int
2049sys_fchownat(struct tcb *tcp)
2050{
2051 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002052 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002053 printpath(tcp, tcp->u_arg[1]);
2054 printuid(", ", tcp->u_arg[2]);
2055 printuid(", ", tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002056 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002057 printflags(fstatatflags, tcp->u_arg[4], "AT_???");
2058 }
2059 return 0;
2060}
2061#endif
2062
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002063int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002064sys_fchown(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002065{
2066 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002067 printfd(tcp, tcp->u_arg[0]);
Roland McGrath6bc12202003-11-13 22:32:27 +00002068 printuid(", ", tcp->u_arg[1]);
2069 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002070 }
2071 return 0;
2072}
2073
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002074static int
2075decode_chmod(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002076{
2077 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002078 printpath(tcp, tcp->u_arg[offset]);
2079 tprintf(", %#lo", tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002080 }
2081 return 0;
2082}
2083
2084int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002085sys_chmod(struct tcb *tcp)
2086{
2087 return decode_chmod(tcp, 0);
2088}
2089
2090#ifdef LINUX
2091int
2092sys_fchmodat(struct tcb *tcp)
2093{
2094 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03002095 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002096 return decode_chmod(tcp, 1);
2097}
2098#endif
2099
2100int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002101sys_fchmod(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002102{
2103 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002104 printfd(tcp, tcp->u_arg[0]);
2105 tprintf(", %#lo", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002106 }
2107 return 0;
2108}
2109
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002110#ifdef ALPHA
2111int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002112sys_osf_utimes(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002113{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002114 if (entering(tcp)) {
2115 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002116 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002117 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
2118 }
2119 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002120}
2121#endif
2122
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002123static int
Roland McGrath6afc5652007-07-24 01:57:11 +00002124decode_utimes(struct tcb *tcp, int offset, int special)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002125{
2126 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002127 printpath(tcp, tcp->u_arg[offset]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002128 tprints(", ");
Roland McGrath6afc5652007-07-24 01:57:11 +00002129 if (tcp->u_arg[offset + 1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002130 tprints("NULL");
Roland McGrath6afc5652007-07-24 01:57:11 +00002131 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002132 tprints("{");
Roland McGrath6afc5652007-07-24 01:57:11 +00002133 printtv_bitness(tcp, tcp->u_arg[offset + 1],
2134 BITNESS_CURRENT, special);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002135 tprints(", ");
Roland McGrathe6d0f712007-08-07 01:22:49 +00002136 printtv_bitness(tcp, tcp->u_arg[offset + 1]
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002137 + sizeof(struct timeval),
Roland McGrath6afc5652007-07-24 01:57:11 +00002138 BITNESS_CURRENT, special);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002139 tprints("}");
Roland McGrath6afc5652007-07-24 01:57:11 +00002140 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002141 }
2142 return 0;
2143}
2144
2145int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002146sys_utimes(struct tcb *tcp)
2147{
Roland McGrath6afc5652007-07-24 01:57:11 +00002148 return decode_utimes(tcp, 0, 0);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002149}
2150
2151#ifdef LINUX
2152int
2153sys_futimesat(struct tcb *tcp)
2154{
2155 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03002156 print_dirfd(tcp, tcp->u_arg[0]);
Roland McGrath6afc5652007-07-24 01:57:11 +00002157 return decode_utimes(tcp, 1, 0);
2158}
2159
2160int
2161sys_utimensat(struct tcb *tcp)
2162{
2163 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002164 print_dirfd(tcp, tcp->u_arg[0]);
Roland McGrath6afc5652007-07-24 01:57:11 +00002165 decode_utimes(tcp, 1, 1);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002166 tprints(", ");
Roland McGrath6afc5652007-07-24 01:57:11 +00002167 printflags(utimensatflags, tcp->u_arg[3], "AT_???");
2168 }
2169 return 0;
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002170}
2171#endif
2172
2173int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002174sys_utime(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002175{
Roland McGrath7e9817c2007-07-05 20:31:58 +00002176 union {
2177 long utl[2];
2178 int uti[2];
2179 } u;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002180
2181 if (entering(tcp)) {
2182 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002183 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002184 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002185 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002186 else if (!verbose(tcp))
2187 tprintf("%#lx", tcp->u_arg[1]);
Roland McGrath7e9817c2007-07-05 20:31:58 +00002188 else if (umoven(tcp, tcp->u_arg[1],
2189 2 * personality_wordsize[current_personality],
2190 (char *) &u) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002191 tprints("[?, ?]");
Roland McGrath7e9817c2007-07-05 20:31:58 +00002192 else if (personality_wordsize[current_personality]
2193 == sizeof u.utl[0]) {
2194 tprintf("[%s,", sprinttime(u.utl[0]));
2195 tprintf(" %s]", sprinttime(u.utl[1]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002196 }
Roland McGrath7e9817c2007-07-05 20:31:58 +00002197 else if (personality_wordsize[current_personality]
2198 == sizeof u.uti[0]) {
2199 tprintf("[%s,", sprinttime(u.uti[0]));
2200 tprintf(" %s]", sprinttime(u.uti[1]));
2201 }
2202 else
2203 abort();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002204 }
2205 return 0;
2206}
2207
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002208static int
2209decode_mknod(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002210{
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002211 int mode = tcp->u_arg[offset + 1];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002212
2213 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002214 printpath(tcp, tcp->u_arg[offset]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002215 tprintf(", %s", sprintmode(mode));
2216 switch (mode & S_IFMT) {
2217 case S_IFCHR: case S_IFBLK:
2218#ifdef LINUXSPARC
2219 if (current_personality == 1)
2220 tprintf(", makedev(%lu, %lu)",
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002221 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
2222 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002223 else
Roland McGrath186c5ac2002-12-15 23:58:23 +00002224#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002225 tprintf(", makedev(%lu, %lu)",
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002226 (unsigned long) major(tcp->u_arg[offset + 2]),
2227 (unsigned long) minor(tcp->u_arg[offset + 2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002228 break;
2229 default:
2230 break;
2231 }
2232 }
2233 return 0;
2234}
2235
2236int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002237sys_mknod(struct tcb *tcp)
2238{
2239 return decode_mknod(tcp, 0);
2240}
2241
2242#ifdef LINUX
2243int
2244sys_mknodat(struct tcb *tcp)
2245{
2246 if (entering(tcp))
Dmitry V. Levin31382132011-03-04 05:08:02 +03002247 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002248 return decode_mknod(tcp, 1);
2249}
2250#endif
2251
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00002252#ifdef FREEBSD
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002253int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002254sys_mkfifo(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002255{
2256 if (entering(tcp)) {
2257 printpath(tcp, tcp->u_arg[0]);
2258 tprintf(", %#lo", tcp->u_arg[1]);
2259 }
2260 return 0;
2261}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00002262#endif /* FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002263
2264int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002265sys_fsync(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002266{
2267 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002268 printfd(tcp, tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002269 }
2270 return 0;
2271}
2272
Michal Ludvig53b320f2002-09-23 13:30:09 +00002273#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002274
2275static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002276printdir(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002277{
2278 struct dirent d;
2279
2280 if (!verbose(tcp)) {
2281 tprintf("%#lx", addr);
2282 return;
2283 }
2284 if (umove(tcp, addr, &d) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002285 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002286 return;
2287 }
2288 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002289 tprints("d_name=");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002290 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002291 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002292}
2293
2294int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002295sys_readdir(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002296{
2297 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002298 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002299 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002300 } else {
2301 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
2302 tprintf("%#lx", tcp->u_arg[1]);
2303 else
2304 printdir(tcp, tcp->u_arg[1]);
2305 /* Not much point in printing this out, it is always 1. */
2306 if (tcp->u_arg[2] != 1)
2307 tprintf(", %lu", tcp->u_arg[2]);
2308 }
2309 return 0;
2310}
2311
Michal Ludvig53b320f2002-09-23 13:30:09 +00002312#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002313
Roland McGrath40542842004-01-13 09:47:49 +00002314#if defined FREEBSD || defined LINUX
Roland McGratha4d48532005-06-08 20:45:28 +00002315static const struct xlat direnttypes[] = {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002316 { DT_UNKNOWN, "DT_UNKNOWN" },
2317 { DT_FIFO, "DT_FIFO" },
2318 { DT_CHR, "DT_CHR" },
2319 { DT_DIR, "DT_DIR" },
2320 { DT_BLK, "DT_BLK" },
2321 { DT_REG, "DT_REG" },
2322 { DT_LNK, "DT_LNK" },
2323 { DT_SOCK, "DT_SOCK" },
2324 { DT_WHT, "DT_WHT" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002325 { 0, NULL },
2326};
2327
2328#endif
2329
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002330int
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002331sys_getdents(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002332{
2333 int i, len, dents = 0;
2334 char *buf;
2335
2336 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002337 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002338 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002339 return 0;
2340 }
2341 if (syserror(tcp) || !verbose(tcp)) {
2342 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2343 return 0;
2344 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002345 len = tcp->u_rval;
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002346 /* Beware of insanely large or negative values in tcp->u_rval */
2347 if (tcp->u_rval > 1024*1024)
2348 len = 1024*1024;
2349 if (tcp->u_rval < 0)
2350 len = 0;
Mike Frysinger229738c2009-10-07 20:41:56 -04002351 buf = len ? malloc(len) : NULL;
Denys Vlasenko1d46ba52011-08-31 14:00:02 +02002352 if (len && !buf)
2353 die_out_of_memory();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002354 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002355 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002356 free(buf);
2357 return 0;
2358 }
2359 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002360 tprints("{");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002361 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00002362 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Michal Ludvig53b320f2002-09-23 13:30:09 +00002363#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002364 if (!abbrev(tcp)) {
2365 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2366 i ? " " : "", d->d_ino, d->d_off);
2367 tprintf("d_reclen=%u, d_name=\"%s\"}",
2368 d->d_reclen, d->d_name);
2369 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00002370#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002371#ifdef SVR4
2372 if (!abbrev(tcp)) {
2373 tprintf("%s{d_ino=%lu, d_off=%lu, ",
Roland McGrath186c5ac2002-12-15 23:58:23 +00002374 i ? " " : "",
2375 (unsigned long) d->d_ino,
2376 (unsigned long) d->d_off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002377 tprintf("d_reclen=%u, d_name=\"%s\"}",
2378 d->d_reclen, d->d_name);
2379 }
2380#endif /* SVR4 */
2381#ifdef SUNOS4
2382 if (!abbrev(tcp)) {
2383 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2384 i ? " " : "", d->d_off, d->d_fileno,
2385 d->d_reclen);
2386 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2387 d->d_namlen, d->d_namlen, d->d_name);
2388 }
2389#endif /* SUNOS4 */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002390#ifdef FREEBSD
2391 if (!abbrev(tcp)) {
2392 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2393 i ? " " : "", d->d_fileno, d->d_reclen);
2394 printxval(direnttypes, d->d_type, "DT_???");
2395 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2396 d->d_namlen, d->d_namlen, d->d_name);
2397 }
Roland McGrath186c5ac2002-12-15 23:58:23 +00002398#endif /* FREEBSD */
Pavel Machek9a9f10b2000-02-01 16:22:52 +00002399 if (!d->d_reclen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002400 tprints("/* d_reclen == 0, problem here */");
Pavel Machek9a9f10b2000-02-01 16:22:52 +00002401 break;
2402 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002403 i += d->d_reclen;
2404 dents++;
2405 }
2406 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002407 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002408 else
2409 tprintf("/* %u entries */", dents);
2410 tprintf(", %lu", tcp->u_arg[2]);
2411 free(buf);
2412 return 0;
2413}
2414
John Hughesbdf48f52001-03-06 15:08:09 +00002415
2416#if _LFS64_LARGEFILE
2417int
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002418sys_getdents64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +00002419{
2420 int i, len, dents = 0;
2421 char *buf;
2422
2423 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002424 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002425 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +00002426 return 0;
2427 }
2428 if (syserror(tcp) || !verbose(tcp)) {
2429 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2430 return 0;
2431 }
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002432
John Hughesbdf48f52001-03-06 15:08:09 +00002433 len = tcp->u_rval;
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002434 /* Beware of insanely large or negative tcp->u_rval */
2435 if (tcp->u_rval > 1024*1024)
2436 len = 1024*1024;
2437 if (tcp->u_rval < 0)
2438 len = 0;
Mike Frysinger229738c2009-10-07 20:41:56 -04002439 buf = len ? malloc(len) : NULL;
Denys Vlasenko1d46ba52011-08-31 14:00:02 +02002440 if (len && !buf)
2441 die_out_of_memory();
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002442
John Hughesbdf48f52001-03-06 15:08:09 +00002443 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002444 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
John Hughesbdf48f52001-03-06 15:08:09 +00002445 free(buf);
2446 return 0;
2447 }
2448 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002449 tprints("{");
John Hughesbdf48f52001-03-06 15:08:09 +00002450 for (i = 0; i < len;) {
2451 struct dirent64 *d = (struct dirent64 *) &buf[i];
Michal Ludvig53b320f2002-09-23 13:30:09 +00002452#if defined(LINUX) || defined(SVR4)
John Hughesbdf48f52001-03-06 15:08:09 +00002453 if (!abbrev(tcp)) {
Dmitry V. Levin1f336e52006-10-14 20:20:46 +00002454 tprintf("%s{d_ino=%" PRIu64 ", d_off=%" PRId64 ", ",
Roland McGrath186c5ac2002-12-15 23:58:23 +00002455 i ? " " : "",
Roland McGrath92053242004-01-13 10:16:47 +00002456 d->d_ino,
2457 d->d_off);
Roland McGrath40542842004-01-13 09:47:49 +00002458#ifdef LINUX
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002459 tprints("d_type=");
Roland McGrath40542842004-01-13 09:47:49 +00002460 printxval(direnttypes, d->d_type, "DT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002461 tprints(", ");
Roland McGrath40542842004-01-13 09:47:49 +00002462#endif
John Hughesbdf48f52001-03-06 15:08:09 +00002463 tprintf("d_reclen=%u, d_name=\"%s\"}",
2464 d->d_reclen, d->d_name);
2465 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00002466#endif /* LINUX || SVR4 */
John Hughesbdf48f52001-03-06 15:08:09 +00002467#ifdef SUNOS4
2468 if (!abbrev(tcp)) {
2469 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2470 i ? " " : "", d->d_off, d->d_fileno,
2471 d->d_reclen);
2472 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2473 d->d_namlen, d->d_namlen, d->d_name);
2474 }
2475#endif /* SUNOS4 */
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002476 if (!d->d_reclen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002477 tprints("/* d_reclen == 0, problem here */");
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002478 break;
2479 }
John Hughesbdf48f52001-03-06 15:08:09 +00002480 i += d->d_reclen;
2481 dents++;
2482 }
2483 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002484 tprints("}");
John Hughesbdf48f52001-03-06 15:08:09 +00002485 else
2486 tprintf("/* %u entries */", dents);
2487 tprintf(", %lu", tcp->u_arg[2]);
2488 free(buf);
2489 return 0;
2490}
2491#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +00002492
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002493#ifdef FREEBSD
2494int
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002495sys_getdirentries(struct tcb *tcp)
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002496{
2497 int i, len, dents = 0;
2498 long basep;
2499 char *buf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002500
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002501 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002502 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002503 tprints(", ");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002504 return 0;
2505 }
2506 if (syserror(tcp) || !verbose(tcp)) {
2507 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2508 return 0;
2509 }
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002510
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002511 len = tcp->u_rval;
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002512 /* Beware of insanely large or negative tcp->u_rval */
2513 if (tcp->u_rval > 1024*1024)
2514 len = 1024*1024;
2515 if (tcp->u_rval < 0)
2516 len = 0;
Denys Vlasenko5d645812011-08-20 12:48:18 +02002517 buf = malloc(len);
Denys Vlasenko1d46ba52011-08-31 14:00:02 +02002518 if (!buf)
2519 die_out_of_memory();
Denys Vlasenko79a79ea2011-09-01 16:35:44 +02002520
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002521 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002522 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002523 free(buf);
2524 return 0;
2525 }
2526 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002527 tprints("{");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002528 for (i = 0; i < len;) {
2529 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2530 if (!abbrev(tcp)) {
2531 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2532 i ? " " : "", d->d_fileno, d->d_reclen);
2533 printxval(direnttypes, d->d_type, "DT_???");
2534 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2535 d->d_namlen, d->d_namlen, d->d_name);
2536 }
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002537 if (!d->d_reclen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002538 tprints("/* d_reclen == 0, problem here */");
Dmitry V. Levin153fbd62008-04-19 23:49:58 +00002539 break;
2540 }
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002541 i += d->d_reclen;
2542 dents++;
2543 }
2544 if (!abbrev(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002545 tprints("}");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002546 else
2547 tprintf("/* %u entries */", dents);
2548 free(buf);
2549 tprintf(", %lu", tcp->u_arg[2]);
2550 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2551 tprintf(", %#lx", tcp->u_arg[3]);
2552 else
2553 tprintf(", [%lu]", basep);
2554 return 0;
2555}
2556#endif
2557
Michal Ludvig53b320f2002-09-23 13:30:09 +00002558#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002559int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002560sys_getcwd(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002561{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002562 if (exiting(tcp)) {
2563 if (syserror(tcp))
2564 tprintf("%#lx", tcp->u_arg[0]);
2565 else
2566 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
2567 tprintf(", %lu", tcp->u_arg[1]);
2568 }
2569 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002570}
Michal Ludvig53b320f2002-09-23 13:30:09 +00002571#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002572
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002573#ifdef FREEBSD
2574int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002575sys___getcwd(struct tcb *tcp)
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002576{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002577 if (exiting(tcp)) {
2578 if (syserror(tcp))
2579 tprintf("%#lx", tcp->u_arg[0]);
2580 else
2581 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2582 tprintf(", %lu", tcp->u_arg[1]);
2583 }
2584 return 0;
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002585}
2586#endif
2587
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002588#ifdef HAVE_SYS_ASYNCH_H
2589
2590int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002591sys_aioread(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002592{
2593 struct aio_result_t res;
2594
2595 if (entering(tcp)) {
2596 tprintf("%lu, ", tcp->u_arg[0]);
2597 } else {
2598 if (syserror(tcp))
2599 tprintf("%#lx", tcp->u_arg[1]);
2600 else
2601 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2602 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2603 printxval(whence, tcp->u_arg[4], "L_???");
2604 if (syserror(tcp) || tcp->u_arg[5] == 0
2605 || umove(tcp, tcp->u_arg[5], &res) < 0)
2606 tprintf(", %#lx", tcp->u_arg[5]);
2607 else
2608 tprintf(", {aio_return %d aio_errno %d}",
2609 res.aio_return, res.aio_errno);
2610 }
2611 return 0;
2612}
2613
2614int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002615sys_aiowrite(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002616{
2617 struct aio_result_t res;
2618
2619 if (entering(tcp)) {
2620 tprintf("%lu, ", tcp->u_arg[0]);
2621 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2622 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2623 printxval(whence, tcp->u_arg[4], "L_???");
2624 }
2625 else {
2626 if (tcp->u_arg[5] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002627 tprints(", NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002628 else if (syserror(tcp)
2629 || umove(tcp, tcp->u_arg[5], &res) < 0)
2630 tprintf(", %#lx", tcp->u_arg[5]);
2631 else
2632 tprintf(", {aio_return %d aio_errno %d}",
2633 res.aio_return, res.aio_errno);
2634 }
2635 return 0;
2636}
2637
2638int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002639sys_aiowait(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002640{
2641 if (entering(tcp))
2642 printtv(tcp, tcp->u_arg[0]);
2643 return 0;
2644}
2645
2646int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002647sys_aiocancel(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002648{
2649 struct aio_result_t res;
2650
2651 if (exiting(tcp)) {
2652 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002653 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002654 else if (syserror(tcp)
2655 || umove(tcp, tcp->u_arg[0], &res) < 0)
2656 tprintf("%#lx", tcp->u_arg[0]);
2657 else
2658 tprintf("{aio_return %d aio_errno %d}",
2659 res.aio_return, res.aio_errno);
2660 }
2661 return 0;
2662}
2663
2664#endif /* HAVE_SYS_ASYNCH_H */
Roland McGrath186c5ac2002-12-15 23:58:23 +00002665
Roland McGratha4d48532005-06-08 20:45:28 +00002666static const struct xlat xattrflags[] = {
Roland McGrath561c7992003-04-02 01:10:44 +00002667#ifdef XATTR_CREATE
Roland McGrath186c5ac2002-12-15 23:58:23 +00002668 { XATTR_CREATE, "XATTR_CREATE" },
2669 { XATTR_REPLACE, "XATTR_REPLACE" },
Roland McGrath561c7992003-04-02 01:10:44 +00002670#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +00002671 { 0, NULL }
2672};
2673
Roland McGrath3292e222004-08-31 06:30:48 +00002674static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002675print_xattr_val(struct tcb *tcp, int failed,
2676 unsigned long arg,
2677 unsigned long insize,
2678 unsigned long size)
Roland McGrath3292e222004-08-31 06:30:48 +00002679{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002680 if (!failed) {
2681 unsigned long capacity = 4 * size + 1;
2682 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
2683 if (buf == NULL || /* probably a bogus size argument */
2684 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
2685 failed = 1;
Roland McGrath883567c2005-02-02 03:38:32 +00002686 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002687 else {
2688 unsigned char *out = buf;
2689 unsigned char *in = &buf[3 * size];
2690 size_t i;
2691 for (i = 0; i < size; ++i) {
2692 if (isprint(in[i]))
2693 *out++ = in[i];
2694 else {
2695#define tohex(n) "0123456789abcdef"[n]
2696 *out++ = '\\';
2697 *out++ = 'x';
2698 *out++ = tohex(in[i] / 16);
2699 *out++ = tohex(in[i] % 16);
2700 }
2701 }
2702 /* Don't print terminating NUL if there is one. */
2703 if (i > 0 && in[i - 1] == '\0')
2704 out -= 4;
2705 *out = '\0';
2706 tprintf(", \"%s\", %ld", buf, insize);
2707 }
2708 free(buf);
Roland McGrath883567c2005-02-02 03:38:32 +00002709 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002710 if (failed)
2711 tprintf(", 0x%lx, %ld", arg, insize);
Roland McGrath3292e222004-08-31 06:30:48 +00002712}
2713
Roland McGrath186c5ac2002-12-15 23:58:23 +00002714int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002715sys_setxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002716{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002717 if (entering(tcp)) {
2718 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002719 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002720 printstr(tcp, tcp->u_arg[1], -1);
2721 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002722 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002723 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2724 }
2725 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002726}
2727
2728int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002729sys_fsetxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002730{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002731 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002732 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002733 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002734 printstr(tcp, tcp->u_arg[1], -1);
2735 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002736 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002737 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
2738 }
2739 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002740}
2741
2742int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002743sys_getxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002744{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002745 if (entering(tcp)) {
2746 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002747 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002748 printstr(tcp, tcp->u_arg[1], -1);
2749 } else {
2750 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2751 tcp->u_rval);
2752 }
2753 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002754}
2755
2756int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002757sys_fgetxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002758{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002759 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002760 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002761 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002762 printstr(tcp, tcp->u_arg[1], -1);
2763 } else {
2764 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2765 tcp->u_rval);
2766 }
2767 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002768}
2769
2770int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002771sys_listxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002772{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002773 if (entering(tcp)) {
2774 printpath(tcp, tcp->u_arg[0]);
2775 } else {
2776 /* XXX Print value in format */
2777 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2778 }
2779 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002780}
2781
2782int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002783sys_flistxattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002784{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002785 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002786 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002787 } else {
2788 /* XXX Print value in format */
2789 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2790 }
2791 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002792}
2793
2794int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002795sys_removexattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002796{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002797 if (entering(tcp)) {
2798 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002799 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002800 printstr(tcp, tcp->u_arg[1], -1);
2801 }
2802 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002803}
2804
2805int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002806sys_fremovexattr(struct tcb *tcp)
Roland McGrath186c5ac2002-12-15 23:58:23 +00002807{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002808 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002809 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002810 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002811 printstr(tcp, tcp->u_arg[1], -1);
2812 }
2813 return 0;
Roland McGrath186c5ac2002-12-15 23:58:23 +00002814}
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002815
2816
2817static const struct xlat advise[] = {
2818 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2819 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2820 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2821 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2822 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2823 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2824 { 0, NULL }
2825};
2826
2827
Roland McGrathe27ed342004-10-20 02:24:19 +00002828#ifdef LINUX
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002829int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002830sys_fadvise64(struct tcb *tcp)
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002831{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002832 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002833 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +03002834 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002835 tprints(", ");
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002836 argn = printllval(tcp, "%lld", 1);
2837 tprintf(", %ld, ", tcp->u_arg[argn++]);
2838 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002839 }
2840 return 0;
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002841}
2842#endif
2843
2844
2845int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002846sys_fadvise64_64(struct tcb *tcp)
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002847{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002848 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002849 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +03002850 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002851 tprints(", ");
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002852#if defined ARM || defined POWERPC
2853 argn = printllval(tcp, "%lld, ", 2);
2854#else
2855 argn = printllval(tcp, "%lld, ", 1);
2856#endif
2857 argn = printllval(tcp, "%lld, ", argn);
2858#if defined ARM || defined POWERPC
Kirill A. Shutemov896db212009-09-19 03:21:33 +03002859 printxval(advise, tcp->u_arg[1], "POSIX_FADV_???");
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002860#else
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002861 printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002862#endif
Denys Vlasenko1d632462009-04-14 12:51:00 +00002863 }
2864 return 0;
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002865}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002866
2867#ifdef LINUX
2868static const struct xlat inotify_modes[] = {
Dmitry V. Levind475c062011-03-03 01:02:41 +00002869 { 0x00000001, "IN_ACCESS" },
2870 { 0x00000002, "IN_MODIFY" },
2871 { 0x00000004, "IN_ATTRIB" },
2872 { 0x00000008, "IN_CLOSE_WRITE"},
2873 { 0x00000010, "IN_CLOSE_NOWRITE"},
2874 { 0x00000020, "IN_OPEN" },
2875 { 0x00000040, "IN_MOVED_FROM" },
2876 { 0x00000080, "IN_MOVED_TO" },
2877 { 0x00000100, "IN_CREATE" },
2878 { 0x00000200, "IN_DELETE" },
2879 { 0x00000400, "IN_DELETE_SELF"},
2880 { 0x00000800, "IN_MOVE_SELF" },
2881 { 0x00002000, "IN_UNMOUNT" },
2882 { 0x00004000, "IN_Q_OVERFLOW" },
2883 { 0x00008000, "IN_IGNORED" },
2884 { 0x01000000, "IN_ONLYDIR" },
2885 { 0x02000000, "IN_DONT_FOLLOW"},
2886 { 0x20000000, "IN_MASK_ADD" },
2887 { 0x40000000, "IN_ISDIR" },
2888 { 0x80000000, "IN_ONESHOT" },
2889 { 0, NULL }
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002890};
2891
Sebastian Pipping1e1405a2011-03-03 00:50:55 +01002892static const struct xlat inotify_init_flags[] = {
2893 { 0x00000800, "IN_NONBLOCK" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002894 { 0x00080000, "IN_CLOEXEC" },
2895 { 0, NULL }
Sebastian Pipping1e1405a2011-03-03 00:50:55 +01002896};
2897
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002898int
2899sys_inotify_add_watch(struct tcb *tcp)
2900{
2901 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002902 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002903 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002904 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002905 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002906 printflags(inotify_modes, tcp->u_arg[2], "IN_???");
2907 }
2908 return 0;
2909}
2910
2911int
2912sys_inotify_rm_watch(struct tcb *tcp)
2913{
2914 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +03002915 printfd(tcp, tcp->u_arg[0]);
2916 tprintf(", %ld", tcp->u_arg[1]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002917 }
2918 return 0;
2919}
Roland McGrath96a96612008-05-20 04:56:18 +00002920
2921int
Mark Wielaardbab89402010-03-21 14:41:26 +01002922sys_inotify_init1(struct tcb *tcp)
2923{
2924 if (entering(tcp))
Sebastian Pipping1e1405a2011-03-03 00:50:55 +01002925 printflags(inotify_init_flags, tcp->u_arg[0], "IN_???");
Mark Wielaardbab89402010-03-21 14:41:26 +01002926 return 0;
2927}
2928
2929int
Roland McGrath96a96612008-05-20 04:56:18 +00002930sys_fallocate(struct tcb *tcp)
2931{
2932 if (entering(tcp)) {
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002933 int argn;
Dmitry V. Levin31382132011-03-04 05:08:02 +03002934 printfd(tcp, tcp->u_arg[0]); /* fd */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002935 tprints(", ");
Roland McGrath96a96612008-05-20 04:56:18 +00002936 tprintf("%#lo, ", tcp->u_arg[1]); /* mode */
Andreas Schwabb5600fc2009-11-04 17:08:34 +01002937 argn = printllval(tcp, "%llu, ", 2); /* offset */
2938 printllval(tcp, "%llu", argn); /* len */
Roland McGrath96a96612008-05-20 04:56:18 +00002939 }
2940 return 0;
2941}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002942#endif