Changeset 98665 in vbox for trunk/src/VBox/Main
- Timestamp:
- Feb 21, 2023 7:49:56 AM (2 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r98610 r98665 1456 1456 /** @} */ 1457 1457 }; 1458 1459 1460 /******************************************************************************* 1461 * Callback data structures. * 1462 *******************************************************************************/ 1463 1464 /** 1465 * Callback data for guest file system operations. 1466 */ 1467 typedef struct CALLBACKDATA_FS_NOTIFY 1468 { 1469 /** Callback data header. */ 1470 CALLBACKDATA_HEADER hdr; 1471 /** Notification type (of type GUEST_FS_NOTIFYTYPE_XXX). */ 1472 uint32_t uType; 1473 /** IPRT result of overall operation. */ 1474 uint32_t rc; 1475 union 1476 { 1477 struct 1478 { 1479 GSTCTLFSOBJINFO objInfo; 1480 /** Resolved user name. */ 1481 char *pszUser; 1482 /** Size (in bytes) of \a pszUser. */ 1483 uint32_t cbUser; 1484 /** Resolved user group(s). */ 1485 char *pszGroups; 1486 /** Size (in bytes) of \a pszGroups. */ 1487 uint32_t cbGroups; 1488 } QueryInfo; 1489 struct 1490 { 1491 /** Path of created temporary file / directory. */ 1492 char *pszPath; 1493 /** Size (in bytes) of \a pszPath. */ 1494 uint32_t cbPath; 1495 } CreateTemp; 1496 } u; 1497 } CALLBACKDATA_FS_NOTIFY; 1498 /** Pointer to a CALLBACKDATA_FS_NOTIFY struct. */ 1499 typedef CALLBACKDATA_FS_NOTIFY *PCALLBACKDATA_FS_NOTIFY; 1458 1500 #endif /* !MAIN_INCLUDED_GuestCtrlImplPrivate_h */ 1459 1501 -
trunk/src/VBox/Main/include/GuestSessionImpl.h
r98272 r98665 325 325 bool i_isTerminated(void) const; 326 326 int i_onRemove(void); 327 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 328 int i_onFsNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData); 329 #endif 327 330 int i_onSessionStatusChange(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData); 328 331 PathStyle_T i_getGuestPathStyle(void); -
trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp
r98278 r98665 231 231 break; 232 232 233 /* File system stuff. */ 234 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 235 case GUEST_MSG_FS_NOTIFY: 236 vrc = pSession->i_dispatchToThis(pCtxCb, pSvcCb); 237 break; 238 #endif 233 239 /* Session stuff. */ 234 240 case GUEST_MSG_SESSION_NOTIFY: -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r98643 r98665 1254 1254 if (RT_SUCCESS(vrc)) 1255 1255 { 1256 /// @todo To be implemented 1256 PCALLBACKDATA_FS_NOTIFY const pFsNotify = (PCALLBACKDATA_FS_NOTIFY)pEvent->Payload().Raw(); 1257 AssertPtrReturn(pFsNotify, VERR_INVALID_POINTER); 1258 vrcGuest = (int)pFsNotify->rc; 1259 if (RT_SUCCESS(vrcGuest)) 1260 { 1261 AssertReturn(pFsNotify->uType == GUEST_FS_NOTIFYTYPE_CREATE_TEMP, VERR_INVALID_PARAMETER); 1262 AssertReturn(pFsNotify->u.CreateTemp.cbPath, VERR_INVALID_PARAMETER); 1263 strName = pFsNotify->u.CreateTemp.pszPath; 1264 RTStrFree(pFsNotify->u.CreateTemp.pszPath); 1265 } 1266 else 1267 { 1268 if (pvrcGuest) 1269 *pvrcGuest = vrcGuest; 1270 vrc = VERR_GSTCTL_GUEST_ERROR; 1271 } 1272 } 1273 else 1274 { 1275 if (vrc == VERR_GSTCTL_GUEST_ERROR) 1276 { 1277 if (pvrcGuest) 1278 *pvrcGuest = pEvent->GuestResult(); 1279 } 1257 1280 } 1258 1281 } … … 1527 1550 break; 1528 1551 1552 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 1553 case GUEST_MSG_FS_NOTIFY: 1554 vrc = i_onFsNotify(pCbCtx, pSvcCbData); 1555 break; 1556 #endif 1529 1557 case GUEST_MSG_SESSION_NOTIFY: /* Guest Additions >= 4.3.0. */ 1530 1558 vrc = i_onSessionStatusChange(pCbCtx, pSvcCbData); … … 1951 1979 return vrc; 1952 1980 1953 uint32_t fFlags = GSTCTL_QUERYINFO_F_NONE; 1954 if (fFollowSymlinks) 1955 fFlags |= GSTCTL_QUERYINFO_F_FOLLOW_LINK; 1981 uint32_t const fFlags = fFollowSymlinks ? GSTCTL_QUERYINFO_F_FOLLOW_LINK : GSTCTL_QUERYINFO_F_ON_LINK; 1956 1982 1957 1983 /* Prepare HGCM call. */ … … 1959 1985 int i = 0; 1960 1986 HGCMSvcSetU32(&paParms[i++], pEvent->ContextID()); 1961 HGCMSvcSet Pv (&paParms[i++], (void*)strPath.c_str(), (ULONG)strPath.length() + 1);1987 HGCMSvcSetStr(&paParms[i++], strPath.c_str()); 1962 1988 HGCMSvcSetU32(&paParms[i++], GSTCTLFSOBJATTRADD_UNIX /* Implicit */); 1963 1989 HGCMSvcSetU32(&paParms[i++], fFlags); … … 1971 1997 if (RT_SUCCESS(vrc)) 1972 1998 { 1973 /// @todo To be implemented1974 #if 01975 const ComPtr<IEvent> pThisEvent = pEvent->Event();1976 if ( pThisEvent.isNotNull()) /* Make sure that we actually have an event associated. */1999 PCALLBACKDATA_FS_NOTIFY const pFsNotify = (PCALLBACKDATA_FS_NOTIFY)pEvent->Payload().Raw(); 2000 AssertPtrReturn(pFsNotify, VERR_INVALID_POINTER); 2001 vrcGuest = (int)pFsNotify->rc; 2002 if (RT_SUCCESS(vrcGuest)) 1977 2003 { 1978 if (pType) 1979 { 1980 HRESULT hrc = pThisEvent->COMGETTER(Type)(pType); 1981 if (FAILED(hrc)) 1982 vrc = VERR_COM_UNEXPECTED; 1983 } 1984 if ( RT_SUCCESS(vrc) 1985 && ppEvent) 1986 pThisEvent.queryInterfaceTo(ppEvent); 1987 1988 unconst(pThisEvent).setNull(); 1989 } 1990 1991 if (pEvent->Payload().Size() == sizeof(GSTCTLFSOBJINFO)) 1992 { 1993 HRESULT hrc1 = pFileEvent->COMGETTER(Data)(ComSafeArrayAsOutParam(data)); 1994 ComAssertComRC(hrc1); 1995 2004 AssertReturn(pFsNotify->uType == GUEST_FS_NOTIFYTYPE_QUERY_INFO, VERR_INVALID_PARAMETER); 1996 2005 objData.Init(strPath); 1997 1998 PGSTCTLFSOBJINFO 1999 2000 objData.FromGuestFsObjInfo((PGSTCTLFSOBJINFO)pEvent->Payload().Raw()); 2006 vrc = objData.FromGuestFsObjInfo(&pFsNotify->u.QueryInfo.objInfo); 2007 RTStrFree(pFsNotify->u.QueryInfo.pszUser); 2008 RTStrFree(pFsNotify->u.QueryInfo.pszGroups); 2001 2009 } 2002 2010 else 2003 vrc = VERR_INVALID_PARAMETER; 2004 #endif 2011 { 2012 if (pvrcGuest) 2013 *pvrcGuest = vrcGuest; 2014 vrc = VERR_GSTCTL_GUEST_ERROR; 2015 } 2005 2016 } 2006 2017 else … … 2231 2242 } 2232 2243 2233 /** 2234 * Handles guest session status changes from the guest. 2244 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 2245 /** 2246 * Handles guest file system notifications. 2235 2247 * 2236 2248 * @returns VBox status code. 2237 2249 * @param pCbCtx Host callback context from HGCM service. 2238 2250 * @param pSvcCbData HGCM service callback data. 2251 */ 2252 int GuestSession::i_onFsNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData) 2253 { 2254 AssertPtrReturn(pCbCtx, VERR_INVALID_POINTER); 2255 AssertPtrReturn(pSvcCbData, VERR_INVALID_POINTER); 2256 2257 if (pSvcCbData->mParms < 4) 2258 return VERR_INVALID_PARAMETER; 2259 2260 CALLBACKDATA_FS_NOTIFY dataCb; 2261 RT_ZERO(dataCb); 2262 /* pSvcCb->mpaParms[0] always contains the context ID. */ 2263 int vrc = HGCMSvcGetU32(&pSvcCbData->mpaParms[1], &dataCb.uType); 2264 AssertRCReturn(vrc, vrc); 2265 vrc = HGCMSvcGetU32(&pSvcCbData->mpaParms[2], &dataCb.rc); 2266 AssertRCReturn(vrc, vrc); 2267 2268 int const vrcGuest = (int)dataCb.rc; 2269 2270 if (RT_SUCCESS(vrcGuest)) 2271 { 2272 switch (dataCb.uType) 2273 { 2274 case GUEST_FS_NOTIFYTYPE_QUERY_INFO: 2275 { 2276 AssertBreakStmt(pSvcCbData->mParms >= 7, VERR_INVALID_PARAMETER); 2277 PGSTCTLFSOBJINFO pObjInfo; 2278 uint32_t cbObjInfo; 2279 vrc = HGCMSvcGetPv(&pSvcCbData->mpaParms[3], (void **)&pObjInfo, &cbObjInfo); 2280 AssertRCBreak(vrc); 2281 AssertBreakStmt(cbObjInfo == sizeof(GSTCTLFSOBJINFO), VERR_INVALID_PARAMETER); 2282 memcpy(&dataCb.u.QueryInfo.objInfo, pObjInfo, sizeof(GSTCTLFSOBJINFO)); 2283 2284 char *pszUser; 2285 uint32_t cbUser; 2286 vrc = HGCMSvcGetStr(&pSvcCbData->mpaParms[4], &pszUser, &cbUser); 2287 AssertRCBreak(vrc); 2288 dataCb.u.QueryInfo.pszUser = RTStrDup(pszUser); 2289 AssertPtrBreakStmt(dataCb.u.QueryInfo.pszUser, vrc = VERR_NO_MEMORY); 2290 dataCb.u.QueryInfo.cbUser = cbUser; 2291 2292 char *pszGroups; 2293 uint32_t cbGroups; 2294 vrc = HGCMSvcGetStr(&pSvcCbData->mpaParms[5], &pszGroups, &cbGroups); 2295 AssertRCBreak(vrc); 2296 dataCb.u.QueryInfo.pszGroups = RTStrDup(pszGroups); 2297 AssertPtrBreakStmt(dataCb.u.QueryInfo.pszGroups, vrc = VERR_NO_MEMORY); 2298 dataCb.u.QueryInfo.cbGroups = cbGroups; 2299 2300 /** @todo ACLs not implemented yet. */ 2301 break; 2302 } 2303 2304 case GUEST_FS_NOTIFYTYPE_CREATE_TEMP: 2305 { 2306 char *pszPath; 2307 uint32_t cbPath; 2308 vrc = HGCMSvcGetStr(&pSvcCbData->mpaParms[3], &pszPath, &cbPath); 2309 AssertRCBreak(vrc); 2310 dataCb.u.CreateTemp.pszPath = RTStrDup(pszPath); 2311 AssertPtrBreakStmt(dataCb.u.CreateTemp.pszPath, vrc = VERR_NO_MEMORY); 2312 dataCb.u.CreateTemp.cbPath = cbPath; 2313 break; 2314 } 2315 2316 case GUEST_FS_NOTIFYTYPE_UNKNOWN: 2317 RT_FALL_THROUGH(); 2318 default: 2319 vrc = VERR_NOT_SUPPORTED; 2320 break; 2321 } 2322 } 2323 2324 try 2325 { 2326 GuestWaitEventPayload evPayload(dataCb.uType, &dataCb, sizeof(dataCb)); 2327 vrc = signalWaitEventInternal(pCbCtx, dataCb.rc, &evPayload); 2328 } 2329 catch (int vrcEx) /* Thrown by GuestWaitEventPayload constructor. */ 2330 { 2331 vrc = vrcEx; 2332 } 2333 2334 return vrc; 2335 } 2336 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 2337 2338 /** 2339 * Handles guest session status changes from the guest. 2340 * 2341 * @returns VBox status code. 2342 * @param pCbCtx Host callback context from HGCM service. 2343 * @param pSvcCbData HGCM service callback data. 2239 2344 * 2240 2345 * @note Takes the read lock (for session ID lookup). … … 2243 2348 { 2244 2349 AssertPtrReturn(pCbCtx, VERR_INVALID_POINTER); 2245 /* pCallback is optional. */2246 2350 AssertPtrReturn(pSvcCbData, VERR_INVALID_POINTER); 2247 2351
Note:
See TracChangeset
for help on using the changeset viewer.