Changeset 71250 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Mar 7, 2018 11:02:14 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp
r71173 r71250 204 204 } 205 205 206 #ifdef DEBUG207 206 LogFlowFuncLeaveRC(vrc); 208 #endif209 207 return vrc; 210 208 } … … 244 242 } 245 243 244 /** 245 * Closes this guest directory and removes it from the 246 * guest session's directory list. 247 * 248 * @return VBox status code. 249 * @param pGuestRc Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned. 250 */ 251 int GuestDirectory::i_closeInternal(int *pGuestRc) 252 { 253 AssertPtrReturn(pGuestRc, VERR_INVALID_POINTER); 254 255 int rc = mData.mProcessTool.i_terminate(30 * 1000 /* 30s timeout */, pGuestRc); 256 if (RT_FAILURE(rc)) 257 return rc; 258 259 AssertPtr(mSession); 260 int rc2 = mSession->i_directoryRemoveFromList(this); 261 if (RT_SUCCESS(rc)) 262 rc = rc2; 263 264 LogFlowThisFunc(("Returning rc=%Rrc\n", rc)); 265 return rc; 266 } 267 268 /** 269 * Reads the next directory entry. 270 * 271 * @return VBox status code. Will return VERR_NO_MORE_FILES if no more entries are available. 272 * @param fsObjInfo Where to store the read directory entry. 273 * @param pGuestRc Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned. 274 */ 275 int GuestDirectory::i_readInternal(ComObjPtr<GuestFsObjInfo> &fsObjInfo, int *pGuestRc) 276 { 277 AssertPtrReturn(pGuestRc, VERR_INVALID_POINTER); 278 279 /* Create the FS info object. */ 280 HRESULT hr = fsObjInfo.createObject(); 281 if (FAILED(hr)) 282 return VERR_COM_UNEXPECTED; 283 284 GuestProcessStreamBlock curBlock; 285 int rc = mData.mProcessTool.i_waitEx(GUESTPROCESSTOOL_FLAG_STDOUT_BLOCK, 286 &curBlock, pGuestRc); 287 if (RT_SUCCESS(rc)) 288 { 289 /* 290 * Note: The guest process can still be around to serve the next 291 * upcoming stream block next time. 292 */ 293 if (!mData.mProcessTool.i_isRunning()) 294 rc = mData.mProcessTool.i_terminatedOk(); 295 296 if (RT_SUCCESS(rc)) 297 { 298 if (curBlock.GetCount()) /* Did we get content? */ 299 { 300 GuestFsObjData objData; 301 rc = objData.FromLs(curBlock); 302 if (RT_SUCCESS(rc)) 303 { 304 rc = fsObjInfo->init(objData); 305 } 306 else 307 rc = VERR_PATH_NOT_FOUND; 308 } 309 else 310 { 311 /* Nothing to read anymore. Tell the caller. */ 312 rc = VERR_NO_MORE_FILES; 313 } 314 } 315 } 316 317 LogFlowThisFunc(("Returning rc=%Rrc\n", rc)); 318 return rc; 319 } 320 246 321 /* static */ 247 322 HRESULT GuestDirectory::i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc) … … 264 339 HRESULT hr = S_OK; 265 340 266 int guestRc;267 int rc = mData.mProcessTool.i_terminate(30 * 1000, &guestRc);341 int rcGuest; 342 int rc = i_closeInternal(&rcGuest); 268 343 if (RT_FAILURE(rc)) 269 344 { … … 271 346 { 272 347 case VERR_GSTCTL_GUEST_ERROR: 273 hr = Guest Process::i_setErrorExternal(this, guestRc);348 hr = GuestDirectory::i_setErrorExternal(this, rcGuest); 274 349 break; 275 350 … … 287 362 } 288 363 289 AssertPtr(mSession);290 int rc2 = mSession->i_directoryRemoveFromList(this);291 if (RT_SUCCESS(rc))292 rc = rc2;293 294 LogFlowThisFunc(("Returning rc=%Rrc\n", rc));295 364 return hr; 296 365 } … … 303 372 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 304 373 305 GuestProcessStreamBlock curBlock; 306 int guestRc; 307 308 int rc = mData.mProcessTool.i_waitEx(GUESTPROCESSTOOL_FLAG_STDOUT_BLOCK, 309 &curBlock, &guestRc); 310 311 /* 312 * Note: The guest process can still be around to serve the next 313 * upcoming stream block next time. 314 */ 315 if ( RT_SUCCESS(rc) 316 && !mData.mProcessTool.i_isRunning()) 317 { 318 rc = mData.mProcessTool.i_terminatedOk(); 319 } 320 374 HRESULT hr = S_OK; 375 376 ComObjPtr<GuestFsObjInfo> fsObjInfo; int rcGuest; 377 int rc = i_readInternal(fsObjInfo, &rcGuest); 321 378 if (RT_SUCCESS(rc)) 322 379 { 323 if (curBlock.GetCount()) /* Did we get content? */ 324 { 325 GuestFsObjData objData; 326 rc = objData.FromLs(curBlock); 327 if (RT_FAILURE(rc)) 328 rc = VERR_PATH_NOT_FOUND; 329 330 if (RT_SUCCESS(rc)) 331 { 332 /* Create the object. */ 333 ComObjPtr<GuestFsObjInfo> pFsObjInfo; 334 HRESULT hr2 = pFsObjInfo.createObject(); 335 if (FAILED(hr2)) 336 rc = VERR_COM_UNEXPECTED; 337 338 if (RT_SUCCESS(rc)) 339 rc = pFsObjInfo->init(objData); 340 341 if (RT_SUCCESS(rc)) 342 { 343 /* Return info object to the caller. */ 344 hr2 = pFsObjInfo.queryInterfaceTo(aObjInfo.asOutParam()); 345 if (FAILED(hr2)) 346 rc = VERR_COM_UNEXPECTED; 347 } 348 } 349 } 350 else 351 { 352 /* Nothing to read anymore. Tell the caller. */ 353 rc = VERR_NO_MORE_FILES; 354 } 355 } 356 357 HRESULT hr = S_OK; 358 359 if (RT_FAILURE(rc)) /** @todo Add more errors here. */ 380 /* Return info object to the caller. */ 381 hr = fsObjInfo.queryInterfaceTo(aObjInfo.asOutParam()); 382 } 383 else 360 384 { 361 385 switch (rc) 362 386 { 363 387 case VERR_GSTCTL_GUEST_ERROR: 364 hr = Guest Process::i_setErrorExternal(this, guestRc);388 hr = GuestDirectory::i_setErrorExternal(this, rcGuest); 365 389 break; 366 390 … … 377 401 case VERR_NO_MORE_FILES: 378 402 /* See SDK reference. */ 379 hr = setError(VBOX_E_OBJECT_NOT_FOUND, tr(" No more entries for directory \"%s\""),403 hr = setError(VBOX_E_OBJECT_NOT_FOUND, tr("Reading directory \"%s\" failed: No more entries"), 380 404 mData.mOpenInfo.mPath.c_str()); 381 405 break; 382 406 383 407 default: 384 hr = setError(VBOX_E_IPRT_ERROR, tr(" Error while reading directory \"%s\": %Rrc\n"),408 hr = setError(VBOX_E_IPRT_ERROR, tr("Reading directory \"%s\" returned error: %Rrc\n"), 385 409 mData.mOpenInfo.mPath.c_str(), rc); 386 410 break;
Note:
See TracChangeset
for help on using the changeset viewer.