Linux Perf
statx.c
Go to the documentation of this file.
1 /*
2  * trace/beauty/statx.c
3  *
4  * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
5  *
6  * Released under the GPL v2. (and only v2, not any later version)
7  */
8 
9 #include "trace/beauty/beauty.h"
10 #include <linux/kernel.h>
11 #include <sys/types.h>
12 #include <uapi/linux/fcntl.h>
13 #include <uapi/linux/stat.h>
14 
15 size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_arg *arg)
16 {
17  int printed = 0, flags = arg->val;
18 
19  if (flags == 0)
20  return scnprintf(bf, size, "SYNC_AS_STAT");
21 #define P_FLAG(n) \
22  if (flags & AT_##n) { \
23  printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
24  flags &= ~AT_##n; \
25  }
26 
27  P_FLAG(SYMLINK_NOFOLLOW);
28  P_FLAG(REMOVEDIR);
29  P_FLAG(SYMLINK_FOLLOW);
30  P_FLAG(NO_AUTOMOUNT);
31  P_FLAG(EMPTY_PATH);
32  P_FLAG(STATX_FORCE_SYNC);
33  P_FLAG(STATX_DONT_SYNC);
34 
35 #undef P_FLAG
36 
37  if (flags)
38  printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
39 
40  return printed;
41 }
42 
43 size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg)
44 {
45  int printed = 0, flags = arg->val;
46 
47 #define P_FLAG(n) \
48  if (flags & STATX_##n) { \
49  printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
50  flags &= ~STATX_##n; \
51  }
52 
53  P_FLAG(TYPE);
54  P_FLAG(MODE);
55  P_FLAG(NLINK);
56  P_FLAG(UID);
57  P_FLAG(GID);
58  P_FLAG(ATIME);
59  P_FLAG(MTIME);
60  P_FLAG(CTIME);
61  P_FLAG(INO);
62  P_FLAG(SIZE);
63  P_FLAG(BLOCKS);
64  P_FLAG(BTIME);
65 
66 #undef P_FLAG
67 
68  if (flags)
69  printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
70 
71  return printed;
72 }
size_t size
Definition: evsel.c:60
size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_arg *arg)
Definition: statx.c:15
unsigned long val
Definition: beauty.h:44
u32 flags
size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg)
Definition: statx.c:43
#define P_FLAG(n)