Changeset 77848 in vbox for trunk/src/VBox
- Timestamp:
- Mar 22, 2019 1:24:24 PM (6 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedFolders
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedFolders/VBoxSharedFoldersSvc.cpp
r77837 r77848 98 98 static STAMPROFILE g_StatQueryMapInfo; 99 99 static STAMPROFILE g_StatQueryFeatures; 100 static STAMPROFILE g_StatCopyFile; 101 static STAMPROFILE g_StatCopyFileFail; 100 102 static STAMPROFILE g_StatCopyFilePart; 101 103 static STAMPROFILE g_StatCopyFilePartFail; … … 1504 1506 } 1505 1507 1508 case SHFL_FN_COPY_FILE: 1509 { 1510 pStat = &g_StatCopyFile; 1511 pStatFail = &g_StatCopyFileFail; 1512 1513 /* Validate input: */ 1514 ASSERT_GUEST_STMT_BREAK(cParms == SHFL_CPARMS_COPY_FILE, rc = VERR_WRONG_PARAMETER_COUNT); 1515 ASSERT_GUEST_STMT_BREAK(paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* i32RootSrc */ 1516 ASSERT_GUEST_STMT_BREAK(paParms[1].type == VBOX_HGCM_SVC_PARM_PTR, rc = VERR_WRONG_PARAMETER_TYPE); /* pStrPathSrc */ 1517 PCSHFLSTRING pStrPathSrc = (PCSHFLSTRING)paParms[1].u.pointer.addr; 1518 ASSERT_GUEST_STMT_BREAK(ShflStringIsValidIn(pStrPathSrc, paParms[1].u.pointer.size, 1519 RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8)), 1520 rc = VERR_INVALID_PARAMETER); 1521 ASSERT_GUEST_STMT_BREAK(paParms[2].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* i32RootDst */ 1522 ASSERT_GUEST_STMT_BREAK(paParms[3].type == VBOX_HGCM_SVC_PARM_PTR, rc = VERR_WRONG_PARAMETER_TYPE); /* pStrPathDst */ 1523 PCSHFLSTRING pStrPathDst = (PCSHFLSTRING)paParms[3].u.pointer.addr; 1524 ASSERT_GUEST_STMT_BREAK(ShflStringIsValidIn(pStrPathDst, paParms[3].u.pointer.size, 1525 RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8)), 1526 rc = VERR_INVALID_PARAMETER); 1527 ASSERT_GUEST_STMT_BREAK(paParms[4].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* f32Flags */ 1528 ASSERT_GUEST_STMT_BREAK(paParms[4].u.uint32 == 0, rc = VERR_INVALID_FLAGS); 1529 1530 /* Execute the function: */ 1531 rc = vbsfCopyFile(pClient, paParms[0].u.uint32, pStrPathSrc, paParms[2].u.uint64, pStrPathDst, paParms[3].u.uint32); 1532 break; 1533 } 1534 1535 1506 1536 case SHFL_FN_COPY_FILE_PART: 1507 1537 { … … 1531 1561 break; 1532 1562 } 1533 1534 1563 1535 1564 default: … … 1841 1870 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatQueryMapInfo, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_QUERY_MAP_INFO", "/HGCM/VBoxSharedFolders/FnQueryMapInfo"); 1842 1871 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatQueryFeatures, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_QUERY_FEATURES", "/HGCM/VBoxSharedFolders/FnQueryFeatures"); 1872 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCopyFile, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_COPY_FILE successes", "/HGCM/VBoxSharedFolders/FnCopyFile"); 1873 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCopyFileFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_COPY_FILE failures", "/HGCM/VBoxSharedFolders/FnCopyFileFail"); 1843 1874 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCopyFilePart, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_COPY_FILE_PART successes", "/HGCM/VBoxSharedFolders/FnCopyFilePart"); 1844 1875 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCopyFilePartFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_COPY_FILE_PART failures", "/HGCM/VBoxSharedFolders/FnCopyFilePartFail"); -
trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp
r77838 r77848 121 121 } 122 122 123 static int vbsfBuildFullPath(SHFLCLIENTDATA *pClient, SHFLROOT root, P SHFLSTRING pPath,123 static int vbsfBuildFullPath(SHFLCLIENTDATA *pClient, SHFLROOT root, PCSHFLSTRING pPath, 124 124 uint32_t cbPath, char **ppszFullPath, uint32_t *pcbFullPathRoot, 125 125 bool fWildCard = false, bool fPreserveLastComponent = false) … … 1368 1368 } 1369 1369 1370 /** Implements SHFL_FN_COPY_FILE_PART (wrapping RTFileCopyPart). */ 1370 /** 1371 * Implements SHFL_FN_COPY_FILE_PART (wrapping RTFileCopyPart). 1372 */ 1371 1373 int vbsfCopyFilePart(SHFLCLIENTDATA *pClient, SHFLROOT idRootSrc, SHFLHANDLE hFileSrc, uint64_t offSrc, 1372 1374 SHFLROOT idRootDst, SHFLHANDLE hFileDst, uint64_t offDst, uint64_t *pcbToCopy, uint32_t fFlags) … … 1392 1394 if (RT_SUCCESS(rc)) 1393 1395 { 1396 /* 1397 * Do the job. 1398 */ 1394 1399 rc = RTFileCopyPart(pHandleSrc->file.Handle, offSrc, pHandleDst->file.Handle, offDst, cbToCopy, 0, &cbTotal); 1395 1400 *pcbToCopy = cbTotal; … … 2292 2297 } 2293 2298 2299 /** 2300 * Implements SHFL_FN_COPY_FILE (wrapping RTFileCopy). 2301 */ 2302 int vbsfCopyFile(SHFLCLIENTDATA *pClient, SHFLROOT idRootSrc, PCSHFLSTRING pStrPathSrc, 2303 SHFLROOT idRootDst, PCSHFLSTRING pStrPathDst, uint32_t fFlags) 2304 { 2305 AssertPtrReturn(pClient, VERR_INVALID_PARAMETER); 2306 if (pClient->fu32Flags & SHFL_CF_UTF8) 2307 LogFunc(("pClient %p, idRootSrc %#RX32, '%.*s', idRootSrc %#RX32, '%.*s', fFlags %#x\n", pClient, idRootSrc, 2308 pStrPathSrc->u16Length, pStrPathSrc->String.ach, idRootDst, pStrPathDst->u16Length, pStrPathDst->String.ach, fFlags)); 2309 else 2310 LogFunc(("pClient %p, idRootSrc %#RX32, '%.*ls', idRootSrc %#RX32, '%.*ls', fFlags %#x\n", pClient, 2311 idRootSrc, pStrPathSrc->u16Length / sizeof(RTUTF16), pStrPathSrc->String.ach, 2312 idRootDst, pStrPathDst->u16Length / sizeof(RTUTF16), pStrPathDst->String.ach, fFlags)); 2313 2314 /* 2315 * Build host paths. 2316 */ 2317 char *pszPathSrc = NULL; 2318 int rc = vbsfBuildFullPath(pClient, idRootSrc, pStrPathSrc, pStrPathSrc->u16Size + SHFLSTRING_HEADER_SIZE, &pszPathSrc, NULL); 2319 if (RT_SUCCESS(rc)) 2320 { 2321 char *pszPathDst = NULL; 2322 rc = vbsfBuildFullPath(pClient, idRootDst, pStrPathDst, pStrPathDst->u16Size + SHFLSTRING_HEADER_SIZE, &pszPathDst, NULL); 2323 if (RT_SUCCESS(rc)) 2324 { 2325 /* 2326 * Do the job. 2327 */ 2328 rc = RTFileCopy(pszPathSrc, pszPathDst); 2329 2330 vbsfFreeFullPath(pszPathDst); 2331 } 2332 vbsfFreeFullPath(pszPathSrc); 2333 } 2334 2335 RT_NOREF(fFlags); 2336 LogFunc(("returns %Rrc\n", rc)); 2337 return rc; 2338 } 2339 2294 2340 #ifdef UNITTEST 2295 2341 /** Unit test the SHFL_FN_SYMLINK API. Located here as a form of API -
trunk/src/VBox/HostServices/SharedFolders/vbsf.h
r77837 r77848 42 42 int vbsfRemove(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pPath, uint32_t cbPath, uint32_t flags); 43 43 int vbsfRename(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pSrc, SHFLSTRING *pDest, uint32_t flags); 44 int vbsfCopyFile(SHFLCLIENTDATA *pClient, SHFLROOT idRootSrc, PCSHFLSTRING pStrPathSrc, 45 SHFLROOT idRootDst, PCSHFLSTRING pStrPathDst, uint32_t fFlags); 44 46 int vbsfDirList(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle, SHFLSTRING *pPath, uint32_t flags, uint32_t *pcbBuffer, uint8_t *pBuffer, uint32_t *pIndex, uint32_t *pcFiles); 45 47 int vbsfFileInfo(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle, uint32_t flags, uint32_t *pcbBuffer, uint8_t *pBuffer); -
trunk/src/VBox/HostServices/SharedFolders/vbsfpath.cpp
r76553 r77848 429 429 430 430 int vbsfPathGuestToHost(SHFLCLIENTDATA *pClient, SHFLROOT hRoot, 431 P SHFLSTRING pGuestString, uint32_t cbGuestString,431 PCSHFLSTRING pGuestString, uint32_t cbGuestString, 432 432 char **ppszHostPath, uint32_t *pcbHostPathRoot, 433 433 uint32_t fu32Options, … … 472 472 /* UTF-8 */ 473 473 cbGuestPath = pGuestString->u16Length; 474 pchGuestPath = (char *)&pGuestString->String.utf8[0];474 pchGuestPath = pGuestString->String.ach; 475 475 } 476 476 else 477 477 { 478 478 /* UTF-16 */ 479 uint32_t cwcSrc;480 PRTUTF16 pwszSrc;481 479 482 480 #ifdef RT_OS_DARWIN /* Misplaced hack! See todo! */ 483 cwcSrc= 0;484 pwszSrc = NULL;481 uint32_t cwcSrc = 0; 482 PRTUTF16 pwszSrc = NULL; 485 483 rc = vbsfNormalizeStringDarwin(&pGuestString->String.ucs2[0], 486 484 pGuestString->u16Length / sizeof(RTUTF16), 487 485 &pwszSrc, &cwcSrc); 488 486 #else 489 cwcSrc = pGuestString->u16Length / sizeof(RTUTF16);490 pwszSrc = &pGuestString->String.ucs2[0];487 uint32_t const cwcSrc = pGuestString->u16Length / sizeof(RTUTF16); 488 PCRTUTF16 const pwszSrc = &pGuestString->String.ucs2[0]; 491 489 #endif 492 490 -
trunk/src/VBox/HostServices/SharedFolders/vbsfpath.h
r76570 r77848 44 44 */ 45 45 int vbsfPathGuestToHost(SHFLCLIENTDATA *pClient, SHFLROOT hRoot, 46 P SHFLSTRING pGuestString, uint32_t cbGuestString,46 PCSHFLSTRING pGuestString, uint32_t cbGuestString, 47 47 char **ppszHostPath, uint32_t *pcbHostPathRoot, 48 48 uint32_t fu32Options, uint32_t *pfu32PathFlags);
Note:
See TracChangeset
for help on using the changeset viewer.