tools/testing/selftests/bpf/test_lirc_mode2_user.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/test_lirc_mode2_user.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/test_lirc_mode2_user.c- Extension
.c- Size
- 4422 bytes
- Lines
- 178
- 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
linux/bpf.hlinux/input.herrno.hstdio.hstdlib.hstring.hunistd.hpoll.hsys/types.hsys/ioctl.hsys/stat.hfcntl.hbpf_util.hbpf/bpf.hbpf/libbpf.htesting_helpers.h
Detected Declarations
function main
Annotated Snippet
if (ret != sizeof(event)) {
printf("Failed to read decoded IR: %m\n");
return 1;
}
if (event.type == EV_MSC && event.code == MSC_SCAN &&
event.value == 0x1ead) {
break;
}
}
/* Write raw IR */
ret = write(lircfd, &testir2, sizeof(testir2));
if (ret != sizeof(testir2)) {
printf("Failed to send test IR message: %m\n");
return 1;
}
for (;;) {
poll(&pfd, 1, 100);
/* Read decoded IR */
ret = read(inputfd, &event, sizeof(event));
if (ret != sizeof(event)) {
printf("Failed to read decoded IR: %m\n");
return 1;
}
if (event.type == EV_REL && event.code == REL_Y &&
event.value == 1 ) {
break;
}
}
prog_cnt = 10;
ret = bpf_prog_query(lircfd, BPF_LIRC_MODE2, 0, prog_flags, prog_ids,
&prog_cnt);
if (ret) {
printf("Failed to query bpf programs on lirc device: %m\n");
return 1;
}
if (prog_cnt != 1) {
printf("Expected one program to be attached\n");
return 1;
}
/* Let's try detaching it now it is actually attached */
ret = bpf_prog_detach2(progfd, lircfd, BPF_LIRC_MODE2);
if (ret) {
printf("bpf_prog_detach2: returned %m\n");
return 1;
}
return 0;
}
Annotation
- Immediate include surface: `linux/bpf.h`, `linux/input.h`, `errno.h`, `stdio.h`, `stdlib.h`, `string.h`, `unistd.h`, `poll.h`.
- Detected declarations: `function main`.
- 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.