/* Get the device. */
dev = udev_device_new_from_subsystem_sysname(udev, "usb", busid); if (!dev) {
dbg("unable to find device with bus ID %s", busid); goto err_close_busid_dev;
}
/* Check what kind of device it is. */
bDevClass = udev_device_get_sysattr_value(dev, "bDeviceClass"); if (!bDevClass) {
dbg("unable to get bDevClass device attribute"); goto err_close_busid_dev;
}
if (!strncmp(bDevClass, "09", strlen(bDevClass))) {
dbg("skip unbinding of hub"); goto err_close_busid_dev;
}
/* Get the device driver. */
driver = udev_device_get_driver(dev); if (!driver) { /* No driver bound to this device. */ goto out;
}
if (!strncmp(USBIP_HOST_DRV_NAME, driver,
strlen(USBIP_HOST_DRV_NAME))) { /* Already bound to usbip-host. */
status = UNBIND_ST_USBIP_HOST; goto out;
}
/* Check whether the device with this bus ID exists. */
udev = udev_new();
dev = udev_device_new_from_subsystem_sysname(udev, "usb", busid); if (!dev) {
err("device with the specified bus ID does not exist"); return -1;
}
devpath = udev_device_get_devpath(dev);
udev_unref(udev);
/* If the device is already attached to vhci_hcd - bail out */ if (strstr(devpath, USBIP_VHCI_DRV_NAME)) {
err("bind loop detected: device: %s is attached to %s\n",
devpath, USBIP_VHCI_DRV_NAME); return -1;
}
rc = unbind_other(busid); if (rc == UNBIND_ST_FAILED) {
err("could not unbind driver from device on busid %s", busid); return -1;
} elseif (rc == UNBIND_ST_USBIP_HOST) {
err("device on busid %s is already bound to %s", busid,
USBIP_HOST_DRV_NAME); return -1;
}
rc = modify_match_busid(busid, 1); if (rc < 0) {
err("unable to bind device on %s", busid); return -1;
}
rc = bind_usbip(busid); if (rc < 0) {
err("could not bind device to %s", USBIP_HOST_DRV_NAME);
modify_match_busid(busid, 0); return -1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.