static int32_t read_attr_usbip_status(struct usbip_usb_device *udev)
{ char status_attr_path[SYSFS_PATH_MAX]; int size; int fd; int length; char status[2] = { 0 }; int value = 0;
if (hdriver->ops.read_device(edev->sudev, &edev->udev) < 0) goto err;
edev->status = read_attr_usbip_status(&edev->udev); if (edev->status < 0) goto err;
/* reallocate buffer to include usb interface data */
size = sizeof(struct usbip_exported_device) +
edev->udev.bNumInterfaces * sizeof(struct usbip_usb_interface);
for (i = 0; i < edev->udev.bNumInterfaces; i++) { /* vudc does not support reading interfaces */ if (!hdriver->ops.read_interface) break;
hdriver->ops.read_interface(&edev->udev, i, &edev->uinf[i]);
}
return edev;
err: if (edev->sudev)
udev_device_unref(edev->sudev); if (edev)
free(edev);
rc = refresh_exported_devices(hdriver); if (rc < 0) return -1;
return 0;
}
int usbip_export_device(struct usbip_exported_device *edev, int sockfd)
{ char attr_name[] = "usbip_sockfd"; char sockfd_attr_path[SYSFS_PATH_MAX]; int size; char sockfd_buff[30]; int ret;
if (edev->status != SDEV_ST_AVAILABLE) {
dbg("device not available: %s", edev->udev.busid); switch (edev->status) { case SDEV_ST_ERROR:
dbg("status SDEV_ST_ERROR");
ret = ST_DEV_ERR; break; case SDEV_ST_USED:
dbg("status SDEV_ST_USED");
ret = ST_DEV_BUSY; break; default:
dbg("status unknown: 0x%x", edev->status);
ret = -1;
} return ret;
}
/* only the first interface is true */
size = snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s",
edev->udev.path, attr_name); if (size < 0 || (unsignedint)size >= sizeof(sockfd_attr_path)) {
err("exported device path length %i >= %lu or < 0", size,
(longunsigned)sizeof(sockfd_attr_path)); 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.