57
void printDevices(PUSBDEVICE pDevices,
58
const char *pcszDevices,
59
const char *pcszMethod)
61
PUSBDEVICE pDevice = pDevices;
63
RTPrintf("Enumerating usb devices using %s at %s\n", pcszMethod, pcszDevices);
66
RTPrintf(" Manufacturer: %s, product: %s, serial number string: %s\n",
67
pDevice->pszManufacturer, pDevice->pszProduct,
68
pDevice->pszSerialNumber);
69
RTPrintf(" Device address: %s\n", pDevice->pszAddress);
70
pDevice = pDevice->pNext;
74
void freeDevices(PUSBDEVICE pDevices)
76
PUSBDEVICE pDevice = pDevices, pDeviceNext;
80
pDeviceNext = pDevice->pNext;
82
pDevice = pDeviceNext;
89
119
RTPrintf (", description: %s", it->mDescription.c_str());
122
PCUSBDEVTREELOCATION pcLocation = USBProxyLinuxGetDeviceRoot(false);
123
if (pcLocation && !pcLocation->fUseSysfs)
125
PUSBDEVICE pDevice = USBProxyLinuxGetDevices(pcLocation->szDevicesRoot,
127
printDevices(pDevice, pcLocation->szDevicesRoot, "usbfs");
128
freeDevices(pDevice);
92
130
#ifdef VBOX_USB_WITH_SYSFS
93
VBoxMainUSBDeviceInfo deviceInfo;
94
rc = deviceInfo.UpdateDevices();
97
RTPrintf ("Failed to update the host USB device information, error %Rrc\n",
101
RTPrintf ("Listing USB devices detected:\n");
102
for (USBDeviceInfoList::const_iterator it = deviceInfo.DevicesBegin();
103
it != deviceInfo.DevicesEnd(); ++it)
105
char szProduct[1024];
106
if (RTLinuxSysFsReadStrFile(szProduct, sizeof(szProduct),
107
"%s/product", it->mSysfsPath.c_str()) == -1)
111
RTPrintf ("Failed to get the product name for device %s: error %s\n",
112
it->mDevice.c_str(), strerror(errno));
118
RTPrintf (" device: %s (%s), sysfs path: %s\n", szProduct, it->mDevice.c_str(),
119
it->mSysfsPath.c_str());
120
RTPrintf (" interfaces:\n");
121
for (USBInterfaceList::const_iterator it2 = it->mInterfaces.begin();
122
it2 != it->mInterfaces.end(); ++it2)
124
char szDriver[RTPATH_MAX];
125
strcpy(szDriver, "none");
126
ssize_t size = RTLinuxSysFsGetLinkDest(szDriver, sizeof(szDriver),
127
"%s/driver", it2->c_str());
128
if (size == -1 && errno != ENOENT)
130
RTPrintf ("Failed to get the driver for interface %s of device %s: error %s\n",
131
it2->c_str(), it->mDevice.c_str(), strerror(errno));
134
if (RTLinuxSysFsExists("%s/driver", it2->c_str()) != (size != -1))
136
RTPrintf ("RTLinuxSysFsExists did not return the expected value for the driver link of interface %s of device %s.\n",
137
it2->c_str(), it->mDevice.c_str());
140
uint64_t u64InterfaceClass;
141
u64InterfaceClass = RTLinuxSysFsReadIntFile(16, "%s/bInterfaceClass",
143
RTPrintf (" sysfs path: %s, driver: %s, interface class: 0x%x\n",
144
it2->c_str(), szDriver, u64InterfaceClass);
147
VBoxMainHotplugWaiter waiter;
148
RTPrintf ("Waiting for hotplug events. Note that DBus often seems to deliver duplicate events in close succession.\n");
131
pcLocation = USBProxyLinuxGetDeviceRoot(true);
132
if (pcLocation && pcLocation->fUseSysfs)
134
PUSBDEVICE pDevice = USBProxyLinuxGetDevices(pcLocation->szDevicesRoot,
136
printDevices(pDevice, pcLocation->szDevicesRoot, "sysfs");
137
freeDevices(pDevice);
139
VBoxMainHotplugWaiter waiter(pcLocation->szDevicesRoot);
149
140
RTPrintf ("Waiting for a hotplug event for five seconds...\n");
150
141
doHotplugEvent(&waiter, 5000);
151
142
RTPrintf ("Waiting for a hotplug event, Ctrl-C to abort...\n");