1// SPDX-License-Identifier: GPL-2.0
2
3#include <linux/bpf.h>
4#include <bpf/bpf_helpers.h>
5
6struct {
7 __uint(type, BPF_MAP_TYPE_ARRAY);
8 __uint(max_entries, 1);
9 __type(key, __u32);
10 __type(value, __u64);
11 __uint(pinning, LIBBPF_PIN_BY_NAME);
12} pinmap SEC(".maps");
13
14struct {
15 __uint(type, BPF_MAP_TYPE_HASH);
16 __uint(max_entries, 1);
17 __type(key, __u32);
18 __type(value, __u64);
19} nopinmap SEC(".maps");
20
21struct {
22 __uint(type, BPF_MAP_TYPE_HASH);
23 __uint(max_entries, 1);
24 __type(key, __u32);
25 __type(value, __u64);
26 __uint(pinning, LIBBPF_PIN_NONE);
27} nopinmap2 SEC(".maps");
28
29char _license[] SEC("license") = "GPL";
30

source code of linux/tools/testing/selftests/bpf/progs/test_pinning.c