blob: 8dd0231639cef03cd39ab8cd46ef5cd1fb22174e [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00006 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000029 */
30
31#include "defs.h"
Roland McGrathc531e572008-08-01 01:13:10 +000032
Denys Vlasenko9472a272013-02-12 11:43:46 +010033#if defined(SPARC) || defined(SPARC64)
Wichert Akkermandacfb6e1999-06-03 14:21:07 +000034struct stat {
35 unsigned short st_dev;
36 unsigned int st_ino;
37 unsigned short st_mode;
38 short st_nlink;
39 unsigned short st_uid;
40 unsigned short st_gid;
41 unsigned short st_rdev;
42 unsigned int st_size;
43 int st_atime;
44 unsigned int __unused1;
45 int st_mtime;
46 unsigned int __unused2;
47 int st_ctime;
48 unsigned int __unused3;
49 int st_blksize;
50 int st_blocks;
51 unsigned int __unused4[2];
52};
Denys Vlasenko84703742012-02-25 02:38:52 +010053# if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +000054struct stat_sparc64 {
55 unsigned int st_dev;
56 unsigned long st_ino;
57 unsigned int st_mode;
58 unsigned int st_nlink;
59 unsigned int st_uid;
60 unsigned int st_gid;
61 unsigned int st_rdev;
62 long st_size;
63 long st_atime;
64 long st_mtime;
65 long st_ctime;
66 long st_blksize;
67 long st_blocks;
68 unsigned long __unused4[2];
69};
Denys Vlasenko84703742012-02-25 02:38:52 +010070# endif /* SPARC64 */
71# define stat kernel_stat
72# include <asm/stat.h>
73# undef stat
H.J. Lu35be5812012-04-16 13:00:01 +020074#elif defined(X32)
75struct stat {
76 unsigned long long st_dev;
77 unsigned long long st_ino;
78 unsigned long long st_nlink;
79
80 unsigned int st_mode;
81 unsigned int st_uid;
82 unsigned int st_gid;
83 unsigned int __pad0;
84 unsigned long long st_rdev;
85 long long st_size;
86 long long st_blksize;
87 long long st_blocks;
88
89 unsigned long long st_atime;
90 unsigned long long st_atime_nsec;
91 unsigned long long st_mtime;
92 unsigned long long st_mtime_nsec;
93 unsigned long long st_ctime;
94 unsigned long long st_ctime_nsec;
95 long long __unused[3];
96};
H.J. Lu085e4282012-04-17 11:05:04 -070097
98struct stat64 {
99 unsigned long long st_dev;
100 unsigned char __pad0[4];
101 unsigned long __st_ino;
102 unsigned int st_mode;
103 unsigned int st_nlink;
104 unsigned long st_uid;
105 unsigned long st_gid;
106 unsigned long long st_rdev;
107 unsigned char __pad3[4];
108 long long st_size;
109 unsigned long st_blksize;
110 unsigned long long st_blocks;
111 unsigned long st_atime;
112 unsigned long st_atime_nsec;
113 unsigned long st_mtime;
114 unsigned int st_mtime_nsec;
115 unsigned long st_ctime;
116 unsigned long st_ctime_nsec;
117 unsigned long long st_ino;
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000118} __attribute__((packed));
119# define HAVE_STAT64 1
Dmitry V. Levinbd2e28a2013-05-01 15:14:25 +0000120
121struct __old_kernel_stat {
122 unsigned short st_dev;
123 unsigned short st_ino;
124 unsigned short st_mode;
125 unsigned short st_nlink;
126 unsigned short st_uid;
127 unsigned short st_gid;
128 unsigned short st_rdev;
129 unsigned int st_size;
130 unsigned int st_atime;
131 unsigned int st_mtime;
132 unsigned int st_ctime;
133};
Denys Vlasenko84703742012-02-25 02:38:52 +0100134#else
135# undef dev_t
136# undef ino_t
137# undef mode_t
138# undef nlink_t
139# undef uid_t
140# undef gid_t
141# undef off_t
142# undef loff_t
Denys Vlasenko84703742012-02-25 02:38:52 +0100143# define dev_t __kernel_dev_t
144# define ino_t __kernel_ino_t
145# define mode_t __kernel_mode_t
146# define nlink_t __kernel_nlink_t
147# define uid_t __kernel_uid_t
148# define gid_t __kernel_gid_t
149# define off_t __kernel_off_t
150# define loff_t __kernel_loff_t
Wichert Akkermana6013701999-07-08 14:00:58 +0000151
Denys Vlasenko84703742012-02-25 02:38:52 +0100152# include <asm/stat.h>
Wichert Akkermana6013701999-07-08 14:00:58 +0000153
Denys Vlasenko84703742012-02-25 02:38:52 +0100154# undef dev_t
155# undef ino_t
156# undef mode_t
157# undef nlink_t
158# undef uid_t
159# undef gid_t
160# undef off_t
161# undef loff_t
Denys Vlasenko84703742012-02-25 02:38:52 +0100162# define dev_t dev_t
163# define ino_t ino_t
164# define mode_t mode_t
165# define nlink_t nlink_t
166# define uid_t uid_t
167# define gid_t gid_t
168# define off_t off_t
169# define loff_t loff_t
170#endif
171
Denys Vlasenko84703742012-02-25 02:38:52 +0100172#define stat libc_stat
173#define stat64 libc_stat64
174#include <sys/stat.h>
175#undef stat
176#undef stat64
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100177/* These might be macros. */
Denys Vlasenko84703742012-02-25 02:38:52 +0100178#undef st_atime
179#undef st_mtime
180#undef st_ctime
Wichert Akkermand4d8e921999-04-18 23:30:29 +0000181
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000182#include <fcntl.h>
Roland McGrath186c5ac2002-12-15 23:58:23 +0000183
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000184#ifdef MAJOR_IN_SYSMACROS
Denys Vlasenko84703742012-02-25 02:38:52 +0100185# include <sys/sysmacros.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000186#endif
187
188#ifdef MAJOR_IN_MKDEV
Denys Vlasenko84703742012-02-25 02:38:52 +0100189# include <sys/mkdev.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000190#endif
191
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000192/* several stats */
193
Denys Vlasenko9472a272013-02-12 11:43:46 +0100194#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000195typedef struct {
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000196 int tv_sec;
197 int tv_nsec;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000198} timestruct_t;
199
200struct solstat {
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000201 unsigned st_dev;
202 int st_pad1[3]; /* network id */
203 unsigned st_ino;
204 unsigned st_mode;
205 unsigned st_nlink;
206 unsigned st_uid;
207 unsigned st_gid;
208 unsigned st_rdev;
209 int st_pad2[2];
210 int st_size;
211 int st_pad3; /* st_size, off_t expansion */
212 timestruct_t st_atime;
213 timestruct_t st_mtime;
214 timestruct_t st_ctime;
215 int st_blksize;
216 int st_blocks;
217 char st_fstype[16];
218 int st_pad4[8]; /* expansion area */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000219};
220
221static void
Dmitry V. Levinb838b1e2008-04-19 23:47:47 +0000222printstatsol(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000223{
224 struct solstat statbuf;
225
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000226 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200227 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000228 return;
229 }
230 if (!abbrev(tcp)) {
231 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
232 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
233 (unsigned long) (statbuf.st_dev & 0x3ffff),
234 (unsigned long) statbuf.st_ino,
235 sprintmode(statbuf.st_mode));
236 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
237 (unsigned long) statbuf.st_nlink,
238 (unsigned long) statbuf.st_uid,
239 (unsigned long) statbuf.st_gid);
240 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
241 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
242 }
243 else
244 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
245 switch (statbuf.st_mode & S_IFMT) {
246 case S_IFCHR: case S_IFBLK:
247 tprintf("st_rdev=makedev(%lu, %lu), ",
248 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
249 (unsigned long) (statbuf.st_rdev & 0x3ffff));
250 break;
251 default:
252 tprintf("st_size=%u, ", statbuf.st_size);
253 break;
254 }
255 if (!abbrev(tcp)) {
Dmitry V. Levinb838b1e2008-04-19 23:47:47 +0000256 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
257 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
258 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000259 }
260 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200261 tprints("...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000262}
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000263
Denys Vlasenko9472a272013-02-12 11:43:46 +0100264# if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000265static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000266printstat_sparc64(struct tcb *tcp, long addr)
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000267{
268 struct stat_sparc64 statbuf;
269
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000270 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200271 tprints("{...}");
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000272 return;
273 }
274
275 if (!abbrev(tcp)) {
276 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
277 (unsigned long) major(statbuf.st_dev),
278 (unsigned long) minor(statbuf.st_dev),
279 (unsigned long) statbuf.st_ino,
280 sprintmode(statbuf.st_mode));
281 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
282 (unsigned long) statbuf.st_nlink,
283 (unsigned long) statbuf.st_uid,
284 (unsigned long) statbuf.st_gid);
285 tprintf("st_blksize=%lu, ",
286 (unsigned long) statbuf.st_blksize);
287 tprintf("st_blocks=%lu, ",
288 (unsigned long) statbuf.st_blocks);
289 }
290 else
291 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
292 switch (statbuf.st_mode & S_IFMT) {
293 case S_IFCHR: case S_IFBLK:
294 tprintf("st_rdev=makedev(%lu, %lu), ",
295 (unsigned long) major(statbuf.st_rdev),
296 (unsigned long) minor(statbuf.st_rdev));
297 break;
298 default:
299 tprintf("st_size=%lu, ", statbuf.st_size);
300 break;
301 }
302 if (!abbrev(tcp)) {
303 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
304 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100305 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000306 }
307 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200308 tprints("...}");
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000309}
Denys Vlasenko9472a272013-02-12 11:43:46 +0100310# endif /* SPARC64 */
311#endif /* SPARC[64] */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000312
Denys Vlasenko84703742012-02-25 02:38:52 +0100313#if defined POWERPC64
Andreas Schwabd69fa492010-07-12 21:39:57 +0200314struct stat_powerpc32 {
315 unsigned int st_dev;
316 unsigned int st_ino;
317 unsigned int st_mode;
318 unsigned short st_nlink;
319 unsigned int st_uid;
320 unsigned int st_gid;
321 unsigned int st_rdev;
322 unsigned int st_size;
323 unsigned int st_blksize;
324 unsigned int st_blocks;
325 unsigned int st_atime;
326 unsigned int st_atime_nsec;
327 unsigned int st_mtime;
328 unsigned int st_mtime_nsec;
329 unsigned int st_ctime;
330 unsigned int st_ctime_nsec;
331 unsigned int __unused4;
332 unsigned int __unused5;
333};
334
335static void
336printstat_powerpc32(struct tcb *tcp, long addr)
337{
338 struct stat_powerpc32 statbuf;
339
340 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200341 tprints("{...}");
Andreas Schwabd69fa492010-07-12 21:39:57 +0200342 return;
343 }
344
345 if (!abbrev(tcp)) {
346 tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ",
347 major(statbuf.st_dev), minor(statbuf.st_dev),
348 statbuf.st_ino,
349 sprintmode(statbuf.st_mode));
350 tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ",
351 statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid);
352 tprintf("st_blksize=%u, ", statbuf.st_blksize);
353 tprintf("st_blocks=%u, ", statbuf.st_blocks);
354 }
355 else
356 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
357 switch (statbuf.st_mode & S_IFMT) {
358 case S_IFCHR: case S_IFBLK:
359 tprintf("st_rdev=makedev(%lu, %lu), ",
360 (unsigned long) major(statbuf.st_rdev),
361 (unsigned long) minor(statbuf.st_rdev));
362 break;
363 default:
364 tprintf("st_size=%u, ", statbuf.st_size);
365 break;
366 }
367 if (!abbrev(tcp)) {
368 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
369 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100370 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
Andreas Schwabd69fa492010-07-12 21:39:57 +0200371 }
372 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200373 tprints("...}");
Andreas Schwabd69fa492010-07-12 21:39:57 +0200374}
Denys Vlasenko84703742012-02-25 02:38:52 +0100375#endif /* POWERPC64 */
Andreas Schwabd69fa492010-07-12 21:39:57 +0200376
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000377#include "xlat/fileflags.h"
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000378
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000379static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000380realprintstat(struct tcb *tcp, struct stat *statbuf)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000381{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000382 if (!abbrev(tcp)) {
383 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
384 (unsigned long) major(statbuf->st_dev),
385 (unsigned long) minor(statbuf->st_dev),
386 (unsigned long) statbuf->st_ino,
387 sprintmode(statbuf->st_mode));
388 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
389 (unsigned long) statbuf->st_nlink,
390 (unsigned long) statbuf->st_uid,
391 (unsigned long) statbuf->st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000392#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Denys Vlasenko1d632462009-04-14 12:51:00 +0000393 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
394#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000395#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Denys Vlasenko1d632462009-04-14 12:51:00 +0000396 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
397#endif
398 }
399 else
400 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
401 switch (statbuf->st_mode & S_IFMT) {
402 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +0000403#ifdef HAVE_STRUCT_STAT_ST_RDEV
Denys Vlasenko1d632462009-04-14 12:51:00 +0000404 tprintf("st_rdev=makedev(%lu, %lu), ",
405 (unsigned long) major(statbuf->st_rdev),
406 (unsigned long) minor(statbuf->st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000407#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000408 tprintf("st_size=makedev(%lu, %lu), ",
409 (unsigned long) major(statbuf->st_size),
410 (unsigned long) minor(statbuf->st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000411#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000412 break;
413 default:
Dmitry V. Levine9a06b72011-02-23 16:16:50 +0000414 tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000415 break;
416 }
417 if (!abbrev(tcp)) {
418 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
419 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
420 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000421#if HAVE_STRUCT_STAT_ST_FLAGS
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200422 tprints(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +0000423 printflags(fileflags, statbuf->st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +0000424#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000425#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +0000426 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
427#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000428#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +0000429 tprintf(", st_level=%ld", statbuf->st_level);
430#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000431#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +0000432 tprintf(", st_fstype=%.*s",
433 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
434#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000435#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +0000436 tprintf(", st_gen=%u", statbuf->st_gen);
437#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200438 tprints("}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000439 }
440 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200441 tprints("...}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000442}
443
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000444#ifndef X32
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000445static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000446printstat(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000447{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000448 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000449
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000450 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200451 tprints("NULL");
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000452 return;
453 }
454 if (syserror(tcp) || !verbose(tcp)) {
455 tprintf("%#lx", addr);
456 return;
457 }
458
Denys Vlasenko9472a272013-02-12 11:43:46 +0100459#if defined(SPARC) || defined(SPARC64)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000460 if (current_personality == 1) {
461 printstatsol(tcp, addr);
462 return;
463 }
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000464#ifdef SPARC64
465 else if (current_personality == 2) {
466 printstat_sparc64(tcp, addr);
467 return;
468 }
469#endif
Denys Vlasenko9472a272013-02-12 11:43:46 +0100470#endif /* SPARC[64] */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000471
Denys Vlasenko84703742012-02-25 02:38:52 +0100472#if defined POWERPC64
Andreas Schwabd69fa492010-07-12 21:39:57 +0200473 if (current_personality == 1) {
474 printstat_powerpc32(tcp, addr);
475 return;
476 }
477#endif
478
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000479 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200480 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000481 return;
482 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000483
484 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000485}
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000486#else /* X32 */
487# define printstat printstat64
488#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000489
Elliott Hughes391c0d82014-04-03 17:50:14 -0700490#if !defined HAVE_STAT64 && (defined AARCH64 || defined X86_64)
Roland McGrathe6d0f712007-08-07 01:22:49 +0000491/*
492 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
493 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
494 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
495 * __GNUC__ is needed for the required __attribute__ below.
Elliott Hughes391c0d82014-04-03 17:50:14 -0700496 *
497 * Similarly, aarch64 has a unified `struct stat' but its arm personality
498 * needs `struct stat64' (which also expects a 32-bit `long' but which
499 * shouldn't be packed).
Roland McGrathe6d0f712007-08-07 01:22:49 +0000500 */
501struct stat64 {
502 unsigned long long st_dev;
503 unsigned char __pad0[4];
504 unsigned int __st_ino;
505 unsigned int st_mode;
506 unsigned int st_nlink;
507 unsigned int st_uid;
508 unsigned int st_gid;
509 unsigned long long st_rdev;
510 unsigned char __pad3[4];
511 long long st_size;
512 unsigned int st_blksize;
513 unsigned long long st_blocks;
514 unsigned int st_atime;
515 unsigned int st_atime_nsec;
516 unsigned int st_mtime;
517 unsigned int st_mtime_nsec;
518 unsigned int st_ctime;
519 unsigned int st_ctime_nsec;
520 unsigned long long st_ino;
Elliott Hughes391c0d82014-04-03 17:50:14 -0700521}
522# if defined X86_64
523 __attribute__((packed))
524# define STAT64_SIZE 96
525#else
526# define STAT64_SIZE 104
527# endif
528;
Roland McGrathe6d0f712007-08-07 01:22:49 +0000529# define HAVE_STAT64 1
Roland McGrathe6d0f712007-08-07 01:22:49 +0000530#endif
531
Wichert Akkermanc7926982000-04-10 22:22:31 +0000532#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000533static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000534printstat64(struct tcb *tcp, long addr)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000535{
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000536#ifdef X32
537 struct stat statbuf;
538#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000539 struct stat64 statbuf;
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000540#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000541
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000542#ifdef STAT64_SIZE
Roland McGrathe6d0f712007-08-07 01:22:49 +0000543 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
544#endif
545
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000546 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200547 tprints("NULL");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000548 return;
549 }
550 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000551 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000552 return;
553 }
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000554
Denys Vlasenko9472a272013-02-12 11:43:46 +0100555#if defined(SPARC) || defined(SPARC64)
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000556 if (current_personality == 1) {
557 printstatsol(tcp, addr);
558 return;
559 }
560# ifdef SPARC64
561 else if (current_personality == 2) {
562 printstat_sparc64(tcp, addr);
563 return;
564 }
565# endif
Denys Vlasenko9472a272013-02-12 11:43:46 +0100566#endif /* SPARC[64] */
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000567
Elliott Hughes391c0d82014-04-03 17:50:14 -0700568#if defined AARCH64
569 if (current_personality != 0) {
570 printstat(tcp, addr);
571 return;
572 }
573#endif
Denys Vlasenko84703742012-02-25 02:38:52 +0100574#if defined X86_64
H.J. Lu35be5812012-04-16 13:00:01 +0200575 if (current_personality != 1) {
Andreas Schwab61b74352009-10-16 11:37:13 +0200576 printstat(tcp, addr);
577 return;
578 }
579#endif
Dmitry V. Levinff896f72009-10-21 13:43:57 +0000580
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000581 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200582 tprints("{...}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000583 return;
584 }
585
586 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +0000587 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000588 (unsigned long) major(statbuf.st_dev),
589 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +0000590 (unsigned long long) statbuf.st_ino,
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000591 sprintmode(statbuf.st_mode));
592 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
593 (unsigned long) statbuf.st_nlink,
594 (unsigned long) statbuf.st_uid,
595 (unsigned long) statbuf.st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000596#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000597 tprintf("st_blksize=%lu, ",
598 (unsigned long) statbuf.st_blksize);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000599#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
600#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000601 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000602#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000603 }
604 else
605 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
606 switch (statbuf.st_mode & S_IFMT) {
607 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +0000608#ifdef HAVE_STRUCT_STAT_ST_RDEV
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000609 tprintf("st_rdev=makedev(%lu, %lu), ",
610 (unsigned long) major(statbuf.st_rdev),
611 (unsigned long) minor(statbuf.st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000612#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000613 tprintf("st_size=makedev(%lu, %lu), ",
614 (unsigned long) major(statbuf.st_size),
615 (unsigned long) minor(statbuf.st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000616#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000617 break;
618 default:
Roland McGrathc7bd4d32007-08-07 01:05:19 +0000619 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000620 break;
621 }
622 if (!abbrev(tcp)) {
623 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
624 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +0000625 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000626#if HAVE_STRUCT_STAT_ST_FLAGS
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200627 tprints(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +0000628 printflags(fileflags, statbuf.st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +0000629#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000630#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +0000631 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
632#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000633#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +0000634 tprintf(", st_level=%ld", statbuf.st_level);
635#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000636#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +0000637 tprintf(", st_fstype=%.*s",
638 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
639#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000640#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +0000641 tprintf(", st_gen=%u", statbuf.st_gen);
642#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200643 tprints("}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000644 }
645 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200646 tprints("...}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000647}
Wichert Akkermanc7926982000-04-10 22:22:31 +0000648#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000649
Denys Vlasenko8435d672013-02-18 15:47:57 +0100650#if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000651static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000652convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000653{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000654 newbuf->st_dev = oldbuf->st_dev;
655 newbuf->st_ino = oldbuf->st_ino;
656 newbuf->st_mode = oldbuf->st_mode;
657 newbuf->st_nlink = oldbuf->st_nlink;
658 newbuf->st_uid = oldbuf->st_uid;
659 newbuf->st_gid = oldbuf->st_gid;
660 newbuf->st_rdev = oldbuf->st_rdev;
661 newbuf->st_size = oldbuf->st_size;
662 newbuf->st_atime = oldbuf->st_atime;
663 newbuf->st_mtime = oldbuf->st_mtime;
664 newbuf->st_ctime = oldbuf->st_ctime;
665 newbuf->st_blksize = 0; /* not supported in old_stat */
666 newbuf->st_blocks = 0; /* not supported in old_stat */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000667}
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000668
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000669static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000670printoldstat(struct tcb *tcp, long addr)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000671{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000672 struct __old_kernel_stat statbuf;
673 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000674
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000675 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200676 tprints("NULL");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000677 return;
678 }
679 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000680 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000681 return;
682 }
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000683
Denys Vlasenko9472a272013-02-12 11:43:46 +0100684# if defined(SPARC) || defined(SPARC64)
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000685 if (current_personality == 1) {
686 printstatsol(tcp, addr);
687 return;
688 }
Denys Vlasenko84703742012-02-25 02:38:52 +0100689# endif
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000690
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000691 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200692 tprints("{...}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000693 return;
694 }
695
696 convertoldstat(&statbuf, &newstatbuf);
697 realprintstat(tcp, &newstatbuf);
698}
Denys Vlasenko84703742012-02-25 02:38:52 +0100699#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000700
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000701int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000702sys_stat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000703{
704 if (entering(tcp)) {
705 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200706 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000707 } else {
708 printstat(tcp, tcp->u_arg[1]);
709 }
710 return 0;
711}
712
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000713#ifdef X32
714static void
715printstat64_x32(struct tcb *tcp, long addr)
716{
717 struct stat64 statbuf;
718
719 if (!addr) {
720 tprints("NULL");
721 return;
722 }
723 if (syserror(tcp) || !verbose(tcp)) {
724 tprintf("%#lx", addr);
725 return;
726 }
727
728 if (umove(tcp, addr, &statbuf) < 0) {
729 tprints("{...}");
730 return;
731 }
732
733 if (!abbrev(tcp)) {
734 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
735 (unsigned long) major(statbuf.st_dev),
736 (unsigned long) minor(statbuf.st_dev),
737 (unsigned long long) statbuf.st_ino,
738 sprintmode(statbuf.st_mode));
739 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
740 (unsigned long) statbuf.st_nlink,
741 (unsigned long) statbuf.st_uid,
742 (unsigned long) statbuf.st_gid);
743 tprintf("st_blksize=%lu, ",
744 (unsigned long) statbuf.st_blksize);
745 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
746 }
747 else
748 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
749 switch (statbuf.st_mode & S_IFMT) {
750 case S_IFCHR: case S_IFBLK:
751 tprintf("st_rdev=makedev(%lu, %lu), ",
752 (unsigned long) major(statbuf.st_rdev),
753 (unsigned long) minor(statbuf.st_rdev));
754 break;
755 default:
756 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
757 break;
758 }
759 if (!abbrev(tcp)) {
760 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
761 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
762 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
763 tprints("}");
764 }
765 else
766 tprints("...}");
767}
768#endif /* X32 */
769
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000770int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000771sys_stat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000772{
773#ifdef HAVE_STAT64
774 if (entering(tcp)) {
775 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200776 tprints(", ");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000777 } else {
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000778# ifdef X32
779 printstat64_x32(tcp, tcp->u_arg[1]);
780# else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000781 printstat64(tcp, tcp->u_arg[1]);
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000782# endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000783 }
784 return 0;
785#else
786 return printargs(tcp);
787#endif
788}
789
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000790int
791sys_newfstatat(struct tcb *tcp)
792{
793 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300794 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000795 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200796 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000797 } else {
Andreas Schwabd69fa492010-07-12 21:39:57 +0200798#ifdef POWERPC64
799 if (current_personality == 0)
800 printstat(tcp, tcp->u_arg[2]);
801 else
802 printstat64(tcp, tcp->u_arg[2]);
803#elif defined HAVE_STAT64
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000804 printstat64(tcp, tcp->u_arg[2]);
805#else
806 printstat(tcp, tcp->u_arg[2]);
807#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200808 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +0000809 printflags(at_flags, tcp->u_arg[3], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000810 }
811 return 0;
812}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000813
Denys Vlasenko8435d672013-02-18 15:47:57 +0100814#if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000815int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000816sys_oldstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000817{
818 if (entering(tcp)) {
819 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200820 tprints(", ");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000821 } else {
822 printoldstat(tcp, tcp->u_arg[1]);
823 }
824 return 0;
825}
Denys Vlasenko84703742012-02-25 02:38:52 +0100826#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000827
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000828int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000829sys_fstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000830{
Dmitry V. Levin31382132011-03-04 05:08:02 +0300831 if (entering(tcp)) {
832 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200833 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +0300834 } else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000835 printstat(tcp, tcp->u_arg[1]);
836 }
837 return 0;
838}
839
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000840int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000841sys_fstat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000842{
843#ifdef HAVE_STAT64
Dmitry V. Levin31382132011-03-04 05:08:02 +0300844 if (entering(tcp)) {
845 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200846 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +0300847 } else {
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000848# ifdef X32
849 printstat64_x32(tcp, tcp->u_arg[1]);
850# else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000851 printstat64(tcp, tcp->u_arg[1]);
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000852# endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000853 }
854 return 0;
855#else
856 return printargs(tcp);
857#endif
858}
859
Denys Vlasenko8435d672013-02-18 15:47:57 +0100860#if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000861int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000862sys_oldfstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000863{
Dmitry V. Levin31382132011-03-04 05:08:02 +0300864 if (entering(tcp)) {
865 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200866 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +0300867 } else {
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000868 printoldstat(tcp, tcp->u_arg[1]);
869 }
870 return 0;
871}
Denys Vlasenko84703742012-02-25 02:38:52 +0100872#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000873
Denys Vlasenko9472a272013-02-12 11:43:46 +0100874#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000875
876int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000877sys_xstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000878{
879 if (entering(tcp)) {
880 tprintf("%ld, ", tcp->u_arg[0]);
881 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200882 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000883 } else {
Denys Vlasenko84703742012-02-25 02:38:52 +0100884# ifdef _STAT64_VER
John Hughes8fe2c982001-03-06 09:45:18 +0000885 if (tcp->u_arg[0] == _STAT64_VER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100886 printstat64(tcp, tcp->u_arg[2]);
John Hughes8fe2c982001-03-06 09:45:18 +0000887 else
Denys Vlasenko84703742012-02-25 02:38:52 +0100888# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000889 printstat(tcp, tcp->u_arg[2]);
890 }
891 return 0;
892}
893
894int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000895sys_fxstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000896{
897 if (entering(tcp))
898 tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
899 else {
Denys Vlasenko84703742012-02-25 02:38:52 +0100900# ifdef _STAT64_VER
John Hughes8fe2c982001-03-06 09:45:18 +0000901 if (tcp->u_arg[0] == _STAT64_VER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100902 printstat64(tcp, tcp->u_arg[2]);
John Hughes8fe2c982001-03-06 09:45:18 +0000903 else
Denys Vlasenko84703742012-02-25 02:38:52 +0100904# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000905 printstat(tcp, tcp->u_arg[2]);
906 }
907 return 0;
908}
909
910int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000911sys_lxstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000912{
913 if (entering(tcp)) {
914 tprintf("%ld, ", tcp->u_arg[0]);
915 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200916 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000917 } else {
Denys Vlasenko84703742012-02-25 02:38:52 +0100918# ifdef _STAT64_VER
John Hughes8fe2c982001-03-06 09:45:18 +0000919 if (tcp->u_arg[0] == _STAT64_VER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100920 printstat64(tcp, tcp->u_arg[2]);
John Hughes8fe2c982001-03-06 09:45:18 +0000921 else
Denys Vlasenko84703742012-02-25 02:38:52 +0100922# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000923 printstat(tcp, tcp->u_arg[2]);
924 }
925 return 0;
926}
927
Dmitry V. Levin964d80a2014-12-06 03:53:16 +0000928#endif /* SPARC || SPARC64 */