Changeset 76143 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Dec 10, 2018 9:24:46 PM (6 years ago)
- Location:
- trunk/src/VBox/Additions/os2/VBoxSF
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/os2/VBoxSF/VBoxSF.cpp
r76126 r76143 40 40 #include <iprt/ctype.h> 41 41 #include <iprt/mem.h> 42 #include <iprt/path.h> 42 43 43 44 #include <iprt/asm.h> … … 92 93 case VERR_WRITE_PROTECT: return ERROR_WRITE_PROTECT; 93 94 case VERR_IS_A_DIRECTORY: return ERROR_DIRECTORY; 95 case VERR_DISK_FULL: return ERROR_DISK_FULL; 94 96 case VINF_SUCCESS: return NO_ERROR; 95 97 } … … 281 283 /* Note! We won't get there while the folder is on the list. */ 282 284 LogRel(("vboxSfOs2ReleaseFolder: Destroying %p [%s]\n", pFolder, pFolder->szName)); 283 VbglR0SfUnmapFolder(&g_SfClient, &pFolder->hHostFolder);285 vboxSfOs2HostReqUnmapFolderSimple(pFolder->hHostFolder.root); 284 286 RT_ZERO(pFolder); 285 287 RTMemFree(pFolder); … … 387 389 388 390 /* Try do the mapping.*/ 389 rc = VbglR0SfMapFolder(&g_SfClient, pName, &pNew->hHostFolder); 390 if (RT_SUCCESS(rc)) 391 { 392 RTListAppend(&g_FolderHead, &pNew->ListEntry); 393 ASMAtomicIncU32(&g_uFolderRevision); 394 LogRel(("vboxSfOs2MapFolder: %p - %s\n", pNew, pNew->szName)); 395 396 *ppFolder = pNew; 391 VBOXSFMAPFOLDERWITHBUFREQ *pReq = (VBOXSFMAPFOLDERWITHBUFREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq)); 392 if (pReq) 393 { 394 rc = vboxSfOs2HostReqMapFolderWithBuf(pReq, pName, RTPATH_DELIMITER, false /*fCaseSensitive*/); 395 if (RT_SUCCESS(rc)) 396 { 397 pNew->hHostFolder.root = pReq->Parms.id32Root.u.value32; 398 399 RTListAppend(&g_FolderHead, &pNew->ListEntry); 400 ASMAtomicIncU32(&g_uFolderRevision); 401 LogRel(("vboxSfOs2MapFolder: %p - %s\n", pNew, pNew->szName)); 402 403 *ppFolder = pNew; 404 pNew = NULL; 405 } 406 else 407 LogRel(("vboxSfOs2MapFolder: vboxSfOs2HostReqMapFolderWithBuf(,%s,) -> %Rrc\n", pNew->szName, rc)); 408 VbglR0PhysHeapFree(pReq); 397 409 } 398 410 else 399 { 400 LogRel(("vboxSfOs2MapFolder: VbglR0SfMapFolder(,%s,) -> %Rrc\n", pNew->szName, rc)); 401 RTMemFree(pNew); 402 } 411 LogRel(("vboxSfOs2MapFolder: Out of physical heap :-(\n")); 412 RTMemFree(pNew); 403 413 } 404 414 else … … 1350 1360 && pu->Open.Req.CreateParms.Handle != SHFL_HANDLE_NIL) 1351 1361 { 1352 SHFLHANDLE hHandle = pu->Open.Req.CreateParms.Handle;1362 SHFLHANDLE volatile hHandle = pu->Open.Req.CreateParms.Handle; 1353 1363 1354 1364 RT_ZERO(pu->Info.Req); … … 1380 1390 else 1381 1391 { 1382 LogRel(("FS32_FSINFO: VbglR0SfFsInfo/SHFL_INFO_VOLUMEfailed: %Rrc\n", vrc));1392 LogRel(("FS32_FSINFO: vboxSfOs2HostReqQueryVolInfo failed: %Rrc\n", vrc)); 1383 1393 rc = ERROR_GEN_FAILURE; 1384 1394 } … … 1595 1605 */ 1596 1606 PVBOXSFFOLDER pFolder; 1597 PSHFLSTRING pStrFolderPath; 1598 APIRET rc = vboxSfOs2ResolvePath(pszDir, pCdFsd, offCurDirEnd, &pFolder, &pStrFolderPath); 1607 VBOXSFREMOVEREQ *pReq; 1608 APIRET rc = vboxSfOs2ResolvePathEx(pszDir, pCdFsd, offCurDirEnd, RT_UOFFSETOF(VBOXSFREMOVEREQ, StrPath), 1609 &pFolder, (void **)&pReq); 1599 1610 if (rc == NO_ERROR) 1600 1611 { 1601 int vrc = VbglR0SfRemove(&g_SfClient, &pFolder->hHostFolder, pStrFolderPath, SHFL_REMOVE_DIR);1602 LogFlow(("FS32_RMDIR: VbglR0SfRemove -> %Rrc\n", rc));1612 int vrc = vboxSfOs2HostReqRemove(pFolder, pReq, SHFL_REMOVE_DIR); 1613 LogFlow(("FS32_RMDIR: vboxSfOs2HostReqRemove -> %Rrc\n", rc)); 1603 1614 if (RT_SUCCESS(vrc)) 1604 1615 rc = NO_ERROR; … … 1606 1617 rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_ACCESS_DENIED); 1607 1618 1608 vboxSfOs2ReleasePathAndFolder(pStrFolderPath, pFolder); 1619 VbglR0PhysHeapFree(pReq); 1620 vboxSfOs2ReleaseFolder(pFolder); 1609 1621 } 1610 1622 … … 1644 1656 if (rc == NO_ERROR) 1645 1657 { 1646 PVBOXSFFOLDER pDstFolder; 1647 PSHFLSTRING pDstFolderPath; 1648 rc = vboxSfOs2ResolvePath(pszDst, pCdFsd, offDstCurDirEnd, &pDstFolder, &pDstFolderPath); 1658 PVBOXSFFOLDER pDstFolder; 1659 VBOXSFRENAMEWITHSRCBUFREQ *pReq; 1660 rc = vboxSfOs2ResolvePathEx(pszDst, pCdFsd, offDstCurDirEnd, RT_UOFFSETOF(VBOXSFRENAMEWITHSRCBUFREQ, StrDstPath), 1661 &pDstFolder, (void **)&pReq); 1649 1662 if (rc == NO_ERROR) 1650 1663 { … … 1655 1668 * Note! Requires 6.0.0beta2+ or 5.2.24+ host for renaming files. 1656 1669 */ 1657 int vrc = VbglR0SfRename(&g_SfClient, &pSrcFolder->hHostFolder, pSrcFolderPath, pDstFolderPath, 1658 SHFL_RENAME_FILE | SHFL_RENAME_DIR); 1670 int vrc = vboxSfOs2HostReqRenameWithSrcBuf(pSrcFolder, pReq, pSrcFolderPath, SHFL_RENAME_FILE | SHFL_RENAME_DIR); 1659 1671 if (RT_SUCCESS(vrc)) 1660 1672 rc = NO_ERROR; 1661 1673 else 1662 1674 { 1663 Log(("FS32_MOVE: VbglR0SfRenamefailed: %Rrc\n", rc));1675 Log(("FS32_MOVE: vboxSfOs2HostReqRenameWithSrcBuf failed: %Rrc\n", rc)); 1664 1676 rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_ACCESS_DENIED); 1665 1677 } … … 1667 1679 else 1668 1680 { 1669 Log(("FS32_MOVE: source folder '%s' != destiation folder '%s'\n", p SrcFolder->szName, pDstFolder->szName));1681 Log(("FS32_MOVE: source folder '%s' != destiation folder '%s'\n", pszSrc, pszDst)); 1670 1682 rc = ERROR_NOT_SAME_DEVICE; 1671 1683 } 1672 vboxSfOs2ReleasePathAndFolder(pDstFolderPath, pDstFolder); 1684 VbglR0PhysHeapFree(pReq); 1685 vboxSfOs2ReleaseFolder(pDstFolder); 1673 1686 } 1674 1687 vboxSfOs2ReleasePathAndFolder(pSrcFolderPath, pSrcFolder); … … 1688 1701 * Resolve the path. 1689 1702 */ 1690 PVBOXSFFOLDER pFolder; 1691 PSHFLSTRING pStrFolderPath; 1692 APIRET rc = vboxSfOs2ResolvePath(pszFile, pCdFsd, offCurDirEnd, &pFolder, &pStrFolderPath); 1703 PVBOXSFFOLDER pFolder; 1704 VBOXSFREMOVEREQ *pReq; 1705 APIRET rc = vboxSfOs2ResolvePathEx(pszFile, pCdFsd, offCurDirEnd, RT_UOFFSETOF(VBOXSFREMOVEREQ, StrPath), 1706 &pFolder, (void **)&pReq); 1693 1707 if (rc == NO_ERROR) 1694 1708 { 1695 int vrc = VbglR0SfRemove(&g_SfClient, &pFolder->hHostFolder, pStrFolderPath, SHFL_REMOVE_FILE);1696 LogFlow(("FS32_DELETE: VbglR0SfRemove -> %Rrc\n", rc));1709 int vrc = vboxSfOs2HostReqRemove(pFolder, pReq, SHFL_REMOVE_FILE); 1710 LogFlow(("FS32_DELETE: vboxSfOs2HostReqRemove -> %Rrc\n", rc)); 1697 1711 if (RT_SUCCESS(vrc)) 1698 1712 rc = NO_ERROR; … … 1700 1714 rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_ACCESS_DENIED); 1701 1715 1702 vboxSfOs2ReleasePathAndFolder(pStrFolderPath, pFolder); 1716 VbglR0PhysHeapFree(pReq); 1717 vboxSfOs2ReleaseFolder(pFolder); 1703 1718 } 1704 1719 … … 1714 1729 * 1715 1730 * @returns OS/2 status code 1716 * @param pFolder The folder. 1717 * @param hHostFile The host file handle. 1718 * @param fAttribs The attributes to set. 1719 * @param pTimestamps Pointer to the timestamps. NULL if none should be 1720 * modified. 1721 * @param pObjInfoBuf Buffer to use when setting the attributes (host will 1722 * return current info upon successful return). 1731 * @param pFolder The folder. 1732 * @param hHostFile The host file handle. 1733 * @param fAttribs The attributes to set. 1734 * @param pTimestamps Pointer to the timestamps. NULL if none should be 1735 * modified. 1736 * @param pObjInfoBuf Buffer to use when setting the attributes (host 1737 * will return current info upon successful 1738 * return). This must life on the phys heap. 1739 * @param offObjInfoInAlloc Offset of pObjInfoBuf in the phys heap 1740 * allocation where it lives. 1723 1741 */ 1724 1742 APIRET vboxSfOs2SetInfoCommonWorker(PVBOXSFFOLDER pFolder, SHFLHANDLE hHostFile, ULONG fAttribs, 1725 PFILESTATUS pTimestamps, PSHFLFSOBJINFO pObjInfoBuf )1743 PFILESTATUS pTimestamps, PSHFLFSOBJINFO pObjInfoBuf, uint32_t offObjInfoInAlloc) 1726 1744 { 1727 1745 /* … … 1766 1784 * Call the host to do the updating. 1767 1785 */ 1768 uint32_t cbBuf = sizeof(*pObjInfoBuf); 1769 int vrc = VbglR0SfFsInfo(&g_SfClient, &pFolder->hHostFolder, hHostFile, SHFL_INFO_SET | SHFL_INFO_FILE, 1770 &cbBuf, (SHFLDIRINFO *)pObjInfoBuf); 1771 LogFlow(("vboxSfOs2SetFileInfo: VbglR0SfFsInfo -> %Rrc\n", vrc)); 1772 1773 if (RT_SUCCESS(vrc)) 1774 return NO_ERROR; 1775 return vboxSfOs2ConvertStatusToOs2(vrc, ERROR_ACCESS_DENIED); 1786 VBOXSFOBJINFOWITHBUFREQ *pReq = (VBOXSFOBJINFOWITHBUFREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq)); 1787 if (pReq) 1788 { 1789 int vrc = vboxSfOs2HostReqSetObjInfoWithBuf(pFolder, pReq, hHostFile, pObjInfoBuf, offObjInfoInAlloc); 1790 LogFlow(("vboxSfOs2SetFileInfo: vboxSfOs2HostReqSetObjInfoWithBuf -> %Rrc\n", vrc)); 1791 1792 VbglR0PhysHeapFree(pReq); 1793 if (RT_SUCCESS(vrc)) 1794 return NO_ERROR; 1795 return vboxSfOs2ConvertStatusToOs2(vrc, ERROR_ACCESS_DENIED); 1796 } 1797 return ERROR_NOT_ENOUGH_MEMORY; 1776 1798 } 1777 1799 … … 1821 1843 * Join up with FS32_FILEINFO to do the actual setting. 1822 1844 */ 1823 uint64_t const uHandle = pReq->CreateParms.Handle;1824 ASMCompilerBarrier(); /* paranoia */1825 1826 1845 rc = vboxSfOs2SetInfoCommonWorker(pFolder, pReq->CreateParms.Handle, fAttribs, pTimestamps, 1827 &pReq->CreateParms.Info );1828 1829 AssertCompile( sizeof(VBOXSFCLOSEREQ) < sizeof(*pReq));1830 vrc = vboxSfOs2HostReqClose(pFolder, (VBOXSFCLOSEREQ *)pReq, uHandle);1846 &pReq->CreateParms.Info, RT_UOFFSETOF(VBOXSFCREATEREQ, CreateParms.Info)); 1847 1848 AssertCompile(RTASSERT_OFFSET_OF(VBOXSFCREATEREQ, CreateParms.Handle) > sizeof(VBOXSFCLOSEREQ)); /* no aliasing issues */ 1849 vrc = vboxSfOs2HostReqClose(pFolder, (VBOXSFCLOSEREQ *)pReq, pReq->CreateParms.Handle); 1831 1850 AssertRC(vrc); 1832 1851 } -
trunk/src/VBox/Additions/os2/VBoxSF/VBoxSFFile.cpp
r76108 r76143 152 152 */ 153 153 int vrc = vboxSfOs2HostReqCreate(pFolder, pReq); 154 LogFlow(("FS32_OPENCREATE: VbglR0SfCreate -> %Rrc Result=%d fMode=%#x\n", vrc, pReq->CreateParms.Result, pReq->CreateParms.Info.Attr.fMode)); 154 LogFlow(("FS32_OPENCREATE: vboxSfOs2HostReqCreate -> %Rrc Result=%d fMode=%#x\n", 155 vrc, pReq->CreateParms.Result, pReq->CreateParms.Info.Attr.fMode)); 155 156 if (RT_SUCCESS(vrc)) 156 157 { … … 198 199 { 199 200 LogRel(("FS32_OPENCREATE: cbObject=%#RX64 no OPEN_FLAGS_LARGEFILE (%s)\n", pReq->CreateParms.Info.cbObject, pszName)); 200 VbglR0SfClose(&g_SfClient, &pFolder->hHostFolder, pReq->CreateParms.Handle); 201 AssertCompile(RTASSERT_OFFSET_OF(VBOXSFCREATEREQ, CreateParms.Handle) > sizeof(VBOXSFCLOSEREQ)); /* no aliasing issues */ 202 vboxSfOs2HostReqClose(pFolder, (VBOXSFCLOSEREQ *)pReq, pReq->CreateParms.Handle); 201 203 rc = ERROR_ACCESS_DENIED; 202 204 } … … 251 253 RT_NOREF(fIoFlags); 252 254 253 int vrc = VbglR0SfClose(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile);255 int vrc = vboxSfOs2HostReqCloseSimple(pFolder, pSfFsd->hHostFile); 254 256 AssertRC(vrc); 255 257 … … 290 292 || (pSfFsi->sfi_mode & SFMODE_OPEN_ACCESS) == SFMODE_OPEN_READWRITE) 291 293 { 292 int vrc = VbglR0SfFlush(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile);294 int vrc = vboxSfOs2HostReqFlushSimple(pFolder, pSfFsd->hHostFile); 293 295 if (RT_FAILURE(vrc)) 294 296 { 295 LogRel(("FS32_COMMIT: VbglR0SfFlushfailed: %Rrc\n", vrc));297 LogRel(("FS32_COMMIT: vboxSfOs2HostReqFlushSimple failed: %Rrc\n", vrc)); 296 298 return ERROR_FLUSHBUF_FAILED; 297 299 } … … 345 347 { 346 348 /* Have to consult the host to get the current file size. */ 347 348 PSHFLFSOBJINFO pObjInfo = (PSHFLFSOBJINFO)VbglR0PhysHeapAlloc(sizeof(*pObjInfo)); 349 if (!pObjInfo) 349 VBOXSFOBJINFOREQ *pReq = (VBOXSFOBJINFOREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq)); 350 if (pReq) 351 RT_ZERO(*pReq); 352 else 350 353 return ERROR_NOT_ENOUGH_MEMORY; 351 RT_ZERO(*pObjInfo); 352 uint32_t cbObjInfo = sizeof(*pObjInfo); 353 354 int vrc = VbglR0SfFsInfo(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile, 355 SHFL_INFO_FILE | SHFL_INFO_GET, &cbObjInfo, (PSHFLDIRINFO)pObjInfo); 354 355 int vrc = vboxSfOs2HostReqQueryObjInfo(pFolder, pReq, pSfFsd->hHostFile); 356 356 if (RT_SUCCESS(vrc)) 357 357 { 358 358 if (pSfFsi->sfi_mode & SFMODE_LARGE_FILE) 359 pSfFsi->sfi_sizel = p ObjInfo->cbObject;359 pSfFsi->sfi_sizel = pReq->ObjInfo.cbObject; 360 360 else 361 pSfFsi->sfi_sizel = RT_MIN(p ObjInfo->cbObject, _2G - 1);361 pSfFsi->sfi_sizel = RT_MIN(pReq->ObjInfo.cbObject, _2G - 1); 362 362 } 363 363 else 364 364 LogRel(("FS32_CHGFILEPTRL/CFP_RELEND: VbglR0SfFsInfo failed: %Rrc\n", vrc)); 365 VbglR0PhysHeapFree(pObjInfo); 365 366 VbglR0PhysHeapFree(pReq); 366 367 367 368 offNew = pSfFsi->sfi_sizel + off; … … 425 426 }; 426 427 SHFLFSOBJINFO ObjInfo; 427 428 428 } *pBuf = (struct SetFileInfoBuf *)VbglR0PhysHeapAlloc(sizeof(*pBuf)); 429 429 if (pBuf) … … 438 438 rc = vboxSfOs2SetInfoCommonWorker(pFolder, pSfFsd->hHostFile, 439 439 uLevel == FI_LVL_STANDARD ? pBuf->Lvl1.attrFile : pBuf->Lvl1L.attrFile, 440 &pBuf->Lvl1, &pBuf->ObjInfo );440 &pBuf->Lvl1, &pBuf->ObjInfo, RT_UOFFSETOF(struct SetFileInfoBuf, ObjInfo)); 441 441 if (rc == NO_ERROR) 442 442 { … … 467 467 468 468 469 #if 0 469 470 470 471 DECLVBGL(int) VbglR0SfFastPhysFsInfo(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, … … 588 589 } 589 590 591 #endif 592 590 593 591 594 /** … … 712 715 else 713 716 rc = ERROR_NOT_ENOUGH_MEMORY; 714 #el se717 #elif 0 715 718 APIRET rc; 716 719 struct MyEmbReq … … 761 764 { 762 765 Log(("vboxSfOs2QueryFileInfo: VbglR0SfFsInfo failed: %Rrc\n", vrc)); 766 rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_GEN_FAILURE); 767 } 768 769 VbglR0PhysHeapFree(pReq); 770 } 771 else 772 rc = ERROR_NOT_ENOUGH_MEMORY; 773 #else /* clean version of the above. */ 774 APIRET rc; 775 VBOXSFOBJINFOREQ *pReq = (VBOXSFOBJINFOREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq)); 776 if (pReq) 777 { 778 int vrc = vboxSfOs2HostReqQueryObjInfo(pFolder, pReq, pSfFsd->hHostFile); 779 if (RT_SUCCESS(vrc)) 780 { 781 rc = vboxSfOs2FileStatusFromObjInfo(pbData, cbData, uLevel, &pReq->ObjInfo); 782 if (rc == NO_ERROR) 783 { 784 /* Update the timestamps in the independent file data: */ 785 int16_t cMinLocalTimeDelta = vboxSfOs2GetLocalTimeDelta(); 786 vboxSfOs2DateTimeFromTimeSpec(&pSfFsi->sfi_cdate, &pSfFsi->sfi_ctime, pReq->ObjInfo.BirthTime, cMinLocalTimeDelta); 787 vboxSfOs2DateTimeFromTimeSpec(&pSfFsi->sfi_adate, &pSfFsi->sfi_atime, pReq->ObjInfo.AccessTime, cMinLocalTimeDelta); 788 vboxSfOs2DateTimeFromTimeSpec(&pSfFsi->sfi_mdate, &pSfFsi->sfi_mtime, pReq->ObjInfo.ModificationTime, cMinLocalTimeDelta); 789 790 /* And the size field as we're at it: */ 791 pSfFsi->sfi_sizel = pReq->ObjInfo.cbObject; 792 } 793 } 794 else 795 { 796 Log(("vboxSfOs2QueryFileInfo: vboxSfOs2HostReqQueryObjInfo failed: %Rrc\n", vrc)); 763 797 rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_GEN_FAILURE); 764 798 } … … 929 963 { 930 964 /* 931 * Call the host. We need a full object info structure here to pass 932 * a 64-bit unsigned integer value. Sigh. 965 * Call the host. 933 966 */ 934 /** @todo Shared folders: New SET_FILE_SIZE API. */ 935 PSHFLFSOBJINFO pObjInfo = (PSHFLFSOBJINFO)VbglR0PhysHeapAlloc(sizeof(*pObjInfo)); 936 if (pObjInfo) 937 { 938 RT_ZERO(*pObjInfo); 939 pObjInfo->cbObject = cbFile; 940 uint32_t cbObjInfo = sizeof(*pObjInfo); 941 int vrc = VbglR0SfFsInfo(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile, 942 SHFL_INFO_SIZE | SHFL_INFO_SET, &cbObjInfo, (PSHFLDIRINFO)pObjInfo); 943 if (RT_SUCCESS(vrc)) 944 { 945 pSfFsi->sfi_sizel = cbFile; 946 rc = NO_ERROR; 947 } 948 else 949 { 950 LogRel(("FS32_NEWSIZEL: VbglR0SfFsInfo failed: %Rrc\n", vrc)); 951 if (vrc == VERR_DISK_FULL) 952 rc = ERROR_DISK_FULL; 953 else 954 rc = ERROR_GEN_FAILURE; 955 } 956 VbglR0PhysHeapFree(pObjInfo); 967 int vrc = vboxSfOs2HostReqSetFileSizeSimple(pFolder, pSfFsd->hHostFile, cbFile); 968 if (RT_SUCCESS(vrc)) 969 { 970 pSfFsi->sfi_sizel = cbFile; 971 rc = NO_ERROR; 957 972 } 958 973 else 959 rc = ERROR_NOT_ENOUGH_MEMORY; 974 { 975 LogRel(("FS32_NEWSIZEL: VbglR0SfFsInfo failed: %Rrc\n", vrc)); 976 rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_GEN_FAILURE); 977 } 960 978 } 961 979 else … … 988 1006 * avoid locking/unlocking user memory. 989 1007 */ 990 uint64_t offRead = pSfFsi->sfi_positionl; 991 uint32_t cbRead = *pcb; 992 uint32_t cbActual = cbRead; 993 if (cbRead <= _8K - ALLOC_HDR_SIZE) 994 { 995 void *pvBuf = VbglR0PhysHeapAlloc(cbRead); 996 if (pvBuf != NULL) 997 { 1008 uint64_t const offRead = pSfFsi->sfi_positionl; 1009 uint32_t const cbToRead = *pcb; 1010 uint32_t cbActual = cbToRead; 1011 #if 0 /** @todo debug some other day. */ 1012 if (cbToRead <= _8K - ALLOC_HDR_SIZE - RT_UOFFSETOF(VBOXSFREADEMBEDDEDREQ, abData[0])) 1013 { 1014 size_t cbReq = RT_UOFFSETOF(VBOXSFREADEMBEDDEDREQ, abData[0]) + RT_ALIGN_32(cbToRead, 4); 1015 VBOXSFREADEMBEDDEDREQ *pReq = (VBOXSFREADEMBEDDEDREQ *)VbglR0PhysHeapAlloc(cbReq); 1016 if (pReq != NULL) 1017 { 1018 RT_BZERO(pReq, cbReq); 1019 998 1020 APIRET rc; 999 int vrc = VbglR0SfRead(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile, 1000 offRead, &cbActual, (uint8_t *)pvBuf, true /*fLocked*/); 1021 int vrc = vboxSfOs2HostReqReadEmbedded(pFolder, pReq, pSfFsd->hHostFile, offRead, cbToRead); 1001 1022 if (RT_SUCCESS(vrc)) 1002 1023 { 1003 AssertStmt(cbActual <= cbRead, cbActual = cbRead); 1004 rc = KernCopyOut(pvData, pvBuf, cbActual); 1024 cbActual = pReq->Parms.cb32Read.u.value32; 1025 AssertStmt(cbActual <= cbToRead, cbActual = cbToRead); 1026 rc = KernCopyOut(pvData, &pReq->abData[0], cbActual); 1005 1027 if (rc == NO_ERROR) 1006 1028 { … … 1015 1037 else 1016 1038 { 1017 Log(("FS32_READ: VbglR0SfRead(off=%#x,cb=%#x) -> %Rrc [copy]\n", offRead, cbRead, vrc));1039 Log(("FS32_READ: vboxSfOs2HostReqReadEmbedded(off=%#RU64,cb=%#x) -> %Rrc [copy]\n", offRead, cbToRead, vrc)); 1018 1040 rc = ERROR_BAD_NET_RESP; 1019 1041 } 1020 VbglR0PhysHeapFree(p vBuf);1042 VbglR0PhysHeapFree(pReq); 1021 1043 return rc; 1022 1044 } 1023 1045 } 1046 #endif 1047 1024 1048 1025 1049 /* … … 1030 1054 if (RT_SUCCESS(vrc)) 1031 1055 { 1032 AssertStmt(cbActual <= cb Read, cbActual = cbRead);1056 AssertStmt(cbActual <= cbToRead, cbActual = cbToRead); 1033 1057 *pcb = cbActual; 1034 1058 pSfFsi->sfi_positionl = offRead + cbActual; … … 1039 1063 return NO_ERROR; 1040 1064 } 1041 Log(("FS32_READ: VbglR0SfRead(off=%# x,cb=%#x) -> %Rrc [direct]\n", offRead, cbRead, vrc));1065 Log(("FS32_READ: VbglR0SfRead(off=%#RU64,cb=%#x) -> %Rrc [direct]\n", offRead, cbToRead, vrc)); 1042 1066 RT_NOREF_PV(fIoFlags); 1043 1067 return ERROR_BAD_NET_RESP; -
trunk/src/VBox/Additions/os2/VBoxSF/VBoxSFFind.cpp
r76109 r76143 467 467 * Resolve path to a folder and folder relative path. 468 468 */ 469 PVBOXSFFOLDER pFolder;470 PSHFLSTRING pStrFolderPath;471 469 RT_NOREF(pCdFsi); 472 APIRET rc = vboxSfOs2ResolvePath(pszPath, pCdFsd, offCurDirEnd, &pFolder, &pStrFolderPath); 473 LogFlow(("FS32_FINDFIRST: vboxSfOs2ResolvePath: -> %u pFolder=%p\n", rc, pFolder)); 470 PVBOXSFFOLDER pFolder; 471 VBOXSFCREATEREQ *pReq; 472 APIRET rc = vboxSfOs2ResolvePathEx(pszPath, pCdFsd, offCurDirEnd, RT_UOFFSETOF(VBOXSFCREATEREQ, StrPath), 473 &pFolder, (void **)&pReq); 474 LogFlow(("FS32_FINDFIRST: vboxSfOs2ResolvePathEx: -> %u pReq=%p\n", rc, pReq)); 474 475 if (rc == NO_ERROR) 475 476 { 477 PSHFLSTRING pStrFolderPath = &pReq->StrPath; 478 476 479 /* 477 480 * Look for a wildcard filter at the end of the path, saving it all for … … 537 540 else if (pwszFilter) 538 541 { 539 pFilter = pStrFolderPath; 540 pStrFolderPath = vboxSfOs2StrAlloc(pwszFilter - pFilter->String.utf16); 541 if (pStrFolderPath) 542 { 543 pStrFolderPath->u16Length = (uint16_t)((uintptr_t)pwszFilter - (uintptr_t)pFilter->String.utf16); 544 memcpy(pStrFolderPath->String.utf16, pFilter->String.utf16, pStrFolderPath->u16Length); 542 /* Copy the whole path for filtering. */ 543 pFilter = vboxSfOs2StrDup(pStrFolderPath); 544 if (pFilter) 545 { 546 /* Strip the filename off the one we're opening. */ 547 pStrFolderPath->u16Length = (uint16_t)((uintptr_t)pwszFilter - (uintptr_t)pStrFolderPath->String.utf16); 548 pStrFolderPath->u16Size = pStrFolderPath->u16Length + (uint16_t)sizeof(RTUTF16); 545 549 pStrFolderPath->String.utf16[pStrFolderPath->u16Length / sizeof(RTUTF16)] = '\0'; 546 550 } … … 559 563 * Make sure we've got a buffer for keeping unused search results. 560 564 */ 565 /** @todo use phys heap for this too? */ 561 566 PVBOXSFFSBUF pDataBuf = NULL; 562 567 if (rc == NO_ERROR) … … 578 583 /* 579 584 * Now, try open the directory for reading. 580 * We pre-use the data buffer for parameter passin to avoid581 * wasting any stack space.582 585 */ 583 PSHFLCREATEPARMS pParams = (PSHFLCREATEPARMS)(pDataBuf + 1);584 RT_ZERO(*pParams);585 pParams->CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACT_OPEN_IF_EXISTS 586 | SHFL_CF_ACCESS_READ | SHFL_CF_ACCESS_ATTR_READ | SHFL_CF_ACCESS_DENYNONE;587 int vrc = VbglR0SfCreate(&g_SfClient, &pFolder->hHostFolder, pStrFolderPath, pParams);588 LogFlow(("FS32_FINDFIRST: VbglR0SfCreate(%ls) -> %Rrc Result=%d fMode=%#x hHandle=%#RX64\n",589 p StrFolderPath->String.utf16, vrc, pParams->Result, pParams->Info.Attr.fMode, pParams->Handle));586 pReq->CreateParms.CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACT_OPEN_IF_EXISTS 587 | SHFL_CF_ACCESS_READ | SHFL_CF_ACCESS_ATTR_READ | SHFL_CF_ACCESS_DENYNONE; 588 589 int vrc = vboxSfOs2HostReqCreate(pFolder, pReq); 590 LogFlow(("FS32_FINDFIRST: vboxSfOs2HostReqCreate(%ls) -> %Rrc Result=%d fMode=%#x hHandle=%#RX64\n", 591 pStrFolderPath->String.utf16, vrc, pReq->CreateParms.Result, pReq->CreateParms.Info.Attr.fMode, 592 pReq->CreateParms.Handle)); 590 593 if (RT_SUCCESS(vrc)) 591 594 { 592 switch (p Params->Result)595 switch (pReq->CreateParms.Result) 593 596 { 594 597 case SHFL_FILE_EXISTS: 595 if (p Params->Handle != SHFL_HANDLE_NIL)598 if (pReq->CreateParms.Handle != SHFL_HANDLE_NIL) 596 599 { 597 600 /* 598 601 * Initialize the structures. 599 602 */ 600 pFsFsd->hHostDir = p Params->Handle;603 pFsFsd->hHostDir = pReq->CreateParms.Handle; 601 604 pFsFsd->u32Magic = VBOXSFFS_MAGIC; 602 605 pFsFsd->pFolder = pFolder; … … 631 634 else 632 635 { 633 vrc = VbglR0SfClose(&g_SfClient, &pFolder->hHostFolder, pFsFsd->hHostDir); 636 AssertCompile(sizeof(VBOXSFCLOSEREQ) < sizeof(*pReq)); 637 vrc = vboxSfOs2HostReqClose(pFolder, (VBOXSFCLOSEREQ *)pReq, pFsFsd->hHostDir); 634 638 AssertRC(vrc); 635 639 pFsFsd->u32Magic = ~VBOXSFFS_MAGIC; … … 641 645 else 642 646 { 643 LogFlow(("FS32_FINDFIRST: VbglR0SfCreate returns NIL handle for '%ls'\n", pStrFolderPath->String.utf16)); 647 LogFlow(("FS32_FINDFIRST: vboxSfOs2HostReqCreate returns NIL handle for '%ls'\n", 648 pStrFolderPath->String.utf16)); 644 649 rc = ERROR_PATH_NOT_FOUND; 645 650 } … … 661 666 662 667 RTMemFree(pDataBuf); 663 if (pFilter != pStrFolderPath)664 vboxSfOs2StrFree(pFilter);665 vboxSfOs2Release PathAndFolder(pStrFolderPath,pFolder);668 vboxSfOs2StrFree(pFilter); 669 VbglR0PhysHeapFree(pReq); 670 vboxSfOs2ReleaseFolder(pFolder); 666 671 } 667 672 … … 801 806 if (pFsFsd->hHostDir != SHFL_HANDLE_NIL) 802 807 { 803 int vrc = VbglR0SfClose(&g_SfClient, &pFolder->hHostFolder, pFsFsd->hHostDir);808 int vrc = vboxSfOs2HostReqCloseSimple(pFolder, pFsFsd->hHostDir); 804 809 AssertRC(vrc); 805 810 } -
trunk/src/VBox/Additions/os2/VBoxSF/VBoxSFInternal.h
r76118 r76143 238 238 APIRET vboxSfOs2FileStatusFromObjInfo(PBYTE pbDst, ULONG cbDst, ULONG uLevel, SHFLFSOBJINFO const *pSrc); 239 239 APIRET vboxSfOs2SetInfoCommonWorker(PVBOXSFFOLDER pFolder, SHFLHANDLE hHostFile, ULONG fAttribs, 240 PFILESTATUS pTimestamps, PSHFLFSOBJINFO pObjInfoBuf );240 PFILESTATUS pTimestamps, PSHFLFSOBJINFO pObjInfoBuf, uint32_t offObjInfoInAlloc); 241 241 APIRET vboxSfOs2MakeEmptyEaList(PEAOP pEaOp, ULONG uLevel); 242 242 APIRET vboxSfOs2MakeEmptyEaListEx(PEAOP pEaOp, ULONG uLevel, uint32_t *pcbWritten, ULONG *poffError); … … 244 244 DECLASM(PVBOXSFVP) Fsh32GetVolParams(USHORT hVbp, PVPFSI *ppVpFsi /*optional*/); 245 245 246 247 /** @name Host request helpers 248 * 249 * @todo generalize these and put back into VbglR0Sf. 250 * 251 * @{ */ 252 253 254 /** Request structure for vboxSfOs2HostReqMapFolderWithBuf. */ 255 typedef struct VBOXSFMAPFOLDERWITHBUFREQ 256 { 257 VBGLIOCIDCHGCMFASTCALL Hdr; 258 VMMDevHGCMCall Call; 259 VBoxSFParmMapFolder Parms; 260 union 261 { 262 HGCMPageListInfo PgLst; 263 uint8_t abPadding[8 + sizeof(RTGCPHYS64) * 2 /*RT_UOFFSETOF(HGCMPageListInfo, aPages[2])*/]; 264 } u; 265 } VBOXSFMAPFOLDERWITHBUFREQ; 266 267 /** 268 * SHFL_FN_MAP_FOLDER request. 269 */ 270 DECLINLINE(int) vboxSfOs2HostReqMapFolderWithBuf(VBOXSFMAPFOLDERWITHBUFREQ *pReq, PSHFLSTRING pStrName, 271 RTUTF16 wcDelimiter, bool fCaseSensitive) 272 { 273 pReq->Parms.id32Root.type = VMMDevHGCMParmType_32bit; 274 pReq->Parms.id32Root.u.value32 = SHFL_ROOT_NIL; 275 276 pReq->Parms.uc32Delimiter.type = VMMDevHGCMParmType_32bit; 277 pReq->Parms.uc32Delimiter.u.value32 = wcDelimiter; 278 279 pReq->Parms.fCaseSensitive.type = VMMDevHGCMParmType_32bit; 280 pReq->Parms.fCaseSensitive.u.value32 = fCaseSensitive; 281 282 AssertReturn(pStrName->u16Size <= PAGE_SIZE - SHFLSTRING_HEADER_SIZE, VERR_FILENAME_TOO_LONG); 283 pReq->Parms.pStrName.type = VMMDevHGCMParmType_PageList; 284 pReq->Parms.pStrName.u.PageList.size = SHFLSTRING_HEADER_SIZE + pStrName->u16Size; 285 pReq->Parms.pStrName.u.PageList.offset = RT_UOFFSETOF(VBOXSFMAPFOLDERWITHBUFREQ, u.PgLst) - sizeof(VBGLIOCIDCHGCMFASTCALL); 286 pReq->u.PgLst.flags = VBOX_HGCM_F_PARM_DIRECTION_BOTH; 287 pReq->u.PgLst.aPages[0] = VbglR0PhysHeapGetPhysAddr(pStrName); 288 pReq->u.PgLst.offFirstPage = (uint16_t)(pReq->u.PgLst.aPages[0] & PAGE_OFFSET_MASK); 289 pReq->u.PgLst.aPages[0] &= ~(RTGCPHYS)PAGE_OFFSET_MASK; 290 uint32_t cbReq; 291 if (PAGE_SIZE - pReq->u.PgLst.offFirstPage <= pStrName->u16Size + SHFLSTRING_HEADER_SIZE) 292 { 293 pReq->u.PgLst.cPages = 1; 294 cbReq = RT_UOFFSETOF(VBOXSFMAPFOLDERWITHBUFREQ, u.PgLst.aPages[1]); 295 } 296 else 297 { 298 pReq->u.PgLst.aPages[1] = pReq->u.PgLst.aPages[0] + PAGE_SIZE; 299 pReq->u.PgLst.cPages = 2; 300 cbReq = RT_UOFFSETOF(VBOXSFMAPFOLDERWITHBUFREQ, u.PgLst.aPages[2]); 301 } 302 303 VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient, 304 SHFL_FN_MAP_FOLDER, SHFL_CPARMS_MAP_FOLDER, cbReq); 305 306 int vrc = VbglR0HGCMFastCall(g_SfClient.handle, &pReq->Hdr, cbReq); 307 if (RT_SUCCESS(vrc)) 308 vrc = pReq->Call.header.result; 309 return vrc; 310 } 311 312 313 314 /** Request structure used by vboxSfOs2HostReqUnmapFolder. */ 315 typedef struct VBOXSFUNMAPFOLDERREQ 316 { 317 VBGLIOCIDCHGCMFASTCALL Hdr; 318 VMMDevHGCMCall Call; 319 VBoxSFParmUnmapFolder Parms; 320 } VBOXSFUNMAPFOLDERREQ; 321 322 323 /** 324 * SHFL_FN_UNMAP_FOLDER request. 325 */ 326 DECLINLINE(int) vboxSfOs2HostReqUnmapFolderSimple(uint32_t idRoot) 327 { 328 VBOXSFUNMAPFOLDERREQ *pReq = (VBOXSFUNMAPFOLDERREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq)); 329 if (pReq) 330 { 331 pReq->Parms.id32Root.type = VMMDevHGCMParmType_32bit; 332 pReq->Parms.id32Root.u.value32 = idRoot; 333 334 VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient, 335 SHFL_FN_UNMAP_FOLDER, SHFL_CPARMS_UNMAP_FOLDER, sizeof(*pReq)); 336 337 int vrc = VbglR0HGCMFastCall(g_SfClient.handle, &pReq->Hdr, sizeof(*pReq)); 338 if (RT_SUCCESS(vrc)) 339 vrc = pReq->Call.header.result; 340 341 VbglR0PhysHeapFree(pReq); 342 return vrc; 343 } 344 return VERR_NO_MEMORY; 345 } 246 346 247 347 … … 286 386 287 387 288 /** Request structure for vboxSfOs2HostReqC reate. */388 /** Request structure for vboxSfOs2HostReqClose. */ 289 389 typedef struct VBOXSFCLOSEREQ 290 390 { … … 297 397 * SHFL_FN_CLOSE request. 298 398 */ 299 DECLINLINE(int) vboxSfOs2HostReqClose(PVBOXSFFOLDER pFolder, VBOXSFCLOSEREQ *pReq, uint64_t uHandle)399 DECLINLINE(int) vboxSfOs2HostReqClose(PVBOXSFFOLDER pFolder, VBOXSFCLOSEREQ *pReq, uint64_t hHostFile) 300 400 { 301 401 VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient, … … 306 406 307 407 pReq->Parms.u64Handle.type = VMMDevHGCMParmType_64bit; 308 pReq->Parms.u64Handle.u.value64 = uHandle;408 pReq->Parms.u64Handle.u.value64 = hHostFile; 309 409 310 410 int vrc = VbglR0HGCMFastCall(g_SfClient.handle, &pReq->Hdr, sizeof(*pReq)); … … 312 412 vrc = pReq->Call.header.result; 313 413 return vrc; 414 } 415 416 /** 417 * SHFL_FN_CLOSE request, allocate request buffer. 418 */ 419 DECLINLINE(int) vboxSfOs2HostReqCloseSimple(PVBOXSFFOLDER pFolder, uint64_t hHostFile) 420 { 421 VBOXSFCLOSEREQ *pReq = (VBOXSFCLOSEREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq)); 422 if (pReq) 423 { 424 int vrc = vboxSfOs2HostReqClose(pFolder, pReq, hHostFile); 425 VbglR0PhysHeapFree(pReq); 426 return vrc; 427 } 428 return VERR_NO_MEMORY; 314 429 } 315 430 … … 327 442 * SHFL_FN_INFORMATION[SHFL_INFO_VOLUME | SHFL_INFO_GET] request. 328 443 */ 329 DECLINLINE(int) vboxSfOs2HostReqQueryVolInfo(PVBOXSFFOLDER pFolder, VBOXSFVOLINFOREQ *pReq, uint64_t uHandle)444 DECLINLINE(int) vboxSfOs2HostReqQueryVolInfo(PVBOXSFFOLDER pFolder, VBOXSFVOLINFOREQ *pReq, uint64_t hHostFile) 330 445 { 331 446 VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient, … … 336 451 337 452 pReq->Parms.u64Handle.type = VMMDevHGCMParmType_64bit; 338 pReq->Parms.u64Handle.u.value64 = uHandle;453 pReq->Parms.u64Handle.u.value64 = hHostFile; 339 454 340 455 pReq->Parms.f32Flags.type = VMMDevHGCMParmType_32bit; … … 356 471 357 472 473 /** Request structure for vboxSfOs2HostReqSetObjInfo & vboxSfOs2HostReqQueryObjInfo. */ 474 typedef struct VBOXSFOBJINFOREQ 475 { 476 VBGLIOCIDCHGCMFASTCALL Hdr; 477 VMMDevHGCMCall Call; 478 VBoxSFParmInformation Parms; 479 SHFLFSOBJINFO ObjInfo; 480 } VBOXSFOBJINFOREQ; 481 482 /** 483 * SHFL_FN_INFORMATION[SHFL_INFO_GET | SHFL_INFO_FILE] request. 484 */ 485 DECLINLINE(int) vboxSfOs2HostReqQueryObjInfo(PVBOXSFFOLDER pFolder, VBOXSFOBJINFOREQ *pReq, uint64_t hHostFile) 486 { 487 VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient, 488 SHFL_FN_INFORMATION, SHFL_CPARMS_INFORMATION, sizeof(*pReq)); 489 490 pReq->Parms.id32Root.type = VMMDevHGCMParmType_32bit; 491 pReq->Parms.id32Root.u.value32 = pFolder->hHostFolder.root; 492 493 pReq->Parms.u64Handle.type = VMMDevHGCMParmType_64bit; 494 pReq->Parms.u64Handle.u.value64 = hHostFile; 495 496 pReq->Parms.f32Flags.type = VMMDevHGCMParmType_32bit; 497 pReq->Parms.f32Flags.u.value32 = SHFL_INFO_GET | SHFL_INFO_FILE; 498 499 pReq->Parms.cb32.type = VMMDevHGCMParmType_32bit; 500 pReq->Parms.cb32.u.value32 = sizeof(pReq->ObjInfo); 501 502 pReq->Parms.pInfo.type = VMMDevHGCMParmType_Embedded; 503 pReq->Parms.pInfo.u.Embedded.cbData = sizeof(pReq->ObjInfo); 504 pReq->Parms.pInfo.u.Embedded.offData = RT_UOFFSETOF(VBOXSFOBJINFOREQ, ObjInfo) - sizeof(VBGLIOCIDCHGCMFASTCALL); 505 pReq->Parms.pInfo.u.Embedded.fFlags = VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST; 506 507 int vrc = VbglR0HGCMFastCall(g_SfClient.handle, &pReq->Hdr, sizeof(*pReq)); 508 if (RT_SUCCESS(vrc)) 509 vrc = pReq->Call.header.result; 510 return vrc; 511 } 512 513 514 /** 515 * SHFL_FN_INFORMATION[SHFL_INFO_SET | SHFL_INFO_FILE] request. 516 */ 517 DECLINLINE(int) vboxSfOs2HostReqSetObjInfo(PVBOXSFFOLDER pFolder, VBOXSFOBJINFOREQ *pReq, uint64_t hHostFile) 518 { 519 VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient, 520 SHFL_FN_INFORMATION, SHFL_CPARMS_INFORMATION, sizeof(*pReq)); 521 522 pReq->Parms.id32Root.type = VMMDevHGCMParmType_32bit; 523 pReq->Parms.id32Root.u.value32 = pFolder->hHostFolder.root; 524 525 pReq->Parms.u64Handle.type = VMMDevHGCMParmType_64bit; 526 pReq->Parms.u64Handle.u.value64 = hHostFile; 527 528 pReq->Parms.f32Flags.type = VMMDevHGCMParmType_32bit; 529 pReq->Parms.f32Flags.u.value32 = SHFL_INFO_SET | SHFL_INFO_FILE; 530 531 pReq->Parms.cb32.type = VMMDevHGCMParmType_32bit; 532 pReq->Parms.cb32.u.value32 = sizeof(pReq->ObjInfo); 533 534 pReq->Parms.pInfo.type = VMMDevHGCMParmType_Embedded; 535 pReq->Parms.pInfo.u.Embedded.cbData = sizeof(pReq->ObjInfo); 536 pReq->Parms.pInfo.u.Embedded.offData = RT_UOFFSETOF(VBOXSFOBJINFOREQ, ObjInfo) - sizeof(VBGLIOCIDCHGCMFASTCALL); 537 pReq->Parms.pInfo.u.Embedded.fFlags = VBOX_HGCM_F_PARM_DIRECTION_BOTH; 538 539 int vrc = VbglR0HGCMFastCall(g_SfClient.handle, &pReq->Hdr, sizeof(*pReq)); 540 if (RT_SUCCESS(vrc)) 541 vrc = pReq->Call.header.result; 542 return vrc; 543 } 544 545 546 /** Request structure for vboxSfOs2HostReqSetObjInfo. */ 547 typedef struct VBOXSFOBJINFOWITHBUFREQ 548 { 549 VBGLIOCIDCHGCMFASTCALL Hdr; 550 VMMDevHGCMCall Call; 551 VBoxSFParmInformation Parms; 552 union 553 { 554 HGCMPageListInfo PgLst; 555 uint8_t abPadding[8 + sizeof(RTGCPHYS64) * 2 /*RT_UOFFSETOF(HGCMPageListInfo, aPages[2])*/]; 556 } u; 557 } VBOXSFOBJINFOWITHBUFREQ; 558 559 /** 560 * SHFL_FN_INFORMATION[SHFL_INFO_SET | SHFL_INFO_FILE] request, with separate 561 * buffer (on the physical heap). 562 */ 563 DECLINLINE(int) vboxSfOs2HostReqSetObjInfoWithBuf(PVBOXSFFOLDER pFolder, VBOXSFOBJINFOWITHBUFREQ *pReq, uint64_t hHostFile, 564 PSHFLFSOBJINFO pObjInfo, uint32_t offObjInfoInAlloc) 565 { 566 pReq->Parms.id32Root.type = VMMDevHGCMParmType_32bit; 567 pReq->Parms.id32Root.u.value32 = pFolder->hHostFolder.root; 568 569 pReq->Parms.u64Handle.type = VMMDevHGCMParmType_64bit; 570 pReq->Parms.u64Handle.u.value64 = hHostFile; 571 572 pReq->Parms.f32Flags.type = VMMDevHGCMParmType_32bit; 573 pReq->Parms.f32Flags.u.value32 = SHFL_INFO_SET | SHFL_INFO_FILE; 574 575 pReq->Parms.cb32.type = VMMDevHGCMParmType_32bit; 576 pReq->Parms.cb32.u.value32 = sizeof(*pObjInfo); 577 578 pReq->Parms.pInfo.type = VMMDevHGCMParmType_PageList; 579 pReq->Parms.pInfo.u.PageList.size = sizeof(*pObjInfo); 580 pReq->Parms.pInfo.u.PageList.offset = RT_UOFFSETOF(VBOXSFOBJINFOREQ, ObjInfo) - sizeof(VBGLIOCIDCHGCMFASTCALL); 581 pReq->u.PgLst.flags = VBOX_HGCM_F_PARM_DIRECTION_BOTH; 582 pReq->u.PgLst.aPages[0] = VbglR0PhysHeapGetPhysAddr((uint8_t *)pObjInfo - offObjInfoInAlloc) + offObjInfoInAlloc; 583 pReq->u.PgLst.offFirstPage = (uint16_t)(pReq->u.PgLst.aPages[0] & PAGE_OFFSET_MASK); 584 pReq->u.PgLst.aPages[0] &= ~(RTGCPHYS)PAGE_OFFSET_MASK; 585 uint32_t cbReq; 586 if (PAGE_SIZE - pReq->u.PgLst.offFirstPage <= sizeof(*pObjInfo)) 587 { 588 pReq->u.PgLst.cPages = 1; 589 cbReq = RT_UOFFSETOF(VBOXSFOBJINFOWITHBUFREQ, u.PgLst.aPages[1]); 590 } 591 else 592 { 593 pReq->u.PgLst.aPages[1] = pReq->u.PgLst.aPages[0] + PAGE_SIZE; 594 pReq->u.PgLst.cPages = 2; 595 cbReq = RT_UOFFSETOF(VBOXSFOBJINFOWITHBUFREQ, u.PgLst.aPages[2]); 596 } 597 598 VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient, 599 SHFL_FN_INFORMATION, SHFL_CPARMS_INFORMATION, cbReq); 600 601 int vrc = VbglR0HGCMFastCall(g_SfClient.handle, &pReq->Hdr, cbReq); 602 if (RT_SUCCESS(vrc)) 603 vrc = pReq->Call.header.result; 604 return vrc; 605 } 606 607 608 /** Request structure for vboxSfOs2HostReqRemove. */ 609 typedef struct VBOXSFREMOVEREQ 610 { 611 VBGLIOCIDCHGCMFASTCALL Hdr; 612 VMMDevHGCMCall Call; 613 VBoxSFParmRemove Parms; 614 SHFLSTRING StrPath; 615 } VBOXSFREMOVEREQ; 616 617 /** 618 * SHFL_FN_REMOVE request. 619 */ 620 DECLINLINE(int) vboxSfOs2HostReqRemove(PVBOXSFFOLDER pFolder, VBOXSFREMOVEREQ *pReq, uint32_t fFlags) 621 { 622 VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient, 623 SHFL_FN_REMOVE, SHFL_CPARMS_REMOVE, 624 RT_UOFFSETOF(VBOXSFREMOVEREQ, StrPath.String) + pReq->StrPath.u16Size); 625 626 pReq->Parms.id32Root.type = VMMDevHGCMParmType_32bit; 627 pReq->Parms.id32Root.u.value32 = pFolder->hHostFolder.root; 628 629 pReq->Parms.pStrPath.type = VMMDevHGCMParmType_Embedded; 630 pReq->Parms.pStrPath.u.Embedded.cbData = SHFLSTRING_HEADER_SIZE + pReq->StrPath.u16Size; 631 pReq->Parms.pStrPath.u.Embedded.offData = RT_UOFFSETOF(VBOXSFREMOVEREQ, StrPath) - sizeof(VBGLIOCIDCHGCMFASTCALL); 632 pReq->Parms.pStrPath.u.Embedded.fFlags = VBOX_HGCM_F_PARM_DIRECTION_TO_HOST; 633 634 pReq->Parms.f32Flags.type = VMMDevHGCMParmType_32bit; 635 pReq->Parms.f32Flags.u.value32 = fFlags; 636 637 int vrc = VbglR0HGCMFastCall(g_SfClient.handle, &pReq->Hdr, 638 RT_UOFFSETOF(VBOXSFREMOVEREQ, StrPath.String) + pReq->StrPath.u16Size); 639 if (RT_SUCCESS(vrc)) 640 vrc = pReq->Call.header.result; 641 return vrc; 642 } 643 644 645 /** Request structure for vboxSfOs2HostReqRename. */ 646 typedef struct VBOXSFRENAMEWITHSRCBUFREQ 647 { 648 VBGLIOCIDCHGCMFASTCALL Hdr; 649 VMMDevHGCMCall Call; 650 VBoxSFParmRename Parms; 651 union 652 { 653 HGCMPageListInfo PgLst; 654 uint8_t abPadding[8 + sizeof(RTGCPHYS64) * 2 /*RT_UOFFSETOF(HGCMPageListInfo, aPages[2])*/]; 655 } u; 656 SHFLSTRING StrDstPath; 657 } VBOXSFRENAMEWITHSRCBUFREQ; 658 659 /** 660 * SHFL_FN_REMOVE request. 661 */ 662 DECLINLINE(int) vboxSfOs2HostReqRenameWithSrcBuf(PVBOXSFFOLDER pFolder, VBOXSFRENAMEWITHSRCBUFREQ *pReq, 663 PSHFLSTRING pSrcStr, uint32_t fFlags) 664 { 665 VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient, 666 SHFL_FN_RENAME, SHFL_CPARMS_RENAME, 667 RT_UOFFSETOF(VBOXSFRENAMEWITHSRCBUFREQ, StrDstPath.String) + pReq->StrDstPath.u16Size); 668 669 pReq->Parms.id32Root.type = VMMDevHGCMParmType_32bit; 670 pReq->Parms.id32Root.u.value32 = pFolder->hHostFolder.root; 671 672 /** @todo Using page lists for contiguous buffers sucks. */ 673 AssertReturn(pSrcStr->u16Size <= PAGE_SIZE - SHFLSTRING_HEADER_SIZE, VERR_FILENAME_TOO_LONG); 674 pReq->Parms.pStrSrcPath.type = VMMDevHGCMParmType_PageList; 675 pReq->Parms.pStrSrcPath.u.PageList.size = SHFLSTRING_HEADER_SIZE + pSrcStr->u16Size; 676 pReq->Parms.pStrSrcPath.u.PageList.offset = RT_UOFFSETOF(VBOXSFRENAMEWITHSRCBUFREQ, u.PgLst) - sizeof(VBGLIOCIDCHGCMFASTCALL); 677 pReq->u.PgLst.flags = VBOX_HGCM_F_PARM_DIRECTION_TO_HOST; 678 pReq->u.PgLst.aPages[0] = VbglR0PhysHeapGetPhysAddr(pSrcStr); 679 pReq->u.PgLst.offFirstPage = (uint16_t)(pReq->u.PgLst.aPages[0] & PAGE_OFFSET_MASK); 680 pReq->u.PgLst.aPages[0] &= ~(RTGCPHYS)PAGE_OFFSET_MASK; 681 if (PAGE_SIZE - pReq->u.PgLst.offFirstPage <= SHFLSTRING_HEADER_SIZE + pSrcStr->u16Size) 682 { 683 pReq->u.PgLst.aPages[1] = NIL_RTGCPHYS64; 684 pReq->u.PgLst.cPages = 1; 685 } 686 else 687 { 688 pReq->u.PgLst.aPages[1] = pReq->u.PgLst.aPages[0] + PAGE_SIZE; 689 pReq->u.PgLst.cPages = 2; 690 } 691 692 pReq->Parms.pStrDstPath.type = VMMDevHGCMParmType_Embedded; 693 pReq->Parms.pStrDstPath.u.Embedded.cbData = SHFLSTRING_HEADER_SIZE + pReq->StrDstPath.u16Size; 694 pReq->Parms.pStrDstPath.u.Embedded.offData = RT_UOFFSETOF(VBOXSFRENAMEWITHSRCBUFREQ, StrDstPath) - sizeof(VBGLIOCIDCHGCMFASTCALL); 695 pReq->Parms.pStrDstPath.u.Embedded.fFlags = VBOX_HGCM_F_PARM_DIRECTION_TO_HOST; 696 697 pReq->Parms.f32Flags.type = VMMDevHGCMParmType_32bit; 698 pReq->Parms.f32Flags.u.value32 = fFlags; 699 700 int vrc = VbglR0HGCMFastCall(g_SfClient.handle, &pReq->Hdr, 701 RT_UOFFSETOF(VBOXSFRENAMEWITHSRCBUFREQ, StrDstPath.String) + pReq->StrDstPath.u16Size); 702 if (RT_SUCCESS(vrc)) 703 vrc = pReq->Call.header.result; 704 return vrc; 705 } 706 707 708 /** Request structure for vboxSfOs2HostReqFlush. */ 709 typedef struct VBOXSFFLUSHREQ 710 { 711 VBGLIOCIDCHGCMFASTCALL Hdr; 712 VMMDevHGCMCall Call; 713 VBoxSFParmFlush Parms; 714 } VBOXSFFLUSHREQ; 715 716 /** 717 * SHFL_FN_FLUSH request. 718 */ 719 DECLINLINE(int) vboxSfOs2HostReqFlush(PVBOXSFFOLDER pFolder, VBOXSFFLUSHREQ *pReq, uint64_t hHostFile) 720 { 721 VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient, 722 SHFL_FN_FLUSH, SHFL_CPARMS_FLUSH, sizeof(*pReq)); 723 724 pReq->Parms.id32Root.type = VMMDevHGCMParmType_32bit; 725 pReq->Parms.id32Root.u.value32 = pFolder->hHostFolder.root; 726 727 pReq->Parms.u64Handle.type = VMMDevHGCMParmType_64bit; 728 pReq->Parms.u64Handle.u.value64 = hHostFile; 729 730 int vrc = VbglR0HGCMFastCall(g_SfClient.handle, &pReq->Hdr, sizeof(*pReq)); 731 if (RT_SUCCESS(vrc)) 732 vrc = pReq->Call.header.result; 733 return vrc; 734 } 735 736 /** 737 * SHFL_FN_FLUSH request, allocate request buffer. 738 */ 739 DECLINLINE(int) vboxSfOs2HostReqFlushSimple(PVBOXSFFOLDER pFolder, uint64_t hHostFile) 740 { 741 VBOXSFFLUSHREQ *pReq = (VBOXSFFLUSHREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq)); 742 if (pReq) 743 { 744 int vrc = vboxSfOs2HostReqFlush(pFolder, pReq, hHostFile); 745 VbglR0PhysHeapFree(pReq); 746 return vrc; 747 } 748 return VERR_NO_MEMORY; 749 } 750 751 752 /** Request structure for vboxSfOs2HostReqSetFileSize. */ 753 typedef struct VBOXSFSETFILESIZEREQ 754 { 755 VBGLIOCIDCHGCMFASTCALL Hdr; 756 VMMDevHGCMCall Call; 757 VBoxSFParmSetFileSize Parms; 758 } VBOXSFSETFILESIZEREQ; 759 760 /** 761 * SHFL_FN_SET_FILE_SIZE request. 762 */ 763 DECLINLINE(int) vboxSfOs2HostReqSetFileSize(PVBOXSFFOLDER pFolder, VBOXSFSETFILESIZEREQ *pReq, 764 uint64_t hHostFile, uint64_t cbNewSize) 765 { 766 VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient, 767 SHFL_FN_SET_FILE_SIZE, SHFL_CPARMS_SET_FILE_SIZE, sizeof(*pReq)); 768 769 pReq->Parms.id32Root.type = VMMDevHGCMParmType_32bit; 770 pReq->Parms.id32Root.u.value32 = pFolder->hHostFolder.root; 771 772 pReq->Parms.u64Handle.type = VMMDevHGCMParmType_64bit; 773 pReq->Parms.u64Handle.u.value64 = hHostFile; 774 775 pReq->Parms.cb64NewSize.type = VMMDevHGCMParmType_64bit; 776 pReq->Parms.cb64NewSize.u.value64 = cbNewSize; 777 778 int vrc = VbglR0HGCMFastCall(g_SfClient.handle, &pReq->Hdr, sizeof(*pReq)); 779 if (RT_SUCCESS(vrc)) 780 vrc = pReq->Call.header.result; 781 return vrc; 782 } 783 784 /** 785 * SHFL_FN_SET_FILE_SIZE request, allocate request buffer. 786 */ 787 DECLINLINE(int) vboxSfOs2HostReqSetFileSizeSimple(PVBOXSFFOLDER pFolder, uint64_t hHostFile, uint64_t cbNewSize) 788 { 789 VBOXSFSETFILESIZEREQ *pReq = (VBOXSFSETFILESIZEREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq)); 790 if (pReq) 791 { 792 int vrc = vboxSfOs2HostReqSetFileSize(pFolder, pReq, hHostFile, cbNewSize); 793 VbglR0PhysHeapFree(pReq); 794 return vrc; 795 } 796 return VERR_NO_MEMORY; 797 } 798 799 800 /** Request structure for vboxSfOs2HostReqRead. */ 801 typedef struct VBOXSFREADEMBEDDEDREQ 802 { 803 VBGLIOCIDCHGCMFASTCALL Hdr; 804 VMMDevHGCMCall Call; 805 VBoxSFParmRead Parms; 806 uint8_t abData[RT_FLEXIBLE_ARRAY]; 807 } VBOXSFREADEMBEDDEDREQ; 808 809 /** 810 * SHFL_FN_INFORMATION[SHFL_INFO_GET | SHFL_INFO_FILE] request. 811 */ 812 DECLINLINE(int) vboxSfOs2HostReqReadEmbedded(PVBOXSFFOLDER pFolder, VBOXSFREADEMBEDDEDREQ *pReq, uint64_t hHostFile, 813 uint64_t offRead, uint32_t cbToRead) 814 { 815 VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient, 816 SHFL_FN_READ, SHFL_CPARMS_READ, RT_UOFFSETOF(VBOXSFREADEMBEDDEDREQ, abData[0]) + cbToRead); 817 818 pReq->Parms.id32Root.type = VMMDevHGCMParmType_32bit; 819 pReq->Parms.id32Root.u.value32 = pFolder->hHostFolder.root; 820 821 pReq->Parms.u64Handle.type = VMMDevHGCMParmType_64bit; 822 pReq->Parms.u64Handle.u.value64 = hHostFile; 823 824 pReq->Parms.off64Read.type = VMMDevHGCMParmType_64bit; 825 pReq->Parms.off64Read.u.value64 = offRead; 826 827 pReq->Parms.cb32Read.type = VMMDevHGCMParmType_32bit; 828 pReq->Parms.cb32Read.u.value32 = cbToRead; 829 830 pReq->Parms.pBuf.type = VMMDevHGCMParmType_Embedded; 831 pReq->Parms.pBuf.u.Embedded.cbData = cbToRead; 832 pReq->Parms.pBuf.u.Embedded.offData = RT_UOFFSETOF(VBOXSFREADEMBEDDEDREQ, abData[0]) - sizeof(VBGLIOCIDCHGCMFASTCALL); 833 pReq->Parms.pBuf.u.Embedded.fFlags = VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST; 834 835 int vrc = VbglR0HGCMFastCall(g_SfClient.handle, &pReq->Hdr, RT_UOFFSETOF(VBOXSFREADEMBEDDEDREQ, abData[0]) + cbToRead); 836 if (RT_SUCCESS(vrc)) 837 vrc = pReq->Call.header.result; 838 return vrc; 839 } 840 841 842 /** @} */ 843 358 844 #endif 359 845
Note:
See TracChangeset
for help on using the changeset viewer.