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.

Dependency Surface

Detected Declarations

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

Implementation Notes