tools/usb/ffs-aio-example/simple/device_app/aio_simple.c
Source file repositories/reference/linux-study-clean/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c
File Facts
- System
- Linux kernel
- Corpus path
tools/usb/ffs-aio-example/simple/device_app/aio_simple.c- Extension
.c- Size
- 9770 bytes
- Lines
- 387
- 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
endian.herrno.hfcntl.hstdarg.hstdio.hstdlib.hstring.hsys/ioctl.hsys/stat.hsys/types.hsys/poll.hunistd.hstdbool.hsys/eventfd.hlibaio.hlinux/usb/functionfs.h
Detected Declarations
function display_eventfunction handle_ep0function main
Annotated Snippet
if (!ret) {
perror("unable to read event from ep0");
return;
}
display_event(&event);
switch (event.type) {
case FUNCTIONFS_SETUP:
if (event.u.setup.bRequestType & USB_DIR_IN)
write(ep0, NULL, 0);
else
read(ep0, NULL, 0);
break;
case FUNCTIONFS_ENABLE:
*ready = true;
break;
case FUNCTIONFS_DISABLE:
*ready = false;
break;
default:
break;
}
}
}
int main(int argc, char *argv[])
{
int i, ret;
char *ep_path;
int ep0;
int ep[2];
io_context_t ctx;
int evfd;
fd_set rfds;
char *buf_in, *buf_out;
struct iocb *iocb_in, *iocb_out;
int req_in = 0, req_out = 0;
bool ready;
if (argc != 2) {
printf("ffs directory not specified!\n");
return 1;
}
ep_path = malloc(strlen(argv[1]) + 4 /* "/ep#" */ + 1 /* '\0' */);
if (!ep_path) {
perror("malloc");
return 1;
}
/* open endpoint files */
sprintf(ep_path, "%s/ep0", argv[1]);
ep0 = open(ep_path, O_RDWR);
if (ep0 < 0) {
perror("unable to open ep0");
return 1;
}
if (write(ep0, &descriptors, sizeof(descriptors)) < 0) {
perror("unable do write descriptors");
return 1;
}
if (write(ep0, &strings, sizeof(strings)) < 0) {
perror("unable to write strings");
return 1;
}
for (i = 0; i < 2; ++i) {
sprintf(ep_path, "%s/ep%d", argv[1], i+1);
ep[i] = open(ep_path, O_RDWR);
if (ep[i] < 0) {
printf("unable to open ep%d: %s\n", i+1,
strerror(errno));
return 1;
}
}
free(ep_path);
memset(&ctx, 0, sizeof(ctx));
/* setup aio context to handle up to 2 requests */
if (io_setup(2, &ctx) < 0) {
perror("unable to setup aio");
return 1;
}
Annotation
- Immediate include surface: `endian.h`, `errno.h`, `fcntl.h`, `stdarg.h`, `stdio.h`, `stdlib.h`, `string.h`, `sys/ioctl.h`.
- Detected declarations: `function display_event`, `function handle_ep0`, `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.