20 #include <sysfs/libsysfs.h>
32 #include "usbip_common.h"
36 static const char usbip_attach_usage_string[] =
37 "usbip attach <args>\n"
38 " -h, --host=<host> The machine with exported USB devices\n"
39 " -b, --busid=<busid> Busid of the device on <host>\n";
43 printf(
"usage: %s", usbip_attach_usage_string);
47 static int record_connection(
char *
host,
char *
port,
char *
busid,
int rhport)
85 err(
"open vhci_driver");
109 static int query_import_device(
int sockfd,
char *
busid)
117 memset(&reply, 0,
sizeof(reply));
122 err(
"send op_common");
132 err(
"send op_import_request");
139 err(
"recv op_common");
145 err(
"recv op_import_reply");
152 if (
strncmp(reply.udev.busid, busid, SYSFS_BUS_ID_SIZE)) {
153 err(
"recv different busid %s", reply.udev.busid);
158 return import_device(sockfd, &reply.udev);
161 static int attach_device(
char *
host,
char *busid)
173 rhport = query_import_device(sockfd, busid);
183 err(
"record connection");
192 static const struct option opts[] = {
193 {
"host", required_argument,
NULL,
'h' },
194 {
"busid", required_argument,
NULL,
'b' },
203 opt = getopt_long(argc, argv,
"h:b:", opts,
NULL);
223 ret = attach_device(host, busid);