1 // SPDX-License-Identifier: LGPL-2.1
3 * trace/beauty/pkey_alloc.c
5 * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
8 #include "trace/beauty/beauty.h"
9 #include <linux/kernel.h>
10 #include <linux/log2.h>
12 size_t strarray__scnprintf_flags(struct strarray
*sa
, char *bf
, size_t size
, bool show_prefix
, unsigned long flags
)
17 const char *s
= sa
->entries
[0];
19 return scnprintf(bf
, size
, "%s%s", show_prefix
? sa
->prefix
: "", s
);
20 return scnprintf(bf
, size
, "%d", 0);
23 for (i
= 1; i
< sa
->nr_entries
; ++i
) {
24 unsigned long bit
= 1UL << (i
- 1);
30 printed
+= scnprintf(bf
+ printed
, size
- printed
, "|");
32 if (sa
->entries
[i
] != NULL
)
33 printed
+= scnprintf(bf
+ printed
, size
- printed
, "%s%s", show_prefix
? sa
->prefix
: "", sa
->entries
[i
]);
35 printed
+= scnprintf(bf
+ printed
, size
- printed
, "0x%#", bit
);
41 static size_t pkey_alloc__scnprintf_access_rights(int access_rights
, char *bf
, size_t size
, bool show_prefix
)
43 #include "trace/beauty/generated/pkey_alloc_access_rights_array.c"
44 static DEFINE_STRARRAY(pkey_alloc_access_rights
, "PKEY_");
46 return strarray__scnprintf_flags(&strarray__pkey_alloc_access_rights
, bf
, size
, show_prefix
, access_rights
);
49 size_t syscall_arg__scnprintf_pkey_alloc_access_rights(char *bf
, size_t size
, struct syscall_arg
*arg
)
51 unsigned long cmd
= arg
->val
;
53 return pkey_alloc__scnprintf_access_rights(cmd
, bf
, size
, arg
->show_string_prefix
);