tools/usb/usbip/src/usbip.c
Source file repositories/reference/linux-study-clean/tools/usb/usbip/src/usbip.c
File Facts
- System
- Linux kernel
- Corpus path
tools/usb/usbip/src/usbip.c- Extension
.c- Size
- 3804 bytes
- Lines
- 192
- 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
stdio.hstdlib.hgetopt.hsyslog.husbip_common.husbip_network.husbip.h
Detected Declarations
struct commandfunction usbip_usagefunction usbip_helpfunction usbip_versionfunction run_commandfunction main
Annotated Snippet
struct command {
const char *name;
int (*fn)(int argc, char *argv[]);
const char *help;
void (*usage)(void);
};
static const struct command cmds[] = {
{
.name = "help",
.fn = usbip_help,
.help = NULL,
.usage = NULL
},
{
.name = "version",
.fn = usbip_version,
.help = NULL,
.usage = NULL
},
{
.name = "attach",
.fn = usbip_attach,
.help = "Attach a remote USB device",
.usage = usbip_attach_usage
},
{
.name = "detach",
.fn = usbip_detach,
.help = "Detach a remote USB device",
.usage = usbip_detach_usage
},
{
.name = "list",
.fn = usbip_list,
.help = "List exportable or local USB devices",
.usage = usbip_list_usage
},
{
.name = "bind",
.fn = usbip_bind,
.help = "Bind device to " USBIP_HOST_DRV_NAME ".ko",
.usage = usbip_bind_usage
},
{
.name = "unbind",
.fn = usbip_unbind,
.help = "Unbind device from " USBIP_HOST_DRV_NAME ".ko",
.usage = usbip_unbind_usage
},
{
.name = "port",
.fn = usbip_port_show,
.help = "Show imported USB devices",
.usage = NULL
},
{ NULL, NULL, NULL, NULL }
};
static int usbip_help(int argc, char *argv[])
{
const struct command *cmd;
int i;
int ret = 0;
if (argc > 1 && argv++) {
for (i = 0; cmds[i].name != NULL; i++)
if (!strcmp(cmds[i].name, argv[0]) && cmds[i].usage) {
cmds[i].usage();
goto done;
}
ret = -1;
}
usbip_usage();
printf("\n");
for (cmd = cmds; cmd->name != NULL; cmd++)
if (cmd->help != NULL)
printf(" %-10s %s\n", cmd->name, cmd->help);
printf("\n");
done:
return ret;
}
static int usbip_version(int argc, char *argv[])
{
(void) argc;
(void) argv;
printf(PROGNAME " (%s)\n", usbip_version_string);
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `getopt.h`, `syslog.h`, `usbip_common.h`, `usbip_network.h`, `usbip.h`.
- Detected declarations: `struct command`, `function usbip_usage`, `function usbip_help`, `function usbip_version`, `function run_command`, `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.