]> granicus.if.org Git - strace/blob - statx.c
Add support for long options
[strace] / statx.c
1 /*
2  * Copyright (c) 2017-2019 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                 tprints(", ");
23                 printpath(tcp, tcp->u_arg[1]);
24                 tprints(", ");
25
26                 unsigned int flags = tcp->u_arg[2];
27                 printflags(at_statx_sync_types, flags & AT_STATX_SYNC_TYPE,
28                            NULL);
29                 flags &= ~AT_STATX_SYNC_TYPE;
30                 if (flags) {
31                         tprints("|");
32                         printflags(at_flags, flags, NULL);
33                 }
34
35                 tprints(", ");
36                 printflags(statx_masks, tcp->u_arg[3], "STATX_???");
37                 tprints(", ");
38         } else {
39 #define PRINT_FIELD_TIME(field)                                         \
40         do {                                                            \
41                 tprintf(", " #field "={tv_sec=%" PRId64                 \
42                         ", tv_nsec=%" PRIu32 "}",                       \
43                         stx.field.sec, stx.field.nsec);                 \
44                 tprints_comment(sprinttime_nsec(stx.field.sec,          \
45                         zero_extend_signed_to_ull(stx.field.nsec)));    \
46         } while (0)
47
48                 struct_statx stx;
49                 if (umove_or_printaddr(tcp, tcp->u_arg[4], &stx))
50                         return 0;
51
52                 tprints("{stx_mask=");
53                 printflags(statx_masks, stx.stx_mask, "STATX_???");
54
55                 if (!abbrev(tcp))
56                         PRINT_FIELD_U(", ", stx, stx_blksize);
57
58                 tprints(", stx_attributes=");
59                 printflags(statx_attrs, stx.stx_attributes, "STATX_ATTR_???");
60
61                 if (!abbrev(tcp)) {
62                         PRINT_FIELD_U(", ", stx, stx_nlink);
63                         printuid(", stx_uid=", stx.stx_uid);
64                         printuid(", stx_gid=", stx.stx_gid);
65                 }
66
67                 tprints(", stx_mode=");
68                 print_symbolic_mode_t(stx.stx_mode);
69
70                 if (!abbrev(tcp))
71                         PRINT_FIELD_U(", ", stx, stx_ino);
72
73                 PRINT_FIELD_U(", ", stx, stx_size);
74
75                 if (!abbrev(tcp)) {
76                         PRINT_FIELD_U(", ", stx, stx_blocks);
77
78                         tprints(", stx_attributes_mask=");
79                         printflags(statx_attrs, stx.stx_attributes_mask,
80                                    "STATX_ATTR_???");
81
82                         PRINT_FIELD_TIME(stx_atime);
83                         PRINT_FIELD_TIME(stx_btime);
84                         PRINT_FIELD_TIME(stx_ctime);
85                         PRINT_FIELD_TIME(stx_mtime);
86                         PRINT_FIELD_U(", ", stx, stx_rdev_major);
87                         PRINT_FIELD_U(", ", stx, stx_rdev_minor);
88                         PRINT_FIELD_U(", ", stx, stx_dev_major);
89                         PRINT_FIELD_U(", ", stx, stx_dev_minor);
90                 } else {
91                         tprints(", ...");
92                 }
93                 tprints("}");
94         }
95         return 0;
96 }