Merge tag 'ntb-5.11' of git://github.com/jonmason/ntb
[linux/fpc-iii.git] / tools / perf / trace / beauty / statx.c
blob110f0c609d840eec5824158459c6fe34af897389
1 // SPDX-License-Identifier: LGPL-2.1
2 /*
3 * trace/beauty/statx.c
5 * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
6 */
8 #include "trace/beauty/beauty.h"
9 #include <linux/kernel.h>
10 #include <sys/types.h>
11 #include <uapi/linux/fcntl.h>
12 #include <uapi/linux/stat.h>
14 size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_arg *arg)
16 bool show_prefix = arg->show_string_prefix;
17 const char *prefix = "AT_";
18 int printed = 0, flags = arg->val;
20 if (flags == 0)
21 return scnprintf(bf, size, "%s%s", show_prefix ? "AT_STATX_" : "", "SYNC_AS_STAT");
22 #define P_FLAG(n) \
23 if (flags & AT_##n) { \
24 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
25 flags &= ~AT_##n; \
28 P_FLAG(SYMLINK_NOFOLLOW);
29 P_FLAG(REMOVEDIR);
30 P_FLAG(SYMLINK_FOLLOW);
31 P_FLAG(NO_AUTOMOUNT);
32 P_FLAG(EMPTY_PATH);
33 P_FLAG(STATX_FORCE_SYNC);
34 P_FLAG(STATX_DONT_SYNC);
36 #undef P_FLAG
38 if (flags)
39 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
41 return printed;
44 size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg)
46 bool show_prefix = arg->show_string_prefix;
47 const char *prefix = "STATX_";
48 int printed = 0, flags = arg->val;
50 #define P_FLAG(n) \
51 if (flags & STATX_##n) { \
52 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
53 flags &= ~STATX_##n; \
56 P_FLAG(TYPE);
57 P_FLAG(MODE);
58 P_FLAG(NLINK);
59 P_FLAG(UID);
60 P_FLAG(GID);
61 P_FLAG(ATIME);
62 P_FLAG(MTIME);
63 P_FLAG(CTIME);
64 P_FLAG(INO);
65 P_FLAG(SIZE);
66 P_FLAG(BLOCKS);
67 P_FLAG(BTIME);
68 P_FLAG(MNT_ID);
70 #undef P_FLAG
72 if (flags)
73 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
75 return printed;