tools/testing/selftests/bpf/prog_tests/pinning_devmap_reuse.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/pinning_devmap_reuse.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/pinning_devmap_reuse.c- Extension
.c- Size
- 1284 bytes
- Lines
- 51
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
sys/types.hsys/stat.hunistd.htest_progs.htest_pinning_devmap.skel.h
Detected Declarations
function test_pinning_devmap_reuse
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <test_progs.h>
#include "test_pinning_devmap.skel.h"
void test_pinning_devmap_reuse(void)
{
const char *pinpath1 = "/sys/fs/bpf/pinmap1";
const char *pinpath2 = "/sys/fs/bpf/pinmap2";
struct test_pinning_devmap *skel1 = NULL, *skel2 = NULL;
int err;
DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts);
/* load the object a first time */
skel1 = test_pinning_devmap__open_and_load();
if (!ASSERT_OK_PTR(skel1, "skel_load1"))
goto out;
/* load the object a second time, re-using the pinned map */
skel2 = test_pinning_devmap__open_and_load();
if (!ASSERT_OK_PTR(skel2, "skel_load2"))
goto out;
/* we can close the reference safely without
* the map's refcount falling to 0
*/
test_pinning_devmap__destroy(skel1);
skel1 = NULL;
/* now, swap the pins */
err = renameat2(0, pinpath1, 0, pinpath2, RENAME_EXCHANGE);
if (!ASSERT_OK(err, "swap pins"))
goto out;
/* load the object again, this time the re-use should fail */
skel1 = test_pinning_devmap__open_and_load();
if (!ASSERT_ERR_PTR(skel1, "skel_load3"))
goto out;
out:
unlink(pinpath1);
unlink(pinpath2);
test_pinning_devmap__destroy(skel1);
test_pinning_devmap__destroy(skel2);
}
Annotation
- Immediate include surface: `sys/types.h`, `sys/stat.h`, `unistd.h`, `test_progs.h`, `test_pinning_devmap.skel.h`.
- Detected declarations: `function test_pinning_devmap_reuse`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.