tools/usb/usbip/src/usbip_list.c
Source file repositories/reference/linux-study-clean/tools/usb/usbip/src/usbip_list.c
File Facts
- System
- Linux kernel
- Corpus path
tools/usb/usbip/src/usbip_list.c- Extension
.c- Size
- 9190 bytes
- Lines
- 374
- 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
sys/types.hlibudev.herrno.hstdbool.hstdint.hstdio.hstdlib.hstring.hgetopt.hnetdb.hunistd.hdirent.hlinux/usb/ch9.husbip_common.husbip_network.husbip.h
Detected Declarations
function usbip_list_usagefunction get_exported_devicesfunction list_exported_devicesfunction print_devicefunction print_product_namefunction list_devicesfunction list_gadget_devicesfunction udev_list_entry_foreachfunction usbip_list
Annotated Snippet
if (rc < 0) {
dbg("usbip_net_recv failed: usbip_usb_device[%d]", i);
return -1;
}
usbip_net_pack_usb_device(0, &udev);
usbip_names_get_product(product_name, sizeof(product_name),
udev.idVendor, udev.idProduct);
usbip_names_get_class(class_name, sizeof(class_name),
udev.bDeviceClass, udev.bDeviceSubClass,
udev.bDeviceProtocol);
printf("%11s: %s\n", udev.busid, product_name);
printf("%11s: %s\n", "", udev.path);
printf("%11s: %s\n", "", class_name);
for (j = 0; j < udev.bNumInterfaces; j++) {
rc = usbip_net_recv(sockfd, &uintf, sizeof(uintf));
if (rc < 0) {
err("usbip_net_recv failed: usbip_usb_intf[%d]",
j);
return -1;
}
usbip_net_pack_usb_interface(0, &uintf);
usbip_names_get_class(class_name, sizeof(class_name),
uintf.bInterfaceClass,
uintf.bInterfaceSubClass,
uintf.bInterfaceProtocol);
printf("%11s: %2d - %s\n", "", j, class_name);
}
printf("\n");
}
return 0;
}
static int list_exported_devices(char *host)
{
int rc;
int sockfd;
sockfd = usbip_net_tcp_connect(host, usbip_port_string);
if (sockfd < 0) {
err("could not connect to %s:%s: %s", host,
usbip_port_string, gai_strerror(sockfd));
return -1;
}
dbg("connected to %s:%s", host, usbip_port_string);
rc = get_exported_devices(host, sockfd);
if (rc < 0) {
err("failed to get device list from %s", host);
return -1;
}
close(sockfd);
return 0;
}
static void print_device(const char *busid, const char *vendor,
const char *product, bool parsable)
{
if (parsable)
printf("busid=%s#usbid=%.4s:%.4s#", busid, vendor, product);
else
printf(" - busid %s (%.4s:%.4s)\n", busid, vendor, product);
}
static void print_product_name(char *product_name, bool parsable)
{
if (!parsable)
printf(" %s\n", product_name);
}
static int list_devices(bool parsable)
{
struct udev *udev;
struct udev_enumerate *enumerate;
struct udev_list_entry *devices, *dev_list_entry;
struct udev_device *dev;
const char *path;
const char *idVendor;
const char *idProduct;
const char *bConfValue;
const char *bNumIntfs;
const char *busid;
char product_name[128];
Annotation
- Immediate include surface: `sys/types.h`, `libudev.h`, `errno.h`, `stdbool.h`, `stdint.h`, `stdio.h`, `stdlib.h`, `string.h`.
- Detected declarations: `function usbip_list_usage`, `function get_exported_devices`, `function list_exported_devices`, `function print_device`, `function print_product_name`, `function list_devices`, `function list_gadget_devices`, `function udev_list_entry_foreach`, `function usbip_list`.
- 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.