]> granicus.if.org Git - strace/blob - statx.c
Update copyright headers
[strace] / statx.c
1 /*
2  * Copyright (c) 2017-2018 The strace developers.
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: LGPL-2.1-or-later
6  */
7
8 #include "defs.h"
9 #include "print_fields.h"
10 #include "statx.h"
11
12 #include <sys/stat.h>
13
14 #include "xlat/statx_masks.h"
15 #include "xlat/statx_attrs.h"
16 #include "xlat/at_statx_sync_types.h"
17
18 SYS_FUNC(statx)
19 {
20         if (entering(tcp)) {
21                 print_dirfd(tcp, tcp->u_arg[0]);
22                 printpath(tcp, tcp->u_arg[1]);
23                 tprints(", ");
24
25                 unsigned int flags = tcp->u_arg[2];
26                 printflags(at_statx_sync_types, flags & AT_STATX_SYNC_TYPE,
27                            NULL);
28                 flags &= ~AT_STATX_SYNC_TYPE;
29                 if (flags) {
30                         tprints("|");
31                         printflags(at_flags, flags, NULL);
32                 }
33
34                 tprints(", ");
35                 printflags(statx_masks, tcp->u_arg[3], "STATX_???");
36                 tprints(", ");
37         } else {
38 #define PRINT_FIELD_TIME(field)                                         \
39         do {                                                            \
40                 tprintf(", " #field "={tv_sec=%" PRId64                 \
41                         ", tv_nsec=%" PRIu32 "}",                       \
42                         stx.field.sec, stx.field.nsec);                 \
43                 tprints_comment(sprinttime_nsec(stx.field.sec,          \
44                         zero_extend_signed_to_ull(stx.field.nsec)));    \
45         } while (0)
46
47                 struct_statx stx;
48                 if (umove_or_printaddr(tcp, tcp->u_arg[4], &stx))
49                         return 0;
50
51                 tprints("{stx_mask=");
52                 printflags(statx_masks, stx.stx_mask, "STATX_???");
53
54                 if (!abbrev(tcp))
55                         PRINT_FIELD_U(", ", stx, stx_blksize);
56
57                 tprints(", stx_attributes=");
58                 printflags(statx_attrs, stx.stx_attributes, "STATX_ATTR_???");
59
60                 if (!abbrev(tcp)) {
61                         PRINT_FIELD_U(", ", stx, stx_nlink);
62                         printuid(", stx_uid=", stx.stx_uid);
63                         printuid(", stx_gid=", stx.stx_gid);
64                 }
65
66                 tprints(", stx_mode=");
67                 print_symbolic_mode_t(stx.stx_mode);
68
69                 if (!abbrev(tcp))
70                         PRINT_FIELD_U(", ", stx, stx_ino);
71
72                 PRINT_FIELD_U(", ", stx, stx_size);
73
74                 if (!abbrev(tcp)) {
75                         PRINT_FIELD_U(", ", stx, stx_blocks);
76
77                         tprints(", stx_attributes_mask=");
78                         printflags(statx_attrs, stx.stx_attributes_mask,
79                                    "STATX_ATTR_???");
80
81                         PRINT_FIELD_TIME(stx_atime);
82                         PRINT_FIELD_TIME(stx_btime);
83                         PRINT_FIELD_TIME(stx_ctime);
84                         PRINT_FIELD_TIME(stx_mtime);
85                         PRINT_FIELD_U(", ", stx, stx_rdev_major);
86                         PRINT_FIELD_U(", ", stx, stx_rdev_minor);
87                         PRINT_FIELD_U(", ", stx, stx_dev_major);
88                         PRINT_FIELD_U(", ", stx, stx_dev_minor);
89                 } else {
90                         tprints(", ...");
91                 }
92                 tprints("}");
93         }
94         return 0;
95 }