tools/testing/selftests/filesystems/statmount/statmount_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/filesystems/statmount/statmount_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/filesystems/statmount/statmount_test.c- Extension
.c- Size
- 21631 bytes
- Lines
- 895
- 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
assert.hstddef.hsched.hfcntl.hsys/param.hsys/mount.hsys/stat.hsys/statfs.hlinux/stat.hstatmount.hkselftest.h
Detected Declarations
function write_filefunction get_mnt_idfunction cleanup_namespacefunction setup_namespacefunction setup_mount_treefunction test_listmount_empty_rootfunction test_statmount_zero_maskfunction test_statmount_mnt_basicfunction test_statmount_sb_basicfunction test_statmount_mnt_pointfunction test_statmount_mnt_rootfunction test_statmount_fs_typefunction test_statmount_mnt_optsfunction test_statmount_stringfunction test_listmount_treefunction test_statmount_by_fdfunction test_statmount_by_fd_unmountedfunction main
Annotated Snippet
if (ret == -1) {
ksft_test_result_fail("mounting submount %s: %s\n",
root_mntpoint, strerror(errno));
return -1;
}
}
return 0;
}
static void test_listmount_empty_root(void)
{
ssize_t res;
const unsigned int size = 32;
uint64_t list[size];
res = listmount(LSMT_ROOT, 0, 0, list, size, 0);
if (res == -1) {
ksft_test_result_fail("listmount: %s\n", strerror(errno));
return;
}
if (res != 1) {
ksft_test_result_fail("listmount result is %zi != 1\n", res);
return;
}
if (list[0] != root_id) {
ksft_test_result_fail("listmount ID doesn't match 0x%llx != 0x%llx\n",
(unsigned long long) list[0],
(unsigned long long) root_id);
return;
}
ksft_test_result_pass("listmount empty root\n");
}
static void test_statmount_zero_mask(void)
{
struct statmount sm;
int ret;
ret = statmount(root_id, 0, 0, 0, &sm, sizeof(sm), 0);
if (ret == -1) {
ksft_test_result_fail("statmount zero mask: %s\n",
strerror(errno));
return;
}
if (sm.size != sizeof(sm)) {
ksft_test_result_fail("unexpected size: %u != %u\n",
sm.size, (uint32_t) sizeof(sm));
return;
}
if (sm.mask != 0) {
ksft_test_result_fail("unexpected mask: 0x%llx != 0x0\n",
(unsigned long long) sm.mask);
return;
}
ksft_test_result_pass("statmount zero mask\n");
}
static void test_statmount_mnt_basic(void)
{
struct statmount sm;
int ret;
uint64_t mask = STATMOUNT_MNT_BASIC;
ret = statmount(root_id, 0, 0, mask, &sm, sizeof(sm), 0);
if (ret == -1) {
ksft_test_result_fail("statmount mnt basic: %s\n",
strerror(errno));
return;
}
if (sm.size != sizeof(sm)) {
ksft_test_result_fail("unexpected size: %u != %u\n",
sm.size, (uint32_t) sizeof(sm));
return;
}
if (sm.mask != mask) {
ksft_test_result_skip("statmount mnt basic unavailable\n");
return;
}
if (sm.mnt_id != root_id) {
ksft_test_result_fail("unexpected root ID: 0x%llx != 0x%llx\n",
(unsigned long long) sm.mnt_id,
(unsigned long long) root_id);
return;
}
if (sm.mnt_id_old != old_root_id) {
Annotation
- Immediate include surface: `assert.h`, `stddef.h`, `sched.h`, `fcntl.h`, `sys/param.h`, `sys/mount.h`, `sys/stat.h`, `sys/statfs.h`.
- Detected declarations: `function write_file`, `function get_mnt_id`, `function cleanup_namespace`, `function setup_namespace`, `function setup_mount_tree`, `function test_listmount_empty_root`, `function test_statmount_zero_mask`, `function test_statmount_mnt_basic`, `function test_statmount_sb_basic`, `function test_statmount_mnt_point`.
- 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.