tools/testing/selftests/namespaces/init_ino_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/namespaces/init_ino_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/namespaces/init_ino_test.c- Extension
.c- Size
- 1715 bytes
- Lines
- 62
- 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
fcntl.hstdio.hstdlib.hsys/stat.hunistd.herrno.hstring.hlinux/nsfs.hkselftest_harness.h
Detected Declarations
struct ns_info
Annotated Snippet
struct ns_info {
const char *name;
const char *proc_path;
unsigned int expected_ino;
};
static struct ns_info namespaces[] = {
{ "ipc", "/proc/1/ns/ipc", IPC_NS_INIT_INO },
{ "uts", "/proc/1/ns/uts", UTS_NS_INIT_INO },
{ "user", "/proc/1/ns/user", USER_NS_INIT_INO },
{ "pid", "/proc/1/ns/pid", PID_NS_INIT_INO },
{ "cgroup", "/proc/1/ns/cgroup", CGROUP_NS_INIT_INO },
{ "time", "/proc/1/ns/time", TIME_NS_INIT_INO },
{ "net", "/proc/1/ns/net", NET_NS_INIT_INO },
{ "mnt", "/proc/1/ns/mnt", MNT_NS_INIT_INO },
};
TEST(init_namespace_inodes)
{
struct stat st;
for (int i = 0; i < sizeof(namespaces) / sizeof(namespaces[0]); i++) {
int ret = stat(namespaces[i].proc_path, &st);
/* Some namespaces might not be available (e.g., time namespace on older kernels) */
if (ret < 0) {
if (errno == ENOENT) {
ksft_test_result_skip("%s namespace not available\n",
namespaces[i].name);
continue;
}
ASSERT_GE(ret, 0)
TH_LOG("Failed to stat %s: %s",
namespaces[i].proc_path, strerror(errno));
}
ASSERT_EQ(st.st_ino, namespaces[i].expected_ino)
TH_LOG("Namespace %s has inode 0x%lx, expected 0x%x",
namespaces[i].name, st.st_ino, namespaces[i].expected_ino);
ksft_print_msg("Namespace %s: inode 0x%lx matches expected 0x%x\n",
namespaces[i].name, st.st_ino, namespaces[i].expected_ino);
}
}
TEST_HARNESS_MAIN
Annotation
- Immediate include surface: `fcntl.h`, `stdio.h`, `stdlib.h`, `sys/stat.h`, `unistd.h`, `errno.h`, `string.h`, `linux/nsfs.h`.
- Detected declarations: `struct ns_info`.
- 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.