tools/testing/selftests/filesystems/binderfs/binderfs_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/filesystems/binderfs/binderfs_test.c- Extension
.c- Size
- 12430 bytes
- Lines
- 542
- 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.hpthread.hsched.hstdbool.hstdio.hstdlib.hstring.hsys/fsuid.hsys/ioctl.hsys/mount.hsys/socket.hsys/stat.hsys/sysinfo.hsys/types.hsys/wait.hunistd.hlinux/android/binder.hlinux/android/binderfs.hkselftest_harness.h
Detected Declarations
enum idmap_typefunction change_mountnsfunction __do_binderfs_testfunction EXPECT_NEfunction EXPECT_GEfunction wait_for_pidfunction setid_userns_rootfunction read_nointrfunction write_nointrfunction write_id_mappingfunction change_usernsfunction ASSERT_EQfunction change_idmapsfunction f0fe2c0f050dfunction ASSERT_NEfunction ASSERT_EQfunction ASSERT_GEfunction ASSERT_EQfunction ASSERT_GEfunction ASSERT_EQfunction ASSERT_EQ
Annotated Snippet
EXPECT_GE(fd, 0) {
TH_LOG("%s - Failed to open binder feature: %s",
strerror(errno), binder_features[i]);
goto umount;
}
close(fd);
}
/* success: binder feature files found */
result = 0;
umount:
ret = umount2(binderfs_mntpt, MNT_DETACH);
EXPECT_EQ(ret, 0) {
TH_LOG("%s - Failed to unmount binderfs", strerror(errno));
}
rmdir:
ret = rmdir(binderfs_mntpt);
EXPECT_EQ(ret, 0) {
TH_LOG("%s - Failed to rmdir binderfs mount", strerror(errno));
}
out:
return result;
}
static int wait_for_pid(pid_t pid)
{
int status, ret;
again:
ret = waitpid(pid, &status, 0);
if (ret == -1) {
if (errno == EINTR)
goto again;
return -1;
}
if (!WIFEXITED(status))
return -1;
return WEXITSTATUS(status);
}
static int setid_userns_root(void)
{
if (setuid(0))
return -1;
if (setgid(0))
return -1;
setfsuid(0);
setfsgid(0);
return 0;
}
enum idmap_type {
UID_MAP,
GID_MAP,
};
static ssize_t read_nointr(int fd, void *buf, size_t count)
{
ssize_t ret;
again:
ret = read(fd, buf, count);
if (ret < 0 && errno == EINTR)
goto again;
return ret;
}
static ssize_t write_nointr(int fd, const void *buf, size_t count)
{
ssize_t ret;
again:
ret = write(fd, buf, count);
if (ret < 0 && errno == EINTR)
goto again;
return ret;
}
static int write_id_mapping(enum idmap_type type, pid_t pid, const char *buf,
size_t buf_size)
{
int fd;
int ret;
char path[4096];
Annotation
- Immediate include surface: `errno.h`, `fcntl.h`, `pthread.h`, `sched.h`, `stdbool.h`, `stdio.h`, `stdlib.h`, `string.h`.
- Detected declarations: `enum idmap_type`, `function change_mountns`, `function __do_binderfs_test`, `function EXPECT_NE`, `function EXPECT_GE`, `function wait_for_pid`, `function setid_userns_root`, `function read_nointr`, `function write_nointr`, `function write_id_mapping`.
- 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.