Changeset 63378 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 12, 2016 6:29:33 PM (8 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/VFSExplorerImpl.cpp
r63187 r63378 160 160 161 161 TaskVFSExplorer(TaskType aTaskType, VFSExplorer *aThat, Progress *aProgress) 162 : taskType(aTaskType),163 pVFSExplorer(aThat),164 progress(aProgress),165 rc(S_OK)162 : m_taskType(aTaskType), 163 m_pVFSExplorer(aThat), 164 m_ptrProgress(aProgress), 165 m_rc(S_OK) 166 166 { 167 167 m_strTaskName = "Explorer::Task"; … … 176 176 #endif 177 177 178 TaskType taskType;179 VFSExplorer * pVFSExplorer;180 181 ComObjPtr<Progress> progress;182 HRESULT rc;178 TaskType m_taskType; 179 VFSExplorer *m_pVFSExplorer; 180 181 ComObjPtr<Progress> m_ptrProgress; 182 HRESULT m_rc; 183 183 184 184 /* task data */ 185 std::list<Utf8Str> filenames;185 std::list<Utf8Str> m_lstFilenames; 186 186 187 187 friend class VFSExplorer; … … 191 191 void VFSExplorer::TaskVFSExplorer::handler() 192 192 { 193 VFSExplorer *pVFSExplorer = this-> pVFSExplorer;193 VFSExplorer *pVFSExplorer = this->m_pVFSExplorer; 194 194 195 195 LogFlowFuncEnter(); … … 198 198 HRESULT rc = S_OK; 199 199 200 switch (this-> taskType)200 switch (this->m_taskType) 201 201 { 202 202 case TaskVFSExplorer::Update: … … 217 217 } 218 218 default: 219 AssertMsgFailed(("Invalid task type %u specified!\n", this-> taskType));219 AssertMsgFailed(("Invalid task type %u specified!\n", this->m_taskType)); 220 220 break; 221 221 } … … 232 232 233 233 if (pTask && 234 !pTask-> progress.isNull())234 !pTask->m_ptrProgress.isNull()) 235 235 { 236 236 BOOL fCanceled; 237 pTask-> progress->COMGETTER(Canceled)(&fCanceled);237 pTask->m_ptrProgress->COMGETTER(Canceled)(&fCanceled); 238 238 if (fCanceled) 239 239 return -1; 240 pTask-> progress->SetCurrentOperationProgress(uPercent);240 pTask->m_ptrProgress->SetCurrentOperationProgress(uPercent); 241 241 } 242 242 return VINF_SUCCESS; … … 288 288 throw setError(VBOX_E_FILE_ERROR, tr ("Can't open directory '%s' (%Rrc)"), pszPath, vrc); 289 289 290 if (aTask-> progress)291 aTask-> progress->SetCurrentOperationProgress(33);290 if (aTask->m_ptrProgress) 291 aTask->m_ptrProgress->SetCurrentOperationProgress(33); 292 292 RTDIRENTRYEX entry; 293 293 while (RT_SUCCESS(vrc)) … … 304 304 } 305 305 } 306 if (aTask-> progress)307 aTask-> progress->SetCurrentOperationProgress(66);306 if (aTask->m_ptrProgress) 307 aTask->m_ptrProgress->SetCurrentOperationProgress(66); 308 308 } 309 309 catch(HRESULT aRC) … … 318 318 RTDirClose(pDir); 319 319 320 if (aTask-> progress)321 aTask-> progress->SetCurrentOperationProgress(99);320 if (aTask->m_ptrProgress) 321 aTask->m_ptrProgress->SetCurrentOperationProgress(99); 322 322 323 323 /* Assign the result on success (this clears the old list) */ … … 325 325 m->entryList.assign(fileList.begin(), fileList.end()); 326 326 327 aTask-> rc = rc;328 329 if (!aTask-> progress.isNull())330 aTask-> progress->i_notifyComplete(rc);327 aTask->m_rc = rc; 328 329 if (!aTask->m_ptrProgress.isNull()) 330 aTask->m_ptrProgress->i_notifyComplete(rc); 331 331 332 332 LogFlowFunc(("rc=%Rhrc\n", rc)); … … 347 347 HRESULT rc = S_OK; 348 348 349 float fPercentStep = 100.0f / (float)aTask-> filenames.size();349 float fPercentStep = 100.0f / (float)aTask->m_lstFilenames.size(); 350 350 try 351 351 { … … 353 353 std::list<Utf8Str>::const_iterator it; 354 354 size_t i = 0; 355 for (it = aTask-> filenames.begin();356 it != aTask-> filenames.end();355 for (it = aTask->m_lstFilenames.begin(); 356 it != aTask->m_lstFilenames.end(); 357 357 ++it, ++i) 358 358 { … … 363 363 if (RT_FAILURE(vrc)) 364 364 throw setError(VBOX_E_FILE_ERROR, tr("Can't delete file '%s' (%Rrc)"), szPath, vrc); 365 if (aTask-> progress)366 aTask-> progress->SetCurrentOperationProgress((ULONG)(fPercentStep * (float)i));365 if (aTask->m_ptrProgress) 366 aTask->m_ptrProgress->SetCurrentOperationProgress((ULONG)(fPercentStep * (float)i)); 367 367 } 368 368 } 369 catch (HRESULT aRC)369 catch (HRESULT aRC) 370 370 { 371 371 rc = aRC; 372 372 } 373 373 374 aTask-> rc = rc;375 376 if ( !aTask->progress.isNull())377 aTask-> progress->i_notifyComplete(rc);374 aTask->m_rc = rc; 375 376 if (aTask->m_ptrProgress.isNotNull()) 377 aTask->m_ptrProgress->i_notifyComplete(rc); 378 378 379 379 LogFlowFunc(("rc=%Rhrc\n", rc)); … … 522 522 /* Add all filenames to delete as task data */ 523 523 for (size_t i = 0; i < aNames.size(); ++i) 524 pTask-> filenames.push_back(aNames[i]);524 pTask->m_lstFilenames.push_back(aNames[i]); 525 525 526 526 //this function delete task in case of exceptions, so there is no need in the call of delete operator -
trunk/src/VBox/Main/src-server/linux/USBGetDevices.cpp
r62363 r63378 459 459 460 460 /** Just a worker for USBProxyServiceLinux::getDevices that avoids some code duplication. */ 461 static int usbfsAddDeviceToChain(PUSBDEVICE pDev, PUSBDEVICE *ppFirst, PUSBDEVICE **pppNext, const char *p cszUsbfsRoot,462 bool testfs, int rc)461 static int usbfsAddDeviceToChain(PUSBDEVICE pDev, PUSBDEVICE *ppFirst, PUSBDEVICE **pppNext, const char *pszUsbfsRoot, 462 bool fUnsupportedDevicesToo, int rc) 463 463 { 464 464 /* usbDeterminState requires the address. */ … … 466 466 if (pDevNew) 467 467 { 468 RTStrAPrintf((char **)&pDevNew->pszAddress, "%s/%03d/%03d", p cszUsbfsRoot, pDevNew->bBus, pDevNew->bDevNum);468 RTStrAPrintf((char **)&pDevNew->pszAddress, "%s/%03d/%03d", pszUsbfsRoot, pDevNew->bBus, pDevNew->bDevNum); 469 469 if (pDevNew->pszAddress) 470 470 { 471 471 pDevNew->enmState = usbDeterminState(pDevNew); 472 if (pDevNew->enmState != USBDEVICESTATE_UNSUPPORTED || testfs)472 if (pDevNew->enmState != USBDEVICESTATE_UNSUPPORTED || fUnsupportedDevicesToo) 473 473 { 474 474 if (*pppNext) … … 497 497 498 498 499 static int usbfsOpenDevicesFile(const char *p cszUsbfsRoot, FILE **ppFile)499 static int usbfsOpenDevicesFile(const char *pszUsbfsRoot, FILE **ppFile) 500 500 { 501 501 char *pszPath; 502 502 FILE *pFile; 503 RTStrAPrintf(&pszPath, "%s/devices", p cszUsbfsRoot);503 RTStrAPrintf(&pszPath, "%s/devices", pszUsbfsRoot); 504 504 if (!pszPath) 505 505 return VERR_NO_MEMORY; … … 514 514 515 515 /** 516 * USBProxyService::getDevices() implementation for usbfs. The @a testfs flag 517 * tells the function to return information about unsupported devices as well. 518 * This is used as a sanity test to check that a devices file is really what 519 * we expect. 520 */ 521 static PUSBDEVICE usbfsGetDevices(const char *pcszUsbfsRoot, bool testfs) 516 * USBProxyService::getDevices() implementation for usbfs. 517 * 518 * The @a fUnsupportedDevicesToo flag tells the function to return information 519 * about unsupported devices as well. This is used as a sanity test to check 520 * that a devices file is really what we expect. 521 */ 522 static PUSBDEVICE usbfsGetDevices(const char *pszUsbfsRoot, bool fUnsupportedDevicesToo) 522 523 { 523 524 PUSBDEVICE pFirst = NULL; 524 525 FILE *pFile = NULL; 525 526 int rc; 526 rc = usbfsOpenDevicesFile(p cszUsbfsRoot, &pFile);527 rc = usbfsOpenDevicesFile(pszUsbfsRoot, &pFile); 527 528 if (RT_SUCCESS(rc)) 528 529 { … … 535 536 536 537 /* Set close on exit and hope no one is racing us. */ 537 rc = 538 539 538 rc = fcntl(fileno(pFile), F_SETFD, FD_CLOEXEC) >= 0 539 ? VINF_SUCCESS 540 : RTErrConvertFromErrno(errno); 540 541 while ( RT_SUCCESS(rc) 541 542 && fgets(szLine, sizeof(szLine), pFile)) … … 584 585 AssertMsg(cHits >= 3 || cHits == 0, ("cHits=%d\n", cHits)); 585 586 if (cHits >= 3) 586 rc = usbfsAddDeviceToChain(&Dev, &pFirst, &ppNext, p cszUsbfsRoot, testfs, rc);587 rc = usbfsAddDeviceToChain(&Dev, &pFirst, &ppNext, pszUsbfsRoot, fUnsupportedDevicesToo, rc); 587 588 else 588 589 deviceFreeMembers(&Dev); … … 777 778 AssertMsg(cHits >= 3 || cHits == 0, ("cHits=%d\n", cHits)); 778 779 if (cHits >= 3) 779 rc = usbfsAddDeviceToChain(&Dev, &pFirst, &ppNext, p cszUsbfsRoot, testfs, rc);780 rc = usbfsAddDeviceToChain(&Dev, &pFirst, &ppNext, pszUsbfsRoot, fUnsupportedDevicesToo, rc); 780 781 781 782 /* … … 836 837 * @returns a bus number greater than 0 on success or 0 on failure. 837 838 */ 838 static unsigned usbsysfsGetBusFromPath(const char *p cszPath)839 { 840 const char *p cszFile = strrchr(pcszPath, '/');841 if (!p cszFile)839 static unsigned usbsysfsGetBusFromPath(const char *pszPath) 840 { 841 const char *pszFile = strrchr(pszPath, '/'); 842 if (!pszFile) 842 843 return 0; 843 unsigned bus = RTStrToUInt32(p cszFile + 1);844 unsigned bus = RTStrToUInt32(pszFile + 1); 844 845 if ( !bus 845 && p cszFile[1] == 'u' && pcszFile[2] == 's' && pcszFile[3] == 'b')846 bus = RTStrToUInt32(p cszFile + 4);846 && pszFile[1] == 'u' && pszFile[2] == 's' && pszFile[3] == 'b') 847 bus = RTStrToUInt32(pszFile + 4); 847 848 return bus; 848 849 } … … 864 865 865 866 /** 866 * If a file @a p cszNode from /sys/bus/usb/devices is a device rather than an867 * If a file @a pszNode from /sys/bus/usb/devices is a device rather than an 867 868 * interface add an element for the device to @a pvecDevInfo. 868 869 */ 869 static int usbsysfsAddIfDevice(const char *p cszDevicesRoot, const char *pcszNode, VECTOR_OBJ(USBDeviceInfo) *pvecDevInfo)870 { 871 const char *p cszFile = strrchr(pcszNode, '/');872 if (!p cszFile)870 static int usbsysfsAddIfDevice(const char *pszDevicesRoot, const char *pszNode, VECTOR_OBJ(USBDeviceInfo) *pvecDevInfo) 871 { 872 const char *pszFile = strrchr(pszNode, '/'); 873 if (!pszFile) 873 874 return VERR_INVALID_PARAMETER; 874 if (strchr(p cszFile, ':'))875 if (strchr(pszFile, ':')) 875 876 return VINF_SUCCESS; 876 877 877 unsigned bus = usbsysfsGetBusFromPath(p cszNode);878 unsigned bus = usbsysfsGetBusFromPath(pszNode); 878 879 if (!bus) 879 880 return VINF_SUCCESS; 880 881 881 882 int64_t device; 882 int rc = RTLinuxSysFsReadIntFile(10, &device, "%s/devnum", p cszNode);883 int rc = RTLinuxSysFsReadIntFile(10, &device, "%s/devnum", pszNode); 883 884 if (RT_FAILURE(rc)) 884 885 return VINF_SUCCESS; … … 892 893 szDevPath, sizeof(szDevPath), 893 894 "%s/%.3d/%.3d", 894 p cszDevicesRoot, bus, device);895 pszDevicesRoot, bus, device); 895 896 if (RT_FAILURE(rc)) 896 897 return VINF_SUCCESS; 897 898 898 899 USBDeviceInfo info; 899 if (usbsysfsInitDevInfo(&info, szDevPath, p cszNode))900 if (usbsysfsInitDevInfo(&info, szDevPath, pszNode)) 900 901 { 901 902 rc = VEC_PUSH_BACK_OBJ(pvecDevInfo, USBDeviceInfo, &info); … … 915 916 * as the test requires file-system interaction. 916 917 */ 917 static bool usbsysfsMuiIsAnInterfaceOf(const char *p cszIface, const char *pcszDev)918 { 919 size_t cchDev = strlen(p cszDev);920 921 AssertPtr(p cszIface);922 AssertPtr(p cszDev);923 Assert(p cszIface[0] == '/');924 Assert(p cszDev[0] == '/');925 Assert(p cszDev[cchDev - 1] != '/');926 927 /* If this passes, p cszIface is at least cchDev long */928 if (strncmp(p cszIface, pcszDev, cchDev))918 static bool usbsysfsMuiIsAnInterfaceOf(const char *pszIface, const char *pszDev) 919 { 920 size_t cchDev = strlen(pszDev); 921 922 AssertPtr(pszIface); 923 AssertPtr(pszDev); 924 Assert(pszIface[0] == '/'); 925 Assert(pszDev[0] == '/'); 926 Assert(pszDev[cchDev - 1] != '/'); 927 928 /* If this passes, pszIface is at least cchDev long */ 929 if (strncmp(pszIface, pszDev, cchDev)) 929 930 return false; 930 931 931 /* If this passes, p cszIface is longer than cchDev */932 if (p cszIface[cchDev] != '/')932 /* If this passes, pszIface is longer than cchDev */ 933 if (pszIface[cchDev] != '/') 933 934 return false; 934 935 935 936 /* In sysfs an interface is an immediate subdirectory of the device */ 936 if (strchr(p cszIface + cchDev + 1, '/'))937 if (strchr(pszIface + cchDev + 1, '/')) 937 938 return false; 938 939 939 940 /* And it always has a colon in its name */ 940 if (!strchr(p cszIface + cchDev + 1, ':'))941 if (!strchr(pszIface + cchDev + 1, ':')) 941 942 return false; 942 943 … … 971 972 * device. 972 973 */ 973 static int usbsysfsAddIfInterfaceOf(const char *p cszNode, USBDeviceInfo *pInfo)974 { 975 if (!usbsysfsMuiIsAnInterfaceOf(p cszNode, pInfo->mSysfsPath))974 static int usbsysfsAddIfInterfaceOf(const char *pszNode, USBDeviceInfo *pInfo) 975 { 976 if (!usbsysfsMuiIsAnInterfaceOf(pszNode, pInfo->mSysfsPath)) 976 977 return VINF_SUCCESS; 977 978 978 char *pszDup = (char *)RTStrDup(p cszNode);979 char *pszDup = (char *)RTStrDup(pszNode); 979 980 if (pszDup) 980 981 { … … 995 996 * files on which realpath() fails. 996 997 */ 997 static int usbsysfsReadFilePathsFromDir(const char *p cszPath, DIR *pDir, VECTOR_PTR(char *) *pvecpchDevs)998 static int usbsysfsReadFilePathsFromDir(const char *pszPath, DIR *pDir, VECTOR_PTR(char *) *pvecpchDevs) 998 999 { 999 1000 struct dirent entry, *pResult; … … 1007 1008 if (entry.d_name[0] == '.') 1008 1009 continue; 1009 if (snprintf(szPath, sizeof(szPath), "%s/%s", p cszPath, entry.d_name) < 0)1010 return RTErrConvertFromErrno(errno); /** @todo r=bird: snprintf isn't document to set errno. Also, wouldn't it be better to continue on errors? Finally, you don't need to copy p cszPath each time... */1010 if (snprintf(szPath, sizeof(szPath), "%s/%s", pszPath, entry.d_name) < 0) 1011 return RTErrConvertFromErrno(errno); /** @todo r=bird: snprintf isn't document to set errno. Also, wouldn't it be better to continue on errors? Finally, you don't need to copy pszPath each time... */ 1011 1012 if (!realpath(szPath, szRealPath)) 1012 1013 return RTErrConvertFromErrno(errno); 1013 char *pszPath = RTStrDup(szRealPath);1014 if (!pszPath )1014 char *pszPathCopy = RTStrDup(szRealPath); 1015 if (!pszPathCopy) 1015 1016 return VERR_NO_MEMORY; 1016 if (RT_FAILURE(rc = VEC_PUSH_BACK_PTR(pvecpchDevs, char *, pszPath )))1017 if (RT_FAILURE(rc = VEC_PUSH_BACK_PTR(pvecpchDevs, char *, pszPathCopy))) 1017 1018 return rc; 1018 1019 } … … 1025 1026 * 1026 1027 * @returns zero on success or (positive) posix error value. 1027 * @param p cszPath the path to dump.1028 * @param pszPath the path to dump. 1028 1029 * @param pvecpchDevs an empty vector of char pointers - must be cleaned up 1029 1030 * by the caller even on failure. 1030 1031 * @param withRealPath whether to canonicalise the filename with realpath 1031 1032 */ 1032 static int usbsysfsReadFilePaths(const char *p cszPath, VECTOR_PTR(char *) *pvecpchDevs)1033 static int usbsysfsReadFilePaths(const char *pszPath, VECTOR_PTR(char *) *pvecpchDevs) 1033 1034 { 1034 1035 AssertPtrReturn(pvecpchDevs, EINVAL); 1035 1036 AssertReturn(VEC_SIZE_PTR(pvecpchDevs) == 0, EINVAL); 1036 AssertPtrReturn(p cszPath, EINVAL);1037 1038 DIR *pDir = opendir(p cszPath);1037 AssertPtrReturn(pszPath, EINVAL); 1038 1039 DIR *pDir = opendir(pszPath); 1039 1040 if (!pDir) 1040 1041 return RTErrConvertFromErrno(errno); 1041 int rc = usbsysfsReadFilePathsFromDir(p cszPath, pDir, pvecpchDevs);1042 int rc = usbsysfsReadFilePathsFromDir(pszPath, pDir, pvecpchDevs); 1042 1043 if (closedir(pDir) < 0 && RT_SUCCESS(rc)) 1043 1044 rc = RTErrConvertFromErrno(errno); … … 1054 1055 * to simplify exit logic 1055 1056 */ 1056 static int usbsysfsEnumerateHostDevicesWorker(const char *p cszDevicesRoot,1057 static int usbsysfsEnumerateHostDevicesWorker(const char *pszDevicesRoot, 1057 1058 VECTOR_OBJ(USBDeviceInfo) *pvecDevInfo, 1058 1059 VECTOR_PTR(char *) *pvecpchDevs) … … 1069 1070 VEC_FOR_EACH(pvecpchDevs, char *, ppszEntry) 1070 1071 { 1071 rc = usbsysfsAddIfDevice(p cszDevicesRoot, *ppszEntry, pvecDevInfo);1072 rc = usbsysfsAddIfDevice(pszDevicesRoot, *ppszEntry, pvecDevInfo); 1072 1073 if (RT_FAILURE(rc)) 1073 1074 return rc; … … 1086 1087 1087 1088 1088 static int usbsysfsEnumerateHostDevices(const char *p cszDevicesRoot, VECTOR_OBJ(USBDeviceInfo) *pvecDevInfo)1089 static int usbsysfsEnumerateHostDevices(const char *pszDevicesRoot, VECTOR_OBJ(USBDeviceInfo) *pvecDevInfo) 1089 1090 { 1090 1091 VECTOR_PTR(char *) vecpchDevs; … … 1093 1094 LogFlowFunc(("entered\n")); 1094 1095 VEC_INIT_PTR(&vecpchDevs, char *, RTStrFree); 1095 int rc = usbsysfsEnumerateHostDevicesWorker(p cszDevicesRoot, pvecDevInfo, &vecpchDevs);1096 int rc = usbsysfsEnumerateHostDevicesWorker(pszDevicesRoot, pvecDevInfo, &vecpchDevs); 1096 1097 VEC_CLEANUP_PTR(&vecpchDevs); 1097 1098 LogFlowFunc(("rc=%Rrc\n", rc)); … … 1390 1391 * USBProxyService::getDevices() implementation for sysfs. 1391 1392 */ 1392 static PUSBDEVICE usbsysfsGetDevices(const char *p cszDevicesRoot, bool testfs)1393 static PUSBDEVICE usbsysfsGetDevices(const char *pszDevicesRoot, bool fUnsupportedDevicesToo) 1393 1394 { 1394 1395 /* Add each of the devices found to the chain. */ … … 1400 1401 1401 1402 VEC_INIT_OBJ(&vecDevInfo, USBDeviceInfo, usbsysfsCleanupDevInfo); 1402 rc = usbsysfsEnumerateHostDevices(p cszDevicesRoot, &vecDevInfo);1403 rc = usbsysfsEnumerateHostDevices(pszDevicesRoot, &vecDevInfo); 1403 1404 if (RT_FAILURE(rc)) 1404 1405 return NULL; … … 1412 1413 if ( RT_SUCCESS(rc) 1413 1414 && ( pDev->enmState != USBDEVICESTATE_UNSUPPORTED 1414 || testfs)1415 || fUnsupportedDevicesToo) 1415 1416 && pDev->pszAddress != NULL 1416 1417 ) … … 1448 1449 static void *testDLSym(void *handle, const char *symbol) 1449 1450 { 1451 RT_NOREF(handle, symbol); 1450 1452 Assert(handle == RTLD_DEFAULT); 1451 1453 Assert(!RTStrCmp(symbol, "inotify_init")); … … 1494 1496 static const char **g_papszUsbfsDeviceAddresses = NULL; 1495 1497 1496 static PUSBDEVICE testGetUsbfsDevices(const char *pcszUsbfsRoot, bool testfs) 1497 { 1498 const char **pcsz; 1498 static PUSBDEVICE testGetUsbfsDevices(const char *pszUsbfsRoot, bool fUnsupportedDevicesToo) 1499 { 1500 RT_NOREF(pszUsbfsRoot, fUnsupportedDevicesToo); 1501 const char **psz; 1499 1502 PUSBDEVICE pList = NULL, pTail = NULL; 1500 for (p csz = g_papszUsbfsDeviceAddresses; pcsz && *pcsz; ++pcsz)1503 for (psz = g_papszUsbfsDeviceAddresses; psz && *psz; ++psz) 1501 1504 { 1502 1505 PUSBDEVICE pNext = (PUSBDEVICE)RTMemAllocZ(sizeof(USBDEVICE)); 1503 1506 if (pNext) 1504 pNext->pszAddress = RTStrDup(*p csz);1507 pNext->pszAddress = RTStrDup(*psz); 1505 1508 if (!pNext || !pNext->pszAddress) 1506 1509 { … … 1534 1537 static const char **g_papszAccessibleFiles = NULL; 1535 1538 1536 static int testAccess(const char *pcszPath, int mode) 1537 { 1538 const char **pcsz; 1539 for (pcsz = g_papszAccessibleFiles; pcsz && *pcsz; ++pcsz) 1540 if (!RTStrCmp(pcszPath, *pcsz)) 1539 static int testAccess(const char *pszPath, int mode) 1540 { 1541 RT_NOREF(mode); 1542 const char **psz; 1543 for (psz = g_papszAccessibleFiles; psz && *psz; ++psz) 1544 if (!RTStrCmp(pszPath, *psz)) 1541 1545 return 0; 1542 1546 return -1; … … 1559 1563 1560 1564 /** The path we pretend the usbfs root is located at, or NULL. */ 1561 const char *s_p cszTestUsbfsRoot;1565 const char *s_pszTestUsbfsRoot; 1562 1566 /** Should usbfs be accessible to the current user? */ 1563 1567 bool s_fTestUsbfsAccessible; 1564 1568 /** The path we pretend the device node tree root is located at, or NULL. */ 1565 const char *s_p cszTestDevicesRoot;1569 const char *s_pszTestDevicesRoot; 1566 1570 /** Should the device node tree be accessible to the current user? */ 1567 1571 bool s_fTestDevicesAccessible; … … 1569 1573 int s_rcTestMethodInitResult; 1570 1574 /** The value of the VBOX_USB environment variable. */ 1571 const char *s_p cszTestEnvUsb;1575 const char *s_pszTestEnvUsb; 1572 1576 /** The value of the VBOX_USB_ROOT environment variable. */ 1573 const char *s_p cszTestEnvUsbRoot;1577 const char *s_pszTestEnvUsbRoot; 1574 1578 1575 1579 … … 1577 1581 * during unit testing, and (hack!) what return code it will see from 1578 1582 * the access method-specific initialisation. */ 1579 void TestUSBSetupInit(const char *p cszUsbfsRoot, bool fUsbfsAccessible,1580 const char *p cszDevicesRoot, bool fDevicesAccessible,1583 void TestUSBSetupInit(const char *pszUsbfsRoot, bool fUsbfsAccessible, 1584 const char *pszDevicesRoot, bool fDevicesAccessible, 1581 1585 int rcMethodInitResult) 1582 1586 { 1583 s_p cszTestUsbfsRoot = pcszUsbfsRoot;1587 s_pszTestUsbfsRoot = pszUsbfsRoot; 1584 1588 s_fTestUsbfsAccessible = fUsbfsAccessible; 1585 s_p cszTestDevicesRoot = pcszDevicesRoot;1589 s_pszTestDevicesRoot = pszDevicesRoot; 1586 1590 s_fTestDevicesAccessible = fDevicesAccessible; 1587 1591 s_rcTestMethodInitResult = rcMethodInitResult; … … 1591 1595 /** Specify the environment that the @a init method will see during unit 1592 1596 * testing. */ 1593 void TestUSBSetEnv(const char *p cszEnvUsb, const char *pcszEnvUsbRoot)1594 { 1595 s_p cszTestEnvUsb = pcszEnvUsb;1596 s_p cszTestEnvUsbRoot = pcszEnvUsbRoot;1597 void TestUSBSetEnv(const char *pszEnvUsb, const char *pszEnvUsbRoot) 1598 { 1599 s_pszTestEnvUsb = pszEnvUsb; 1600 s_pszTestEnvUsbRoot = pszEnvUsbRoot; 1597 1601 } 1598 1602 … … 1600 1604 * return test values. */ 1601 1605 # define RTEnvGet(a) \ 1602 ( !RTStrCmp(a, "VBOX_USB") ? s_p cszTestEnvUsb \1603 : !RTStrCmp(a, "VBOX_USB_ROOT") ? s_p cszTestEnvUsbRoot \1606 ( !RTStrCmp(a, "VBOX_USB") ? s_pszTestEnvUsb \ 1607 : !RTStrCmp(a, "VBOX_USB_ROOT") ? s_pszTestEnvUsbRoot \ 1604 1608 : NULL) 1605 # define USBProxyLinuxCheckDeviceRoot(p cszPath, fUseNodes) \1609 # define USBProxyLinuxCheckDeviceRoot(pszPath, fUseNodes) \ 1606 1610 ( ((fUseNodes) && s_fTestDevicesAccessible \ 1607 && !RTStrCmp(p cszPath, s_pcszTestDevicesRoot)) \1611 && !RTStrCmp(pszPath, s_pszTestDevicesRoot)) \ 1608 1612 || (!(fUseNodes) && s_fTestUsbfsAccessible \ 1609 && !RTStrCmp(p cszPath, s_pcszTestUsbfsRoot)))1610 # define RTDirExists(p cszDir) \1611 ( (p cszDir) \1612 && ( !RTStrCmp(p cszDir, s_pcszTestDevicesRoot) \1613 || !RTStrCmp(p cszDir, s_pcszTestUsbfsRoot)))1614 # define RTFileExists(p cszFile) \1615 ( (p cszFile) \1616 && s_p cszTestUsbfsRoot \1617 && !RTStrNCmp(p cszFile, s_pcszTestUsbfsRoot, strlen(s_pcszTestUsbfsRoot)) \1618 && !RTStrCmp(p cszFile + strlen(s_pcszTestUsbfsRoot), "/devices"))1613 && !RTStrCmp(pszPath, s_pszTestUsbfsRoot))) 1614 # define RTDirExists(pszDir) \ 1615 ( (pszDir) \ 1616 && ( !RTStrCmp(pszDir, s_pszTestDevicesRoot) \ 1617 || !RTStrCmp(pszDir, s_pszTestUsbfsRoot))) 1618 # define RTFileExists(pszFile) \ 1619 ( (pszFile) \ 1620 && s_pszTestUsbfsRoot \ 1621 && !RTStrNCmp(pszFile, s_pszTestUsbfsRoot, strlen(s_pszTestUsbfsRoot)) \ 1622 && !RTStrCmp(pszFile + strlen(s_pszTestUsbfsRoot), "/devices")) 1619 1623 1620 1624 #endif /* UNIT_TEST */ … … 1631 1635 * the prefered access method is USBFS-like and to 1632 1636 * false if it is sysfs/device node-like 1633 * @param pp cszDevicesRoot on success the root of the tree of USBFS-like1637 * @param ppszDevicesRoot on success the root of the tree of USBFS-like 1634 1638 * device nodes will be stored here 1635 1639 */ 1636 int USBProxyLinuxChooseMethod(bool *pfUsingUsbfsDevices, const char **pp cszDevicesRoot)1640 int USBProxyLinuxChooseMethod(bool *pfUsingUsbfsDevices, const char **ppszDevicesRoot) 1637 1641 { 1638 1642 /* … … 1647 1651 bool fUsbfsChosen = false; 1648 1652 bool fSysfsChosen = false; 1649 const char *p cszUsbFromEnv = RTEnvGet("VBOX_USB");1650 const char *p cszUsbRoot = NULL;1651 if (p cszUsbFromEnv)1653 const char *pszUsbFromEnv = RTEnvGet("VBOX_USB"); 1654 const char *pszUsbRoot = NULL; 1655 if (pszUsbFromEnv) 1652 1656 { 1653 1657 bool fValidVBoxUSB = true; 1654 1658 1655 p cszUsbRoot = RTEnvGet("VBOX_USB_ROOT");1656 if (!RTStrICmp(p cszUsbFromEnv, "USBFS"))1659 pszUsbRoot = RTEnvGet("VBOX_USB_ROOT"); 1660 if (!RTStrICmp(pszUsbFromEnv, "USBFS")) 1657 1661 { 1658 1662 LogRel(("Default USB access method set to \"usbfs\" from environment\n")); 1659 1663 fUsbfsChosen = true; 1660 1664 } 1661 else if (!RTStrICmp(p cszUsbFromEnv, "SYSFS"))1665 else if (!RTStrICmp(pszUsbFromEnv, "SYSFS")) 1662 1666 { 1663 1667 LogRel(("Default USB method set to \"sysfs\" from environment\n")); … … 1666 1670 else 1667 1671 { 1668 LogRel(("Invalid VBOX_USB environment variable setting \"%s\"\n", p cszUsbFromEnv));1672 LogRel(("Invalid VBOX_USB environment variable setting \"%s\"\n", pszUsbFromEnv)); 1669 1673 fValidVBoxUSB = false; 1670 p cszUsbFromEnv = NULL;1671 } 1672 if (!fValidVBoxUSB && p cszUsbRoot)1673 p cszUsbRoot = NULL;1674 } 1675 if (!p cszUsbRoot)1674 pszUsbFromEnv = NULL; 1675 } 1676 if (!fValidVBoxUSB && pszUsbRoot) 1677 pszUsbRoot = NULL; 1678 } 1679 if (!pszUsbRoot) 1676 1680 { 1677 1681 if ( !fUsbfsChosen … … 1679 1683 { 1680 1684 fSysfsChosen = true; 1681 p cszUsbRoot = "/dev/vboxusb";1685 pszUsbRoot = "/dev/vboxusb"; 1682 1686 } 1683 1687 else if ( !fSysfsChosen … … 1685 1689 { 1686 1690 fUsbfsChosen = true; 1687 p cszUsbRoot = "/proc/bus/usb";1688 } 1689 } 1690 else if (!USBProxyLinuxCheckDeviceRoot(p cszUsbRoot, fSysfsChosen))1691 p cszUsbRoot = NULL;1692 if (p cszUsbRoot)1691 pszUsbRoot = "/proc/bus/usb"; 1692 } 1693 } 1694 else if (!USBProxyLinuxCheckDeviceRoot(pszUsbRoot, fSysfsChosen)) 1695 pszUsbRoot = NULL; 1696 if (pszUsbRoot) 1693 1697 { 1694 1698 *pfUsingUsbfsDevices = fUsbfsChosen; 1695 *pp cszDevicesRoot = pcszUsbRoot;1699 *ppszDevicesRoot = pszUsbRoot; 1696 1700 return VINF_SUCCESS; 1697 1701 } 1698 1702 /* else */ 1699 return p cszUsbFromEnv ? VERR_NOT_FOUND1703 return pszUsbFromEnv ? VERR_NOT_FOUND 1700 1704 : RTDirExists("/dev/vboxusb") ? VERR_VUSB_USB_DEVICE_PERMISSION 1701 1705 : RTFileExists("/proc/bus/usb/devices") ? VERR_VUSB_USBFS_PERMISSION … … 1713 1717 * Check whether a USB device tree root is usable. 1714 1718 * 1715 * @param p cszRoot the path to the root of the device tree1719 * @param pszRoot the path to the root of the device tree 1716 1720 * @param fIsDeviceNodes whether this is a device node (or usbfs) tree 1717 1721 * @note returns a pointer into a static array so it will stay valid 1718 1722 */ 1719 bool USBProxyLinuxCheckDeviceRoot(const char *p cszRoot, bool fIsDeviceNodes)1723 bool USBProxyLinuxCheckDeviceRoot(const char *pszRoot, bool fIsDeviceNodes) 1720 1724 { 1721 1725 bool fOK = false; … … 1723 1727 { 1724 1728 #ifdef VBOX_USB_WITH_USBFS 1725 if (!access(p cszRoot, R_OK | X_OK))1729 if (!access(pszRoot, R_OK | X_OK)) 1726 1730 { 1727 1731 fOK = true; 1728 PUSBDEVICE pDevices = usbfsGetDevices(p cszRoot, true);1732 PUSBDEVICE pDevices = usbfsGetDevices(pszRoot, true); 1729 1733 if (pDevices) 1730 1734 { … … 1740 1744 #ifdef VBOX_USB_WITH_SYSFS 1741 1745 /* device nodes */ 1742 else if (usbsysfsInotifyAvailable() && !access(p cszRoot, R_OK | X_OK))1746 else if (usbsysfsInotifyAvailable() && !access(pszRoot, R_OK | X_OK)) 1743 1747 fOK = true; 1744 1748 #endif … … 1756 1760 * Result should be freed using #deviceFree or something equivalent. 1757 1761 * 1758 * @param p cszDevicesRoot the path to the root of the device tree1762 * @param pszDevicesRoot the path to the root of the device tree 1759 1763 * @param fUseSysfs whether to use sysfs (or usbfs) for enumeration 1760 1764 */ 1761 PUSBDEVICE USBProxyLinuxGetDevices(const char *p cszDevicesRoot, bool fUseSysfs)1765 PUSBDEVICE USBProxyLinuxGetDevices(const char *pszDevicesRoot, bool fUseSysfs) 1762 1766 { 1763 1767 if (!fUseSysfs) 1764 1768 { 1765 1769 #ifdef VBOX_USB_WITH_USBFS 1766 return usbfsGetDevices(p cszDevicesRoot, false);1770 return usbfsGetDevices(pszDevicesRoot, false); 1767 1771 #else 1768 1772 return NULL; … … 1771 1775 1772 1776 #ifdef VBOX_USB_WITH_SYSFS 1773 return usbsysfsGetDevices(p cszDevicesRoot, false);1777 return usbsysfsGetDevices(pszDevicesRoot, false); 1774 1778 #else 1775 1779 return NULL; -
trunk/src/VBox/Main/src-server/xpcom/server_module.cpp
r62485 r63378 175 175 176 176 nsresult rc = NS_OK; 177 int vrc = VINF_SUCCESS;178 177 179 178 do … … 312 311 while (0); 313 312 314 LogFlowFunc(("rc=%Rhrc (%#08x) , vrc=%Rrc\n", rc, rc, vrc));313 LogFlowFunc(("rc=%Rhrc (%#08x)\n", rc, rc)); 315 314 LogFlowFuncLeave(); 316 315 -
trunk/src/VBox/Main/testcase/tstAPI.cpp
r60063 r63378 44 44 /////////////////////////////////////////////////////////////////////////////// 45 45 46 static Bstr getObjectName(ComPtr<IVirtualBox> aVirtualBox, 47 46 #ifdef VBOX_WITH_RESOURCE_USAGE_API 47 static Bstr getObjectName(ComPtr<IVirtualBox> aVirtualBox, ComPtr<IUnknown> aObject); 48 48 static void queryMetrics(ComPtr<IVirtualBox> aVirtualBox, 49 49 ComPtr<IPerformanceCollector> collector, … … 51 51 static void listAffectedMetrics(ComPtr<IVirtualBox> aVirtualBox, 52 52 ComSafeArrayIn(IPerformanceMetric*, aMetrics)); 53 #endif 53 54 54 55 // funcs … … 1596 1597 1597 1598 #ifdef VBOX_WITH_RESOURCE_USAGE_API 1599 1598 1600 static void queryMetrics(ComPtr<IVirtualBox> aVirtualBox, 1599 1601 ComPtr<IPerformanceCollector> collector,
Note:
See TracChangeset
for help on using the changeset viewer.