This source file includes following definitions.
- strarray__scnprintf_flags
- pkey_alloc__scnprintf_access_rights
- syscall_arg__scnprintf_pkey_alloc_access_rights
1
2
3
4
5
6
7
8 #include "trace/beauty/beauty.h"
9 #include <linux/kernel.h>
10 #include <linux/log2.h>
11
12 size_t strarray__scnprintf_flags(struct strarray *sa, char *bf, size_t size, bool show_prefix, unsigned long flags)
13 {
14 int i, printed = 0;
15
16 if (flags == 0) {
17 const char *s = sa->entries[0];
18 if (s)
19 return scnprintf(bf, size, "%s%s", show_prefix ? sa->prefix : "", s);
20 return scnprintf(bf, size, "%d", 0);
21 }
22
23 for (i = 1; i < sa->nr_entries; ++i) {
24 unsigned long bit = 1UL << (i - 1);
25
26 if (!(flags & bit))
27 continue;
28
29 if (printed != 0)
30 printed += scnprintf(bf + printed, size - printed, "|");
31
32 if (sa->entries[i] != NULL)
33 printed += scnprintf(bf + printed, size - printed, "%s%s", show_prefix ? sa->prefix : "", sa->entries[i]);
34 else
35 printed += scnprintf(bf + printed, size - printed, "0x%#", bit);
36 }
37
38 return printed;
39 }
40
41 static size_t pkey_alloc__scnprintf_access_rights(int access_rights, char *bf, size_t size, bool show_prefix)
42 {
43 #include "trace/beauty/generated/pkey_alloc_access_rights_array.c"
44 static DEFINE_STRARRAY(pkey_alloc_access_rights, "PKEY_");
45
46 return strarray__scnprintf_flags(&strarray__pkey_alloc_access_rights, bf, size, show_prefix, access_rights);
47 }
48
49 size_t syscall_arg__scnprintf_pkey_alloc_access_rights(char *bf, size_t size, struct syscall_arg *arg)
50 {
51 unsigned long cmd = arg->val;
52
53 return pkey_alloc__scnprintf_access_rights(cmd, bf, size, arg->show_string_prefix);
54 }