]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blob - tools/perf/trace/beauty/flock.c
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-kernels.git] / tools / perf / trace / beauty / flock.c
1 // SPDX-License-Identifier: GPL-2.0
2 #include <fcntl.h>
3
4 #ifndef LOCK_MAND
5 #define LOCK_MAND 32
6 #endif
7
8 #ifndef LOCK_READ
9 #define LOCK_READ 64
10 #endif
11
12 #ifndef LOCK_WRITE
13 #define LOCK_WRITE 128
14 #endif
15
16 #ifndef LOCK_RW
17 #define LOCK_RW 192
18 #endif
19
20 static size_t syscall_arg__scnprintf_flock(char *bf, size_t size,
21 struct syscall_arg *arg)
22 {
23 int printed = 0, op = arg->val;
24
25 if (op == 0)
26 return scnprintf(bf, size, "NONE");
27 #define P_CMD(cmd) \
28 if ((op & LOCK_##cmd) == LOCK_##cmd) { \
29 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #cmd); \
30 op &= ~LOCK_##cmd; \
31 }
32
33 P_CMD(SH);
34 P_CMD(EX);
35 P_CMD(NB);
36 P_CMD(UN);
37 P_CMD(MAND);
38 P_CMD(RW);
39 P_CMD(READ);
40 P_CMD(WRITE);
41 #undef P_OP
42
43 if (op)
44 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", op);
45
46 return printed;
47 }
48
49 #define SCA_FLOCK syscall_arg__scnprintf_flock