1// SPDX-License-Identifier: GPL-2.0
2#include <vmlinux.h>
3#include <bpf/bpf_helpers.h>
4
5struct {
6	__uint(type, BPF_MAP_TYPE_ARRAY);
7	__uint(max_entries, 1);
8	__type(key, __u32);
9	__type(value, __u64);
10} array_map SEC(".maps");
11
12static __u64
13check_array_elem(struct bpf_map *map, __u32 *key, __u64 *val,
14		 void *data)
15{
16	bpf_get_current_comm(key, sizeof(*key));
17	return 0;
18}
19
20SEC("raw_tp/sys_enter")
21int test_map_key_write(const void *ctx)
22{
23	bpf_for_each_map_elem(&array_map, check_array_elem, NULL, 0);
24	return 0;
25}
26
27char _license[] SEC("license") = "GPL";
28