tools/testing/selftests/filesystems/open_tree_ns/open_tree_ns_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/filesystems/open_tree_ns/open_tree_ns_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/filesystems/open_tree_ns/open_tree_ns_test.c- Extension
.c- Size
- 21641 bytes
- Lines
- 1008
- 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
errno.hfcntl.hlimits.hlinux/nsfs.hsched.hstdio.hstdlib.hstring.hsys/ioctl.hsys/mount.hsys/stat.hsys/wait.hunistd.h../wrappers.h../statmount/statmount.h../utils.h../../kselftest_harness.h
Detected Declarations
function Copyrightfunction get_mnt_ns_id_from_pathfunction log_mountfunction dump_mountsfunction ASSERT_NEfunction ASSERT_FALSE
Annotated Snippet
if (!sm) {
TH_LOG(" [%zd] mnt_id %llu: statmount failed: %s",
i, (unsigned long long)list[i], strerror(errno));
continue;
}
log_mount(_metadata, sm);
free(sm);
}
}
FIXTURE(open_tree_ns)
{
int fd;
uint64_t current_ns_id;
};
FIXTURE_VARIANT(open_tree_ns)
{
const char *path;
unsigned int flags;
bool expect_success;
bool expect_different_ns;
int min_mounts;
};
FIXTURE_VARIANT_ADD(open_tree_ns, basic_root)
{
.path = "/",
.flags = OPEN_TREE_NAMESPACE | OPEN_TREE_CLOEXEC,
.expect_success = true,
.expect_different_ns = true,
/*
* The empty rootfs is hidden from listmount()/mountinfo,
* so we only see the bind mount on top of it.
*/
.min_mounts = 1,
};
FIXTURE_VARIANT_ADD(open_tree_ns, recursive_root)
{
.path = "/",
.flags = OPEN_TREE_NAMESPACE | AT_RECURSIVE | OPEN_TREE_CLOEXEC,
.expect_success = true,
.expect_different_ns = true,
.min_mounts = 1,
};
FIXTURE_VARIANT_ADD(open_tree_ns, subdir_tmp)
{
.path = "/tmp",
.flags = OPEN_TREE_NAMESPACE | OPEN_TREE_CLOEXEC,
.expect_success = true,
.expect_different_ns = true,
.min_mounts = 1,
};
FIXTURE_VARIANT_ADD(open_tree_ns, subdir_proc)
{
.path = "/proc",
.flags = OPEN_TREE_NAMESPACE | OPEN_TREE_CLOEXEC,
.expect_success = true,
.expect_different_ns = true,
.min_mounts = 1,
};
FIXTURE_VARIANT_ADD(open_tree_ns, recursive_tmp)
{
.path = "/tmp",
.flags = OPEN_TREE_NAMESPACE | AT_RECURSIVE | OPEN_TREE_CLOEXEC,
.expect_success = true,
.expect_different_ns = true,
.min_mounts = 1,
};
FIXTURE_VARIANT_ADD(open_tree_ns, recursive_run)
{
.path = "/run",
.flags = OPEN_TREE_NAMESPACE | AT_RECURSIVE | OPEN_TREE_CLOEXEC,
.expect_success = true,
.expect_different_ns = true,
.min_mounts = 1,
};
FIXTURE_VARIANT_ADD(open_tree_ns, invalid_recursive_alone)
{
.path = "/",
.flags = AT_RECURSIVE | OPEN_TREE_CLOEXEC,
.expect_success = false,
.expect_different_ns = false,
Annotation
- Immediate include surface: `errno.h`, `fcntl.h`, `limits.h`, `linux/nsfs.h`, `sched.h`, `stdio.h`, `stdlib.h`, `string.h`.
- Detected declarations: `function Copyright`, `function get_mnt_ns_id_from_path`, `function log_mount`, `function dump_mounts`, `function ASSERT_NE`, `function ASSERT_FALSE`.
- 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.