Changeset 37151 in vbox for trunk/src/VBox
- Timestamp:
- May 19, 2011 12:12:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxUSB/solaris/USBLib-solaris.cpp
r36341 r37151 74 74 *******************************************************************************/ 75 75 static int usblibDoIOCtl(unsigned iFunction, void *pvData, size_t cbData); 76 static int usblibRunHelper(USBHELPER_OP HelperOp, void *pvData);77 76 78 77 … … 220 219 221 220 222 #if 1223 221 USBLIB_DECL(int) USBLibResetDevice(char *pszDevicePath, bool fReattach) 224 222 { … … 240 238 return rc; 241 239 } 242 #else243 244 USBLIB_DECL(int) USBLibResetDevice(char *pszDevicePath, bool fReattach)245 {246 VBOXUSBHELPERDATA_RESET Data;247 Data.pszDevicePath = pszDevicePath;248 Data.fHardReset = fReattach;249 return usblibRunHelper(RESET, &Data);250 }251 #endif252 253 USBLIB_DECL(int) USBLibAddDeviceAlias(PUSBDEVICE pDevice)254 {255 VBOXUSBHELPERDATA_ALIAS Data;256 Data.idVendor = pDevice->idVendor;257 Data.idProduct = pDevice->idProduct;258 Data.bcdDevice = pDevice->bcdDevice;259 Data.pszDevicePath = pDevice->pszDevicePath;260 return usblibRunHelper(ADD_ALIAS, &Data);261 }262 263 264 USBLIB_DECL(int) USBLibRemoveDeviceAlias(PUSBDEVICE pDevice)265 {266 VBOXUSBHELPERDATA_ALIAS Data;267 Data.idVendor = pDevice->idVendor;268 Data.idProduct = pDevice->idProduct;269 Data.bcdDevice = pDevice->bcdDevice;270 Data.pszDevicePath = pDevice->pszDevicePath;271 return usblibRunHelper(DEL_ALIAS, &Data);272 }273 274 #if 0275 USBLIB_DECL(int) USBLibConfigureDevice(PUSBDEVICE pDevice)276 {277 return usblibRunHelper(pDevice, CONFIGURE);278 }279 #endif280 281 static int usblibRunHelper(USBHELPER_OP HelperOp, void *pvUsbHelperData)282 {283 LogFlow((USBLIBR3 ":usblibRunHelper HelperOp=%d pvUSBHelperData=%p\n", HelperOp, pvUsbHelperData));284 285 /*286 * Find VBoxUSBHelper.287 */288 char szDriverCtl[PATH_MAX];289 int rc = RTPathExecDir(szDriverCtl, sizeof(szDriverCtl) - sizeof("/" VBOXUSB_HELPER_NAME));290 if (RT_SUCCESS(rc))291 {292 strcat(szDriverCtl, "/" VBOXUSB_HELPER_NAME);293 if (!RTPathExists(szDriverCtl))294 {295 LogRel(("USBProxy: path %s does not exist. Failed to run USB helper %s.\n", szDriverCtl, VBOXUSB_HELPER_NAME));296 return VERR_FILE_NOT_FOUND;297 }298 299 /*300 * Run VBoxUSBHelper task.301 */302 const char *pszArgs[5];303 if (HelperOp == RESET)304 {305 PVBOXUSBHELPERDATA_RESET pData = (PVBOXUSBHELPERDATA_RESET)pvUsbHelperData;306 pszArgs[0] = szDriverCtl;307 pszArgs[1] = pData->fHardReset ? "hardreset" : "softreset";308 pszArgs[2] = pData->pszDevicePath;309 pszArgs[3] = NULL;310 }311 else312 {313 PVBOXUSBHELPERDATA_ALIAS pData = (PVBOXUSBHELPERDATA_ALIAS)pvUsbHelperData;314 char szDriverAlias[128];315 316 #if 0317 /*318 * USB vid.pid.rev driver binding alias.319 */320 RTStrPrintf(szDriverAlias, sizeof(szDriverAlias), "usb%x,%x.%x", pData->idVendor, pData->idProduct, pData->bcdDevice);321 #else322 /*323 * Path based driver binding alias.324 */325 RTStrPrintf(szDriverAlias, sizeof(szDriverAlias), "%s", pData->pszDevicePath + sizeof("/devices"));326 #endif327 pszArgs[0] = szDriverCtl;328 pszArgs[1] = HelperOp == ADD_ALIAS ? "add" : "del";329 pszArgs[2] = szDriverAlias;330 pszArgs[3] = VBOXUSB_DRIVER_NAME;331 }332 pszArgs[4] = NULL;333 RTPROCESS pid = NIL_RTPROCESS;334 rc = RTProcCreate(pszArgs[0], pszArgs, RTENV_DEFAULT, 0, &pid);335 if (RT_SUCCESS(rc))336 {337 RTPROCSTATUS Status;338 rc = RTProcWait(pid, 0, &Status);339 if (RT_SUCCESS(rc))340 {341 if (Status.enmReason == RTPROCEXITREASON_NORMAL)342 {343 switch (Status.iStatus)344 {345 case 0: return VINF_SUCCESS; /* @todo later maybe ignore -4 as well (see VBoxUSBHelper return codes). */346 case -1: return VERR_PERMISSION_DENIED;347 case -2: return VERR_INVALID_PARAMETER;348 case -3: return VERR_GENERAL_FAILURE;349 default: return VERR_INTERNAL_ERROR;350 }351 }352 else353 LogRel((USBLIBR3 ":abnormal termination of USB Helper. enmReason=%d\n", Status.enmReason));354 rc = VERR_GENERAL_FAILURE;355 }356 else357 LogRel((USBLIBR3 ":RTProcWait failed rc=%Rrc\n", rc));358 }359 else360 {361 /* Bad. RTProcCreate() failed! */362 LogRel((USBLIBR3 ":Failed to fork() process for running USB helper for device %s: rc=%Rrc\n", rc));363 }364 }365 return rc;366 }367 240 368 241 … … 394 267 return rc; 395 268 } 396
Note:
See TracChangeset
for help on using the changeset viewer.