Changeset 42530 in vbox
- Timestamp:
- Aug 2, 2012 12:11:44 PM (12 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
-
include/GuestCtrlImplPrivate.h (modified) (9 diffs)
-
include/GuestFsObjInfoImpl.h (modified) (2 diffs)
-
include/GuestSessionImpl.h (modified) (1 diff)
-
src-client/GuestCtrlPrivate.cpp (modified) (9 diffs)
-
src-client/GuestSessionImpl.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r42525 r42530 72 72 typedef std::vector <Utf8Str> ProcessArguments; 73 73 74 class GuestProcessStreamBlock; 75 74 76 75 77 /** … … 116 118 int mRC; 117 119 }; 120 118 121 119 122 /* … … 174 177 }; 175 178 179 176 180 /* 177 181 * Class representing a guest control process event. … … 207 211 }; 208 212 213 209 214 /** 210 215 * Simple structure mantaining guest credentials. … … 217 222 }; 218 223 224 219 225 typedef std::vector <Utf8Str> GuestEnvironmentArray; 220 226 class GuestEnvironment … … 259 265 260 266 std::map <Utf8Str, Utf8Str> mEnvironment; 267 }; 268 269 270 /** 271 * Structure representing information of a 272 * file system object. 273 */ 274 struct GuestFsObjData 275 { 276 /** Helper function to extract the data from 277 * a guest stream block. */ 278 int From(const GuestProcessStreamBlock &strmBlk); 279 280 int64_t mAccessTime; 281 int64_t mAllocatedSize; 282 int64_t mBirthTime; 283 int64_t mChangeTime; 284 uint32_t mDeviceNumber; 285 Utf8Str mFileAttrs; 286 uint32_t mGenerationID; 287 uint32_t mGID; 288 Utf8Str mGroupName; 289 uint32_t mNumHardLinks; 290 int64_t mModificationTime; 291 Utf8Str mName; 292 int64_t mNodeID; 293 uint32_t mNodeIDDevice; 294 int64_t mObjectSize; 295 FsObjType_T mType; 296 uint32_t mUID; 297 uint32_t mUserFlags; 298 Utf8Str mUserName; 299 Utf8Str mACL; 261 300 }; 262 301 … … 281 320 }; 282 321 322 283 323 /** 284 324 * Class representing the "value" side of a "key=value" pair. … … 313 353 public: 314 354 315 GuestProcessStreamBlock(); 316 317 //GuestProcessStreamBlock(GuestProcessStreamBlock &); 318 319 virtual ~GuestProcessStreamBlock(); 355 GuestProcessStreamBlock(void); 356 357 virtual ~GuestProcessStreamBlock(void); 320 358 321 359 public: … … 327 365 #endif 328 366 329 int GetInt64Ex(const char *pszKey, int64_t *piVal) ;330 331 int64_t GetInt64(const char *pszKey) ;332 333 size_t GetCount( );334 335 const char* GetString(const char *pszKey) ;336 337 int GetUInt32Ex(const char *pszKey, uint32_t *puVal) ;338 339 uint32_t GetUInt32(const char *pszKey) ;367 int GetInt64Ex(const char *pszKey, int64_t *piVal) const; 368 369 int64_t GetInt64(const char *pszKey) const; 370 371 size_t GetCount(void) const; 372 373 const char* GetString(const char *pszKey) const; 374 375 int GetUInt32Ex(const char *pszKey, uint32_t *puVal) const; 376 377 uint32_t GetUInt32(const char *pszKey) const; 340 378 341 379 int SetValue(const char *pszKey, const char *pszValue); -
trunk/src/VBox/Main/include/GuestFsObjInfoImpl.h
r42095 r42530 21 21 22 22 #include "VirtualBoxBase.h" 23 #include "GuestCtrlImplPrivate.h" 23 24 24 25 /** … … 78 79 private: 79 80 80 struct Data 81 { 82 LONG64 mAccessTime; 83 LONG64 mAllocatedSize; 84 LONG64 mBirthTime; 85 LONG64 mChangeTime; 86 ULONG mDeviceNumber; 87 Utf8Str mFileAttrs; 88 ULONG mGenerationID; 89 ULONG mGID; 90 Utf8Str mGroupName; 91 ULONG mNumHardLinks; 92 LONG64 mModificationTime; 93 Utf8Str mName; 94 LONG64 mNodeID; 95 ULONG mNodeIDDevice; 96 LONG64 mObjectSize; 97 FsObjType mType; 98 ULONG mUID; 99 ULONG mUserFlags; 100 Utf8Str mUserName; 101 Utf8Str mACL; 102 } mData; 81 GuestFsObjData mData; 103 82 }; 104 83 -
trunk/src/VBox/Main/include/GuestSessionImpl.h
r42525 r42530 127 127 int dispatchToProcess(uint32_t uContextID, uint32_t uFunction, void *pvData, size_t cbData); 128 128 int fileClose(ComObjPtr<GuestFile> pFile); 129 int fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData); 130 int fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize); 129 131 const GuestCredentials &getCredentials(void); 130 132 const GuestEnvironment &getEnvironment(void); -
trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp
r42507 r42530 586 586 } 587 587 588 int GuestFsObjData::From(const GuestProcessStreamBlock &strmBlk) 589 { 590 int rc = VINF_SUCCESS; 591 592 try 593 { 594 Utf8Str strType(strmBlk.GetString("ftype")); 595 if (strType.equalsIgnoreCase("-")) 596 mType = FsObjType_File; 597 else if (strType.equalsIgnoreCase("d")) 598 mType = FsObjType_Directory; 599 /** @todo Add more types! */ 600 else 601 mType = FsObjType_Undefined; 602 603 rc = strmBlk.GetInt64Ex("st_size", &mObjectSize); 604 if (RT_FAILURE(rc)) throw rc; 605 606 /** @todo Add complete GuestFsObjData info! */ 607 } 608 catch (int rc2) 609 { 610 rc = rc2; 611 } 612 613 return rc; 614 } 615 588 616 /////////////////////////////////////////////////////////////////////////////// 589 617 … … 621 649 * @return IPRT status code. 622 650 */ 623 void GuestProcessStreamBlock::Clear( )651 void GuestProcessStreamBlock::Clear(void) 624 652 { 625 653 m_mapPairs.clear(); … … 627 655 628 656 #ifdef DEBUG 629 void GuestProcessStreamBlock::Dump( )657 void GuestProcessStreamBlock::Dump(void) 630 658 { 631 659 LogFlowFunc(("Dumping contents of stream block=0x%p (%ld items):\n", … … 647 675 * @param piVal Pointer to value to return. 648 676 */ 649 int GuestProcessStreamBlock::GetInt64Ex(const char *pszKey, int64_t *piVal) 677 int GuestProcessStreamBlock::GetInt64Ex(const char *pszKey, int64_t *piVal) const 650 678 { 651 679 AssertPtrReturn(pszKey, VERR_INVALID_POINTER); … … 666 694 * @param pszKey Name of key to get the value for. 667 695 */ 668 int64_t GuestProcessStreamBlock::GetInt64(const char *pszKey) 696 int64_t GuestProcessStreamBlock::GetInt64(const char *pszKey) const 669 697 { 670 698 int64_t iVal; … … 679 707 * @return uint32_t Current number of stream pairs. 680 708 */ 681 size_t GuestProcessStreamBlock::GetCount( )709 size_t GuestProcessStreamBlock::GetCount(void) const 682 710 { 683 711 return m_mapPairs.size(); … … 690 718 * @param pszKey Name of key to get the value for. 691 719 */ 692 const char* GuestProcessStreamBlock::GetString(const char *pszKey) 720 const char* GuestProcessStreamBlock::GetString(const char *pszKey) const 693 721 { 694 722 AssertPtrReturn(pszKey, NULL); … … 714 742 * @param puVal Pointer to value to return. 715 743 */ 716 int GuestProcessStreamBlock::GetUInt32Ex(const char *pszKey, uint32_t *puVal) 744 int GuestProcessStreamBlock::GetUInt32Ex(const char *pszKey, uint32_t *puVal) const 717 745 { 718 746 AssertPtrReturn(pszKey, VERR_INVALID_POINTER); … … 733 761 * @param pszKey Name of key to get the value for. 734 762 */ 735 uint32_t GuestProcessStreamBlock::GetUInt32(const char *pszKey) 763 uint32_t GuestProcessStreamBlock::GetUInt32(const char *pszKey) const 736 764 { 737 765 uint32_t uVal; -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r42525 r42530 504 504 } 505 505 506 /* Note: Will work on directories and others, too. */ 507 int GuestSession::fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData) 508 { 509 LogFlowThisFunc(("strPath=%s\n", strPath.c_str())); 510 511 GuestProcessInfo procInfo; 512 procInfo.mName = Utf8StrFmt(tr("Querying info for \"%s\"", strPath.c_str())); 513 procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_STAT); 514 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut; 515 516 /* Construct arguments. */ 517 procInfo.mArguments.push_back(Utf8Str("--machinereadable")); 518 procInfo.mArguments.push_back(strPath); 519 520 GuestProcessStream streamOut; 521 522 ComObjPtr<GuestProcess> pProcess; 523 int rc = processCreateExInteral(procInfo, pProcess); 524 if (RT_SUCCESS(rc)) 525 { 526 GuestProcessWaitResult waitRes; 527 BYTE byBuf[_64K]; 528 size_t cbRead; 529 530 for (;;) 531 { 532 rc = pProcess->waitFor(ProcessWaitForFlag_StdOut, 533 30 * 1000 /* Timeout */, waitRes); 534 if ( RT_FAILURE(rc) 535 || waitRes.mResult != ProcessWaitResult_StdOut) 536 { 537 break; 538 } 539 540 rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf), 541 30 * 1000 /* Timeout */, byBuf, sizeof(byBuf), 542 &cbRead); 543 if (RT_FAILURE(rc)) 544 break; 545 546 rc = streamOut.AddData(byBuf, cbRead); 547 if (RT_FAILURE(rc)) 548 break; 549 } 550 551 LogFlowThisFunc(("rc=%Rrc, cbRead=%RU32, cbStreamOut=%RU32\n", 552 rc, cbRead, streamOut.GetSize())); 553 } 554 555 if (RT_SUCCESS(rc)) 556 { 557 GuestProcessStreamBlock streamBlock; 558 rc = streamOut.ParseBlock(streamBlock); 559 if (RT_SUCCESS(rc)) 560 { 561 rc = objData.From(streamBlock); 562 } 563 else 564 AssertMsgFailed(("Parsing stream block failed: %Rrc\n", rc)); 565 } 566 567 LogFlowFuncLeaveRC(rc); 568 return rc; 569 } 570 571 int GuestSession::fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize) 572 { 573 AssertPtrReturn(pllSize, VERR_INVALID_POINTER); 574 575 GuestFsObjData objData; 576 int rc = fileQueryInfoInternal(strPath, objData); 577 if (RT_SUCCESS(rc)) 578 { 579 if (objData.mType == FsObjType_File) 580 *pllSize = objData.mObjectSize; 581 else 582 rc = VERR_NOT_A_FILE; 583 } 584 585 return rc; 586 } 587 506 588 const GuestCredentials& GuestSession::getCredentials(void) 507 589 { … … 1082 1164 LogFlowThisFuncEnter(); 1083 1165 1084 AutoCaller autoCaller(this); 1085 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1086 1087 ReturnComNotImplemented(); 1166 if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0')) 1167 return setError(E_INVALIDARG, tr("No file to query size for specified")); 1168 CheckComArgOutPointerValid(aSize); 1169 1170 AutoCaller autoCaller(this); 1171 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1172 1173 HRESULT hr = S_OK; 1174 1175 int64_t llSize; 1176 int rc = fileQuerySizeInternal(Utf8Str(aPath), &llSize); 1177 if (RT_SUCCESS(rc)) 1178 { 1179 *aSize = llSize; 1180 } 1181 else 1182 { 1183 switch (rc) 1184 { 1185 /** @todo Add more errors here! */ 1186 1187 default: 1188 hr = setError(VBOX_E_IPRT_ERROR, tr("Querying file size failed: %Rrc"), rc); 1189 break; 1190 } 1191 } 1192 1193 return hr; 1088 1194 #endif /* VBOX_WITH_GUEST_CONTROL */ 1089 1195 }
Note:
See TracChangeset
for help on using the changeset viewer.

