samples/bpf/fds_example.c
Source file repositories/reference/linux-study-clean/samples/bpf/fds_example.c
File Facts
- System
- Linux kernel
- Corpus path
samples/bpf/fds_example.c- Extension
.c- Size
- 4453 bytes
- Lines
- 196
- 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
linux/unistd.hlinux/bpf.hstdio.hstdlib.hstdint.hunistd.hstring.hassert.herrno.hsys/types.hsys/socket.hbpf/bpf.hbpf/libbpf.hbpf_insn.hsock_example.hbpf_util.h
Detected Declarations
function usagefunction bpf_prog_createfunction bpf_do_mapfunction bpf_do_progfunction main
Annotated Snippet
switch (opt) {
/* General args */
case 'F':
file = optarg;
break;
case 'P':
flags |= BPF_F_PIN;
break;
case 'G':
flags |= BPF_F_GET;
break;
/* Map-related args */
case 'm':
mode = BPF_M_MAP;
break;
case 'k':
key = strtoul(optarg, NULL, 0);
flags |= BPF_F_KEY;
break;
case 'v':
value = strtoul(optarg, NULL, 0);
flags |= BPF_F_VAL;
break;
/* Prog-related args */
case 'p':
mode = BPF_M_PROG;
break;
case 'o':
object = optarg;
break;
default:
goto out;
}
}
if (!(flags & BPF_F_PIN_GET) || !file)
goto out;
switch (mode) {
case BPF_M_MAP:
return bpf_do_map(file, flags, key, value);
case BPF_M_PROG:
return bpf_do_prog(file, flags, object);
}
out:
usage();
return -1;
}
Annotation
- Immediate include surface: `linux/unistd.h`, `linux/bpf.h`, `stdio.h`, `stdlib.h`, `stdint.h`, `unistd.h`, `string.h`, `assert.h`.
- Detected declarations: `function usage`, `function bpf_prog_create`, `function bpf_do_map`, `function bpf_do_prog`, `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.