blob: dd0b02e020d31d0cf7ed2c6ccd0fd77082d0b062 [file] [log] [blame]
Dmitry V. Levinab21a942014-12-28 18:15:25 +00001#ifndef DO_PRINTSTAT
2# define DO_PRINTSTAT do_printstat
3#endif
4
5#ifndef STRUCT_STAT
6# define STRUCT_STAT struct stat
7#endif
8
Dmitry V. Levine6e475c2015-01-08 03:13:59 +00009#ifndef STAT_MAJOR
10# define STAT_MAJOR(x) major(x)
11#endif
12
13#ifndef STAT_MINOR
14# define STAT_MINOR(x) minor(x)
15#endif
16
Dmitry V. Levinab21a942014-12-28 18:15:25 +000017static void
18DO_PRINTSTAT(struct tcb *tcp, const STRUCT_STAT *statbuf)
19{
20 if (!abbrev(tcp)) {
21 tprintf("{st_dev=makedev(%u, %u), st_ino=%llu, st_mode=%s, ",
Dmitry V. Levine6e475c2015-01-08 03:13:59 +000022 (unsigned int) STAT_MAJOR(statbuf->st_dev),
23 (unsigned int) STAT_MINOR(statbuf->st_dev),
Dmitry V. Levinab21a942014-12-28 18:15:25 +000024 (unsigned long long) statbuf->st_ino,
25 sprintmode(statbuf->st_mode));
26 tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ",
27 (unsigned int) statbuf->st_nlink,
28 (unsigned int) statbuf->st_uid,
29 (unsigned int) statbuf->st_gid);
30#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
31 tprintf("st_blksize=%u, ", (unsigned int) statbuf->st_blksize);
32#endif
33#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
34 tprintf("st_blocks=%llu, ",
35 (unsigned long long) statbuf->st_blocks);
36#endif
37 } else {
38 tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
39 }
40
41 switch (statbuf->st_mode & S_IFMT) {
42 case S_IFCHR: case S_IFBLK:
43#ifdef HAVE_STRUCT_STAT_ST_RDEV
44 tprintf("st_rdev=makedev(%u, %u), ",
Dmitry V. Levine6e475c2015-01-08 03:13:59 +000045 (unsigned int) STAT_MAJOR(statbuf->st_rdev),
46 (unsigned int) STAT_MINOR(statbuf->st_rdev));
Dmitry V. Levinab21a942014-12-28 18:15:25 +000047#else /* !HAVE_STRUCT_STAT_ST_RDEV */
48 tprintf("st_size=makedev(%u, %u), ",
Dmitry V. Levine6e475c2015-01-08 03:13:59 +000049 (unsigned int) STAT_MAJOR(statbuf->st_size),
50 (unsigned int) STAT_MINOR(statbuf->st_size));
Dmitry V. Levinab21a942014-12-28 18:15:25 +000051#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
52 break;
53 default:
54 tprintf("st_size=%llu, ",
55 (unsigned long long) statbuf->st_size);
56 break;
57 }
58
59 if (!abbrev(tcp)) {
60 tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
61 tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
62 tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
63#if HAVE_STRUCT_STAT_ST_FLAGS
64 tprintf(", st_flags=%u", (unsigned int) statbuf->st_flags);
65#endif
66#if HAVE_STRUCT_STAT_ST_FSTYPE
67 tprintf(", st_fstype=%.*s",
68 (int) sizeof statbuf->st_fstype, statbuf->st_fstype);
69#endif
70#if HAVE_STRUCT_STAT_ST_GEN
71 tprintf(", st_gen=%u", (unsigned int) statbuf->st_gen);
72#endif
73 tprints("}");
74 } else {
75 tprints("...}");
76 }
77}
78
Dmitry V. Levine6e475c2015-01-08 03:13:59 +000079#undef STAT_MINOR
80#undef STAT_MAJOR
Dmitry V. Levinab21a942014-12-28 18:15:25 +000081#undef STRUCT_STAT
82#undef DO_PRINTSTAT