blob: c78b173d4be43007c73e206be6068cda59929244 [file] [log] [blame]
Elliott Hughes39bac052017-05-25 16:56:11 -07001/*
2 * Copyright (c) 2017 The strace developers.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include "defs.h"
Elliott Hughesdc75b012017-07-05 13:54:44 -070029#include "print_fields.h"
Elliott Hughes39bac052017-05-25 16:56:11 -070030#include "statx.h"
31
32#include <sys/stat.h>
33
34#include "xlat/statx_masks.h"
35#include "xlat/statx_attrs.h"
36#include "xlat/at_statx_sync_types.h"
37
38SYS_FUNC(statx)
39{
40 if (entering(tcp)) {
41 print_dirfd(tcp, tcp->u_arg[0]);
42 printpath(tcp, tcp->u_arg[1]);
43 tprints(", ");
44
45 unsigned int flags = tcp->u_arg[2];
46 printflags(at_statx_sync_types, flags & AT_STATX_SYNC_TYPE,
47 NULL);
48 flags &= ~AT_STATX_SYNC_TYPE;
49 if (flags) {
50 tprints("|");
51 printflags(at_flags, flags, NULL);
52 }
53
54 tprints(", ");
55 printflags(statx_masks, tcp->u_arg[3], "STATX_???");
56 tprints(", ");
57 } else {
Elliott Hughes39bac052017-05-25 16:56:11 -070058#define PRINT_FIELD_TIME(field) \
59 do { \
60 tprintf(", " #field "={tv_sec=%" PRId64 \
61 ", tv_nsec=%" PRIu32 "}", \
62 stx.field.sec, stx.field.nsec); \
63 tprints_comment(sprinttime_nsec(stx.field.sec, \
64 zero_extend_signed_to_ull(stx.field.nsec))); \
65 } while (0)
66
67 struct_statx stx;
68 if (umove_or_printaddr(tcp, tcp->u_arg[4], &stx))
69 return 0;
70
71 tprints("{stx_mask=");
72 printflags(statx_masks, stx.stx_mask, "STATX_???");
73
74 if (!abbrev(tcp))
Elliott Hughesdc75b012017-07-05 13:54:44 -070075 PRINT_FIELD_U(", ", stx, stx_blksize);
Elliott Hughes39bac052017-05-25 16:56:11 -070076
77 tprints(", stx_attributes=");
78 printflags(statx_attrs, stx.stx_attributes, "STATX_ATTR_???");
79
80 if (!abbrev(tcp)) {
Elliott Hughesdc75b012017-07-05 13:54:44 -070081 PRINT_FIELD_U(", ", stx, stx_nlink);
Elliott Hughes39bac052017-05-25 16:56:11 -070082 printuid(", stx_uid=", stx.stx_uid);
83 printuid(", stx_gid=", stx.stx_gid);
84 }
85
86 tprints(", stx_mode=");
87 print_symbolic_mode_t(stx.stx_mode);
88
89 if (!abbrev(tcp))
Elliott Hughesdc75b012017-07-05 13:54:44 -070090 PRINT_FIELD_U(", ", stx, stx_ino);
Elliott Hughes39bac052017-05-25 16:56:11 -070091
Elliott Hughesdc75b012017-07-05 13:54:44 -070092 PRINT_FIELD_U(", ", stx, stx_size);
Elliott Hughes39bac052017-05-25 16:56:11 -070093
94 if (!abbrev(tcp)) {
Elliott Hughesdc75b012017-07-05 13:54:44 -070095 PRINT_FIELD_U(", ", stx, stx_blocks);
Elliott Hughes39bac052017-05-25 16:56:11 -070096
97 tprints(", stx_attributes_mask=");
98 printflags(statx_attrs, stx.stx_attributes_mask,
99 "STATX_ATTR_???");
100
101 PRINT_FIELD_TIME(stx_atime);
102 PRINT_FIELD_TIME(stx_btime);
103 PRINT_FIELD_TIME(stx_ctime);
104 PRINT_FIELD_TIME(stx_mtime);
Elliott Hughesdc75b012017-07-05 13:54:44 -0700105 PRINT_FIELD_U(", ", stx, stx_rdev_major);
106 PRINT_FIELD_U(", ", stx, stx_rdev_minor);
107 PRINT_FIELD_U(", ", stx, stx_dev_major);
108 PRINT_FIELD_U(", ", stx, stx_dev_minor);
Elliott Hughes39bac052017-05-25 16:56:11 -0700109 } else {
110 tprints(", ...");
111 }
112 tprints("}");
113 }
114 return 0;
115}