samples/hid/hid_mouse.c
Source file repositories/reference/linux-study-clean/samples/hid/hid_mouse.c
File Facts
- System
- Linux kernel
- Corpus path
samples/hid/hid_mouse.c- Extension
.c- Size
- 2958 bytes
- Lines
- 139
- Domain
- Support Tooling And Documentation
- Bucket
- samples
- 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
assert.herrno.hfcntl.hlibgen.hsignal.hstdbool.hstdio.hstdlib.hstring.hsys/resource.hunistd.hlinux/bpf.hlinux/errno.hbpf/bpf.hbpf/libbpf.hhid_mouse.skel.h
Detected Declarations
function int_exitfunction usagefunction get_hid_idfunction main
Annotated Snippet
switch (opt) {
default:
usage(basename(argv[0]));
return 1;
}
}
if (optind == argc) {
usage(basename(argv[0]));
return 1;
}
sysfs_path = argv[optind];
if (!sysfs_path) {
perror("sysfs");
return 1;
}
skel = hid_mouse__open();
if (!skel) {
fprintf(stderr, "%s %s:%d", __func__, __FILE__, __LINE__);
return -1;
}
hid_id = get_hid_id(sysfs_path);
if (hid_id < 0) {
fprintf(stderr, "can not open HID device: %m\n");
return 1;
}
skel->struct_ops.mouse_invert->hid_id = hid_id;
err = hid_mouse__load(skel);
if (err < 0) {
fprintf(stderr, "can not load HID-BPF program: %m\n");
return 1;
}
link = bpf_map__attach_struct_ops(skel->maps.mouse_invert);
if (!link) {
fprintf(stderr, "can not attach HID-BPF program: %m\n");
return 1;
}
signal(SIGINT, int_exit);
signal(SIGTERM, int_exit);
while (running)
sleep(1);
hid_mouse__destroy(skel);
return 0;
}
Annotation
- Immediate include surface: `assert.h`, `errno.h`, `fcntl.h`, `libgen.h`, `signal.h`, `stdbool.h`, `stdio.h`, `stdlib.h`.
- Detected declarations: `function int_exit`, `function usage`, `function get_hid_id`, `function main`.
- Atlas domain: Support Tooling And Documentation / samples.
- 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.