blob: 62cc536b035af4f52421356c3c1be785ff64ccdf [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
Michal Ludvig53b320f2002-09-23 13:30:09 +00002#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00003 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
4 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
5 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00006 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00007 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 * $Id$
32 */
33
34#include "defs.h"
35
36#include <dirent.h>
Michal Ludvig53b320f2002-09-23 13:30:09 +000037#ifdef LINUX
Wichert Akkerman9524bb91999-05-25 23:11:18 +000038#define dirent kernel_dirent
Wichert Akkerman9b0c31d2000-09-03 21:56:29 +000039#define dirent64 kernel_dirent64
Wichert Akkerman9524bb91999-05-25 23:11:18 +000040#include <linux/types.h>
41#include <linux/dirent.h>
42#undef dirent
Michal Ludvig10a88d02002-10-07 14:31:00 +000043#undef dirent64
Wichert Akkerman9524bb91999-05-25 23:11:18 +000044#else
45#define kernel_dirent dirent
46#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000047
Michal Ludvig53b320f2002-09-23 13:30:09 +000048#ifdef LINUX
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000049# ifdef LINUXSPARC
50struct stat {
51 unsigned short st_dev;
52 unsigned int st_ino;
53 unsigned short st_mode;
54 short st_nlink;
55 unsigned short st_uid;
56 unsigned short st_gid;
57 unsigned short st_rdev;
58 unsigned int st_size;
59 int st_atime;
60 unsigned int __unused1;
61 int st_mtime;
62 unsigned int __unused2;
63 int st_ctime;
64 unsigned int __unused3;
65 int st_blksize;
66 int st_blocks;
67 unsigned int __unused4[2];
68};
Roland McGrath6d1a65c2004-07-12 07:44:08 +000069#if defined(SPARC64)
70struct stat_sparc64 {
71 unsigned int st_dev;
72 unsigned long st_ino;
73 unsigned int st_mode;
74 unsigned int st_nlink;
75 unsigned int st_uid;
76 unsigned int st_gid;
77 unsigned int st_rdev;
78 long st_size;
79 long st_atime;
80 long st_mtime;
81 long st_ctime;
82 long st_blksize;
83 long st_blocks;
84 unsigned long __unused4[2];
85};
86#endif /* SPARC64 */
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000087# define stat kernel_stat
88# include <asm/stat.h>
89# undef stat
90# else
Wichert Akkerman5b4d1281999-07-09 00:32:54 +000091# undef dev_t
92# undef ino_t
93# undef mode_t
94# undef nlink_t
95# undef uid_t
96# undef gid_t
97# undef off_t
98# undef loff_t
99
Wichert Akkermana6013701999-07-08 14:00:58 +0000100# define dev_t __kernel_dev_t
101# define ino_t __kernel_ino_t
102# define mode_t __kernel_mode_t
103# define nlink_t __kernel_nlink_t
104# define uid_t __kernel_uid_t
105# define gid_t __kernel_gid_t
106# define off_t __kernel_off_t
107# define loff_t __kernel_loff_t
108
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000109# include <asm/stat.h>
Wichert Akkermana6013701999-07-08 14:00:58 +0000110
111# undef dev_t
112# undef ino_t
113# undef mode_t
114# undef nlink_t
115# undef uid_t
116# undef gid_t
117# undef off_t
118# undef loff_t
Wichert Akkerman5b4d1281999-07-09 00:32:54 +0000119
120# define dev_t dev_t
121# define ino_t ino_t
122# define mode_t mode_t
123# define nlink_t nlink_t
124# define uid_t uid_t
125# define gid_t gid_t
126# define off_t off_t
127# define loff_t loff_t
Wichert Akkermandacfb6e1999-06-03 14:21:07 +0000128# endif
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000129# ifdef HPPA /* asm-parisc/stat.h defines stat64 */
130# undef stat64
131# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000132# define stat libc_stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000133# define stat64 libc_stat64
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000134# include <sys/stat.h>
135# undef stat
Ulrich Drepper0fa01d71999-12-24 07:18:28 +0000136# undef stat64
Roland McGrathca16a402003-01-09 06:53:22 +0000137 /* These might be macros. */
138# undef st_atime
139# undef st_mtime
140# undef st_ctime
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000141# ifdef HPPA
142# define stat64 hpux_stat64
143# endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000144#else
145# include <sys/stat.h>
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000146#endif
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000147
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000148#include <fcntl.h>
149
150#ifdef SVR4
151# include <sys/cred.h>
152#endif /* SVR4 */
153
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000154#ifdef HAVE_SYS_VFS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000155#include <sys/vfs.h>
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000156#endif
157
Roland McGrath186c5ac2002-12-15 23:58:23 +0000158#ifdef HAVE_LINUX_XATTR_H
159#include <linux/xattr.h>
160#elif defined linux
161#define XATTR_CREATE 1
162#define XATTR_REPLACE 2
163#endif
164
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000165#ifdef FREEBSD
166#include <sys/param.h>
167#include <sys/mount.h>
168#include <sys/stat.h>
John Hughes70623be2001-03-08 13:59:00 +0000169#endif
170
171#if HAVE_LONG_LONG_OFF_T
172/*
173 * Ugly hacks for systems that have typedef long long off_t
174 */
John Hughesb8c9f772001-03-07 16:53:07 +0000175
176#define stat64 stat
177#define HAVE_STAT64 1 /* Ugly hack */
John Hughes70623be2001-03-08 13:59:00 +0000178
179#define sys_stat64 sys_stat
180#define sys_fstat64 sys_fstat
181#define sys_lstat64 sys_lstat
182#define sys_lseek64 sys_lseek
183#define sys_truncate64 sys_truncate
184#define sys_ftruncate64 sys_ftruncate
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000185#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000186
187#ifdef MAJOR_IN_SYSMACROS
188#include <sys/sysmacros.h>
189#endif
190
191#ifdef MAJOR_IN_MKDEV
192#include <sys/mkdev.h>
193#endif
194
195#ifdef HAVE_SYS_ASYNCH_H
196#include <sys/asynch.h>
197#endif
198
199#ifdef SUNOS4
200#include <ustat.h>
201#endif
202
203/*
204 * This is a really dirty trick but it should always work. Traditional
205 * Unix says r/w/rw are 0/1/2, so we make them true flags 1/2/3 by
206 * adding 1. Just remember to add 1 to any arg decoded with openmodes.
207 */
Roland McGrathd9f816f2004-09-04 03:39:20 +0000208const struct xlat openmodes[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000209 { O_RDWR+1, "O_RDWR" },
210 { O_RDONLY+1, "O_RDONLY" },
211 { O_WRONLY+1, "O_WRONLY" },
212 { O_NONBLOCK, "O_NONBLOCK" },
213 { O_APPEND, "O_APPEND" },
214 { O_CREAT, "O_CREAT" },
215 { O_TRUNC, "O_TRUNC" },
216 { O_EXCL, "O_EXCL" },
217 { O_NOCTTY, "O_NOCTTY" },
218#ifdef O_SYNC
219 { O_SYNC, "O_SYNC" },
220#endif
221#ifdef O_ASYNC
222 { O_ASYNC, "O_ASYNC" },
223#endif
224#ifdef O_DSYNC
225 { O_DSYNC, "O_DSYNC" },
226#endif
227#ifdef O_RSYNC
228 { O_RSYNC, "O_RSYNC" },
229#endif
230#ifdef O_NDELAY
231 { O_NDELAY, "O_NDELAY" },
232#endif
233#ifdef O_PRIV
234 { O_PRIV, "O_PRIV" },
235#endif
236#ifdef O_DIRECT
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000237 { O_DIRECT, "O_DIRECT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000238#endif
239#ifdef O_LARGEFILE
Roland McGrathfee836e2005-02-02 22:11:32 +0000240# if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
241# undef O_LARGEFILE
242# ifdef SPARC64
243# define O_LARGEFILE 0x40000
244# elif defined X86_64 || defined S390X
245# define O_LARGEFILE 0100000
246# endif
247# endif
Roland McGrath663a8a02005-02-04 09:49:56 +0000248# ifdef O_LARGEFILE
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000249 { O_LARGEFILE, "O_LARGEFILE" },
Roland McGrath663a8a02005-02-04 09:49:56 +0000250# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000251#endif
252#ifdef O_DIRECTORY
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000253 { O_DIRECTORY, "O_DIRECTORY" },
254#endif
255#ifdef O_NOFOLLOW
256 { O_NOFOLLOW, "O_NOFOLLOW" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000257#endif
Roland McGrath1025c3e2005-05-09 07:40:35 +0000258#ifdef O_NOATIME
259 { O_NOATIME, "O_NOATIME" },
260#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000261
262#ifdef FNDELAY
263 { FNDELAY, "FNDELAY" },
264#endif
265#ifdef FAPPEND
266 { FAPPEND, "FAPPEND" },
267#endif
268#ifdef FMARK
269 { FMARK, "FMARK" },
270#endif
271#ifdef FDEFER
272 { FDEFER, "FDEFER" },
273#endif
274#ifdef FASYNC
275 { FASYNC, "FASYNC" },
276#endif
277#ifdef FSHLOCK
278 { FSHLOCK, "FSHLOCK" },
279#endif
280#ifdef FEXLOCK
281 { FEXLOCK, "FEXLOCK" },
282#endif
283#ifdef FCREAT
284 { FCREAT, "FCREAT" },
285#endif
286#ifdef FTRUNC
287 { FTRUNC, "FTRUNC" },
288#endif
289#ifdef FEXCL
290 { FEXCL, "FEXCL" },
291#endif
292#ifdef FNBIO
293 { FNBIO, "FNBIO" },
294#endif
295#ifdef FSYNC
296 { FSYNC, "FSYNC" },
297#endif
298#ifdef FNOCTTY
299 { FNOCTTY, "FNOCTTY" },
Roland McGrath186c5ac2002-12-15 23:58:23 +0000300#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000301#ifdef O_SHLOCK
302 { O_SHLOCK, "O_SHLOCK" },
303#endif
304#ifdef O_EXLOCK
305 { O_EXLOCK, "O_EXLOCK" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000306#endif
307 { 0, NULL },
308};
309
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000310#ifdef LINUX
311
312#ifndef AT_FDCWD
313# define AT_FDCWD -100
314#endif
315
316static void
317print_dirfd(long fd)
318{
319 if (fd == AT_FDCWD)
320 tprintf("AT_FDCWD, ");
321 else
322 tprintf("%ld, ", fd);
323}
324#endif
325
326static int
327decode_open(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000328{
329 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000330 printpath(tcp, tcp->u_arg[offset]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000331 tprintf(", ");
332 /* flags */
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000333 printflags(openmodes, tcp->u_arg[offset + 1] + 1, "O_???");
334 if (tcp->u_arg[offset + 1] & O_CREAT) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000335 /* mode */
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000336 tprintf(", %#lo", tcp->u_arg[offset + 2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000337 }
338 }
339 return 0;
340}
341
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000342int
343sys_open(struct tcb *tcp)
344{
345 return decode_open(tcp, 0);
346}
347
348#ifdef LINUX
349int
350sys_openat(struct tcb *tcp)
351{
352 if (entering(tcp))
353 print_dirfd(tcp->u_arg[0]);
354 return decode_open(tcp, 1);
355}
356#endif
357
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000358#ifdef LINUXSPARC
Roland McGratha4d48532005-06-08 20:45:28 +0000359static const struct xlat openmodessol[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000360 { 0, "O_RDWR" },
361 { 1, "O_RDONLY" },
362 { 2, "O_WRONLY" },
363 { 0x80, "O_NONBLOCK" },
364 { 8, "O_APPEND" },
365 { 0x100, "O_CREAT" },
366 { 0x200, "O_TRUNC" },
367 { 0x400, "O_EXCL" },
368 { 0x800, "O_NOCTTY" },
369 { 0x10, "O_SYNC" },
370 { 0x40, "O_DSYNC" },
371 { 0x8000, "O_RSYNC" },
372 { 4, "O_NDELAY" },
373 { 0x1000, "O_PRIV" },
374 { 0, NULL },
375};
376
377int
378solaris_open(tcp)
379struct tcb *tcp;
380{
381 if (entering(tcp)) {
382 printpath(tcp, tcp->u_arg[0]);
383 tprintf(", ");
384 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000385 printflags(openmodessol, tcp->u_arg[1] + 1, "O_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000386 if (tcp->u_arg[1] & 0x100) {
387 /* mode */
388 tprintf(", %#lo", tcp->u_arg[2]);
389 }
390 }
391 return 0;
392}
393
394#endif
395
396int
397sys_creat(tcp)
398struct tcb *tcp;
399{
400 if (entering(tcp)) {
401 printpath(tcp, tcp->u_arg[0]);
402 tprintf(", %#lo", tcp->u_arg[1]);
403 }
404 return 0;
405}
406
Roland McGrathd9f816f2004-09-04 03:39:20 +0000407static const struct xlat access_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000408 { F_OK, "F_OK", },
409 { R_OK, "R_OK" },
410 { W_OK, "W_OK" },
411 { X_OK, "X_OK" },
412#ifdef EFF_ONLY_OK
413 { EFF_ONLY_OK, "EFF_ONLY_OK" },
414#endif
415#ifdef EX_OK
416 { EX_OK, "EX_OK" },
417#endif
418 { 0, NULL },
419};
420
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000421static int
422decode_access(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000423{
424 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000425 printpath(tcp, tcp->u_arg[offset]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000426 tprintf(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000427 printflags(access_flags, tcp->u_arg[offset + 1], "?_OK");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000428 }
429 return 0;
430}
431
432int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000433sys_access(struct tcb *tcp)
434{
435 return decode_access(tcp, 0);
436}
437
438#ifdef LINUX
439int
440sys_faccessat(struct tcb *tcp)
441{
442 if (entering(tcp))
443 print_dirfd(tcp->u_arg[0]);
444 return decode_access(tcp, 1);
445}
446#endif
447
448int
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000449sys_umask(tcp)
450struct tcb *tcp;
451{
452 if (entering(tcp)) {
453 tprintf("%#lo", tcp->u_arg[0]);
454 }
455 return RVAL_OCTAL;
456}
457
Roland McGrathd9f816f2004-09-04 03:39:20 +0000458static const struct xlat whence[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000459 { SEEK_SET, "SEEK_SET" },
460 { SEEK_CUR, "SEEK_CUR" },
461 { SEEK_END, "SEEK_END" },
462 { 0, NULL },
463};
464
John Hughes70623be2001-03-08 13:59:00 +0000465#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000466int
467sys_lseek(tcp)
468struct tcb *tcp;
469{
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000470 off_t offset;
471 int _whence;
472
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000473 if (entering(tcp)) {
474 tprintf("%ld, ", tcp->u_arg[0]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000475 offset = tcp->u_arg[1];
476 _whence = tcp->u_arg[2];
477 if (_whence == SEEK_SET)
478 tprintf("%lu, ", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000479 else
Roland McGrath186c5ac2002-12-15 23:58:23 +0000480 tprintf("%ld, ", offset);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000481 printxval(whence, _whence, "SEEK_???");
Roland McGrath186c5ac2002-12-15 23:58:23 +0000482 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000483 return RVAL_UDECIMAL;
484}
John Hughes5a826b82001-03-07 13:21:24 +0000485#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000486
Michal Ludvig53b320f2002-09-23 13:30:09 +0000487#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000488int
489sys_llseek (tcp)
490struct tcb *tcp;
491{
492 if (entering(tcp)) {
Roland McGrath8c304bc2004-10-19 22:59:55 +0000493 /*
494 * This one call takes explicitly two 32-bit arguments hi, lo,
495 * rather than one 64-bit argument for which LONG_LONG works
496 * appropriate for the native byte order.
497 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000498 if (tcp->u_arg[4] == SEEK_SET)
499 tprintf("%ld, %llu, ", tcp->u_arg[0],
Roland McGrath8c304bc2004-10-19 22:59:55 +0000500 (((long long int) tcp->u_arg[1]) << 32
501 | (unsigned long long) (unsigned) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000502 else
503 tprintf("%ld, %lld, ", tcp->u_arg[0],
Roland McGrath8c304bc2004-10-19 22:59:55 +0000504 (((long long int) tcp->u_arg[1]) << 32
505 | (unsigned long long) (unsigned) tcp->u_arg[2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000506 }
507 else {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000508 long long int off;
509 if (syserror(tcp) || umove(tcp, tcp->u_arg[3], &off) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000510 tprintf("%#lx, ", tcp->u_arg[3]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000511 else
512 tprintf("[%llu], ", off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000513 printxval(whence, tcp->u_arg[4], "SEEK_???");
514 }
515 return 0;
516}
Roland McGrath186c5ac2002-12-15 23:58:23 +0000517
518int
519sys_readahead (tcp)
520struct tcb *tcp;
521{
522 if (entering(tcp)) {
523 tprintf("%ld, %lld, %ld", tcp->u_arg[0],
524# if defined IA64 || defined X86_64 || defined ALPHA
525 (long long int) tcp->u_arg[1], tcp->u_arg[2]
526# else
Roland McGrath2fe2a3e2004-10-07 19:09:16 +0000527 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]
Roland McGrath186c5ac2002-12-15 23:58:23 +0000528# endif
529 );
530 }
531 return 0;
532}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000533#endif
534
John Hughes70623be2001-03-08 13:59:00 +0000535#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughesbdf48f52001-03-06 15:08:09 +0000536int
537sys_lseek64 (tcp)
538struct tcb *tcp;
539{
540 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000541 long long offset;
542 ALIGN64 (tcp, 1); /* FreeBSD aligns off_t args */
John Hughes0c79e012001-03-08 14:40:06 +0000543 offset = LONG_LONG(tcp->u_arg [1], tcp->u_arg[2]);
John Hughesbdf48f52001-03-06 15:08:09 +0000544 if (tcp->u_arg[3] == SEEK_SET)
545 tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
546 else
547 tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
548 printxval(whence, tcp->u_arg[3], "SEEK_???");
549 }
550 return RVAL_LUDECIMAL;
551}
552#endif
553
John Hughes70623be2001-03-08 13:59:00 +0000554#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000555int
556sys_truncate(tcp)
557struct tcb *tcp;
558{
559 if (entering(tcp)) {
560 printpath(tcp, tcp->u_arg[0]);
561 tprintf(", %lu", tcp->u_arg[1]);
562 }
563 return 0;
564}
John Hughes5a826b82001-03-07 13:21:24 +0000565#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000566
John Hughes70623be2001-03-08 13:59:00 +0000567#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000568int
569sys_truncate64(tcp)
570struct tcb *tcp;
571{
572 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000573 ALIGN64 (tcp, 1);
John Hughes96f51472001-03-06 16:50:41 +0000574 printpath(tcp, tcp->u_arg[0]);
John Hughes0c79e012001-03-08 14:40:06 +0000575 tprintf(", %llu", LONG_LONG(tcp->u_arg[1],tcp->u_arg[2]));
John Hughes96f51472001-03-06 16:50:41 +0000576 }
577 return 0;
578}
579#endif
580
John Hughes70623be2001-03-08 13:59:00 +0000581#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000582int
583sys_ftruncate(tcp)
584struct tcb *tcp;
585{
586 if (entering(tcp)) {
587 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
588 }
589 return 0;
590}
John Hughes5a826b82001-03-07 13:21:24 +0000591#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000592
John Hughes70623be2001-03-08 13:59:00 +0000593#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughes96f51472001-03-06 16:50:41 +0000594int
595sys_ftruncate64(tcp)
596struct tcb *tcp;
597{
598 if (entering(tcp)) {
John Hughes5a826b82001-03-07 13:21:24 +0000599 ALIGN64 (tcp, 1);
John Hughes96f51472001-03-06 16:50:41 +0000600 tprintf("%ld, %llu", tcp->u_arg[0],
John Hughes0c79e012001-03-08 14:40:06 +0000601 LONG_LONG(tcp->u_arg[1] ,tcp->u_arg[2]));
John Hughes96f51472001-03-06 16:50:41 +0000602 }
603 return 0;
604}
605#endif
606
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000607/* several stats */
608
Roland McGrathd9f816f2004-09-04 03:39:20 +0000609static const struct xlat modetypes[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000610 { S_IFREG, "S_IFREG" },
611 { S_IFSOCK, "S_IFSOCK" },
612 { S_IFIFO, "S_IFIFO" },
613 { S_IFLNK, "S_IFLNK" },
614 { S_IFDIR, "S_IFDIR" },
615 { S_IFBLK, "S_IFBLK" },
616 { S_IFCHR, "S_IFCHR" },
617 { 0, NULL },
618};
619
Roland McGrathf9c49b22004-10-06 22:11:54 +0000620static const char *
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000621sprintmode(mode)
622int mode;
623{
624 static char buf[64];
Roland McGrathf9c49b22004-10-06 22:11:54 +0000625 const char *s;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000626
627 if ((mode & S_IFMT) == 0)
628 s = "";
629 else if ((s = xlookup(modetypes, mode & S_IFMT)) == NULL) {
630 sprintf(buf, "%#o", mode);
631 return buf;
632 }
633 sprintf(buf, "%s%s%s%s", s,
634 (mode & S_ISUID) ? "|S_ISUID" : "",
635 (mode & S_ISGID) ? "|S_ISGID" : "",
636 (mode & S_ISVTX) ? "|S_ISVTX" : "");
637 mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
638 if (mode)
639 sprintf(buf + strlen(buf), "|%#o", mode);
640 s = (*buf == '|') ? buf + 1 : buf;
641 return *s ? s : "0";
642}
643
644static char *
645sprinttime(t)
646time_t t;
647{
648 struct tm *tmp;
649 static char buf[32];
650
651 if (t == 0) {
652 sprintf(buf, "0");
653 return buf;
654 }
655 tmp = localtime(&t);
656 sprintf(buf, "%02d/%02d/%02d-%02d:%02d:%02d",
Wichert Akkerman3ed6dc22000-01-11 14:41:09 +0000657 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000658 tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
659 return buf;
660}
661
662#ifdef LINUXSPARC
663typedef struct {
664 int tv_sec;
665 int tv_nsec;
666} timestruct_t;
667
668struct solstat {
669 unsigned st_dev;
670 int st_pad1[3]; /* network id */
671 unsigned st_ino;
672 unsigned st_mode;
673 unsigned st_nlink;
674 unsigned st_uid;
675 unsigned st_gid;
676 unsigned st_rdev;
677 int st_pad2[2];
678 int st_size;
679 int st_pad3; /* st_size, off_t expansion */
680 timestruct_t st_atime;
681 timestruct_t st_mtime;
682 timestruct_t st_ctime;
683 int st_blksize;
684 int st_blocks;
685 char st_fstype[16];
686 int st_pad4[8]; /* expansion area */
687};
688
689static void
690printstatsol(tcp, addr)
691struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000692long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000693{
694 struct solstat statbuf;
695
696 if (!addr) {
697 tprintf("NULL");
698 return;
699 }
700 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000701 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000702 return;
703 }
704 if (umove(tcp, addr, &statbuf) < 0) {
705 tprintf("{...}");
706 return;
707 }
708 if (!abbrev(tcp)) {
709 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
710 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
711 (unsigned long) (statbuf.st_dev & 0x3ffff),
712 (unsigned long) statbuf.st_ino,
713 sprintmode(statbuf.st_mode));
714 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
715 (unsigned long) statbuf.st_nlink,
716 (unsigned long) statbuf.st_uid,
717 (unsigned long) statbuf.st_gid);
718 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
719 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
720 }
721 else
722 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
723 switch (statbuf.st_mode & S_IFMT) {
724 case S_IFCHR: case S_IFBLK:
725 tprintf("st_rdev=makedev(%lu, %lu), ",
726 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
727 (unsigned long) (statbuf.st_rdev & 0x3ffff));
728 break;
729 default:
730 tprintf("st_size=%u, ", statbuf.st_size);
731 break;
732 }
733 if (!abbrev(tcp)) {
734 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
735 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
736 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
737 }
738 else
739 tprintf("...}");
740}
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000741
742#if defined (SPARC64)
743static void
744printstat_sparc64(tcp, addr)
745struct tcb *tcp;
746long addr;
747{
748 struct stat_sparc64 statbuf;
749
750 if (!addr) {
751 tprintf("NULL");
752 return;
753 }
754 if (syserror(tcp) || !verbose(tcp)) {
755 tprintf("%#lx", addr);
756 return;
757 }
758 if (umove(tcp, addr, &statbuf) < 0) {
759 tprintf("{...}");
760 return;
761 }
762
763 if (!abbrev(tcp)) {
764 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
765 (unsigned long) major(statbuf.st_dev),
766 (unsigned long) minor(statbuf.st_dev),
767 (unsigned long) statbuf.st_ino,
768 sprintmode(statbuf.st_mode));
769 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
770 (unsigned long) statbuf.st_nlink,
771 (unsigned long) statbuf.st_uid,
772 (unsigned long) statbuf.st_gid);
773 tprintf("st_blksize=%lu, ",
774 (unsigned long) statbuf.st_blksize);
775 tprintf("st_blocks=%lu, ",
776 (unsigned long) statbuf.st_blocks);
777 }
778 else
779 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
780 switch (statbuf.st_mode & S_IFMT) {
781 case S_IFCHR: case S_IFBLK:
782 tprintf("st_rdev=makedev(%lu, %lu), ",
783 (unsigned long) major(statbuf.st_rdev),
784 (unsigned long) minor(statbuf.st_rdev));
785 break;
786 default:
787 tprintf("st_size=%lu, ", statbuf.st_size);
788 break;
789 }
790 if (!abbrev(tcp)) {
791 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
792 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
793 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
794 tprintf("}");
795 }
796 else
797 tprintf("...}");
798}
799#endif /* SPARC64 */
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000800#endif /* LINUXSPARC */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000801
Roland McGratha4d48532005-06-08 20:45:28 +0000802static const struct xlat fileflags[] = {
John Hughesc0fc3fd2001-03-08 16:10:40 +0000803#ifdef FREEBSD
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000804 { UF_NODUMP, "UF_NODUMP" },
805 { UF_IMMUTABLE, "UF_IMMUTABLE" },
806 { UF_APPEND, "UF_APPEND" },
807 { UF_OPAQUE, "UF_OPAQUE" },
808 { UF_NOUNLINK, "UF_NOUNLINK" },
809 { SF_ARCHIVED, "SF_ARCHIVED" },
810 { SF_IMMUTABLE, "SF_IMMUTABLE" },
811 { SF_APPEND, "SF_APPEND" },
812 { SF_NOUNLINK, "SF_NOUNLINK" },
John Hughesc0fc3fd2001-03-08 16:10:40 +0000813#elif UNIXWARE >= 2
814#ifdef _S_ISMLD
815 { _S_ISMLD, "_S_ISMLD" },
816#endif
817#ifdef _S_ISMOUNTED
818 { _S_ISMOUNTED, "_S_ISMOUNTED" },
819#endif
820#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000821 { 0, NULL },
822};
823
John Hughesc0fc3fd2001-03-08 16:10:40 +0000824#ifdef FREEBSD
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000825int
826sys_chflags(tcp)
827struct tcb *tcp;
828{
829 if (entering(tcp)) {
830 printpath(tcp, tcp->u_arg[0]);
831 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000832 printflags(fileflags, tcp->u_arg[1], "UF_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000833 }
834 return 0;
835}
836
837int
838sys_fchflags(tcp)
839struct tcb *tcp;
840{
841 if (entering(tcp)) {
842 tprintf("%ld, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000843 printflags(fileflags, tcp->u_arg[1], "UF_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000844 }
845 return 0;
846}
847#endif
848
John Hughes70623be2001-03-08 13:59:00 +0000849#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000850static void
851realprintstat(tcp, statbuf)
852struct tcb *tcp;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000853struct stat *statbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000854{
855 if (!abbrev(tcp)) {
856 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
857 (unsigned long) major(statbuf->st_dev),
858 (unsigned long) minor(statbuf->st_dev),
859 (unsigned long) statbuf->st_ino,
860 sprintmode(statbuf->st_mode));
861 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
862 (unsigned long) statbuf->st_nlink,
863 (unsigned long) statbuf->st_uid,
864 (unsigned long) statbuf->st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000865#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000866 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000867#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
868#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000869 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000870#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000871 }
872 else
873 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
874 switch (statbuf->st_mode & S_IFMT) {
875 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +0000876#ifdef HAVE_STRUCT_STAT_ST_RDEV
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000877 tprintf("st_rdev=makedev(%lu, %lu), ",
878 (unsigned long) major(statbuf->st_rdev),
879 (unsigned long) minor(statbuf->st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000880#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000881 tprintf("st_size=makedev(%lu, %lu), ",
882 (unsigned long) major(statbuf->st_size),
883 (unsigned long) minor(statbuf->st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000884#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000885 break;
886 default:
887 tprintf("st_size=%lu, ", statbuf->st_size);
888 break;
889 }
890 if (!abbrev(tcp)) {
891 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
892 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +0000893 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000894#if HAVE_STRUCT_STAT_ST_FLAGS
John Hughesc0fc3fd2001-03-08 16:10:40 +0000895 tprintf(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +0000896 printflags(fileflags, statbuf->st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +0000897#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000898#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +0000899 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
900#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000901#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +0000902 tprintf(", st_level=%ld", statbuf->st_level);
903#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000904#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +0000905 tprintf(", st_fstype=%.*s",
906 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
907#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000908#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +0000909 tprintf(", st_gen=%u", statbuf->st_gen);
910#endif
911 tprintf("}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000912 }
913 else
914 tprintf("...}");
915}
916
Nate Sammons771a6ff1999-04-05 22:39:31 +0000917
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000918static void
919printstat(tcp, addr)
920struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000921long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000922{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000923 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000924
925#ifdef LINUXSPARC
926 if (current_personality == 1) {
927 printstatsol(tcp, addr);
928 return;
929 }
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000930#ifdef SPARC64
931 else if (current_personality == 2) {
932 printstat_sparc64(tcp, addr);
933 return;
934 }
935#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000936#endif /* LINUXSPARC */
937
938 if (!addr) {
939 tprintf("NULL");
940 return;
941 }
942 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000943 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000944 return;
945 }
946 if (umove(tcp, addr, &statbuf) < 0) {
947 tprintf("{...}");
948 return;
949 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000950
951 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000952}
John Hughes70623be2001-03-08 13:59:00 +0000953#endif /* !HAVE_LONG_LONG_OFF_T */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000954
Wichert Akkermanc7926982000-04-10 22:22:31 +0000955#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000956static void
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000957printstat64(tcp, addr)
958struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000959long addr;
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000960{
961 struct stat64 statbuf;
962
963#ifdef LINUXSPARC
964 if (current_personality == 1) {
965 printstatsol(tcp, addr);
966 return;
967 }
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000968#ifdef SPARC64
969 else if (current_personality == 2) {
970 printstat_sparc64(tcp, addr);
971 return;
972 }
973#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000974#endif /* LINUXSPARC */
975
976 if (!addr) {
977 tprintf("NULL");
978 return;
979 }
980 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000981 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000982 return;
983 }
984 if (umove(tcp, addr, &statbuf) < 0) {
985 tprintf("{...}");
986 return;
987 }
988
989 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +0000990#ifdef HAVE_LONG_LONG
991 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
992#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000993 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
Wichert Akkermand077c452000-08-10 18:16:15 +0000994#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000995 (unsigned long) major(statbuf.st_dev),
996 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +0000997#ifdef HAVE_LONG_LONG
998 (unsigned long long) statbuf.st_ino,
999#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001000 (unsigned long) statbuf.st_ino,
Wichert Akkermand077c452000-08-10 18:16:15 +00001001#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001002 sprintmode(statbuf.st_mode));
1003 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
1004 (unsigned long) statbuf.st_nlink,
1005 (unsigned long) statbuf.st_uid,
1006 (unsigned long) statbuf.st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001007#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001008 tprintf("st_blksize=%lu, ",
1009 (unsigned long) statbuf.st_blksize);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001010#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
1011#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001012 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001013#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001014 }
1015 else
1016 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
1017 switch (statbuf.st_mode & S_IFMT) {
1018 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +00001019#ifdef HAVE_STRUCT_STAT_ST_RDEV
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001020 tprintf("st_rdev=makedev(%lu, %lu), ",
1021 (unsigned long) major(statbuf.st_rdev),
1022 (unsigned long) minor(statbuf.st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001023#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001024 tprintf("st_size=makedev(%lu, %lu), ",
1025 (unsigned long) major(statbuf.st_size),
1026 (unsigned long) minor(statbuf.st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001027#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001028 break;
1029 default:
1030 tprintf("st_size=%llu, ", statbuf.st_size);
1031 break;
1032 }
1033 if (!abbrev(tcp)) {
1034 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
1035 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +00001036 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +00001037#if HAVE_STRUCT_STAT_ST_FLAGS
John Hughesc0fc3fd2001-03-08 16:10:40 +00001038 tprintf(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +00001039 printflags(fileflags, statbuf.st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +00001040#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001041#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +00001042 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
1043#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001044#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +00001045 tprintf(", st_level=%ld", statbuf.st_level);
1046#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001047#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +00001048 tprintf(", st_fstype=%.*s",
1049 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
1050#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +00001051#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +00001052 tprintf(", st_gen=%u", statbuf.st_gen);
1053#endif
1054 tprintf("}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001055 }
1056 else
1057 tprintf("...}");
1058}
Wichert Akkermanc7926982000-04-10 22:22:31 +00001059#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001060
Roland McGrath79db8af2003-06-27 21:20:09 +00001061#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001062static void
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001063convertoldstat(oldbuf, newbuf)
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +00001064const struct __old_kernel_stat *oldbuf;
1065struct stat *newbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001066{
1067 newbuf->st_dev=oldbuf->st_dev;
1068 newbuf->st_ino=oldbuf->st_ino;
1069 newbuf->st_mode=oldbuf->st_mode;
1070 newbuf->st_nlink=oldbuf->st_nlink;
1071 newbuf->st_uid=oldbuf->st_uid;
1072 newbuf->st_gid=oldbuf->st_gid;
1073 newbuf->st_rdev=oldbuf->st_rdev;
1074 newbuf->st_size=oldbuf->st_size;
1075 newbuf->st_atime=oldbuf->st_atime;
1076 newbuf->st_mtime=oldbuf->st_mtime;
1077 newbuf->st_ctime=oldbuf->st_ctime;
1078 newbuf->st_blksize=0; /* not supported in old_stat */
1079 newbuf->st_blocks=0; /* not supported in old_stat */
1080}
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001081
1082
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001083static void
1084printoldstat(tcp, addr)
1085struct tcb *tcp;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001086long addr;
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001087{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +00001088 struct __old_kernel_stat statbuf;
1089 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001090
1091#ifdef LINUXSPARC
1092 if (current_personality == 1) {
1093 printstatsol(tcp, addr);
1094 return;
1095 }
1096#endif /* LINUXSPARC */
1097
1098 if (!addr) {
1099 tprintf("NULL");
1100 return;
1101 }
1102 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001103 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001104 return;
1105 }
1106 if (umove(tcp, addr, &statbuf) < 0) {
1107 tprintf("{...}");
1108 return;
1109 }
1110
1111 convertoldstat(&statbuf, &newstatbuf);
1112 realprintstat(tcp, &newstatbuf);
1113}
Michal Ludvig10a88d02002-10-07 14:31:00 +00001114#endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001115
John Hughes70623be2001-03-08 13:59:00 +00001116#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001117int
1118sys_stat(tcp)
1119struct tcb *tcp;
1120{
1121 if (entering(tcp)) {
1122 printpath(tcp, tcp->u_arg[0]);
1123 tprintf(", ");
1124 } else {
1125 printstat(tcp, tcp->u_arg[1]);
1126 }
1127 return 0;
1128}
John Hughesb8c9f772001-03-07 16:53:07 +00001129#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001130
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001131int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001132sys_stat64(tcp)
1133struct tcb *tcp;
1134{
1135#ifdef HAVE_STAT64
1136 if (entering(tcp)) {
1137 printpath(tcp, tcp->u_arg[0]);
1138 tprintf(", ");
1139 } else {
1140 printstat64(tcp, tcp->u_arg[1]);
1141 }
1142 return 0;
1143#else
1144 return printargs(tcp);
1145#endif
1146}
1147
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001148#ifdef LINUX
1149static const struct xlat fstatatflags[] = {
1150#ifndef AT_SYMLINK_NOFOLLOW
1151# define AT_SYMLINK_NOFOLLOW 0x100
1152#endif
1153 { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" },
1154 { 0, NULL },
1155};
1156
1157int
1158sys_newfstatat(struct tcb *tcp)
1159{
1160 if (entering(tcp)) {
1161 print_dirfd(tcp->u_arg[0]);
1162 printpath(tcp, tcp->u_arg[1]);
1163 tprintf(", ");
1164 } else {
1165#ifdef HAVE_STAT64
1166 printstat64(tcp, tcp->u_arg[2]);
1167#else
1168 printstat(tcp, tcp->u_arg[2]);
1169#endif
1170 tprintf(", ");
1171 printflags(fstatatflags, tcp->u_arg[3], "AT_???");
1172 }
1173 return 0;
1174}
1175#endif
1176
Roland McGrath79db8af2003-06-27 21:20:09 +00001177#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001178int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001179sys_oldstat(tcp)
1180struct tcb *tcp;
1181{
1182 if (entering(tcp)) {
1183 printpath(tcp, tcp->u_arg[0]);
1184 tprintf(", ");
1185 } else {
1186 printoldstat(tcp, tcp->u_arg[1]);
1187 }
1188 return 0;
1189}
Roland McGrath79db8af2003-06-27 21:20:09 +00001190#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001191
John Hughes70623be2001-03-08 13:59:00 +00001192#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001193int
1194sys_fstat(tcp)
1195struct tcb *tcp;
1196{
1197 if (entering(tcp))
1198 tprintf("%ld, ", tcp->u_arg[0]);
1199 else {
1200 printstat(tcp, tcp->u_arg[1]);
1201 }
1202 return 0;
1203}
John Hughesb8c9f772001-03-07 16:53:07 +00001204#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001205
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001206int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001207sys_fstat64(tcp)
1208struct tcb *tcp;
1209{
1210#ifdef HAVE_STAT64
1211 if (entering(tcp))
1212 tprintf("%ld, ", tcp->u_arg[0]);
1213 else {
1214 printstat64(tcp, tcp->u_arg[1]);
1215 }
1216 return 0;
1217#else
1218 return printargs(tcp);
1219#endif
1220}
1221
Roland McGrath79db8af2003-06-27 21:20:09 +00001222#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001223int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001224sys_oldfstat(tcp)
1225struct tcb *tcp;
1226{
1227 if (entering(tcp))
1228 tprintf("%ld, ", tcp->u_arg[0]);
1229 else {
1230 printoldstat(tcp, tcp->u_arg[1]);
1231 }
1232 return 0;
1233}
Roland McGrath79db8af2003-06-27 21:20:09 +00001234#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001235
John Hughes70623be2001-03-08 13:59:00 +00001236#ifndef HAVE_LONG_LONG_OFF_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001237int
1238sys_lstat(tcp)
1239struct tcb *tcp;
1240{
1241 if (entering(tcp)) {
1242 printpath(tcp, tcp->u_arg[0]);
1243 tprintf(", ");
1244 } else {
1245 printstat(tcp, tcp->u_arg[1]);
1246 }
1247 return 0;
1248}
John Hughesb8c9f772001-03-07 16:53:07 +00001249#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001250
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001251int
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001252sys_lstat64(tcp)
1253struct tcb *tcp;
1254{
1255#ifdef HAVE_STAT64
1256 if (entering(tcp)) {
1257 printpath(tcp, tcp->u_arg[0]);
1258 tprintf(", ");
1259 } else {
1260 printstat64(tcp, tcp->u_arg[1]);
1261 }
1262 return 0;
1263#else
1264 return printargs(tcp);
1265#endif
1266}
1267
Roland McGrath79db8af2003-06-27 21:20:09 +00001268#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +00001269int
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001270sys_oldlstat(tcp)
1271struct tcb *tcp;
1272{
1273 if (entering(tcp)) {
1274 printpath(tcp, tcp->u_arg[0]);
1275 tprintf(", ");
1276 } else {
1277 printoldstat(tcp, tcp->u_arg[1]);
1278 }
1279 return 0;
1280}
Roland McGrath79db8af2003-06-27 21:20:09 +00001281#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */
Wichert Akkerman328c5e71999-04-16 00:21:26 +00001282
1283
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001284#if defined(SVR4) || defined(LINUXSPARC)
1285
1286int
1287sys_xstat(tcp)
1288struct tcb *tcp;
1289{
1290 if (entering(tcp)) {
1291 tprintf("%ld, ", tcp->u_arg[0]);
1292 printpath(tcp, tcp->u_arg[1]);
1293 tprintf(", ");
1294 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001295#ifdef _STAT64_VER
1296 if (tcp->u_arg[0] == _STAT64_VER)
1297 printstat64 (tcp, tcp->u_arg[2]);
1298 else
1299#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001300 printstat(tcp, tcp->u_arg[2]);
1301 }
1302 return 0;
1303}
1304
1305int
1306sys_fxstat(tcp)
1307struct tcb *tcp;
1308{
1309 if (entering(tcp))
1310 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
1311 else {
John Hughes8fe2c982001-03-06 09:45:18 +00001312#ifdef _STAT64_VER
1313 if (tcp->u_arg[0] == _STAT64_VER)
1314 printstat64 (tcp, tcp->u_arg[2]);
1315 else
1316#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001317 printstat(tcp, tcp->u_arg[2]);
1318 }
1319 return 0;
1320}
1321
1322int
1323sys_lxstat(tcp)
1324struct tcb *tcp;
1325{
1326 if (entering(tcp)) {
1327 tprintf("%ld, ", tcp->u_arg[0]);
1328 printpath(tcp, tcp->u_arg[1]);
1329 tprintf(", ");
1330 } else {
John Hughes8fe2c982001-03-06 09:45:18 +00001331#ifdef _STAT64_VER
1332 if (tcp->u_arg[0] == _STAT64_VER)
1333 printstat64 (tcp, tcp->u_arg[2]);
1334 else
1335#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001336 printstat(tcp, tcp->u_arg[2]);
1337 }
1338 return 0;
1339}
1340
1341int
1342sys_xmknod(tcp)
1343struct tcb *tcp;
1344{
1345 int mode = tcp->u_arg[2];
1346
1347 if (entering(tcp)) {
1348 tprintf("%ld, ", tcp->u_arg[0]);
1349 printpath(tcp, tcp->u_arg[1]);
1350 tprintf(", %s", sprintmode(mode));
1351 switch (mode & S_IFMT) {
1352 case S_IFCHR: case S_IFBLK:
1353#ifdef LINUXSPARC
1354 tprintf(", makedev(%lu, %lu)",
1355 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
1356 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
Roland McGrath186c5ac2002-12-15 23:58:23 +00001357#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001358 tprintf(", makedev(%lu, %lu)",
1359 (unsigned long) major(tcp->u_arg[3]),
1360 (unsigned long) minor(tcp->u_arg[3]));
Roland McGrath186c5ac2002-12-15 23:58:23 +00001361#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001362 break;
1363 default:
1364 break;
1365 }
1366 }
1367 return 0;
1368}
1369
Wichert Akkerman8829a551999-06-11 13:18:40 +00001370#ifdef HAVE_SYS_ACL_H
1371
1372#include <sys/acl.h>
1373
Roland McGratha4d48532005-06-08 20:45:28 +00001374static const struct xlat aclcmds[] = {
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001375#ifdef SETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001376 { SETACL, "SETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001377#endif
1378#ifdef GETACL
Wichert Akkerman8829a551999-06-11 13:18:40 +00001379 { GETACL, "GETACL" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001380#endif
1381#ifdef GETACLCNT
Wichert Akkerman8829a551999-06-11 13:18:40 +00001382 { GETACLCNT, "GETACLCNT" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001383#endif
1384#ifdef ACL_GET
1385 { ACL_GET, "ACL_GET" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001386#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001387#ifdef ACL_SET
1388 { ACL_SET, "ACL_SET" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001389#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001390#ifdef ACL_CNT
1391 { ACL_CNT, "ACL_CNT" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001392#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +00001393 { 0, NULL },
1394};
1395
1396int
1397sys_acl(tcp)
1398struct tcb *tcp;
1399{
1400 if (entering(tcp)) {
1401 printpath(tcp, tcp->u_arg[0]);
1402 tprintf(", ");
1403 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1404 tprintf(", %ld", tcp->u_arg[2]);
1405 /*
1406 * FIXME - dump out the list of aclent_t's pointed to
1407 * by "tcp->u_arg[3]" if it's not NULL.
1408 */
1409 if (tcp->u_arg[3])
1410 tprintf(", %#lx", tcp->u_arg[3]);
1411 else
1412 tprintf(", NULL");
1413 }
1414 return 0;
1415}
1416
1417
1418int
1419sys_facl(tcp)
1420struct tcb *tcp;
1421{
1422 if (entering(tcp)) {
1423 tprintf("%ld, ", tcp->u_arg[0]);
1424 printxval(aclcmds, tcp->u_arg[1], "???ACL???");
1425 tprintf(", %ld", tcp->u_arg[2]);
1426 /*
1427 * FIXME - dump out the list of aclent_t's pointed to
1428 * by "tcp->u_arg[3]" if it's not NULL.
1429 */
1430 if (tcp->u_arg[3])
1431 tprintf(", %#lx", tcp->u_arg[3]);
1432 else
1433 tprintf(", NULL");
1434 }
1435 return 0;
1436}
1437
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001438
Roland McGratha4d48532005-06-08 20:45:28 +00001439static const struct xlat aclipc[] = {
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001440#ifdef IPC_SHM
1441 { IPC_SHM, "IPC_SHM" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001442#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001443#ifdef IPC_SEM
1444 { IPC_SEM, "IPC_SEM" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001445#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001446#ifdef IPC_MSG
1447 { IPC_MSG, "IPC_MSG" },
Roland McGrath186c5ac2002-12-15 23:58:23 +00001448#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +00001449 { 0, NULL },
1450};
1451
1452
1453int
1454sys_aclipc(tcp)
1455struct tcb *tcp;
1456{
1457 if (entering(tcp)) {
1458 printxval(aclipc, tcp->u_arg[0], "???IPC???");
1459 tprintf(", %#lx, ", tcp->u_arg[1]);
1460 printxval(aclcmds, tcp->u_arg[2], "???ACL???");
1461 tprintf(", %ld", tcp->u_arg[3]);
1462 /*
1463 * FIXME - dump out the list of aclent_t's pointed to
1464 * by "tcp->u_arg[4]" if it's not NULL.
1465 */
1466 if (tcp->u_arg[4])
1467 tprintf(", %#lx", tcp->u_arg[4]);
1468 else
1469 tprintf(", NULL");
1470 }
1471 return 0;
1472}
1473
1474
1475
Wichert Akkerman8829a551999-06-11 13:18:40 +00001476#endif /* HAVE_SYS_ACL_H */
1477
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001478#endif /* SVR4 || LINUXSPARC */
1479
Michal Ludvig53b320f2002-09-23 13:30:09 +00001480#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001481
Roland McGrathd9f816f2004-09-04 03:39:20 +00001482static const struct xlat fsmagic[] = {
Wichert Akkerman43a74822000-06-27 17:33:32 +00001483 { 0x73757245, "CODA_SUPER_MAGIC" },
1484 { 0x012ff7b7, "COH_SUPER_MAGIC" },
1485 { 0x1373, "DEVFS_SUPER_MAGIC" },
1486 { 0x1cd1, "DEVPTS_SUPER_MAGIC" },
1487 { 0x414A53, "EFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001488 { 0xef51, "EXT2_OLD_SUPER_MAGIC" },
1489 { 0xef53, "EXT2_SUPER_MAGIC" },
1490 { 0x137d, "EXT_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001491 { 0xf995e849, "HPFS_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001492 { 0x9660, "ISOFS_SUPER_MAGIC" },
1493 { 0x137f, "MINIX_SUPER_MAGIC" },
1494 { 0x138f, "MINIX_SUPER_MAGIC2" },
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001495 { 0x2468, "MINIX2_SUPER_MAGIC" },
1496 { 0x2478, "MINIX2_SUPER_MAGIC2" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001497 { 0x4d44, "MSDOS_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001498 { 0x564c, "NCP_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001499 { 0x6969, "NFS_SUPER_MAGIC" },
1500 { 0x9fa0, "PROC_SUPER_MAGIC" },
Wichert Akkerman43a74822000-06-27 17:33:32 +00001501 { 0x002f, "QNX4_SUPER_MAGIC" },
1502 { 0x52654973, "REISERFS_SUPER_MAGIC" },
1503 { 0x02011994, "SHMFS_SUPER_MAGIC" },
1504 { 0x517b, "SMB_SUPER_MAGIC" },
1505 { 0x012ff7b6, "SYSV2_SUPER_MAGIC" },
1506 { 0x012ff7b5, "SYSV4_SUPER_MAGIC" },
1507 { 0x00011954, "UFS_MAGIC" },
1508 { 0x54190100, "UFS_CIGAM" },
1509 { 0x012ff7b4, "XENIX_SUPER_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001510 { 0x012fd16d, "XIAFS_SUPER_MAGIC" },
Roland McGrathc767ad82004-01-13 10:13:45 +00001511 { 0x62656572, "SYSFS_MAGIC" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001512 { 0, NULL },
1513};
1514
Michal Ludvig53b320f2002-09-23 13:30:09 +00001515#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001516
1517#ifndef SVR4
1518
Roland McGrathf9c49b22004-10-06 22:11:54 +00001519static const char *
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001520sprintfstype(magic)
1521int magic;
1522{
1523 static char buf[32];
Michal Ludvig53b320f2002-09-23 13:30:09 +00001524#ifdef LINUX
Roland McGrathf9c49b22004-10-06 22:11:54 +00001525 const char *s;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001526
1527 s = xlookup(fsmagic, magic);
1528 if (s) {
1529 sprintf(buf, "\"%s\"", s);
1530 return buf;
1531 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00001532#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001533 sprintf(buf, "%#x", magic);
1534 return buf;
1535}
1536
1537static void
1538printstatfs(tcp, addr)
1539struct tcb *tcp;
1540long addr;
1541{
1542 struct statfs statbuf;
1543
1544 if (syserror(tcp) || !verbose(tcp)) {
1545 tprintf("%#lx", addr);
1546 return;
1547 }
1548 if (umove(tcp, addr, &statbuf) < 0) {
1549 tprintf("{...}");
1550 return;
1551 }
1552#ifdef ALPHA
1553
1554 tprintf("{f_type=%s, f_fbsize=%u, f_blocks=%u, f_bfree=%u, ",
1555 sprintfstype(statbuf.f_type),
1556 statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree);
Roland McGrathab147c52003-07-17 09:03:02 +00001557 tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d}, f_namelen=%u",
1558 statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
1559 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
1560 statbuf.f_namelen);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001561#else /* !ALPHA */
1562 tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ",
1563 sprintfstype(statbuf.f_type),
Nate Sammons5c74d201999-04-06 01:37:51 +00001564 (unsigned long)statbuf.f_bsize,
1565 (unsigned long)statbuf.f_blocks,
1566 (unsigned long)statbuf.f_bfree);
Roland McGrathab147c52003-07-17 09:03:02 +00001567 tprintf("f_bavail=%lu, f_files=%lu, f_ffree=%lu, f_fsid={%d, %d}",
1568 (unsigned long)statbuf.f_bavail,
Nate Sammons5c74d201999-04-06 01:37:51 +00001569 (unsigned long)statbuf.f_files,
Roland McGrathab147c52003-07-17 09:03:02 +00001570 (unsigned long)statbuf.f_ffree,
1571 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
Michal Ludvig53b320f2002-09-23 13:30:09 +00001572#ifdef LINUX
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001573 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Michal Ludvig53b320f2002-09-23 13:30:09 +00001574#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001575#endif /* !ALPHA */
Roland McGrathab147c52003-07-17 09:03:02 +00001576#ifdef _STATFS_F_FRSIZE
1577 tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
1578#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001579 tprintf("}");
1580}
1581
1582int
1583sys_statfs(tcp)
1584struct tcb *tcp;
1585{
1586 if (entering(tcp)) {
1587 printpath(tcp, tcp->u_arg[0]);
1588 tprintf(", ");
1589 } else {
1590 printstatfs(tcp, tcp->u_arg[1]);
1591 }
1592 return 0;
1593}
1594
1595int
1596sys_fstatfs(tcp)
1597struct tcb *tcp;
1598{
1599 if (entering(tcp)) {
1600 tprintf("%lu, ", tcp->u_arg[0]);
1601 } else {
1602 printstatfs(tcp, tcp->u_arg[1]);
1603 }
1604 return 0;
1605}
1606
Roland McGrathab147c52003-07-17 09:03:02 +00001607#ifdef LINUX
1608static void
1609printstatfs64(tcp, addr)
1610struct tcb *tcp;
1611long addr;
1612{
1613 struct statfs64 statbuf;
1614
1615 if (syserror(tcp) || !verbose(tcp)) {
1616 tprintf("%#lx", addr);
1617 return;
1618 }
1619 if (umove(tcp, addr, &statbuf) < 0) {
1620 tprintf("{...}");
1621 return;
1622 }
Roland McGrath08738432005-06-03 02:40:39 +00001623 tprintf("{f_type=%s, f_bsize=%llu, f_blocks=%llu, f_bfree=%llu, ",
Roland McGrathab147c52003-07-17 09:03:02 +00001624 sprintfstype(statbuf.f_type),
Roland McGrath08738432005-06-03 02:40:39 +00001625 (unsigned long long)statbuf.f_bsize,
1626 (unsigned long long)statbuf.f_blocks,
1627 (unsigned long long)statbuf.f_bfree);
1628 tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
1629 (unsigned long long)statbuf.f_bavail,
1630 (unsigned long long)statbuf.f_files,
1631 (unsigned long long)statbuf.f_ffree,
Roland McGrathab147c52003-07-17 09:03:02 +00001632 statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
1633 tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
Roland McGrathab147c52003-07-17 09:03:02 +00001634#ifdef _STATFS_F_FRSIZE
Roland McGrath08738432005-06-03 02:40:39 +00001635 tprintf(", f_frsize=%llu", (unsigned long long)statbuf.f_frsize);
Roland McGrathab147c52003-07-17 09:03:02 +00001636#endif
1637 tprintf("}");
1638}
1639
1640int
1641sys_statfs64(tcp)
1642struct tcb *tcp;
1643{
1644 if (entering(tcp)) {
1645 printpath(tcp, tcp->u_arg[0]);
1646 tprintf(", %lu, ", tcp->u_arg[1]);
1647 } else {
1648 if (tcp->u_arg[1] == sizeof (struct statfs64))
1649 printstatfs64(tcp, tcp->u_arg[2]);
1650 else
1651 tprintf("{???}");
1652 }
1653 return 0;
1654}
1655
1656int
1657sys_fstatfs64(tcp)
1658struct tcb *tcp;
1659{
1660 if (entering(tcp)) {
1661 tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
1662 } else {
1663 if (tcp->u_arg[1] == sizeof (struct statfs64))
1664 printstatfs64(tcp, tcp->u_arg[2]);
1665 else
1666 tprintf("{???}");
1667 }
1668 return 0;
1669}
1670#endif
1671
Michal Ludvig53b320f2002-09-23 13:30:09 +00001672#if defined(LINUX) && defined(__alpha)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001673
1674int
1675osf_statfs(tcp)
1676struct tcb *tcp;
1677{
1678 if (entering(tcp)) {
1679 printpath(tcp, tcp->u_arg[0]);
1680 tprintf(", ");
1681 } else {
1682 printstatfs(tcp, tcp->u_arg[1]);
1683 tprintf(", %lu", tcp->u_arg[2]);
1684 }
1685 return 0;
1686}
1687
1688int
1689osf_fstatfs(tcp)
1690struct tcb *tcp;
1691{
1692 if (entering(tcp)) {
1693 tprintf("%lu, ", tcp->u_arg[0]);
1694 } else {
1695 printstatfs(tcp, tcp->u_arg[1]);
1696 tprintf(", %lu", tcp->u_arg[2]);
1697 }
1698 return 0;
1699}
Michal Ludvig53b320f2002-09-23 13:30:09 +00001700#endif /* LINUX && __alpha */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001701
1702#endif /* !SVR4 */
1703
1704#ifdef SUNOS4
1705
1706int
1707sys_ustat(tcp)
1708struct tcb *tcp;
1709{
1710 struct ustat statbuf;
1711
1712 if (entering(tcp)) {
1713 tprintf("makedev(%lu, %lu), ",
1714 (long) major(tcp->u_arg[0]),
1715 (long) minor(tcp->u_arg[0]));
1716 }
1717 else {
1718 if (syserror(tcp) || !verbose(tcp))
1719 tprintf("%#lx", tcp->u_arg[1]);
1720 else if (umove(tcp, tcp->u_arg[1], &statbuf) < 0)
1721 tprintf("{...}");
1722 else {
1723 tprintf("{f_tfree=%lu, f_tinode=%lu, ",
1724 statbuf.f_tfree, statbuf.f_tinode);
1725 tprintf("f_fname=\"%.*s\", ",
1726 (int) sizeof(statbuf.f_fname),
1727 statbuf.f_fname);
1728 tprintf("f_fpack=\"%.*s\"}",
1729 (int) sizeof(statbuf.f_fpack),
1730 statbuf.f_fpack);
1731 }
1732 }
1733 return 0;
1734}
1735
1736#endif /* SUNOS4 */
1737
Wichert Akkermanc7926982000-04-10 22:22:31 +00001738int
1739sys_pivotroot(tcp)
1740struct tcb *tcp;
1741{
1742 if (entering(tcp)) {
1743 printpath(tcp, tcp->u_arg[0]);
1744 tprintf(", ");
1745 printpath(tcp, tcp->u_arg[1]);
1746 }
1747 return 0;
1748}
1749
1750
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001751/* directory */
1752int
1753sys_chdir(tcp)
1754struct tcb *tcp;
1755{
1756 if (entering(tcp)) {
1757 printpath(tcp, tcp->u_arg[0]);
1758 }
1759 return 0;
1760}
1761
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001762static int
1763decode_mkdir(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001764{
1765 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001766 printpath(tcp, tcp->u_arg[offset]);
1767 tprintf(", %#lo", tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001768 }
1769 return 0;
1770}
1771
1772int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001773sys_mkdir(struct tcb *tcp)
1774{
1775 return decode_mkdir(tcp, 0);
1776}
1777
1778#ifdef LINUX
1779int
1780sys_mkdirat(struct tcb *tcp)
1781{
1782 if (entering(tcp))
1783 print_dirfd(tcp->u_arg[0]);
1784 return decode_mkdir(tcp, 1);
1785}
1786#endif
1787
1788int
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001789sys_rmdir(tcp)
1790struct tcb *tcp;
1791{
1792 if (entering(tcp)) {
1793 printpath(tcp, tcp->u_arg[0]);
1794 }
1795 return 0;
1796}
1797
1798int
1799sys_fchdir(tcp)
1800struct tcb *tcp;
1801{
1802 if (entering(tcp)) {
1803 tprintf("%ld", tcp->u_arg[0]);
1804 }
1805 return 0;
1806}
1807
1808int
1809sys_chroot(tcp)
1810struct tcb *tcp;
1811{
1812 if (entering(tcp)) {
1813 printpath(tcp, tcp->u_arg[0]);
1814 }
1815 return 0;
1816}
1817
1818int
1819sys_fchroot(tcp)
1820struct tcb *tcp;
1821{
1822 if (entering(tcp)) {
1823 tprintf("%ld", tcp->u_arg[0]);
1824 }
1825 return 0;
1826}
1827
1828int
1829sys_link(tcp)
1830struct tcb *tcp;
1831{
1832 if (entering(tcp)) {
1833 printpath(tcp, tcp->u_arg[0]);
1834 tprintf(", ");
1835 printpath(tcp, tcp->u_arg[1]);
1836 }
1837 return 0;
1838}
1839
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001840#ifdef LINUX
1841int
1842sys_linkat(struct tcb *tcp)
1843{
1844 if (entering(tcp)) {
1845 print_dirfd(tcp->u_arg[0]);
1846 printpath(tcp, tcp->u_arg[1]);
1847 tprintf(", ");
1848 print_dirfd(tcp->u_arg[2]);
1849 printpath(tcp, tcp->u_arg[3]);
1850 tprintf(", %ld", tcp->u_arg[4]);
1851 }
1852 return 0;
1853}
1854#endif
1855
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001856int
1857sys_unlink(tcp)
1858struct tcb *tcp;
1859{
1860 if (entering(tcp)) {
1861 printpath(tcp, tcp->u_arg[0]);
1862 }
1863 return 0;
1864}
1865
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001866#ifdef LINUX
1867static const struct xlat unlinkatflags[] = {
1868#ifndef AT_REMOVEDIR
1869# define AT_REMOVEDIR 0x200
1870#endif
1871 { AT_REMOVEDIR, "AT_REMOVEDIR" },
1872 { 0, NULL },
1873};
1874
1875int
1876sys_unlinkat(struct tcb *tcp)
1877{
1878 if (entering(tcp)) {
1879 print_dirfd(tcp->u_arg[0]);
1880 printpath(tcp, tcp->u_arg[1]);
1881 tprintf(", ");
1882 printflags(unlinkatflags, tcp->u_arg[2], "AT_???");
1883 }
1884 return 0;
1885}
1886#endif
1887
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001888int
1889sys_symlink(tcp)
1890struct tcb *tcp;
1891{
1892 if (entering(tcp)) {
1893 printpath(tcp, tcp->u_arg[0]);
1894 tprintf(", ");
1895 printpath(tcp, tcp->u_arg[1]);
1896 }
1897 return 0;
1898}
1899
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001900#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001901int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001902sys_symlinkat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001903{
1904 if (entering(tcp)) {
1905 printpath(tcp, tcp->u_arg[0]);
1906 tprintf(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001907 print_dirfd(tcp->u_arg[1]);
1908 printpath(tcp, tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001909 }
1910 return 0;
1911}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001912#endif
1913
1914static int
1915decode_readlink(struct tcb *tcp, int offset)
1916{
1917 if (entering(tcp)) {
1918 printpath(tcp, tcp->u_arg[offset]);
1919 tprintf(", ");
1920 } else {
1921 if (syserror(tcp))
1922 tprintf("%#lx", tcp->u_arg[offset + 1]);
1923 else
1924 printpathn(tcp, tcp->u_arg[offset + 1], tcp->u_rval);
1925 tprintf(", %lu", tcp->u_arg[offset + 2]);
1926 }
1927 return 0;
1928}
1929
1930int
1931sys_readlink(struct tcb *tcp)
1932{
1933 return decode_readlink(tcp, 0);
1934}
1935
1936#ifdef LINUX
1937int
1938sys_readlinkat(struct tcb *tcp)
1939{
1940 if (entering(tcp))
1941 print_dirfd(tcp->u_arg[0]);
1942 return decode_readlink(tcp, 1);
1943}
1944#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001945
1946int
1947sys_rename(tcp)
1948struct tcb *tcp;
1949{
1950 if (entering(tcp)) {
1951 printpath(tcp, tcp->u_arg[0]);
1952 tprintf(", ");
1953 printpath(tcp, tcp->u_arg[1]);
1954 }
1955 return 0;
1956}
1957
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001958#ifdef LINUX
1959int
1960sys_renameat(struct tcb *tcp)
1961{
1962 if (entering(tcp)) {
1963 print_dirfd(tcp->u_arg[0]);
1964 printpath(tcp, tcp->u_arg[1]);
1965 tprintf(", ");
1966 print_dirfd(tcp->u_arg[2]);
1967 printpath(tcp, tcp->u_arg[3]);
1968 }
1969 return 0;
1970}
1971#endif
1972
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001973int
1974sys_chown(tcp)
1975struct tcb *tcp;
1976{
1977 if (entering(tcp)) {
1978 printpath(tcp, tcp->u_arg[0]);
Roland McGrath6bc12202003-11-13 22:32:27 +00001979 printuid(", ", tcp->u_arg[1]);
1980 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001981 }
1982 return 0;
1983}
1984
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00001985#ifdef LINUX
1986int
1987sys_fchownat(struct tcb *tcp)
1988{
1989 if (entering(tcp)) {
1990 print_dirfd(tcp->u_arg[0]);
1991 printpath(tcp, tcp->u_arg[1]);
1992 printuid(", ", tcp->u_arg[2]);
1993 printuid(", ", tcp->u_arg[3]);
1994 tprintf(", ");
1995 printflags(fstatatflags, tcp->u_arg[4], "AT_???");
1996 }
1997 return 0;
1998}
1999#endif
2000
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002001int
2002sys_fchown(tcp)
2003struct tcb *tcp;
2004{
2005 if (entering(tcp)) {
Roland McGrath6bc12202003-11-13 22:32:27 +00002006 tprintf("%ld", tcp->u_arg[0]);
2007 printuid(", ", tcp->u_arg[1]);
2008 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002009 }
2010 return 0;
2011}
2012
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002013static int
2014decode_chmod(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002015{
2016 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002017 printpath(tcp, tcp->u_arg[offset]);
2018 tprintf(", %#lo", tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002019 }
2020 return 0;
2021}
2022
2023int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002024sys_chmod(struct tcb *tcp)
2025{
2026 return decode_chmod(tcp, 0);
2027}
2028
2029#ifdef LINUX
2030int
2031sys_fchmodat(struct tcb *tcp)
2032{
2033 if (entering(tcp))
2034 print_dirfd(tcp->u_arg[0]);
2035 return decode_chmod(tcp, 1);
2036}
2037#endif
2038
2039int
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002040sys_fchmod(tcp)
2041struct tcb *tcp;
2042{
2043 if (entering(tcp)) {
2044 tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
2045 }
2046 return 0;
2047}
2048
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00002049#ifdef ALPHA
2050int
2051sys_osf_utimes(tcp)
2052struct tcb *tcp;
2053{
2054 if (entering(tcp)) {
2055 printpath(tcp, tcp->u_arg[0]);
2056 tprintf(", ");
2057 printtv32(tcp, tcp->u_arg[1]);
2058 }
2059 return 0;
2060}
2061#endif
2062
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002063static int
2064decode_utimes(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002065{
2066 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002067 printpath(tcp, tcp->u_arg[offset]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002068 tprintf(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002069 printtv(tcp, tcp->u_arg[offset + 1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002070 }
2071 return 0;
2072}
2073
2074int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002075sys_utimes(struct tcb *tcp)
2076{
2077 return decode_utimes(tcp, 0);
2078}
2079
2080#ifdef LINUX
2081int
2082sys_futimesat(struct tcb *tcp)
2083{
2084 if (entering(tcp))
2085 print_dirfd(tcp->u_arg[0]);
2086 return decode_utimes(tcp, 1);
2087}
2088#endif
2089
2090int
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002091sys_utime(tcp)
2092struct tcb *tcp;
2093{
2094 long ut[2];
2095
2096 if (entering(tcp)) {
2097 printpath(tcp, tcp->u_arg[0]);
2098 tprintf(", ");
2099 if (!tcp->u_arg[1])
2100 tprintf("NULL");
2101 else if (!verbose(tcp))
2102 tprintf("%#lx", tcp->u_arg[1]);
2103 else if (umoven(tcp, tcp->u_arg[1], sizeof ut,
2104 (char *) ut) < 0)
2105 tprintf("[?, ?]");
2106 else {
2107 tprintf("[%s,", sprinttime(ut[0]));
2108 tprintf(" %s]", sprinttime(ut[1]));
2109 }
2110 }
2111 return 0;
2112}
2113
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002114static int
2115decode_mknod(struct tcb *tcp, int offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002116{
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002117 int mode = tcp->u_arg[offset + 1];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002118
2119 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002120 printpath(tcp, tcp->u_arg[offset]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002121 tprintf(", %s", sprintmode(mode));
2122 switch (mode & S_IFMT) {
2123 case S_IFCHR: case S_IFBLK:
2124#ifdef LINUXSPARC
2125 if (current_personality == 1)
2126 tprintf(", makedev(%lu, %lu)",
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002127 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
2128 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002129 else
Roland McGrath186c5ac2002-12-15 23:58:23 +00002130#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002131 tprintf(", makedev(%lu, %lu)",
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002132 (unsigned long) major(tcp->u_arg[offset + 2]),
2133 (unsigned long) minor(tcp->u_arg[offset + 2]));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002134 break;
2135 default:
2136 break;
2137 }
2138 }
2139 return 0;
2140}
2141
2142int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002143sys_mknod(struct tcb *tcp)
2144{
2145 return decode_mknod(tcp, 0);
2146}
2147
2148#ifdef LINUX
2149int
2150sys_mknodat(struct tcb *tcp)
2151{
2152 if (entering(tcp))
2153 print_dirfd(tcp->u_arg[0]);
2154 return decode_mknod(tcp, 1);
2155}
2156#endif
2157
2158int
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002159sys_mkfifo(tcp)
2160struct tcb *tcp;
2161{
2162 if (entering(tcp)) {
2163 printpath(tcp, tcp->u_arg[0]);
2164 tprintf(", %#lo", tcp->u_arg[1]);
2165 }
2166 return 0;
2167}
2168
2169int
2170sys_fsync(tcp)
2171struct tcb *tcp;
2172{
2173 if (entering(tcp)) {
2174 tprintf("%ld", tcp->u_arg[0]);
2175 }
2176 return 0;
2177}
2178
Michal Ludvig53b320f2002-09-23 13:30:09 +00002179#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002180
2181static void
2182printdir(tcp, addr)
2183struct tcb *tcp;
2184long addr;
2185{
2186 struct dirent d;
2187
2188 if (!verbose(tcp)) {
2189 tprintf("%#lx", addr);
2190 return;
2191 }
2192 if (umove(tcp, addr, &d) < 0) {
2193 tprintf("{...}");
2194 return;
2195 }
2196 tprintf("{d_ino=%ld, ", (unsigned long) d.d_ino);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002197 tprintf("d_name=");
2198 printpathn(tcp, (long) ((struct dirent *) addr)->d_name, d.d_reclen);
2199 tprintf("}");
2200}
2201
2202int
2203sys_readdir(tcp)
2204struct tcb *tcp;
2205{
2206 if (entering(tcp)) {
2207 tprintf("%lu, ", tcp->u_arg[0]);
2208 } else {
2209 if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
2210 tprintf("%#lx", tcp->u_arg[1]);
2211 else
2212 printdir(tcp, tcp->u_arg[1]);
2213 /* Not much point in printing this out, it is always 1. */
2214 if (tcp->u_arg[2] != 1)
2215 tprintf(", %lu", tcp->u_arg[2]);
2216 }
2217 return 0;
2218}
2219
Michal Ludvig53b320f2002-09-23 13:30:09 +00002220#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002221
Roland McGrath40542842004-01-13 09:47:49 +00002222#if defined FREEBSD || defined LINUX
Roland McGratha4d48532005-06-08 20:45:28 +00002223static const struct xlat direnttypes[] = {
Roland McGrath40542842004-01-13 09:47:49 +00002224 { DT_UNKNOWN, "DT_UNKNOWN" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002225 { DT_FIFO, "DT_FIFO" },
2226 { DT_CHR, "DT_CHR" },
2227 { DT_DIR, "DT_DIR" },
2228 { DT_BLK, "DT_BLK" },
2229 { DT_REG, "DT_REG" },
2230 { DT_LNK, "DT_LNK" },
2231 { DT_SOCK, "DT_SOCK" },
2232 { DT_WHT, "DT_WHT" },
2233 { 0, NULL },
2234};
2235
2236#endif
2237
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002238int
2239sys_getdents(tcp)
2240struct tcb *tcp;
2241{
2242 int i, len, dents = 0;
2243 char *buf;
2244
2245 if (entering(tcp)) {
2246 tprintf("%lu, ", tcp->u_arg[0]);
2247 return 0;
2248 }
2249 if (syserror(tcp) || !verbose(tcp)) {
2250 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2251 return 0;
2252 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002253 len = tcp->u_rval;
2254 if ((buf = malloc(len)) == NULL) {
Roland McGrath46100d02005-06-01 18:55:42 +00002255 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2256 fprintf(stderr, "out of memory\n");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002257 return 0;
2258 }
2259 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002260 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002261 free(buf);
2262 return 0;
2263 }
2264 if (!abbrev(tcp))
2265 tprintf("{");
2266 for (i = 0; i < len;) {
Wichert Akkerman9524bb91999-05-25 23:11:18 +00002267 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
Michal Ludvig53b320f2002-09-23 13:30:09 +00002268#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002269 if (!abbrev(tcp)) {
2270 tprintf("%s{d_ino=%lu, d_off=%lu, ",
2271 i ? " " : "", d->d_ino, d->d_off);
2272 tprintf("d_reclen=%u, d_name=\"%s\"}",
2273 d->d_reclen, d->d_name);
2274 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00002275#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002276#ifdef SVR4
2277 if (!abbrev(tcp)) {
2278 tprintf("%s{d_ino=%lu, d_off=%lu, ",
Roland McGrath186c5ac2002-12-15 23:58:23 +00002279 i ? " " : "",
2280 (unsigned long) d->d_ino,
2281 (unsigned long) d->d_off);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002282 tprintf("d_reclen=%u, d_name=\"%s\"}",
2283 d->d_reclen, d->d_name);
2284 }
2285#endif /* SVR4 */
2286#ifdef SUNOS4
2287 if (!abbrev(tcp)) {
2288 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2289 i ? " " : "", d->d_off, d->d_fileno,
2290 d->d_reclen);
2291 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2292 d->d_namlen, d->d_namlen, d->d_name);
2293 }
2294#endif /* SUNOS4 */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002295#ifdef FREEBSD
2296 if (!abbrev(tcp)) {
2297 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2298 i ? " " : "", d->d_fileno, d->d_reclen);
2299 printxval(direnttypes, d->d_type, "DT_???");
2300 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2301 d->d_namlen, d->d_namlen, d->d_name);
2302 }
Roland McGrath186c5ac2002-12-15 23:58:23 +00002303#endif /* FREEBSD */
Pavel Machek9a9f10b2000-02-01 16:22:52 +00002304 if (!d->d_reclen) {
2305 tprintf("/* d_reclen == 0, problem here */");
2306 break;
2307 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002308 i += d->d_reclen;
2309 dents++;
2310 }
2311 if (!abbrev(tcp))
2312 tprintf("}");
2313 else
2314 tprintf("/* %u entries */", dents);
2315 tprintf(", %lu", tcp->u_arg[2]);
2316 free(buf);
2317 return 0;
2318}
2319
John Hughesbdf48f52001-03-06 15:08:09 +00002320
2321#if _LFS64_LARGEFILE
2322int
2323sys_getdents64(tcp)
2324struct tcb *tcp;
2325{
2326 int i, len, dents = 0;
2327 char *buf;
2328
2329 if (entering(tcp)) {
2330 tprintf("%lu, ", tcp->u_arg[0]);
2331 return 0;
2332 }
2333 if (syserror(tcp) || !verbose(tcp)) {
2334 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2335 return 0;
2336 }
2337 len = tcp->u_rval;
2338 if ((buf = malloc(len)) == NULL) {
Roland McGrath46100d02005-06-01 18:55:42 +00002339 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
2340 fprintf(stderr, "out of memory\n");
John Hughesbdf48f52001-03-06 15:08:09 +00002341 return 0;
2342 }
2343 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002344 tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]);
John Hughesbdf48f52001-03-06 15:08:09 +00002345 free(buf);
2346 return 0;
2347 }
2348 if (!abbrev(tcp))
2349 tprintf("{");
2350 for (i = 0; i < len;) {
2351 struct dirent64 *d = (struct dirent64 *) &buf[i];
Michal Ludvig53b320f2002-09-23 13:30:09 +00002352#if defined(LINUX) || defined(SVR4)
John Hughesbdf48f52001-03-06 15:08:09 +00002353 if (!abbrev(tcp)) {
Roland McGrath92053242004-01-13 10:16:47 +00002354 tprintf("%s{d_ino=%llu, d_off=%llu, ",
Roland McGrath186c5ac2002-12-15 23:58:23 +00002355 i ? " " : "",
Roland McGrath92053242004-01-13 10:16:47 +00002356 d->d_ino,
2357 d->d_off);
Roland McGrath40542842004-01-13 09:47:49 +00002358#ifdef LINUX
2359 tprintf("d_type=");
2360 printxval(direnttypes, d->d_type, "DT_???");
2361 tprintf(", ");
2362#endif
John Hughesbdf48f52001-03-06 15:08:09 +00002363 tprintf("d_reclen=%u, d_name=\"%s\"}",
2364 d->d_reclen, d->d_name);
2365 }
Michal Ludvig53b320f2002-09-23 13:30:09 +00002366#endif /* LINUX || SVR4 */
John Hughesbdf48f52001-03-06 15:08:09 +00002367#ifdef SUNOS4
2368 if (!abbrev(tcp)) {
2369 tprintf("%s{d_off=%lu, d_fileno=%lu, d_reclen=%u, ",
2370 i ? " " : "", d->d_off, d->d_fileno,
2371 d->d_reclen);
2372 tprintf("d_namlen=%u, d_name=\"%.*s\"}",
2373 d->d_namlen, d->d_namlen, d->d_name);
2374 }
2375#endif /* SUNOS4 */
2376 i += d->d_reclen;
2377 dents++;
2378 }
2379 if (!abbrev(tcp))
2380 tprintf("}");
2381 else
2382 tprintf("/* %u entries */", dents);
2383 tprintf(", %lu", tcp->u_arg[2]);
2384 free(buf);
2385 return 0;
2386}
2387#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +00002388
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002389#ifdef FREEBSD
2390int
2391sys_getdirentries(tcp)
2392struct tcb * tcp;
2393{
2394 int i, len, dents = 0;
2395 long basep;
2396 char *buf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002397
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002398 if (entering(tcp)) {
2399 tprintf("%lu, ", tcp->u_arg[0]);
2400 return 0;
2401 }
2402 if (syserror(tcp) || !verbose(tcp)) {
2403 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2404 return 0;
2405 }
2406 len = tcp->u_rval;
2407 if ((buf = malloc(len)) == NULL) {
Roland McGrath46100d02005-06-01 18:55:42 +00002408 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
2409 fprintf(stderr, "out of memory\n");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002410 return 0;
2411 }
2412 if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
Roland McGrath46100d02005-06-01 18:55:42 +00002413 tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002414 free(buf);
2415 return 0;
2416 }
2417 if (!abbrev(tcp))
2418 tprintf("{");
2419 for (i = 0; i < len;) {
2420 struct kernel_dirent *d = (struct kernel_dirent *) &buf[i];
2421 if (!abbrev(tcp)) {
2422 tprintf("%s{d_fileno=%u, d_reclen=%u, d_type=",
2423 i ? " " : "", d->d_fileno, d->d_reclen);
2424 printxval(direnttypes, d->d_type, "DT_???");
2425 tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
2426 d->d_namlen, d->d_namlen, d->d_name);
2427 }
2428 i += d->d_reclen;
2429 dents++;
2430 }
2431 if (!abbrev(tcp))
2432 tprintf("}");
2433 else
2434 tprintf("/* %u entries */", dents);
2435 free(buf);
2436 tprintf(", %lu", tcp->u_arg[2]);
2437 if (umove(tcp, tcp->u_arg[3], &basep) < 0)
2438 tprintf(", %#lx", tcp->u_arg[3]);
2439 else
2440 tprintf(", [%lu]", basep);
2441 return 0;
2442}
2443#endif
2444
Michal Ludvig53b320f2002-09-23 13:30:09 +00002445#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002446int
2447sys_getcwd(tcp)
2448struct tcb *tcp;
2449{
2450 if (exiting(tcp)) {
2451 if (syserror(tcp))
2452 tprintf("%#lx", tcp->u_arg[0]);
2453 else
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00002454 printpathn(tcp, tcp->u_arg[0], tcp->u_rval - 1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002455 tprintf(", %lu", tcp->u_arg[1]);
2456 }
2457 return 0;
2458}
Michal Ludvig53b320f2002-09-23 13:30:09 +00002459#endif /* LINUX */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002460
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002461#ifdef FREEBSD
2462int
2463sys___getcwd(tcp)
2464struct tcb *tcp;
2465{
2466 if (exiting(tcp)) {
2467 if (syserror(tcp))
2468 tprintf("%#lx", tcp->u_arg[0]);
2469 else
2470 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
2471 tprintf(", %lu", tcp->u_arg[1]);
2472 }
2473 return 0;
2474}
2475#endif
2476
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002477#ifdef HAVE_SYS_ASYNCH_H
2478
2479int
2480sys_aioread(tcp)
2481struct tcb *tcp;
2482{
2483 struct aio_result_t res;
2484
2485 if (entering(tcp)) {
2486 tprintf("%lu, ", tcp->u_arg[0]);
2487 } else {
2488 if (syserror(tcp))
2489 tprintf("%#lx", tcp->u_arg[1]);
2490 else
2491 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2492 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2493 printxval(whence, tcp->u_arg[4], "L_???");
2494 if (syserror(tcp) || tcp->u_arg[5] == 0
2495 || umove(tcp, tcp->u_arg[5], &res) < 0)
2496 tprintf(", %#lx", tcp->u_arg[5]);
2497 else
2498 tprintf(", {aio_return %d aio_errno %d}",
2499 res.aio_return, res.aio_errno);
2500 }
2501 return 0;
2502}
2503
2504int
2505sys_aiowrite(tcp)
2506struct tcb *tcp;
2507{
2508 struct aio_result_t res;
2509
2510 if (entering(tcp)) {
2511 tprintf("%lu, ", tcp->u_arg[0]);
2512 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
2513 tprintf(", %lu, %lu, ", tcp->u_arg[2], tcp->u_arg[3]);
2514 printxval(whence, tcp->u_arg[4], "L_???");
2515 }
2516 else {
2517 if (tcp->u_arg[5] == 0)
2518 tprintf(", NULL");
2519 else if (syserror(tcp)
2520 || umove(tcp, tcp->u_arg[5], &res) < 0)
2521 tprintf(", %#lx", tcp->u_arg[5]);
2522 else
2523 tprintf(", {aio_return %d aio_errno %d}",
2524 res.aio_return, res.aio_errno);
2525 }
2526 return 0;
2527}
2528
2529int
2530sys_aiowait(tcp)
2531struct tcb *tcp;
2532{
2533 if (entering(tcp))
2534 printtv(tcp, tcp->u_arg[0]);
2535 return 0;
2536}
2537
2538int
2539sys_aiocancel(tcp)
2540struct tcb *tcp;
2541{
2542 struct aio_result_t res;
2543
2544 if (exiting(tcp)) {
2545 if (tcp->u_arg[0] == 0)
2546 tprintf("NULL");
2547 else if (syserror(tcp)
2548 || umove(tcp, tcp->u_arg[0], &res) < 0)
2549 tprintf("%#lx", tcp->u_arg[0]);
2550 else
2551 tprintf("{aio_return %d aio_errno %d}",
2552 res.aio_return, res.aio_errno);
2553 }
2554 return 0;
2555}
2556
2557#endif /* HAVE_SYS_ASYNCH_H */
Roland McGrath186c5ac2002-12-15 23:58:23 +00002558
Roland McGratha4d48532005-06-08 20:45:28 +00002559static const struct xlat xattrflags[] = {
Roland McGrath561c7992003-04-02 01:10:44 +00002560#ifdef XATTR_CREATE
Roland McGrath186c5ac2002-12-15 23:58:23 +00002561 { XATTR_CREATE, "XATTR_CREATE" },
2562 { XATTR_REPLACE, "XATTR_REPLACE" },
Roland McGrath561c7992003-04-02 01:10:44 +00002563#endif
Roland McGrath186c5ac2002-12-15 23:58:23 +00002564 { 0, NULL }
2565};
2566
Roland McGrath3292e222004-08-31 06:30:48 +00002567static void
2568print_xattr_val(tcp, failed, arg, insize, size)
2569struct tcb *tcp;
2570int failed;
2571unsigned long arg;
Roland McGrathaa524c82005-06-01 19:22:06 +00002572unsigned long insize, size;
Roland McGrath3292e222004-08-31 06:30:48 +00002573{
Roland McGrath883567c2005-02-02 03:38:32 +00002574 if (!failed) {
Roland McGrathaa524c82005-06-01 19:22:06 +00002575 unsigned long capacity = 4 * size + 1;
2576 unsigned char *buf = (capacity < size) ? NULL : malloc(capacity);
Roland McGrath883567c2005-02-02 03:38:32 +00002577 if (buf == NULL || /* probably a bogus size argument */
Roland McGrathf7746422005-03-01 23:02:32 +00002578 umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) {
Roland McGrath883567c2005-02-02 03:38:32 +00002579 failed = 1;
2580 }
2581 else {
2582 unsigned char *out = buf;
2583 unsigned char *in = &buf[3 * size];
2584 size_t i;
2585 for (i = 0; i < size; ++i)
2586 if (isprint(in[i]))
2587 *out++ = in[i];
2588 else {
Roland McGrath3292e222004-08-31 06:30:48 +00002589#define tohex(n) "0123456789abcdef"[n]
Roland McGrath883567c2005-02-02 03:38:32 +00002590 *out++ = '\\';
2591 *out++ = 'x';
2592 *out++ = tohex(in[i] / 16);
2593 *out++ = tohex(in[i] % 16);
2594 }
2595 /* Don't print terminating NUL if there is one. */
Dmitry V. Levin504eb0b2006-10-11 22:58:31 +00002596 if (i > 0 && in[i - 1] == '\0')
Roland McGrath883567c2005-02-02 03:38:32 +00002597 out -= 4;
2598 *out = '\0';
2599 tprintf(", \"%s\", %ld", buf, insize);
2600 }
2601 free(buf);
2602 }
2603 if (failed)
2604 tprintf(", 0x%lx, %ld", arg, insize);
Roland McGrath3292e222004-08-31 06:30:48 +00002605}
2606
Roland McGrath186c5ac2002-12-15 23:58:23 +00002607int
2608sys_setxattr(tcp)
2609struct tcb *tcp;
2610{
2611 if (entering(tcp)) {
2612 printpath(tcp, tcp->u_arg[0]);
2613 tprintf(", ");
2614 printstr(tcp, tcp->u_arg[1], -1);
Roland McGrath3292e222004-08-31 06:30:48 +00002615 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2616 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00002617 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
Roland McGrath186c5ac2002-12-15 23:58:23 +00002618 }
2619 return 0;
2620}
2621
2622int
2623sys_fsetxattr(tcp)
2624struct tcb *tcp;
2625{
2626 if (entering(tcp)) {
2627 tprintf("%ld, ", tcp->u_arg[0]);
2628 printstr(tcp, tcp->u_arg[1], -1);
Roland McGrath3292e222004-08-31 06:30:48 +00002629 print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
2630 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00002631 printflags(xattrflags, tcp->u_arg[4], "XATTR_???");
Roland McGrath186c5ac2002-12-15 23:58:23 +00002632 }
2633 return 0;
2634}
2635
2636int
2637sys_getxattr(tcp)
2638struct tcb *tcp;
2639{
2640 if (entering(tcp)) {
2641 printpath(tcp, tcp->u_arg[0]);
2642 tprintf(", ");
2643 printstr(tcp, tcp->u_arg[1], -1);
2644 } else {
Roland McGrath3292e222004-08-31 06:30:48 +00002645 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2646 tcp->u_rval);
Roland McGrath186c5ac2002-12-15 23:58:23 +00002647 }
2648 return 0;
2649}
2650
2651int
2652sys_fgetxattr(tcp)
2653struct tcb *tcp;
2654{
2655 if (entering(tcp)) {
2656 tprintf("%ld, ", tcp->u_arg[0]);
2657 printstr(tcp, tcp->u_arg[1], -1);
2658 } else {
Roland McGrath3292e222004-08-31 06:30:48 +00002659 print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
2660 tcp->u_rval);
Roland McGrath186c5ac2002-12-15 23:58:23 +00002661 }
2662 return 0;
2663}
2664
2665int
2666sys_listxattr(tcp)
2667struct tcb *tcp;
2668{
2669 if (entering(tcp)) {
2670 printpath(tcp, tcp->u_arg[0]);
2671 } else {
2672 /* XXX Print value in format */
2673 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2674 }
2675 return 0;
2676}
2677
2678int
2679sys_flistxattr(tcp)
2680struct tcb *tcp;
2681{
2682 if (entering(tcp)) {
2683 tprintf("%ld", tcp->u_arg[0]);
2684 } else {
2685 /* XXX Print value in format */
2686 tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
2687 }
2688 return 0;
2689}
2690
2691int
2692sys_removexattr(tcp)
2693struct tcb *tcp;
2694{
2695 if (entering(tcp)) {
2696 printpath(tcp, tcp->u_arg[0]);
2697 tprintf(", ");
2698 printstr(tcp, tcp->u_arg[1], -1);
2699 }
2700 return 0;
2701}
2702
2703int
2704sys_fremovexattr(tcp)
2705struct tcb *tcp;
2706{
2707 if (entering(tcp)) {
2708 tprintf("%ld, ", tcp->u_arg[0]);
2709 printstr(tcp, tcp->u_arg[1], -1);
2710 }
2711 return 0;
2712}
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002713
2714
2715static const struct xlat advise[] = {
2716 { POSIX_FADV_NORMAL, "POSIX_FADV_NORMAL" },
2717 { POSIX_FADV_RANDOM, "POSIX_FADV_RANDOM" },
2718 { POSIX_FADV_SEQUENTIAL, "POSIX_FADV_SEQUENTIAL" },
2719 { POSIX_FADV_WILLNEED, "POSIX_FADV_WILLNEED" },
2720 { POSIX_FADV_DONTNEED, "POSIX_FADV_DONTNEED" },
2721 { POSIX_FADV_NOREUSE, "POSIX_FADV_NOREUSE" },
2722 { 0, NULL }
2723};
2724
2725
Roland McGrathe27ed342004-10-20 02:24:19 +00002726#ifdef LINUX
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002727int
2728sys_fadvise64(tcp)
2729struct tcb *tcp;
2730{
2731 if (entering(tcp)) {
2732 tprintf("%ld, %lld, %ld, ",
2733 tcp->u_arg[0],
2734# if defined IA64 || defined X86_64 || defined ALPHA
2735 (long long int) tcp->u_arg[1], tcp->u_arg[2]);
2736 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2737#else
Roland McGrath2fe2a3e2004-10-07 19:09:16 +00002738 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]), tcp->u_arg[3]);
2739 printxval(advise, tcp->u_arg[4], "POSIX_FADV_???");
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002740#endif
2741 }
2742 return 0;
2743}
2744#endif
2745
2746
2747int
2748sys_fadvise64_64(tcp)
2749struct tcb *tcp;
2750{
2751 if (entering(tcp)) {
2752 tprintf("%ld, %lld, %lld, ",
2753 tcp->u_arg[0],
2754# if defined IA64 || defined X86_64 || defined ALPHA
2755 (long long int) tcp->u_arg[1], (long long int) tcp->u_arg[2]);
2756 printxval(advise, tcp->u_arg[3], "POSIX_FADV_???");
2757#else
Roland McGrath2fe2a3e2004-10-07 19:09:16 +00002758 LONG_LONG(tcp->u_arg[1], tcp->u_arg[2]),
2759 LONG_LONG(tcp->u_arg[3], tcp->u_arg[4]));
Roland McGrathdf13e8f2004-10-07 18:51:19 +00002760 printxval(advise, tcp->u_arg[5], "POSIX_FADV_???");
2761#endif
2762 }
2763 return 0;
2764}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +00002765
2766#ifdef LINUX
2767static const struct xlat inotify_modes[] = {
2768 { 0x00000001, "IN_ACCESS" },
2769 { 0x00000002, "IN_MODIFY" },
2770 { 0x00000004, "IN_ATTRIB" },
2771 { 0x00000008, "IN_CLOSE_WRITE" },
2772 { 0x00000010, "IN_CLOSE_NOWRITE" },
2773 { 0x00000020, "IN_OPEN" },
2774 { 0x00000040, "IN_MOVED_FROM" },
2775 { 0x00000080, "IN_MOVED_TO" },
2776 { 0x00000100, "IN_CREATE" },
2777 { 0x00000200, "IN_DELETE" },
2778 { 0x00000400, "IN_DELETE_SELF" },
2779 { 0x00000800, "IN_MOVE_SELF" },
2780 { 0x00002000, "IN_UNMOUNT" },
2781 { 0x00004000, "IN_Q_OVERFLOW" },
2782 { 0x00008000, "IN_IGNORED" },
2783 { 0x01000000, "IN_ONLYDIR" },
2784 { 0x02000000, "IN_DONT_FOLLOW" },
2785 { 0x20000000, "IN_MASK_ADD" },
2786 { 0x40000000, "IN_ISDIR" },
2787 { 0x80000000, "IN_ONESHOT" }
2788};
2789
2790int
2791sys_inotify_add_watch(struct tcb *tcp)
2792{
2793 if (entering(tcp)) {
2794 tprintf("%ld, ", tcp->u_arg[0]);
2795 printpath(tcp, tcp->u_arg[1]);
2796 tprintf(", ");
2797 printflags(inotify_modes, tcp->u_arg[2], "IN_???");
2798 }
2799 return 0;
2800}
2801
2802int
2803sys_inotify_rm_watch(struct tcb *tcp)
2804{
2805 if (entering(tcp)) {
2806 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
2807 }
2808 return 0;
2809}
2810#endif