tools/testing/selftests/prctl/set-anon-vma-name-test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/prctl/set-anon-vma-name-test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/prctl/set-anon-vma-name-test.c- Extension
.c- Size
- 2666 bytes
- Lines
- 105
- 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.
Dependency Surface
errno.hsys/prctl.hstdio.hstdlib.hsys/mman.hstring.hkselftest_harness.h
Detected Declarations
function rename_vmafunction was_renaming_successful
Annotated Snippet
if (sscanf_res == EOF) {
res = 0;
printf("## EOF while parsing the maps file\n");
break;
}
if (!strcmp(name, target_buf) && start_addr == ptr) {
res = 1;
break;
}
}
fclose(maps_file);
return res;
}
FIXTURE(vma) {
void *ptr_anon, *ptr_not_anon;
};
FIXTURE_SETUP(vma) {
self->ptr_anon = mmap(NULL, AREA_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
ASSERT_NE(self->ptr_anon, NULL);
self->ptr_not_anon = mmap(NULL, AREA_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE, 0, 0);
ASSERT_NE(self->ptr_not_anon, NULL);
}
FIXTURE_TEARDOWN(vma) {
munmap(self->ptr_anon, AREA_SIZE);
munmap(self->ptr_not_anon, AREA_SIZE);
}
TEST_F(vma, renaming) {
TH_LOG("Try to rename the VMA with correct parameters");
EXPECT_GE(rename_vma((unsigned long)self->ptr_anon, AREA_SIZE, GOOD_NAME), 0);
EXPECT_TRUE(was_renaming_successful(GOOD_NAME, (unsigned long)self->ptr_anon));
TH_LOG("Try to pass invalid name (with non-printable character \\1) to rename the VMA");
EXPECT_EQ(rename_vma((unsigned long)self->ptr_anon, AREA_SIZE, BAD_NAME), -EINVAL);
TH_LOG("Try to rename non-anonymous VMA");
EXPECT_EQ(rename_vma((unsigned long) self->ptr_not_anon, AREA_SIZE, GOOD_NAME), -EINVAL);
}
TEST_HARNESS_MAIN
Annotation
- Immediate include surface: `errno.h`, `sys/prctl.h`, `stdio.h`, `stdlib.h`, `sys/mman.h`, `string.h`, `kselftest_harness.h`.
- Detected declarations: `function rename_vma`, `function was_renaming_successful`.
- 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.