tools/testing/selftests/user_events/abi_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/user_events/abi_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/user_events/abi_test.c- Extension
.c- Size
- 9084 bytes
- Lines
- 424
- 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
sched.herrno.hlinux/user_events.hstdio.hstdlib.hfcntl.hsys/ioctl.hsys/stat.hunistd.hglob.hstring.hasm/unistd.hkselftest_harness.huser_events_selftests.h
Detected Declarations
function wait_for_deletefunction find_multi_event_dirfunction event_existsfunction change_eventfunction event_deletefunction reg_enable_multifunction reg_enable_flagsfunction reg_enablefunction reg_disablefunction clone_checkfunction main
Annotated Snippet
while (fgets(path, sizeof(path), fp) != NULL) {
if (strstr(path, unique_field)) {
fclose(fp);
/* strscpy is not available, use snprintf */
snprintf(out_dir, dir_len, "%s", buf.gl_pathv[i]);
ret = 0;
goto out;
}
}
fclose(fp);
}
out:
globfree(&buf);
return ret;
}
static bool event_exists(void)
{
int fd = open(enable_file, O_RDWR);
if (fd < 0)
return false;
close(fd);
return true;
}
static int change_event(bool enable)
{
int fd = open(enable_file, O_RDWR);
int ret;
if (fd < 0)
return -1;
if (enable)
ret = write(fd, "1", 1);
else
ret = write(fd, "0", 1);
close(fd);
if (ret == 1)
ret = 0;
else
ret = -1;
return ret;
}
static int event_delete(void)
{
int fd = open(data_file, O_RDWR);
int ret;
if (fd < 0)
return -1;
ret = ioctl(fd, DIAG_IOCSDEL, "__abi_event");
close(fd);
return ret;
}
static int reg_enable_multi(void *enable, int size, int bit, int flags,
char *args)
{
struct user_reg reg = {0};
char full_args[512] = {0};
int fd = open(data_file, O_RDWR);
int len;
int ret;
if (fd < 0)
return -1;
len = snprintf(full_args, sizeof(full_args), "__abi_event %s", args);
if (len > sizeof(full_args)) {
ret = -E2BIG;
goto out;
}
reg.size = sizeof(reg);
reg.name_args = (__u64)full_args;
reg.flags = USER_EVENT_REG_MULTI_FORMAT | flags;
Annotation
- Immediate include surface: `sched.h`, `errno.h`, `linux/user_events.h`, `stdio.h`, `stdlib.h`, `fcntl.h`, `sys/ioctl.h`, `sys/stat.h`.
- Detected declarations: `function wait_for_delete`, `function find_multi_event_dir`, `function event_exists`, `function change_event`, `function event_delete`, `function reg_enable_multi`, `function reg_enable_flags`, `function reg_enable`, `function reg_disable`, `function clone_check`.
- 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.