blob: 69e72b353a37367001398c3c741d61ccb8408d01 [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#ifdef MAJOR_IN_SYSMACROS
Denys Vlasenko84703742012-02-25 02:38:52 +0100183# include <sys/sysmacros.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000184#endif
185
186#ifdef MAJOR_IN_MKDEV
Denys Vlasenko84703742012-02-25 02:38:52 +0100187# include <sys/mkdev.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000188#endif
189
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000190/* several stats */
191
Denys Vlasenko9472a272013-02-12 11:43:46 +0100192#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000193typedef struct {
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000194 int tv_sec;
195 int tv_nsec;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000196} timestruct_t;
197
198struct solstat {
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000199 unsigned st_dev;
200 int st_pad1[3]; /* network id */
201 unsigned st_ino;
202 unsigned st_mode;
203 unsigned st_nlink;
204 unsigned st_uid;
205 unsigned st_gid;
206 unsigned st_rdev;
207 int st_pad2[2];
208 int st_size;
209 int st_pad3; /* st_size, off_t expansion */
210 timestruct_t st_atime;
211 timestruct_t st_mtime;
212 timestruct_t st_ctime;
213 int st_blksize;
214 int st_blocks;
215 char st_fstype[16];
216 int st_pad4[8]; /* expansion area */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000217};
218
219static void
Dmitry V. Levinb838b1e2008-04-19 23:47:47 +0000220printstatsol(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000221{
222 struct solstat statbuf;
223
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000224 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200225 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000226 return;
227 }
228 if (!abbrev(tcp)) {
229 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
230 (unsigned long) ((statbuf.st_dev >> 18) & 0x3fff),
231 (unsigned long) (statbuf.st_dev & 0x3ffff),
232 (unsigned long) statbuf.st_ino,
233 sprintmode(statbuf.st_mode));
234 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
235 (unsigned long) statbuf.st_nlink,
236 (unsigned long) statbuf.st_uid,
237 (unsigned long) statbuf.st_gid);
238 tprintf("st_blksize=%lu, ", (unsigned long) statbuf.st_blksize);
239 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
240 }
241 else
242 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
243 switch (statbuf.st_mode & S_IFMT) {
244 case S_IFCHR: case S_IFBLK:
245 tprintf("st_rdev=makedev(%lu, %lu), ",
246 (unsigned long) ((statbuf.st_rdev >> 18) & 0x3fff),
247 (unsigned long) (statbuf.st_rdev & 0x3ffff));
248 break;
249 default:
250 tprintf("st_size=%u, ", statbuf.st_size);
251 break;
252 }
253 if (!abbrev(tcp)) {
Dmitry V. Levinb838b1e2008-04-19 23:47:47 +0000254 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime.tv_sec));
255 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime.tv_sec));
256 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime.tv_sec));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000257 }
258 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200259 tprints("...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000260}
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000261
Denys Vlasenko9472a272013-02-12 11:43:46 +0100262# if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000263static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000264printstat_sparc64(struct tcb *tcp, long addr)
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000265{
266 struct stat_sparc64 statbuf;
267
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000268 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200269 tprints("{...}");
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000270 return;
271 }
272
273 if (!abbrev(tcp)) {
274 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
275 (unsigned long) major(statbuf.st_dev),
276 (unsigned long) minor(statbuf.st_dev),
277 (unsigned long) statbuf.st_ino,
278 sprintmode(statbuf.st_mode));
279 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
280 (unsigned long) statbuf.st_nlink,
281 (unsigned long) statbuf.st_uid,
282 (unsigned long) statbuf.st_gid);
283 tprintf("st_blksize=%lu, ",
284 (unsigned long) statbuf.st_blksize);
285 tprintf("st_blocks=%lu, ",
286 (unsigned long) statbuf.st_blocks);
287 }
288 else
289 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
290 switch (statbuf.st_mode & S_IFMT) {
291 case S_IFCHR: case S_IFBLK:
292 tprintf("st_rdev=makedev(%lu, %lu), ",
293 (unsigned long) major(statbuf.st_rdev),
294 (unsigned long) minor(statbuf.st_rdev));
295 break;
296 default:
297 tprintf("st_size=%lu, ", statbuf.st_size);
298 break;
299 }
300 if (!abbrev(tcp)) {
301 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
302 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100303 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000304 }
305 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200306 tprints("...}");
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000307}
Denys Vlasenko9472a272013-02-12 11:43:46 +0100308# endif /* SPARC64 */
309#endif /* SPARC[64] */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000310
Denys Vlasenko84703742012-02-25 02:38:52 +0100311#if defined POWERPC64
Andreas Schwabd69fa492010-07-12 21:39:57 +0200312struct stat_powerpc32 {
313 unsigned int st_dev;
314 unsigned int st_ino;
315 unsigned int st_mode;
316 unsigned short st_nlink;
317 unsigned int st_uid;
318 unsigned int st_gid;
319 unsigned int st_rdev;
320 unsigned int st_size;
321 unsigned int st_blksize;
322 unsigned int st_blocks;
323 unsigned int st_atime;
324 unsigned int st_atime_nsec;
325 unsigned int st_mtime;
326 unsigned int st_mtime_nsec;
327 unsigned int st_ctime;
328 unsigned int st_ctime_nsec;
329 unsigned int __unused4;
330 unsigned int __unused5;
331};
332
333static void
334printstat_powerpc32(struct tcb *tcp, long addr)
335{
336 struct stat_powerpc32 statbuf;
337
338 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200339 tprints("{...}");
Andreas Schwabd69fa492010-07-12 21:39:57 +0200340 return;
341 }
342
343 if (!abbrev(tcp)) {
344 tprintf("{st_dev=makedev(%u, %u), st_ino=%u, st_mode=%s, ",
345 major(statbuf.st_dev), minor(statbuf.st_dev),
346 statbuf.st_ino,
347 sprintmode(statbuf.st_mode));
348 tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ",
349 statbuf.st_nlink, statbuf.st_uid, statbuf.st_gid);
350 tprintf("st_blksize=%u, ", statbuf.st_blksize);
351 tprintf("st_blocks=%u, ", statbuf.st_blocks);
352 }
353 else
354 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
355 switch (statbuf.st_mode & S_IFMT) {
356 case S_IFCHR: case S_IFBLK:
357 tprintf("st_rdev=makedev(%lu, %lu), ",
358 (unsigned long) major(statbuf.st_rdev),
359 (unsigned long) minor(statbuf.st_rdev));
360 break;
361 default:
362 tprintf("st_size=%u, ", statbuf.st_size);
363 break;
364 }
365 if (!abbrev(tcp)) {
366 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
367 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100368 tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
Andreas Schwabd69fa492010-07-12 21:39:57 +0200369 }
370 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200371 tprints("...}");
Andreas Schwabd69fa492010-07-12 21:39:57 +0200372}
Denys Vlasenko84703742012-02-25 02:38:52 +0100373#endif /* POWERPC64 */
Andreas Schwabd69fa492010-07-12 21:39:57 +0200374
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000375#include "xlat/fileflags.h"
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000376
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000377static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000378realprintstat(struct tcb *tcp, struct stat *statbuf)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000379{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000380 if (!abbrev(tcp)) {
381 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%lu, st_mode=%s, ",
382 (unsigned long) major(statbuf->st_dev),
383 (unsigned long) minor(statbuf->st_dev),
384 (unsigned long) statbuf->st_ino,
385 sprintmode(statbuf->st_mode));
386 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
387 (unsigned long) statbuf->st_nlink,
388 (unsigned long) statbuf->st_uid,
389 (unsigned long) statbuf->st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000390#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Denys Vlasenko1d632462009-04-14 12:51:00 +0000391 tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
392#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000393#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Denys Vlasenko1d632462009-04-14 12:51:00 +0000394 tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
395#endif
396 }
397 else
398 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
399 switch (statbuf->st_mode & S_IFMT) {
400 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +0000401#ifdef HAVE_STRUCT_STAT_ST_RDEV
Denys Vlasenko1d632462009-04-14 12:51:00 +0000402 tprintf("st_rdev=makedev(%lu, %lu), ",
403 (unsigned long) major(statbuf->st_rdev),
404 (unsigned long) minor(statbuf->st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000405#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000406 tprintf("st_size=makedev(%lu, %lu), ",
407 (unsigned long) major(statbuf->st_size),
408 (unsigned long) minor(statbuf->st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000409#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Denys Vlasenko1d632462009-04-14 12:51:00 +0000410 break;
411 default:
Dmitry V. Levine9a06b72011-02-23 16:16:50 +0000412 tprintf("st_size=%lu, ", (unsigned long) statbuf->st_size);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000413 break;
414 }
415 if (!abbrev(tcp)) {
416 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
417 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
418 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000419#if HAVE_STRUCT_STAT_ST_FLAGS
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200420 tprints(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +0000421 printflags(fileflags, statbuf->st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +0000422#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000423#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +0000424 tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
425#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000426#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +0000427 tprintf(", st_level=%ld", statbuf->st_level);
428#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000429#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +0000430 tprintf(", st_fstype=%.*s",
431 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
432#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000433#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +0000434 tprintf(", st_gen=%u", statbuf->st_gen);
435#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200436 tprints("}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000437 }
438 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200439 tprints("...}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000440}
441
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000442#ifndef X32
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000443static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000444printstat(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000445{
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000446 struct stat statbuf;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000447
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000448 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200449 tprints("NULL");
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000450 return;
451 }
452 if (syserror(tcp) || !verbose(tcp)) {
453 tprintf("%#lx", addr);
454 return;
455 }
456
Denys Vlasenko9472a272013-02-12 11:43:46 +0100457#if defined(SPARC) || defined(SPARC64)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000458 if (current_personality == 1) {
459 printstatsol(tcp, addr);
460 return;
461 }
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000462#ifdef SPARC64
463 else if (current_personality == 2) {
464 printstat_sparc64(tcp, addr);
465 return;
466 }
467#endif
Denys Vlasenko9472a272013-02-12 11:43:46 +0100468#endif /* SPARC[64] */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000469
Denys Vlasenko84703742012-02-25 02:38:52 +0100470#if defined POWERPC64
Andreas Schwabd69fa492010-07-12 21:39:57 +0200471 if (current_personality == 1) {
472 printstat_powerpc32(tcp, addr);
473 return;
474 }
475#endif
476
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000477 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200478 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000479 return;
480 }
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000481
482 realprintstat(tcp, &statbuf);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000483}
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000484#else /* X32 */
485# define printstat printstat64
486#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000487
Elliott Hughes391c0d82014-04-03 17:50:14 -0700488#if !defined HAVE_STAT64 && (defined AARCH64 || defined X86_64)
Roland McGrathe6d0f712007-08-07 01:22:49 +0000489/*
490 * Linux x86_64 has unified `struct stat' but its i386 biarch needs
491 * `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
492 * <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
493 * __GNUC__ is needed for the required __attribute__ below.
Elliott Hughes391c0d82014-04-03 17:50:14 -0700494 *
495 * Similarly, aarch64 has a unified `struct stat' but its arm personality
496 * needs `struct stat64' (which also expects a 32-bit `long' but which
497 * shouldn't be packed).
Roland McGrathe6d0f712007-08-07 01:22:49 +0000498 */
499struct stat64 {
500 unsigned long long st_dev;
501 unsigned char __pad0[4];
502 unsigned int __st_ino;
503 unsigned int st_mode;
504 unsigned int st_nlink;
505 unsigned int st_uid;
506 unsigned int st_gid;
507 unsigned long long st_rdev;
508 unsigned char __pad3[4];
509 long long st_size;
510 unsigned int st_blksize;
511 unsigned long long st_blocks;
512 unsigned int st_atime;
513 unsigned int st_atime_nsec;
514 unsigned int st_mtime;
515 unsigned int st_mtime_nsec;
516 unsigned int st_ctime;
517 unsigned int st_ctime_nsec;
518 unsigned long long st_ino;
Elliott Hughes391c0d82014-04-03 17:50:14 -0700519}
520# if defined X86_64
521 __attribute__((packed))
522# define STAT64_SIZE 96
523#else
524# define STAT64_SIZE 104
525# endif
526;
Roland McGrathe6d0f712007-08-07 01:22:49 +0000527# define HAVE_STAT64 1
Roland McGrathe6d0f712007-08-07 01:22:49 +0000528#endif
529
Wichert Akkermanc7926982000-04-10 22:22:31 +0000530#ifdef HAVE_STAT64
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000531static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000532printstat64(struct tcb *tcp, long addr)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000533{
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000534#ifdef X32
535 struct stat statbuf;
536#else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000537 struct stat64 statbuf;
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000538#endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000539
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000540#ifdef STAT64_SIZE
Roland McGrathe6d0f712007-08-07 01:22:49 +0000541 (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
542#endif
543
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000544 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200545 tprints("NULL");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000546 return;
547 }
548 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000549 tprintf("%#lx", addr);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000550 return;
551 }
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000552
Denys Vlasenko9472a272013-02-12 11:43:46 +0100553#if defined(SPARC) || defined(SPARC64)
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000554 if (current_personality == 1) {
555 printstatsol(tcp, addr);
556 return;
557 }
558# ifdef SPARC64
559 else if (current_personality == 2) {
560 printstat_sparc64(tcp, addr);
561 return;
562 }
563# endif
Denys Vlasenko9472a272013-02-12 11:43:46 +0100564#endif /* SPARC[64] */
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000565
Elliott Hughes391c0d82014-04-03 17:50:14 -0700566#if defined AARCH64
567 if (current_personality != 0) {
568 printstat(tcp, addr);
569 return;
570 }
571#endif
Denys Vlasenko84703742012-02-25 02:38:52 +0100572#if defined X86_64
H.J. Lu35be5812012-04-16 13:00:01 +0200573 if (current_personality != 1) {
Andreas Schwab61b74352009-10-16 11:37:13 +0200574 printstat(tcp, addr);
575 return;
576 }
577#endif
Dmitry V. Levinff896f72009-10-21 13:43:57 +0000578
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000579 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200580 tprints("{...}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000581 return;
582 }
583
584 if (!abbrev(tcp)) {
Wichert Akkermand077c452000-08-10 18:16:15 +0000585 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000586 (unsigned long) major(statbuf.st_dev),
587 (unsigned long) minor(statbuf.st_dev),
Wichert Akkermand077c452000-08-10 18:16:15 +0000588 (unsigned long long) statbuf.st_ino,
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000589 sprintmode(statbuf.st_mode));
590 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
591 (unsigned long) statbuf.st_nlink,
592 (unsigned long) statbuf.st_uid,
593 (unsigned long) statbuf.st_gid);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000594#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000595 tprintf("st_blksize=%lu, ",
596 (unsigned long) statbuf.st_blksize);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000597#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
598#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000599 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000600#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000601 }
602 else
603 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
604 switch (statbuf.st_mode & S_IFMT) {
605 case S_IFCHR: case S_IFBLK:
Roland McGrath6d2b3492002-12-30 00:51:30 +0000606#ifdef HAVE_STRUCT_STAT_ST_RDEV
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000607 tprintf("st_rdev=makedev(%lu, %lu), ",
608 (unsigned long) major(statbuf.st_rdev),
609 (unsigned long) minor(statbuf.st_rdev));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000610#else /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000611 tprintf("st_size=makedev(%lu, %lu), ",
612 (unsigned long) major(statbuf.st_size),
613 (unsigned long) minor(statbuf.st_size));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000614#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000615 break;
616 default:
Roland McGrathc7bd4d32007-08-07 01:05:19 +0000617 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000618 break;
619 }
620 if (!abbrev(tcp)) {
621 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
622 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
John Hughesc0fc3fd2001-03-08 16:10:40 +0000623 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
Roland McGrath6d2b3492002-12-30 00:51:30 +0000624#if HAVE_STRUCT_STAT_ST_FLAGS
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200625 tprints(", st_flags=");
Roland McGrathb2dee132005-06-01 19:02:36 +0000626 printflags(fileflags, statbuf.st_flags, "UF_???");
John Hughesc0fc3fd2001-03-08 16:10:40 +0000627#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000628#if HAVE_STRUCT_STAT_ST_ACLCNT
John Hughesc0fc3fd2001-03-08 16:10:40 +0000629 tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
630#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000631#if HAVE_STRUCT_STAT_ST_LEVEL
John Hughesc0fc3fd2001-03-08 16:10:40 +0000632 tprintf(", st_level=%ld", statbuf.st_level);
633#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000634#if HAVE_STRUCT_STAT_ST_FSTYPE
John Hughesc0fc3fd2001-03-08 16:10:40 +0000635 tprintf(", st_fstype=%.*s",
636 (int) sizeof statbuf.st_fstype, statbuf.st_fstype);
637#endif
Roland McGrath6d2b3492002-12-30 00:51:30 +0000638#if HAVE_STRUCT_STAT_ST_GEN
John Hughesc0fc3fd2001-03-08 16:10:40 +0000639 tprintf(", st_gen=%u", statbuf.st_gen);
640#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200641 tprints("}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000642 }
643 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200644 tprints("...}");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000645}
Wichert Akkermanc7926982000-04-10 22:22:31 +0000646#endif /* HAVE_STAT64 */
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000647
Denys Vlasenko8435d672013-02-18 15:47:57 +0100648#if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000649static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000650convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000651{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000652 newbuf->st_dev = oldbuf->st_dev;
653 newbuf->st_ino = oldbuf->st_ino;
654 newbuf->st_mode = oldbuf->st_mode;
655 newbuf->st_nlink = oldbuf->st_nlink;
656 newbuf->st_uid = oldbuf->st_uid;
657 newbuf->st_gid = oldbuf->st_gid;
658 newbuf->st_rdev = oldbuf->st_rdev;
659 newbuf->st_size = oldbuf->st_size;
660 newbuf->st_atime = oldbuf->st_atime;
661 newbuf->st_mtime = oldbuf->st_mtime;
662 newbuf->st_ctime = oldbuf->st_ctime;
663 newbuf->st_blksize = 0; /* not supported in old_stat */
664 newbuf->st_blocks = 0; /* not supported in old_stat */
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000665}
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000666
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000667static void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000668printoldstat(struct tcb *tcp, long addr)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000669{
Wichert Akkerman25d0c4f1999-04-18 19:35:42 +0000670 struct __old_kernel_stat statbuf;
671 struct stat newstatbuf;
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000672
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000673 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200674 tprints("NULL");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000675 return;
676 }
677 if (syserror(tcp) || !verbose(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000678 tprintf("%#lx", addr);
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000679 return;
680 }
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000681
Denys Vlasenko9472a272013-02-12 11:43:46 +0100682# if defined(SPARC) || defined(SPARC64)
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000683 if (current_personality == 1) {
684 printstatsol(tcp, addr);
685 return;
686 }
Denys Vlasenko84703742012-02-25 02:38:52 +0100687# endif
Denys Vlasenko4e718b52009-04-20 18:30:13 +0000688
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000689 if (umove(tcp, addr, &statbuf) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200690 tprints("{...}");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000691 return;
692 }
693
694 convertoldstat(&statbuf, &newstatbuf);
695 realprintstat(tcp, &newstatbuf);
696}
Denys Vlasenko84703742012-02-25 02:38:52 +0100697#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000698
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000699int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000700sys_stat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000701{
702 if (entering(tcp)) {
703 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200704 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000705 } else {
706 printstat(tcp, tcp->u_arg[1]);
707 }
708 return 0;
709}
710
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000711#ifdef X32
712static void
713printstat64_x32(struct tcb *tcp, long addr)
714{
715 struct stat64 statbuf;
716
717 if (!addr) {
718 tprints("NULL");
719 return;
720 }
721 if (syserror(tcp) || !verbose(tcp)) {
722 tprintf("%#lx", addr);
723 return;
724 }
725
726 if (umove(tcp, addr, &statbuf) < 0) {
727 tprints("{...}");
728 return;
729 }
730
731 if (!abbrev(tcp)) {
732 tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
733 (unsigned long) major(statbuf.st_dev),
734 (unsigned long) minor(statbuf.st_dev),
735 (unsigned long long) statbuf.st_ino,
736 sprintmode(statbuf.st_mode));
737 tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
738 (unsigned long) statbuf.st_nlink,
739 (unsigned long) statbuf.st_uid,
740 (unsigned long) statbuf.st_gid);
741 tprintf("st_blksize=%lu, ",
742 (unsigned long) statbuf.st_blksize);
743 tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
744 }
745 else
746 tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
747 switch (statbuf.st_mode & S_IFMT) {
748 case S_IFCHR: case S_IFBLK:
749 tprintf("st_rdev=makedev(%lu, %lu), ",
750 (unsigned long) major(statbuf.st_rdev),
751 (unsigned long) minor(statbuf.st_rdev));
752 break;
753 default:
754 tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
755 break;
756 }
757 if (!abbrev(tcp)) {
758 tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
759 tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
760 tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
761 tprints("}");
762 }
763 else
764 tprints("...}");
765}
766#endif /* X32 */
767
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000768int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000769sys_stat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000770{
771#ifdef HAVE_STAT64
772 if (entering(tcp)) {
773 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200774 tprints(", ");
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000775 } else {
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000776# ifdef X32
777 printstat64_x32(tcp, tcp->u_arg[1]);
778# else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000779 printstat64(tcp, tcp->u_arg[1]);
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000780# endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000781 }
782 return 0;
783#else
784 return printargs(tcp);
785#endif
786}
787
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000788int
789sys_newfstatat(struct tcb *tcp)
790{
791 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300792 print_dirfd(tcp, tcp->u_arg[0]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000793 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200794 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000795 } else {
Andreas Schwabd69fa492010-07-12 21:39:57 +0200796#ifdef POWERPC64
797 if (current_personality == 0)
798 printstat(tcp, tcp->u_arg[2]);
799 else
800 printstat64(tcp, tcp->u_arg[2]);
801#elif defined HAVE_STAT64
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000802 printstat64(tcp, tcp->u_arg[2]);
803#else
804 printstat(tcp, tcp->u_arg[2]);
805#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200806 tprints(", ");
Dmitry V. Levin7989ad42012-03-13 23:26:01 +0000807 printflags(at_flags, tcp->u_arg[3], "AT_???");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000808 }
809 return 0;
810}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000811
Denys Vlasenko8435d672013-02-18 15:47:57 +0100812#if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000813int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000814sys_oldstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000815{
816 if (entering(tcp)) {
817 printpath(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200818 tprints(", ");
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000819 } else {
820 printoldstat(tcp, tcp->u_arg[1]);
821 }
822 return 0;
823}
Denys Vlasenko84703742012-02-25 02:38:52 +0100824#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000825
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000826int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000827sys_fstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000828{
Dmitry V. Levin31382132011-03-04 05:08:02 +0300829 if (entering(tcp)) {
830 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200831 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +0300832 } else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000833 printstat(tcp, tcp->u_arg[1]);
834 }
835 return 0;
836}
837
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000838int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000839sys_fstat64(struct tcb *tcp)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000840{
841#ifdef HAVE_STAT64
Dmitry V. Levin31382132011-03-04 05:08:02 +0300842 if (entering(tcp)) {
843 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200844 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +0300845 } else {
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000846# ifdef X32
847 printstat64_x32(tcp, tcp->u_arg[1]);
848# else
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000849 printstat64(tcp, tcp->u_arg[1]);
Dmitry V. Levin0eeda2c2013-05-01 16:37:08 +0000850# endif
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000851 }
852 return 0;
853#else
854 return printargs(tcp);
855#endif
856}
857
Denys Vlasenko8435d672013-02-18 15:47:57 +0100858#if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
Ulrich Drepper7f02c4d1999-12-24 08:01:34 +0000859int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000860sys_oldfstat(struct tcb *tcp)
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000861{
Dmitry V. Levin31382132011-03-04 05:08:02 +0300862 if (entering(tcp)) {
863 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200864 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +0300865 } else {
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000866 printoldstat(tcp, tcp->u_arg[1]);
867 }
868 return 0;
869}
Denys Vlasenko84703742012-02-25 02:38:52 +0100870#endif
Wichert Akkerman328c5e71999-04-16 00:21:26 +0000871
Denys Vlasenko9472a272013-02-12 11:43:46 +0100872#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000873
874int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000875sys_xstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000876{
877 if (entering(tcp)) {
878 tprintf("%ld, ", tcp->u_arg[0]);
879 printpath(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200880 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000881 } else {
882 printstat(tcp, tcp->u_arg[2]);
883 }
884 return 0;
885}
886
887int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000888sys_fxstat(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000889{
Dmitry V. Levine00a9572014-12-29 03:15:42 +0000890 if (entering(tcp)) {
891 tprintf("%ld, ", tcp->u_arg[0]);
892 printfd(tcp, tcp->u_arg[1]);
893 tprints(", ");
894 } else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000895 printstat(tcp, tcp->u_arg[2]);
896 }
897 return 0;
898}
899
Dmitry V. Levin964d80a2014-12-06 03:53:16 +0000900#endif /* SPARC || SPARC64 */