Changeset 102654 in vbox
- Timestamp:
- Dec 20, 2023 4:10:26 PM (13 months ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/HostServices/GuestControlSvc.h
r99262 r102654 273 273 HOST_MSG_FS_QUERY_INFO = 336, 274 274 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 275 /** 276 * Retrieves the currently accessible mount points from the guest. 277 * 278 * @since 7.1 279 */ 280 HOST_MSG_MOUNT_POINTS = 337, 275 281 /** Blow the type up to 32-bits. */ 276 282 HOST_MSG_32BIT_HACK = 0x7fffffff … … 324 330 RT_CASE_RET_STR(HOST_MSG_FS_QUERY_INFO); 325 331 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 332 RT_CASE_RET_STR(HOST_MSG_MOUNT_POINTS); 326 333 RT_CASE_RET_STR(HOST_MSG_32BIT_HACK); 327 334 } -
trunk/include/VBox/VBoxGuestLib.h
r100657 r102654 1091 1091 VBGLR3DECL(int) VbglR3GuestCtrlPathGetUserDocuments(PVBGLR3GUESTCTRLCMDCTX pCtx); 1092 1092 VBGLR3DECL(int) VbglR3GuestCtrlPathGetUserHome(PVBGLR3GUESTCTRLCMDCTX pCtx); 1093 VBGLR3DECL(int) VbglR3GuestCtrlGetMountPoints(PVBGLR3GUESTCTRLCMDCTX pCtx); 1093 1094 # ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 1094 1095 /** @name Guest Control file system functions. -
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibGuestCtrl.cpp
r99395 r102654 1175 1175 /** 1176 1176 * Retrieves a HOST_PATH_RENAME message. 1177 * 1178 * @returns VBox status code. 1179 * @param pCtx Guest control command context to use. 1180 * @param pszSource Where to return the source path. 1181 * @param cbSource Size (in bytes) of \a pszSource. 1182 * @param pszDest Where to return the destination path. 1183 * @param cbDest Size (in bytes) of \a pszDest. 1184 * @param pfFlags Where to return the rename flags. 1177 1185 */ 1178 1186 VBGLR3DECL(int) VbglR3GuestCtrlPathGetRename(PVBGLR3GUESTCTRLCMDCTX pCtx, … … 1214 1222 /** 1215 1223 * Retrieves a HOST_PATH_USER_DOCUMENTS message. 1224 * 1225 * @param pCtx Guest control command context to use. 1216 1226 */ 1217 1227 VBGLR3DECL(int) VbglR3GuestCtrlPathGetUserDocuments(PVBGLR3GUESTCTRLCMDCTX pCtx) … … 1237 1247 /** 1238 1248 * Retrieves a HOST_PATH_USER_HOME message. 1249 * 1250 * @param pCtx Guest control command context to use. 1239 1251 */ 1240 1252 VBGLR3DECL(int) VbglR3GuestCtrlPathGetUserHome(PVBGLR3GUESTCTRLCMDCTX pCtx) … … 1249 1261 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 1250 1262 VbglHGCMParmUInt32Set(&Msg.context, HOST_MSG_PATH_USER_HOME); 1263 1264 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1265 if (RT_SUCCESS(rc)) 1266 Msg.context.GetUInt32(&pCtx->uContextID); 1267 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 1268 return rc; 1269 } 1270 1271 1272 /** 1273 * Retrieves a HOST_MSG_MOUNT_POINTS message. 1274 * 1275 * @param pCtx Guest control command context to use. 1276 */ 1277 VBGLR3DECL(int) VbglR3GuestCtrlGetMountPoints(PVBGLR3GUESTCTRLCMDCTX pCtx) 1278 { 1279 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1280 AssertReturn(pCtx->uNumParms == 1, VERR_INVALID_PARAMETER); 1281 1282 int rc; 1283 do 1284 { 1285 HGCMMsgPathUserHome Msg; 1286 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 1287 VbglHGCMParmUInt32Set(&Msg.context, HOST_MSG_MOUNT_POINTS); 1251 1288 1252 1289 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r99262 r102654 1707 1707 1708 1708 /** 1709 * Structure for keeping a mount point enumeration context. 1710 */ 1711 typedef struct VGSVCMOUNTPOINTENUMCTX 1712 { 1713 /** Mount points as strings, delimited with a string terminator ('\0'). 1714 * List ends with an additional string terminator. Might get re-allocated, so don't rely on this pointer! */ 1715 char *psz; 1716 /** Current size of \a psz in bytes. Includes ending terminator. */ 1717 size_t cb; 1718 /** Total allocation Size of \a psz in bytes. */ 1719 size_t cbAlloc; 1720 } VGSVCMOUNTPOINTENUMCTX; 1721 /** Pointer to a structure for keeping a mount point enumeration context. */ 1722 typedef VGSVCMOUNTPOINTENUMCTX *PVGSVCMOUNTPOINTENUMCTX; 1723 1724 /** 1725 * Enumeration callback for storing the mount points. 1726 * 1727 * @returns VBox status code. 1728 * @param pszMountpoint Mount point to handle. 1729 * @param pvUser Pointer of type PVGSVCMOUNTPOINTENUMCTX. 1730 */ 1731 DECLCALLBACK(int) vgsvcGstCtrlSessionHandleMountPointsEnumCallback(const char *pszMountpoint, void *pvUser) 1732 { 1733 PVGSVCMOUNTPOINTENUMCTX pCtx = (PVGSVCMOUNTPOINTENUMCTX)pvUser; 1734 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1735 1736 size_t const cch = strlen(pszMountpoint) + 1 /* Entry terminator */; 1737 AssertReturn(cch < RTPATH_MAX, VERR_INVALID_PARAMETER); /* Paranoia. */ 1738 if (cch > pCtx->cbAlloc - pCtx->cb - 1 /* Ending terminator */) 1739 { 1740 char *pszNew; 1741 int rc2 = RTStrRealloc(&pszNew, pCtx->cbAlloc + RT_MAX(_4K, cch)); 1742 AssertRCReturn(rc2, rc2); 1743 pCtx->psz = pszNew; 1744 } 1745 1746 memcpy(&pCtx->psz[pCtx->cb], pszMountpoint, cch); 1747 pCtx->cb += cch; 1748 AssertReturn(pCtx->cb <= pCtx->cbAlloc, VERR_BUFFER_OVERFLOW); /* Paranoia. */ 1749 1750 return VINF_SUCCESS; 1751 } 1752 1753 /** 1754 * Handles getting the current mount points. 1755 * 1756 * @returns VBox status code. 1757 * @param pSession Guest session. 1758 * @param pHostCtx Host context. 1759 */ 1760 static int vgsvcGstCtrlSessionHandleMountPoints(PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx) 1761 { 1762 AssertPtrReturn(pSession, VERR_INVALID_POINTER); 1763 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 1764 1765 /* 1766 * Retrieve the request. 1767 */ 1768 int rc = VbglR3GuestCtrlGetMountPoints(pHostCtx); 1769 if (RT_SUCCESS(rc)) 1770 { 1771 VGSVCMOUNTPOINTENUMCTX Ctx; 1772 Ctx.cb = 0; 1773 Ctx.cbAlloc = _4K; /* Start with something sensible. */ 1774 Ctx.psz = RTStrAlloc(Ctx.cbAlloc); 1775 if (!Ctx.psz) 1776 rc = VERR_NO_MEMORY; 1777 1778 if (RT_SUCCESS(rc)) 1779 rc = RTFsMountpointsEnum(vgsvcGstCtrlSessionHandleMountPointsEnumCallback, &Ctx); 1780 1781 /* Report back in any case. */ 1782 int rc2 = VbglR3GuestCtrlMsgReplyEx(pHostCtx, rc, 0 /* Type */, Ctx.psz, 1783 RT_SUCCESS(rc) ? (uint32_t)Ctx.cb : 0); 1784 if (RT_FAILURE(rc2)) 1785 { 1786 VGSvcError("Failed to report mount points, rc=%Rrc\n", rc2); 1787 if (RT_SUCCESS(rc)) 1788 rc = rc2; 1789 } 1790 1791 RTStrFree(Ctx.psz); 1792 Ctx.psz = NULL; 1793 } 1794 else 1795 { 1796 VGSvcError("Error fetching parameters for getting mount points request: %Rrc\n", rc); 1797 VbglR3GuestCtrlMsgSkip(pHostCtx->uClientID, rc, UINT32_MAX); 1798 } 1799 return rc; 1800 } 1801 1802 1803 /** 1709 1804 * Handles starting a guest processes. 1710 1805 * … … 2450 2545 if (fImpersonated) 2451 2546 rc = vgsvcGstCtrlSessionHandlePathUserHome(pSession, pHostCtx); 2547 break; 2548 2549 case HOST_MSG_MOUNT_POINTS: 2550 if (fImpersonated) 2551 rc = vgsvcGstCtrlSessionHandleMountPoints(pSession, pHostCtx); 2452 2552 break; 2453 2553 -
trunk/src/VBox/HostServices/GuestControl/VBoxGuestControlSvc.cpp
r102602 r102654 1680 1680 RT_FALL_THROUGH(); 1681 1681 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 1682 case HOST_MSG_MOUNT_POINTS: 1683 RT_FALL_THROUGH(); 1682 1684 case HOST_MSG_EXEC_GET_OUTPUT: /** @todo BUGBUG This can't be right/work. */ 1683 1685 case HOST_MSG_EXEC_TERMINATE: /** @todo BUGBUG This can't be right/work. */ -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r102534 r102654 15266 15266 <interface 15267 15267 name="IGuestSession" extends="$unknown" 15268 uuid=" 5e54f60b-6dcd-4594-a6c9-cf968f004341"15268 uuid="8b2b6773-8b5a-4cd2-95f8-38faf73913e1" 15269 15269 wsmap="managed" 15270 15270 reservedMethods="8" reservedAttributes="12" … … 15402 15402 <desc> 15403 15403 Returns the user's documents directory. Guest path style. 15404 </desc> 15405 </attribute> 15406 <attribute name="mountPoints" type="wstring" readonly="yes" safearray="yes"> 15407 <desc> 15408 Returns all currently accessible (disk-based) mount points. 15409 On Windows guests, this returns the currently mapped the disk drives. 15410 15411 <result name="VBOX_E_NOT_SUPPORTED">If the Guest Additions does not 15412 support this feature.</result> 15404 15413 </desc> 15405 15414 </attribute> -
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r99740 r102654 1211 1211 } 1212 1212 1213 /** 1214 * Returns the payload as a vector of strings, validated. 1215 * 1216 * @returns VBox status code. 1217 * @param vecStrings Where to return the vector of strings on success. 1218 */ 1219 int ToStringVector(std::vector<Utf8Str> &vecStrings) 1220 { 1221 int vrc = VINF_SUCCESS; 1222 1223 vecStrings.clear(); 1224 1225 const char *psz = (const char *)pvData; 1226 AssertPtrReturn(psz, vrc = VERR_INVALID_PARAMETER); 1227 size_t cb = cbData; 1228 while (cb) 1229 { 1230 size_t const cch = strlen(psz); 1231 if (!cch) 1232 break; 1233 size_t const cbStr = cch + 1 /* String terminator */; 1234 vrc = RTStrValidateEncodingEx(psz, cbStr, 1235 RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED | RTSTR_VALIDATE_ENCODING_EXACT_LENGTH); 1236 if (RT_FAILURE(vrc)) 1237 break; 1238 AssertBreakStmt(cb >= cbStr, vrc = VERR_INVALID_PARAMETER); 1239 cb -= cbStr; 1240 psz += cbStr; 1241 } 1242 1243 if (RT_SUCCESS(vrc)) 1244 AssertStmt(cb <= 1 /* Ending terminator */, vrc = VERR_INVALID_PARAMETER); 1245 return vrc; 1246 } 1247 1213 1248 protected: 1214 1249 -
trunk/src/VBox/Main/include/GuestSessionImpl.h
r102614 r102654 87 87 HRESULT getUserDocuments(com::Utf8Str &aUserDocuments); 88 88 HRESULT getUserHome(com::Utf8Str &aUserHome); 89 HRESULT getMountPoints(std::vector<com::Utf8Str> &aMountPoints); 89 90 HRESULT getDirectories(std::vector<ComPtr<IGuestDirectory> > &aDirectories); 90 91 HRESULT getFiles(std::vector<ComPtr<IGuestFile> > &aFiles); … … 345 346 int i_pathRename(const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags, int *pvrcGuest); 346 347 int i_pathUserDocuments(Utf8Str &strPath, int *pvrcGuest); 348 int i_getMountPoints(std::vector<com::Utf8Str> &vecMountPoints, int *pvrcGuest); 347 349 int i_pathUserHome(Utf8Str &strPath, int *pvrcGuest); 348 350 int i_processUnregister(GuestProcess *pProcess); -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r102614 r102654 616 616 default: 617 617 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Getting the user's documents path failed: %Rrc"), vrc); 618 break; 619 } 620 } 621 622 return hrc; 623 } 624 625 HRESULT GuestSession::getMountPoints(std::vector<com::Utf8Str> &aMountPoints) 626 { 627 HRESULT hrc = i_isStartedExternal(); 628 if (FAILED(hrc)) 629 return hrc; 630 631 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; 632 int vrc = i_getMountPoints(aMountPoints, &vrcGuest); 633 if (RT_FAILURE(vrc)) 634 { 635 switch (vrc) 636 { 637 case VERR_GSTCTL_GUEST_ERROR: 638 { 639 switch (vrcGuest) 640 { 641 case VERR_NOT_SUPPORTED: 642 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, 643 tr("Getting the mount points is not supported by installed Guest Additions")); 644 break; 645 646 default: 647 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, 648 tr("Getting the mount points failed on the guest: %Rrc"), vrcGuest); 649 break; 650 } 651 break; 652 } 653 654 default: 655 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Getting the mount points failed: %Rrc"), vrc); 618 656 break; 619 657 } … … 3115 3153 3116 3154 /** 3155 * Returns the currently accessible mount points of the guest. 3156 * 3157 * @returns VBox status code. 3158 * @param vecMountPoints Where to return the mount points (guest-style paths). 3159 * @param pvrcGuest Guest VBox status code, when returning 3160 * VERR_GSTCTL_GUEST_ERROR. Any other return code indicates 3161 * some host side error. 3162 * 3163 * @note Takes the read lock. 3164 */ 3165 int GuestSession::i_getMountPoints(std::vector<com::Utf8Str> &vecMountPoints, int *pvrcGuest) 3166 { 3167 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 3168 3169 GuestWaitEvent *pEvent = NULL; 3170 int vrc = registerWaitEvent(mData.mSession.mID, mData.mObjectID, &pEvent); 3171 if (RT_FAILURE(vrc)) 3172 return vrc; 3173 3174 /* Prepare HGCM call. */ 3175 VBOXHGCMSVCPARM paParms[2]; 3176 int i = 0; 3177 HGCMSvcSetU32(&paParms[i++], pEvent->ContextID()); 3178 3179 alock.release(); /* Drop lock before sending. */ 3180 3181 vrc = i_sendMessage(HOST_MSG_MOUNT_POINTS, i, paParms); 3182 if (RT_SUCCESS(vrc)) 3183 { 3184 vrc = pEvent->Wait(30 * 1000); 3185 if (RT_SUCCESS(vrc)) 3186 { 3187 vrc = pEvent->Payload().ToStringVector(vecMountPoints); 3188 } 3189 else 3190 { 3191 if (pEvent->HasGuestError() && pvrcGuest) 3192 *pvrcGuest = pEvent->GuestResult(); 3193 } 3194 } 3195 3196 unregisterWaitEvent(pEvent); 3197 3198 LogFlowFuncLeaveRC(vrc); 3199 return vrc; 3200 } 3201 3202 /** 3117 3203 * Returns the user's absolute home path, if any. 3118 3204 *
Note:
See TracChangeset
for help on using the changeset viewer.