tools/testing/selftests/filesystems/fsmount_ns/fsmount_ns_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/filesystems/fsmount_ns/fsmount_ns_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/filesystems/fsmount_ns/fsmount_ns_test.c- Extension
.c- Size
- 24466 bytes
- Lines
- 1136
- 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 create_tmpfs_fdfunction ASSERT_GE
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);
}
}
static int create_tmpfs_fd(void)
{
int fs_fd, ret;
fs_fd = sys_fsopen("tmpfs", FSOPEN_CLOEXEC);
if (fs_fd < 0)
return -errno;
ret = sys_fsconfig(fs_fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0);
if (ret < 0) {
close(fs_fd);
return -errno;
}
return fs_fd;
}
FIXTURE(fsmount_ns)
{
int fd;
int fs_fd;
uint64_t current_ns_id;
};
FIXTURE_VARIANT(fsmount_ns)
{
const char *fstype;
unsigned int flags;
bool expect_success;
bool expect_different_ns;
int min_mounts;
};
FIXTURE_VARIANT_ADD(fsmount_ns, basic_tmpfs)
{
.fstype = "tmpfs",
.flags = FSMOUNT_NAMESPACE | FSMOUNT_CLOEXEC,
.expect_success = true,
.expect_different_ns = true,
.min_mounts = 1,
};
FIXTURE_VARIANT_ADD(fsmount_ns, cloexec_only)
{
.fstype = "tmpfs",
.flags = FSMOUNT_CLOEXEC,
.expect_success = true,
.expect_different_ns = false,
.min_mounts = 1,
};
FIXTURE_VARIANT_ADD(fsmount_ns, namespace_only)
{
.fstype = "tmpfs",
.flags = FSMOUNT_NAMESPACE,
.expect_success = true,
.expect_different_ns = true,
.min_mounts = 1,
};
FIXTURE_SETUP(fsmount_ns)
{
int ret;
self->fd = -1;
self->fs_fd = -1;
/* Check if fsopen syscall is supported */
ret = sys_fsopen("tmpfs", 0);
if (ret == -1 && errno == ENOSYS)
SKIP(return, "fsopen() syscall not supported");
if (ret >= 0)
close(ret);
/* Check if statmount/listmount are supported */
ret = statmount(0, 0, 0, 0, NULL, 0, 0);
if (ret == -1 && errno == ENOSYS)
SKIP(return, "statmount() syscall not supported");
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 create_tmpfs_fd`, `function ASSERT_GE`.
- 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.