Changeset 98526 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Feb 10, 2023 3:10:50 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155802
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp
r98278 r98526 53 53 54 54 55 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 56 /** 57 * Returns a stringyfied error of a guest fs error. 58 * 59 * @returns Stringyfied error. 60 * @param guestErrorInfo Guest error info to get stringyfied error for. 61 */ 62 /* static */ 63 Utf8Str GuestFs::guestErrorToString(const GuestErrorInfo &guestErrorInfo) 64 { 65 Utf8Str strErr; 66 67 /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */ 68 switch (guestErrorInfo.getVrc()) 69 { 70 case VERR_ACCESS_DENIED: 71 strErr.printf(tr("Access to \"%s\" denied"), guestErrorInfo.getWhat().c_str()); 72 break; 73 74 case VERR_FILE_NOT_FOUND: /* This is the most likely error. */ 75 RT_FALL_THROUGH(); 76 case VERR_PATH_NOT_FOUND: 77 strErr.printf(tr("No such file or directory \"%s\""), guestErrorInfo.getWhat().c_str()); 78 break; 79 80 case VERR_INVALID_VM_HANDLE: 81 strErr.printf(tr("VMM device is not available (is the VM running?)")); 82 break; 83 84 case VERR_HGCM_SERVICE_NOT_FOUND: 85 strErr.printf(tr("The guest execution service is not available")); 86 break; 87 88 case VERR_BAD_EXE_FORMAT: 89 strErr.printf(tr("The file \"%s\" is not an executable format"), guestErrorInfo.getWhat().c_str()); 90 break; 91 92 case VERR_AUTHENTICATION_FAILURE: 93 strErr.printf(tr("The user \"%s\" was not able to logon"), guestErrorInfo.getWhat().c_str()); 94 break; 95 96 case VERR_INVALID_NAME: 97 strErr.printf(tr("The file \"%s\" is an invalid name"), guestErrorInfo.getWhat().c_str()); 98 break; 99 100 case VERR_TIMEOUT: 101 strErr.printf(tr("The guest did not respond within time")); 102 break; 103 104 case VERR_CANCELLED: 105 strErr.printf(tr("The execution operation was canceled")); 106 break; 107 108 case VERR_GSTCTL_MAX_CID_OBJECTS_REACHED: 109 strErr.printf(tr("Maximum number of concurrent guest processes has been reached")); 110 break; 111 112 case VERR_NOT_FOUND: 113 strErr.printf(tr("The guest execution service is not ready (yet)")); 114 break; 115 116 default: 117 strErr.printf(tr("Unhandled error %Rrc for \"%s\" occurred on guest -- please file a bug report"), 118 guestErrorInfo.getVrc(), guestErrorInfo.getWhat().c_str()); 119 break; 120 } 121 122 return strErr; 123 } 124 125 126 /** 127 * Set the file system object data from a given GSTCTLFSOBJINFO struct. 128 * 129 * @returns VBox status code. 130 * @param pFsObjInfo Pointer to GSTCTLFSOBJINFO struct to use. 131 * @param strUser Resolved user name owning the object on the guest. 132 * @param strGroups Resolved user group(s) the object on the guest is associated with. 133 * On Windows there can be multiple groups assigned. The groups are separated with ";" 134 * The first group found is always the primary group. 135 * @param pvACL ACL data associated with the object. 136 * @param cbACL Size of ACL data (in bytes) associated with the object. 137 */ 138 int GuestFsObjData::FromGuestFsObjInfo(PCGSTCTLFSOBJINFO pFsObjInfo, 139 const Utf8Str &strUser /* = "" */, const Utf8Str &strGroups /* = "" */, const void *pvACL /* = NULL */, size_t cbACL /* = 0 */) 140 { 141 RT_NOREF(pvACL, cbACL); 142 143 int rc; 144 145 mType = GuestBase::fileModeToFsObjType(pFsObjInfo->Attr.fMode); 146 147 mFileAttrs = ""; 148 switch (mType) 149 { 150 case FsObjType_File: mFileAttrs += '-'; break; 151 case FsObjType_Directory: mFileAttrs += 'd'; break; 152 case FsObjType_Symlink: mFileAttrs += 'l'; break; 153 case FsObjType_DevChar: mFileAttrs += 'c'; break; 154 case FsObjType_DevBlock: mFileAttrs += 'b'; break; 155 case FsObjType_Fifo: mFileAttrs += 'f'; break; 156 case FsObjType_Socket: mFileAttrs += 's'; break; 157 case FsObjType_WhiteOut: mFileAttrs += 'w'; break; 158 default: 159 mFileAttrs += '?'; 160 AssertFailedStmt(rc = VERR_NOT_SUPPORTED); 161 break; 162 } 163 164 #define ADD_ATTR(a_Flag, a_Set, a_Clear) \ 165 mFileAttrs += pFsObjInfo->Attr.fMode & a_Flag ? a_Set : a_Clear 166 167 ADD_ATTR(RTFS_UNIX_IRUSR, 'r', '-'); 168 ADD_ATTR(RTFS_UNIX_IWUSR, 'w', '-'); 169 ADD_ATTR(RTFS_UNIX_IXUSR, 'x', '-'); 170 171 ADD_ATTR(RTFS_UNIX_IRGRP, 'r', '-'); 172 ADD_ATTR(RTFS_UNIX_IWGRP, 'w', '-'); 173 ADD_ATTR(RTFS_UNIX_IXGRP, 'x', '-'); 174 175 ADD_ATTR(RTFS_UNIX_IROTH, 'r', '-'); 176 ADD_ATTR(RTFS_UNIX_IWOTH, 'w', '-'); 177 ADD_ATTR(RTFS_UNIX_IXOTH, 'x', '-'); 178 179 /** @todo Implement sticky bits. */ 180 mFileAttrs += " "; /* Reserve 3 chars for sticky bits. */ 181 182 mFileAttrs += " "; /* Separator. */ 183 184 ADD_ATTR(RTFS_DOS_READONLY , 'R', '-'); 185 ADD_ATTR(RTFS_DOS_HIDDEN , 'H', '-'); 186 ADD_ATTR(RTFS_DOS_SYSTEM , 'S', '-'); 187 ADD_ATTR(RTFS_DOS_DIRECTORY , 'D', '-'); 188 ADD_ATTR(RTFS_DOS_ARCHIVED , 'A', '-'); 189 ADD_ATTR(RTFS_DOS_NT_DEVICE , 'd', '-'); 190 ADD_ATTR(RTFS_DOS_NT_NORMAL , 'N', '-'); 191 ADD_ATTR(RTFS_DOS_NT_TEMPORARY , 'T', '-'); 192 ADD_ATTR(RTFS_DOS_NT_SPARSE_FILE , 'P', '-'); 193 ADD_ATTR(RTFS_DOS_NT_REPARSE_POINT , 'J', '-'); 194 ADD_ATTR(RTFS_DOS_NT_COMPRESSED , 'C', '-'); 195 ADD_ATTR(RTFS_DOS_NT_OFFLINE , 'O', '-'); 196 ADD_ATTR(RTFS_DOS_NT_NOT_CONTENT_INDEXED, 'I', '-'); 197 ADD_ATTR(RTFS_DOS_NT_ENCRYPTED , 'E', '-'); 198 199 #undef ADD_ATTR 200 201 mObjectSize = pFsObjInfo->cbObject; 202 mAllocatedSize = pFsObjInfo->cbAllocated; 203 mAccessTime = pFsObjInfo->AccessTime.i64NanosecondsRelativeToUnixEpoch; 204 mBirthTime = pFsObjInfo->BirthTime.i64NanosecondsRelativeToUnixEpoch; 205 mChangeTime = pFsObjInfo->ChangeTime.i64NanosecondsRelativeToUnixEpoch; 206 mModificationTime = pFsObjInfo->ModificationTime.i64NanosecondsRelativeToUnixEpoch; 207 mUserName = strUser; 208 mUID = pFsObjInfo->Attr.u.Unix.uid; 209 mGID = pFsObjInfo->Attr.u.Unix.gid; 210 mGroupName = strGroups; /** @todo Separate multiple group. */ 211 mNumHardLinks = pFsObjInfo->Attr.u.Unix.cHardlinks; 212 mNodeIDDevice = pFsObjInfo->Attr.u.Unix.INodeIdDevice; 213 mNodeID = pFsObjInfo->Attr.u.Unix.INodeId; 214 mDeviceNumber = RTFS_IS_DEV_BLOCK(pFsObjInfo->Attr.fMode) 215 || RTFS_IS_DEV_CHAR (pFsObjInfo->Attr.fMode) ? pFsObjInfo->Attr.u.Unix.Device : 0; 216 mGenerationID = pFsObjInfo->Attr.u.Unix.GenerationId; 217 mUserFlags = 0; 218 219 mACL = ""; /** @todo Implement ACL handling. */ 220 221 return VINF_SUCCESS; 222 } 223 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 224 225 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 55 226 /** 56 227 * Extracts the timespec from a given stream block key. … … 62 233 */ 63 234 /* static */ 64 PRTTIMESPEC GuestFsObjData::TimeSpecFromKey(const Guest ProcessStreamBlock &strmBlk, const Utf8Str &strKey, PRTTIMESPEC pTimeSpec)235 PRTTIMESPEC GuestFsObjData::TimeSpecFromKey(const GuestToolboxStreamBlock &strmBlk, const Utf8Str &strKey, PRTTIMESPEC pTimeSpec) 65 236 { 66 237 AssertPtrReturn(pTimeSpec, NULL); … … 84 255 */ 85 256 /* static */ 86 int64_t GuestFsObjData::UnixEpochNsFromKey(const Guest ProcessStreamBlock &strmBlk, const Utf8Str &strKey)257 int64_t GuestFsObjData::UnixEpochNsFromKey(const GuestToolboxStreamBlock &strmBlk, const Utf8Str &strKey) 87 258 { 88 259 RTTIMESPEC TimeSpec; … … 103 274 * @param fLong Whether the stream block contains long (detailed) information or not. 104 275 */ 105 int GuestFsObjData::From Ls(const GuestProcessStreamBlock &strmBlk, bool fLong)276 int GuestFsObjData::FromToolboxLs(const GuestToolboxStreamBlock &strmBlk, bool fLong) 106 277 { 107 278 LogFlowFunc(("\n")); … … 253 424 * @param strmBlk Stream block output data to parse. 254 425 */ 255 int GuestFsObjData::From Rm(const GuestProcessStreamBlock &strmBlk)426 int GuestFsObjData::FromToolboxRm(const GuestToolboxStreamBlock &strmBlk) 256 427 { 257 428 #ifdef DEBUG … … 272 443 * @param strmBlk Stream block output data to parse. 273 444 */ 274 int GuestFsObjData::From Stat(const GuestProcessStreamBlock &strmBlk)445 int GuestFsObjData::FromToolboxStat(const GuestToolboxStreamBlock &strmBlk) 275 446 { 276 447 /* Should be identical output. */ 277 return GuestFsObjData::From Ls(strmBlk, true /*fLong*/);448 return GuestFsObjData::FromToolboxLs(strmBlk, true /*fLong*/); 278 449 } 279 450 … … 285 456 * @param strmBlk Stream block output data to parse. 286 457 */ 287 int GuestFsObjData::From MkTemp(const GuestProcessStreamBlock &strmBlk)458 int GuestFsObjData::FromToolboxMkTemp(const GuestToolboxStreamBlock &strmBlk) 288 459 { 289 460 LogFlowFunc(("\n")); … … 302 473 } 303 474 475 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 476 304 477 /** 305 478 * Returns the IPRT-compatible file mode. … … 337 510 /////////////////////////////////////////////////////////////////////////////// 338 511 512 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 339 513 /** @todo *NOT* thread safe yet! */ 340 514 /** @todo Add exception handling for STL stuff! */ 341 515 342 Guest ProcessStreamBlock::GuestProcessStreamBlock(void)343 { 344 345 } 346 347 Guest ProcessStreamBlock::~GuestProcessStreamBlock()516 GuestToolboxStreamBlock::GuestToolboxStreamBlock(void) 517 { 518 519 } 520 521 GuestToolboxStreamBlock::~GuestToolboxStreamBlock() 348 522 { 349 523 Clear(); … … 353 527 * Clears (destroys) the currently stored stream pairs. 354 528 */ 355 void Guest ProcessStreamBlock::Clear(void)529 void GuestToolboxStreamBlock::Clear(void) 356 530 { 357 531 mPairs.clear(); … … 362 536 * Dumps the currently stored stream pairs to the (debug) log. 363 537 */ 364 void Guest ProcessStreamBlock::DumpToLog(void) const538 void GuestToolboxStreamBlock::DumpToLog(void) const 365 539 { 366 540 LogFlowFunc(("Dumping contents of stream block=0x%p (%ld items):\n", … … 382 556 * @param piVal Pointer to value to return. 383 557 */ 384 int Guest ProcessStreamBlock::GetInt64Ex(const char *pszKey, int64_t *piVal) const558 int GuestToolboxStreamBlock::GetInt64Ex(const char *pszKey, int64_t *piVal) const 385 559 { 386 560 AssertPtrReturn(pszKey, VERR_INVALID_POINTER); … … 401 575 * @param pszKey Name of key to get the value for. 402 576 */ 403 int64_t Guest ProcessStreamBlock::GetInt64(const char *pszKey) const577 int64_t GuestToolboxStreamBlock::GetInt64(const char *pszKey) const 404 578 { 405 579 int64_t iVal; … … 414 588 * @return uint32_t Current number of stream pairs. 415 589 */ 416 size_t Guest ProcessStreamBlock::GetCount(void) const590 size_t GuestToolboxStreamBlock::GetCount(void) const 417 591 { 418 592 return mPairs.size(); … … 425 599 * @retval VERR_NOT_FOUND if the return code string ("rc") was not found. 426 600 */ 427 int Guest ProcessStreamBlock::GetVrc(void) const601 int GuestToolboxStreamBlock::GetVrc(void) const 428 602 { 429 603 const char *pszValue = GetString("rc"); … … 440 614 * @param pszKey Name of key to get the value for. 441 615 */ 442 const char *Guest ProcessStreamBlock::GetString(const char *pszKey) const616 const char *GuestToolboxStreamBlock::GetString(const char *pszKey) const 443 617 { 444 618 AssertPtrReturn(pszKey, NULL); … … 464 638 * @param puVal Pointer to value to return. 465 639 */ 466 int Guest ProcessStreamBlock::GetUInt32Ex(const char *pszKey, uint32_t *puVal) const640 int GuestToolboxStreamBlock::GetUInt32Ex(const char *pszKey, uint32_t *puVal) const 467 641 { 468 642 const char *pszValue = GetString(pszKey); … … 482 656 * @param iDefault The default to return on error if not found. 483 657 */ 484 int32_t Guest ProcessStreamBlock::GetInt32(const char *pszKey, int32_t iDefault) const658 int32_t GuestToolboxStreamBlock::GetInt32(const char *pszKey, int32_t iDefault) const 485 659 { 486 660 const char *pszValue = GetString(pszKey); … … 503 677 * @param uDefault The default value to return. 504 678 */ 505 uint32_t Guest ProcessStreamBlock::GetUInt32(const char *pszKey, uint32_t uDefault /*= 0*/) const679 uint32_t GuestToolboxStreamBlock::GetUInt32(const char *pszKey, uint32_t uDefault /*= 0*/) const 506 680 { 507 681 uint32_t uVal; … … 518 692 * @param pszValue Value to set. Set NULL for deleting the key. 519 693 */ 520 int Guest ProcessStreamBlock::SetValue(const char *pszKey, const char *pszValue)694 int GuestToolboxStreamBlock::SetValue(const char *pszKey, const char *pszValue) 521 695 { 522 696 AssertPtrReturn(pszKey, VERR_INVALID_POINTER); … … 538 712 if (pszValue) 539 713 { 540 Guest ProcessStreamValue val(pszValue);714 GuestToolboxStreamValue val(pszValue); 541 715 mPairs[strKey] = val; 542 716 } … … 551 725 /////////////////////////////////////////////////////////////////////////////// 552 726 553 Guest ProcessStream::GuestProcessStream(void)727 GuestToolboxStream::GuestToolboxStream(void) 554 728 : m_cbMax(_32M) 555 729 , m_cbAllocated(0) … … 558 732 , m_pbBuffer(NULL) { } 559 733 560 Guest ProcessStream::~GuestProcessStream(void)734 GuestToolboxStream::~GuestToolboxStream(void) 561 735 { 562 736 Destroy(); … … 571 745 * @param cbData Size (in bytes) of data to add. 572 746 */ 573 int Guest ProcessStream::AddData(const BYTE *pbData, size_t cbData)747 int GuestToolboxStream::AddData(const BYTE *pbData, size_t cbData) 574 748 { 575 749 AssertPtrReturn(pbData, VERR_INVALID_POINTER); … … 642 816 * Destroys the internal data buffer. 643 817 */ 644 void Guest ProcessStream::Destroy(void)818 void GuestToolboxStream::Destroy(void) 645 819 { 646 820 if (m_pbBuffer) … … 662 836 * @param pszFile Absolute path to host file to dump the output to. 663 837 */ 664 void Guest ProcessStream::Dump(const char *pszFile)838 void GuestToolboxStream::Dump(const char *pszFile) 665 839 { 666 840 LogFlowFunc(("Dumping contents of stream=0x%p (cbAlloc=%u, cbSize=%u, cbOff=%u) to %s\n", … … 694 868 * @param streamBlock Reference to guest stream block to fill. 695 869 */ 696 int Guest ProcessStream::ParseBlock(GuestProcessStreamBlock &streamBlock)870 int GuestToolboxStream::ParseBlock(GuestToolboxStreamBlock &streamBlock) 697 871 { 698 872 if ( !m_pbBuffer … … 749 923 return vrc; 750 924 } 925 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 751 926 752 927 GuestBase::GuestBase(void) … … 1352 1527 Utf8Str strErr; 1353 1528 1354 #define CASE_TOOL_ERROR(a_eType, a_strTool) \ 1529 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 1530 # define CASE_TOOL_ERROR(a_eType, a_strTool) \ 1355 1531 case a_eType: \ 1356 1532 { \ 1357 strErr = GuestProcessTool ::guestErrorToString(a_strTool, guestErrorInfo); \1533 strErr = GuestProcessToolbox::guestErrorToString(a_strTool, guestErrorInfo); \ 1358 1534 break; \ 1359 1535 } 1536 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 1360 1537 1361 1538 switch (guestErrorInfo.getType()) … … 1377 1554 break; 1378 1555 1379 CASE_TOOL_ERROR(GuestErrorInfo::Type_ToolCat, VBOXSERVICE_TOOL_CAT); 1556 case GuestErrorInfo::Type_Fs: 1557 strErr = GuestFs::guestErrorToString(guestErrorInfo); 1558 break; 1559 1560 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 1380 1561 CASE_TOOL_ERROR(GuestErrorInfo::Type_ToolLs, VBOXSERVICE_TOOL_LS); 1381 1562 CASE_TOOL_ERROR(GuestErrorInfo::Type_ToolMkDir, VBOXSERVICE_TOOL_MKDIR); … … 1383 1564 CASE_TOOL_ERROR(GuestErrorInfo::Type_ToolRm, VBOXSERVICE_TOOL_RM); 1384 1565 CASE_TOOL_ERROR(GuestErrorInfo::Type_ToolStat, VBOXSERVICE_TOOL_STAT); 1385 1566 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 1386 1567 default: 1387 1568 AssertMsgFailed(("Type not implemented (type=%RU32, vrc=%Rrc)\n", guestErrorInfo.getType(), guestErrorInfo.getVrc())); … … 1405 1586 FsObjType_T GuestBase::fileModeToFsObjType(RTFMODE fMode) 1406 1587 { 1407 if (RTFS_IS_FILE(fMode)) return FsObjType_File; 1588 if (RTFS_IS_FIFO(fMode)) return FsObjType_Fifo; 1589 else if (RTFS_IS_DEV_CHAR(fMode)) return FsObjType_DevChar; 1408 1590 else if (RTFS_IS_DIRECTORY(fMode)) return FsObjType_Directory; 1591 else if (RTFS_IS_DEV_BLOCK(fMode)) return FsObjType_DevBlock; 1592 else if (RTFS_IS_FILE(fMode)) return FsObjType_File; 1409 1593 else if (RTFS_IS_SYMLINK(fMode)) return FsObjType_Symlink; 1594 else if (RTFS_IS_SOCKET(fMode)) return FsObjType_Socket; 1595 else if (RTFS_IS_WHITEOUT(fMode)) return FsObjType_WhiteOut; 1410 1596 1411 1597 return FsObjType_Unknown; -
trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp
r98272 r98526 36 36 # error "VBOX_WITH_GUEST_CONTROL must defined in this file" 37 37 #endif 38 #include "GuestImpl.h" 38 39 #include "GuestDirectoryImpl.h" 39 40 #include "GuestSessionImpl.h" 40 41 #include "GuestCtrlImplPrivate.h" 42 #include "VirtualBoxErrorInfoImpl.h" 41 43 42 44 #include "Global.h" 43 45 #include "AutoCaller.h" 46 #include "VBoxEvents.h" 44 47 45 48 #include <VBox/com/array.h> 49 #include <VBox/AssertGuest.h> 46 50 47 51 … … 70 74 int GuestDirectory::init(Console *pConsole, GuestSession *pSession, ULONG aObjectID, const GuestDirectoryOpenInfo &openInfo) 71 75 { 72 LogFlowThisFunc(("pConsole=%p, pSession=%p, aObjectID=%RU32, strPath=%s, strFilter=%s, uFlags=%x\n",73 pConsole, pSession, aObjectID, openInfo.mPath.c_str(), openInfo.m Filter.c_str(), openInfo.mFlags));76 LogFlowThisFunc(("pConsole=%p, pSession=%p, aObjectID=%RU32, strPath=%s, enmFilter=%#x, fFlags=%x\n", 77 pConsole, pSession, aObjectID, openInfo.mPath.c_str(), openInfo.menmFilter, openInfo.mFlags)); 74 78 75 79 AssertPtrReturn(pConsole, VERR_INVALID_POINTER); … … 86 90 mObjectID = aObjectID; 87 91 88 mData.mOpenInfo = openInfo; 89 } 90 91 if (RT_SUCCESS(vrc)) 92 { 93 /* Start the directory process on the guest. */ 94 GuestProcessStartupInfo procInfo; 95 procInfo.mName.printf(tr("Opening directory \"%s\""), openInfo.mPath.c_str()); 96 procInfo.mTimeoutMS = 5 * 60 * 1000; /* 5 minutes timeout. */ 97 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut; 98 procInfo.mExecutable= Utf8Str(VBOXSERVICE_TOOL_LS); 99 100 procInfo.mArguments.push_back(procInfo.mExecutable); 101 procInfo.mArguments.push_back(Utf8Str("--machinereadable")); 102 /* We want the long output format which contains all the object details. */ 103 procInfo.mArguments.push_back(Utf8Str("-l")); 104 #if 0 /* Flags are not supported yet. */ 105 if (uFlags & DirectoryOpenFlag_NoSymlinks) 106 procInfo.mArguments.push_back(Utf8Str("--nosymlinks")); /** @todo What does GNU here? */ 107 #endif 108 /** @todo Recursion support? */ 109 procInfo.mArguments.push_back(openInfo.mPath); /* The directory we want to open. */ 110 111 /* 112 * Start the process synchronously and keep it around so that we can use 113 * it later in subsequent read() calls. 114 */ 115 vrc = mData.mProcessTool.init(mSession, procInfo, false /*fAsync*/, NULL /*pvrcGuest*/); 116 if (RT_SUCCESS(vrc)) 117 { 118 /* As we need to know if the directory we were about to open exists and and is accessible, 119 * do the first read here in order to return a meaningful status here. */ 120 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; 121 vrc = i_readInternal(mData.mObjData, &vrcGuest); 122 if (RT_FAILURE(vrc)) 123 { 124 /* 125 * We need to actively terminate our process tool in case of an error here, 126 * as this otherwise would be done on (directory) object destruction implicitly. 127 * This in turn then will run into a timeout, as the directory object won't be 128 * around anymore at that time. Ugly, but that's how it is for the moment. 129 */ 130 int vrcTerm = mData.mProcessTool.terminate(30 * RT_MS_1SEC, NULL /* prcGuest */); 131 AssertRC(vrcTerm); 132 133 if (vrc == VERR_GSTCTL_GUEST_ERROR) 134 vrc = vrcGuest; 135 } 136 } 92 mData.mOpenInfo = openInfo; 93 mData.mStatus = DirectoryStatus_Undefined; 94 mData.mLastError = VINF_SUCCESS; 95 96 unconst(mEventSource).createObject(); 97 HRESULT hr = mEventSource->init(); 98 if (FAILED(hr)) 99 vrc = VERR_COM_UNEXPECTED; 137 100 } 138 101 … … 177 140 } 178 141 142 HRESULT GuestDirectory::getEventSource(ComPtr<IEventSource> &aEventSource) 143 { 144 /* No need to lock - lifetime constant. */ 145 mEventSource.queryInterfaceTo(aEventSource.asOutParam()); 146 147 return S_OK; 148 } 149 179 150 HRESULT GuestDirectory::getFilter(com::Utf8Str &aFilter) 180 151 { … … 184 155 185 156 aFilter = mData.mOpenInfo.mFilter; 157 158 return S_OK; 159 } 160 161 HRESULT GuestDirectory::getId(ULONG *aId) 162 { 163 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 164 165 *aId = mObjectID; 166 167 return S_OK; 168 } 169 170 HRESULT GuestDirectory::getStatus(DirectoryStatus_T *aStatus) 171 { 172 LogFlowThisFuncEnter(); 173 174 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 175 176 *aStatus = mData.mStatus; 186 177 187 178 return S_OK; … … 209 200 switch (pCbCtx->uMessage) 210 201 { 202 case GUEST_MSG_DISCONNECTED: 203 /** @todo vrc = i_onGuestDisconnected(pCbCtx, pSvcCb); */ 204 vrc = VINF_SUCCESS; // TODO 205 break; 206 211 207 case GUEST_MSG_DIR_NOTIFY: 212 208 { 213 int idx = 1; /* Current parameter index. */ 214 CALLBACKDATA_DIR_NOTIFY dataCb; 215 /* pSvcCb->mpaParms[0] always contains the context ID. */ 216 HGCMSvcGetU32(&pSvcCb->mpaParms[idx++], &dataCb.uType); 217 HGCMSvcGetU32(&pSvcCb->mpaParms[idx++], &dataCb.rc); 218 219 LogFlowFunc(("uType=%RU32, vrcGguest=%Rrc\n", dataCb.uType, (int)dataCb.rc)); 220 221 switch (dataCb.uType) 222 { 223 /* Nothing here yet, nothing to dispatch further. */ 224 225 default: 226 vrc = VERR_NOT_SUPPORTED; 227 break; 228 } 209 vrc = i_onDirNotify(pCbCtx, pSvcCb); 229 210 break; 230 211 } … … 238 219 LogFlowFuncLeaveRC(vrc); 239 220 return vrc; 221 } 222 223 /** 224 * Opens the directory on the guest side. 225 * 226 * @return VBox status code. 227 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned. 228 */ 229 int GuestDirectory::i_open(int *pvrcGuest) 230 { 231 int vrc; 232 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 233 if ((mSession->i_getParent()->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS)) 234 { 235 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 236 237 GuestWaitEvent *pEvent = NULL; 238 GuestEventTypes eventTypes; 239 try 240 { 241 eventTypes.push_back(VBoxEventType_OnGuestDirectoryStateChanged); 242 243 vrc = registerWaitEvent(eventTypes, &pEvent); 244 } 245 catch (std::bad_alloc &) 246 { 247 vrc = VERR_NO_MEMORY; 248 } 249 250 /* Prepare HGCM call. */ 251 VBOXHGCMSVCPARM paParms[8]; 252 int i = 0; 253 HGCMSvcSetU32(&paParms[i++], pEvent->ContextID()); 254 HGCMSvcSetPv(&paParms[i++], (void *)mData.mOpenInfo.mPath.c_str(), (ULONG)mData.mOpenInfo.mPath.length() + 1); 255 HGCMSvcSetPv(&paParms[i++], (void *)mData.mOpenInfo.mFilter.c_str(), (ULONG)mData.mOpenInfo.mFilter.length() + 1); 256 HGCMSvcSetU32(&paParms[i++], mData.mOpenInfo.menmFilter); 257 HGCMSvcSetU32(&paParms[i++], mData.mOpenInfo.mFlags); 258 259 alock.release(); /* Drop lock before sending. */ 260 261 vrc = sendMessage(HOST_MSG_DIR_OPEN, i, paParms); 262 if (RT_SUCCESS(vrc)) 263 { 264 vrc = pEvent->Wait(30 * 1000); 265 if (RT_SUCCESS(vrc)) 266 { 267 } 268 } 269 } 270 else 271 { 272 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 273 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 274 vrc = i_openViaToolbox(pvrcGuest); 275 #else 276 RT_NOREF(pvrcGuest); 277 vrc = VERR_NOT_SUPPORTED; 278 #endif 279 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 280 } 281 #endif 282 283 return vrc; 284 } 285 286 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 287 /** 288 * Opens the directory on the guest side (legacy version). 289 * 290 * @returns VBox status code. 291 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned. 292 * 293 * @note This uses an own guest process via the built-in toolbox in VBoxSerivce. 294 */ 295 int GuestDirectory::i_openViaToolbox(int *pvrcGuest) 296 { 297 /* Start the directory process on the guest. */ 298 GuestProcessStartupInfo procInfo; 299 procInfo.mName.printf(tr("Opening directory \"%s\""), mData.mOpenInfo.mPath.c_str()); 300 procInfo.mTimeoutMS = 5 * 60 * 1000; /* 5 minutes timeout. */ 301 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut; 302 procInfo.mExecutable= Utf8Str(VBOXSERVICE_TOOL_LS); 303 304 procInfo.mArguments.push_back(procInfo.mExecutable); 305 procInfo.mArguments.push_back(Utf8Str("--machinereadable")); 306 /* We want the long output format which contains all the object details. */ 307 procInfo.mArguments.push_back(Utf8Str("-l")); 308 # if 0 /* Flags are not supported yet. */ 309 if (uFlags & DirectoryOpenFlag_NoSymlinks) 310 procInfo.mArguments.push_back(Utf8Str("--nosymlinks")); /** @todo What does GNU here? */ 311 # endif 312 /** @todo Recursion support? */ 313 procInfo.mArguments.push_back(mData.mOpenInfo.mPath); /* The directory we want to open. */ 314 315 /* 316 * Start the process synchronously and keep it around so that we can use 317 * it later in subsequent read() calls. 318 */ 319 int vrc = mData.mProcessTool.init(mSession, procInfo, false /*fAsync*/, NULL /*pvrcGuest*/); 320 if (RT_SUCCESS(vrc)) 321 { 322 /* As we need to know if the directory we were about to open exists and and is accessible, 323 * do the first read here in order to return a meaningful status here. */ 324 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; 325 vrc = i_readInternal(mData.mObjData, &vrcGuest); 326 if (RT_FAILURE(vrc)) 327 { 328 /* 329 * We need to actively terminate our process tool in case of an error here, 330 * as this otherwise would be done on (directory) object destruction implicitly. 331 * This in turn then will run into a timeout, as the directory object won't be 332 * around anymore at that time. Ugly, but that's how it is for the moment. 333 */ 334 /* ignore rc */ mData.mProcessTool.terminate(30 * RT_MS_1SEC, NULL /* pvrcGuest */); 335 } 336 337 if (pvrcGuest) 338 *pvrcGuest = vrcGuest; 339 } 340 341 return vrc; 342 } 343 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 344 345 /** 346 * Called when the guest side notifies the host of a directory event. 347 * 348 * @returns VBox status code. 349 * @param pCbCtx Host callback context. 350 * @param pSvcCbData Host callback data. 351 */ 352 int GuestDirectory::i_onDirNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData) 353 { 354 #ifndef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 355 RT_NOREF(pCbCtx, pSvcCbData); 356 return VERR_NOT_SUPPORTED; 357 #else 358 AssertPtrReturn(pCbCtx, VERR_INVALID_POINTER); 359 AssertPtrReturn(pSvcCbData, VERR_INVALID_POINTER); 360 361 LogFlowThisFuncEnter(); 362 363 if (pSvcCbData->mParms < 3) 364 return VERR_INVALID_PARAMETER; 365 366 int idx = 1; /* Current parameter index. */ 367 CALLBACKDATA_DIR_NOTIFY dataCb; 368 RT_ZERO(dataCb); 369 /* pSvcCb->mpaParms[0] always contains the context ID. */ 370 HGCMSvcGetU32(&pSvcCbData->mpaParms[idx++], &dataCb.uType); 371 HGCMSvcGetU32(&pSvcCbData->mpaParms[idx++], &dataCb.rc); 372 373 int vrcGuest = (int)dataCb.rc; /* uint32_t vs. int. */ 374 375 LogFlowThisFunc(("uType=%RU32, vrcGuest=%Rrc\n", dataCb.uType, vrcGuest)); 376 377 if (RT_FAILURE(vrcGuest)) 378 { 379 /** @todo Set status? */ 380 381 /* Ignore return code, as the event to signal might not be there (anymore). */ 382 signalWaitEventInternal(pCbCtx, vrcGuest, NULL /* pPayload */); 383 return VINF_SUCCESS; /* Report to the guest. */ 384 } 385 386 int vrc = VERR_NOT_SUPPORTED; /* Play safe by default. */ 387 388 ComObjPtr<VirtualBoxErrorInfo> errorInfo; 389 HRESULT hrc = errorInfo.createObject(); 390 ComAssertComRCRet(hrc, VERR_COM_UNEXPECTED); 391 if (RT_FAILURE(vrcGuest)) 392 { 393 hrc = errorInfo->initEx(VBOX_E_GSTCTL_GUEST_ERROR, vrcGuest, 394 COM_IIDOF(IGuestFile), getComponentName(), 395 i_guestErrorToString(vrcGuest, mData.mOpenInfo.mPath.c_str())); 396 ComAssertComRCRet(hrc, VERR_COM_UNEXPECTED); 397 } 398 399 switch (dataCb.uType) 400 { 401 case GUEST_DIR_NOTIFYTYPE_ERROR: 402 { 403 vrc = i_setStatus(DirectoryStatus_Error, vrcGuest); 404 break; 405 } 406 407 case GUEST_DIR_NOTIFYTYPE_OPEN: 408 { 409 vrc = i_setStatus(DirectoryStatus_Open, vrcGuest); 410 break; 411 } 412 413 case GUEST_DIR_NOTIFYTYPE_CLOSE: 414 { 415 vrc = i_setStatus(DirectoryStatus_Close, vrcGuest); 416 break; 417 } 418 419 case GUEST_DIR_NOTIFYTYPE_READ: 420 { 421 ASSERT_GUEST_MSG_STMT_BREAK(pSvcCbData->mParms == 7, ("mParms=%u\n", pSvcCbData->mParms), 422 vrc = VERR_WRONG_PARAMETER_COUNT); 423 ASSERT_GUEST_MSG_STMT_BREAK(pSvcCbData->mpaParms[idx].type == VBOX_HGCM_SVC_PARM_PTR, 424 ("type=%u\n", pSvcCbData->mpaParms[idx].type), 425 vrc = VERR_WRONG_PARAMETER_TYPE); 426 427 PGSTCTLFSOBJINFO pObjInfo; 428 uint32_t cbObjInfo; 429 vrc = HGCMSvcGetPv(&pSvcCbData->mpaParms[idx++], (void **)&pObjInfo, &cbObjInfo); 430 AssertRCBreak(vrc); 431 AssertBreakStmt(cbObjInfo == sizeof(GSTCTLFSOBJINFO), VERR_INVALID_PARAMETER); 432 433 GuestFsObjData fsObjData(mData.mOpenInfo.mPath); 434 vrc = fsObjData.FromGuestFsObjInfo(pObjInfo); 435 AssertRCBreak(vrc); 436 ComObjPtr<GuestFsObjInfo> ptrFsObjInfo; 437 hrc = ptrFsObjInfo.createObject(); 438 ComAssertComRCBreak(hrc, VERR_COM_UNEXPECTED); 439 vrc = ptrFsObjInfo->init(fsObjData); 440 AssertRCBreak(vrc); 441 442 ::FireGuestDirectoryReadEvent(mEventSource, mSession, this, ptrFsObjInfo); 443 break; 444 } 445 446 case GUEST_DIR_NOTIFYTYPE_REWIND: 447 { 448 /* Note: This does not change the overall status of the directory (i.e. open). */ 449 ::FireGuestDirectoryStateChangedEvent(mEventSource, mSession, this, DirectoryStatus_Rewind, errorInfo); 450 break; 451 } 452 453 default: 454 AssertFailed(); 455 break; 456 } 457 458 try 459 { 460 if (RT_SUCCESS(vrc)) 461 { 462 GuestWaitEventPayload payload(dataCb.uType, &dataCb, sizeof(dataCb)); 463 464 /* Ignore return code, as the event to signal might not be there (anymore). */ 465 signalWaitEventInternal(pCbCtx, vrcGuest, &payload); 466 } 467 else /* OOM situation, wrong HGCM parameters or smth. not expected. */ 468 { 469 /* Ignore return code, as the event to signal might not be there (anymore). */ 470 signalWaitEventInternalEx(pCbCtx, vrc, 0 /* guestRc */, NULL /* pPayload */); 471 } 472 } 473 catch (int vrcEx) /* Thrown by GuestWaitEventPayload constructor. */ 474 { 475 /* Also try to signal the waiter, to let it know of the OOM situation. 476 * Ignore return code, as the event to signal might not be there (anymore). */ 477 signalWaitEventInternalEx(pCbCtx, vrcEx, 0 /* guestRc */, NULL /* pPayload */); 478 vrc = vrcEx; 479 } 480 481 LogFlowThisFunc(("uType=%RU32, rcGuest=%Rrc, vrc=%Rrc\n", dataCb.uType, vrcGuest, vrc)); 482 return vrc; 483 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 240 484 } 241 485 … … 302 546 * 303 547 * @return VBox status code. 304 * @param prcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned. 305 */ 306 int GuestDirectory::i_closeInternal(int *prcGuest) 307 { 308 AssertPtrReturn(prcGuest, VERR_INVALID_POINTER); 309 310 int vrc = mData.mProcessTool.terminate(30 * 1000 /* 30s timeout */, prcGuest); 311 if (RT_FAILURE(vrc)) 312 return vrc; 548 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned. 549 */ 550 int GuestDirectory::i_close(int *pvrcGuest) 551 { 552 int vrc; 553 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 554 if (mSession->i_getParent()->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS) 555 { 556 // TODO 557 vrc = VERR_NOT_IMPLEMENTED; 558 } 559 else 560 { 561 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 562 #ifndef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 563 RT_NOREF(pvrcGuest); 564 vrc = VINF_SUCCESS; /* Nothing to do here. */ 565 #else 566 vrc = i_closeViaToolbox(pvrcGuest); 567 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 568 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 569 } 570 #endif 313 571 314 572 AssertPtr(mSession); … … 321 579 } 322 580 581 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 582 /** 583 * Closes this guest directory and removes it from the guest session's directory list (legacy version). 584 * 585 * @return VBox status code. 586 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned. 587 * 588 * @note This uses an own guest process via the built-in toolbox in VBoxSerivce. 589 */ 590 int GuestDirectory::i_closeViaToolbox(int *pvrcGuest) 591 { 592 return mData.mProcessTool.terminate(30 * 1000 /* 30s timeout */, pvrcGuest); 593 } 594 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 595 323 596 /** 324 597 * Reads the next directory entry, internal version. … … 326 599 * @return VBox status code. Will return VERR_NO_MORE_FILES if no more entries are available. 327 600 * @param objData Where to store the read directory entry as internal object data. 328 * @param prcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned. 329 */ 330 int GuestDirectory::i_readInternal(GuestFsObjData &objData, int *prcGuest) 331 { 332 AssertPtrReturn(prcGuest, VERR_INVALID_POINTER); 333 334 GuestProcessStreamBlock curBlock; 335 int vrc = mData.mProcessTool.waitEx(GUESTPROCESSTOOL_WAIT_FLAG_STDOUT_BLOCK, &curBlock, prcGuest); 601 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned. 602 */ 603 int GuestDirectory::i_readInternal(GuestFsObjData &objData, int *pvrcGuest) 604 { 605 AssertPtrReturn(pvrcGuest, VERR_INVALID_POINTER); 606 607 int vrc; 608 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 609 if (mSession->i_getParent()->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS) 610 { 611 // TODO 612 RT_NOREF(objData, pvrcGuest); 613 vrc = 0; 614 } 615 else 616 { 617 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 618 #ifndef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 619 RT_NOREF(objData); 620 vrc = VERR_NOT_SUPPORTED; 621 #else /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 622 vrc = i_readInternalViaToolbox(objData, pvrcGuest); 623 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 624 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 625 } 626 #endif 627 628 LogFlowThisFunc(("Returning vrc=%Rrc\n", vrc)); 629 return vrc; 630 } 631 632 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 633 /** 634 * Reads the next directory entry, internal version (legacy version). 635 * 636 * @return VBox status code. Will return VERR_NO_MORE_FILES if no more entries are available. 637 * @param objData Where to store the read directory entry as internal object data. 638 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned. 639 * 640 * @note This uses an own guest process via the built-in toolbox in VBoxSerivce. 641 */ 642 int GuestDirectory::i_readInternalViaToolbox(GuestFsObjData &objData, int *pvrcGuest) 643 { 644 GuestToolboxStreamBlock curBlock; 645 int vrc = mData.mProcessTool.waitEx(GUESTPROCESSTOOL_WAIT_FLAG_STDOUT_BLOCK, &curBlock, pvrcGuest); 336 646 if (RT_SUCCESS(vrc)) 337 647 { … … 349 659 if (curBlock.GetString("name")) 350 660 { 351 vrc = objData.From Ls(curBlock, true /* fLong */);661 vrc = objData.FromToolboxLs(curBlock, true /* fLong */); 352 662 } 353 663 else … … 362 672 } 363 673 364 LogFlowThisFunc(("Returning vrc=%Rrc\n", vrc));365 return vrc; 366 } 674 return vrc; 675 } 676 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 367 677 368 678 /** … … 371 681 * @return VBox status code. Will return VERR_NO_MORE_FILES if no more entries are available. 372 682 * @param fsObjInfo Where to store the read directory entry. 373 * @param p rcGuestWhere to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned.374 */ 375 int GuestDirectory::i_read(ComObjPtr<GuestFsObjInfo> &fsObjInfo, int *p rcGuest)376 { 377 AssertPtrReturn(p rcGuest, VERR_INVALID_POINTER);683 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned. 684 */ 685 int GuestDirectory::i_read(ComObjPtr<GuestFsObjInfo> &fsObjInfo, int *pvrcGuest) 686 { 687 AssertPtrReturn(pvrcGuest, VERR_INVALID_POINTER); 378 688 379 689 /* Create the FS info object. */ … … 393 703 } 394 704 } 395 else /* Otherwise ask the guest for the next object data (block). */705 else /* Otherwise ask the guest for the next object data. */ 396 706 { 397 707 398 708 GuestFsObjData objData; 399 vrc = i_readInternal(objData, p rcGuest);709 vrc = i_readInternal(objData, pvrcGuest); 400 710 if (RT_SUCCESS(vrc)) 401 711 vrc = fsObjInfo->init(objData); … … 404 714 LogFlowThisFunc(("Returning vrc=%Rrc\n", vrc)); 405 715 return vrc; 716 } 717 718 /** 719 * Rewinds the directory reading. 720 * 721 * @returns VBox status code. 722 * @retval VERR_GSTCTL_GUEST_ERROR when an error from the guest side has been received. 723 * @param uTimeoutMS Timeout (in ms) to wait. 724 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned. 725 */ 726 int GuestDirectory::i_rewind(uint32_t uTimeoutMS, int *pvrcGuest) 727 { 728 RT_NOREF(pvrcGuest); 729 #ifndef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 730 RT_NOREF(uTimeoutMS, pvrcGuest); 731 #else 732 /* Only available for Guest Additions 7.1+. */ 733 if (mSession->i_getParent()->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS) 734 { 735 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 736 737 int vrc; 738 739 GuestWaitEvent *pEvent = NULL; 740 GuestEventTypes eventTypes; 741 try 742 { 743 eventTypes.push_back(VBoxEventType_OnGuestDirectoryStateChanged); 744 vrc = registerWaitEvent(eventTypes, &pEvent); 745 } 746 catch (std::bad_alloc &) 747 { 748 vrc = VERR_NO_MEMORY; 749 } 750 751 if (RT_FAILURE(vrc)) 752 return vrc; 753 754 /* Prepare HGCM call. */ 755 VBOXHGCMSVCPARM paParms[4]; 756 int i = 0; 757 HGCMSvcSetU32(&paParms[i++], pEvent->ContextID()); 758 HGCMSvcSetU32(&paParms[i++], mObjectID /* Directory handle */); 759 760 alock.release(); /* Drop lock before sending. */ 761 762 vrc = sendMessage(HOST_MSG_DIR_REWIND, i, paParms); 763 if (RT_SUCCESS(vrc)) 764 { 765 VBoxEventType_T evtType; 766 ComPtr<IEvent> pIEvent; 767 vrc = waitForEvent(pEvent, uTimeoutMS, &evtType, pIEvent.asOutParam()); 768 if (RT_SUCCESS(vrc)) 769 { 770 if (evtType == VBoxEventType_OnGuestDirectoryStateChanged) 771 { 772 ComPtr<IGuestDirectoryStateChangedEvent> pEvt = pIEvent; 773 Assert(!pEvt.isNull()); 774 } 775 else 776 vrc = VWRN_GSTCTL_OBJECTSTATE_CHANGED; 777 } 778 else if (pEvent->HasGuestError()) /* Return guest vrc if available. */ 779 vrc = pEvent->GetGuestError(); 780 } 781 782 unregisterWaitEvent(pEvent); 783 return vrc; 784 } 785 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 786 787 return VERR_NOT_SUPPORTED; 788 } 789 790 /** 791 * Sets the current internal directory object status. 792 * 793 * @returns VBox status code. 794 * @param enmStatus New directory status to set. 795 * @param vrcDir New result code to set. 796 * 797 * @note Takes the write lock. 798 */ 799 int GuestDirectory::i_setStatus(DirectoryStatus_T enmStatus, int vrcDir) 800 { 801 LogFlowThisFuncEnter(); 802 803 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 804 805 LogFlowThisFunc(("oldStatus=%RU32, newStatus=%RU32, vrcDir=%Rrc\n", mData.mStatus, enmStatus, vrcDir)); 806 807 #ifdef VBOX_STRICT 808 if (enmStatus == DirectoryStatus_Error) 809 AssertMsg(RT_FAILURE(vrcDir), ("Guest vrc must be an error (%Rrc)\n", vrcDir)); 810 else 811 AssertMsg(RT_SUCCESS(vrcDir), ("Guest vrc must not be an error (%Rrc)\n", vrcDir)); 812 #endif 813 814 if (mData.mStatus != enmStatus) 815 { 816 mData.mStatus = enmStatus; 817 mData.mLastError = vrcDir; 818 819 ComObjPtr<VirtualBoxErrorInfo> errorInfo; 820 HRESULT hrc = errorInfo.createObject(); 821 ComAssertComRCRet(hrc, VERR_COM_UNEXPECTED); 822 if (RT_FAILURE(vrcDir)) 823 { 824 hrc = errorInfo->initEx(VBOX_E_GSTCTL_GUEST_ERROR, vrcDir, 825 COM_IIDOF(IGuestDirectory), getComponentName(), 826 i_guestErrorToString(vrcDir, mData.mOpenInfo.mPath.c_str())); 827 ComAssertComRCRet(hrc, VERR_COM_UNEXPECTED); 828 } 829 /* Note: On vrcDir success, errorInfo is set to S_OK and also sent via the event below. */ 830 831 alock.release(); /* Release lock before firing off event. */ 832 833 ::FireGuestDirectoryStateChangedEvent(mEventSource, mSession, this, enmStatus, errorInfo); 834 } 835 836 return VINF_SUCCESS; 406 837 } 407 838 … … 418 849 419 850 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; 420 int vrc = i_close Internal(&vrcGuest);851 int vrc = i_close(&vrcGuest); 421 852 if (RT_FAILURE(vrc)) 422 853 { … … 468 899 case VERR_GSTCTL_GUEST_ERROR: 469 900 { 470 GuestErrorInfo ge(GuestErrorInfo::Type_ToolLs, vrcGuest, mData.mOpenInfo.mPath.c_str()); 901 GuestErrorInfo ge( 902 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 903 GuestErrorInfo::Type_ToolLs 904 #else 905 GuestErrorInfo::Type_Fs 906 #endif 907 , vrcGuest, mData.mOpenInfo.mPath.c_str()); 471 908 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Reading guest directory failed: %s"), 472 909 GuestBase::getErrorAsString(ge).c_str()); 473 910 break; 474 911 } 912 913 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 475 914 case VERR_GSTCTL_PROCESS_EXIT_CODE: 476 915 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading guest directory \"%s\" failed: %Rrc"), 477 916 mData.mOpenInfo.mPath.c_str(), mData.mProcessTool.getRc()); 478 917 break; 479 918 #endif 480 919 case VERR_PATH_NOT_FOUND: 481 920 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading guest directory \"%s\" failed: Path not found"), … … 490 929 491 930 default: 492 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading guest directory \"%s\" returned error: %Rrc\n"),931 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading guest directory \"%s\" returned unhandled error: %Rrc\n"), 493 932 mData.mOpenInfo.mPath.c_str(), vrc); 494 933 break; … … 500 939 } 501 940 941 HRESULT GuestDirectory::rewind(void) 942 { 943 AutoCaller autoCaller(this); 944 if (FAILED(autoCaller.hrc())) return autoCaller.hrc(); 945 946 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; 947 int vrc = i_rewind(30 * 1000 /* Timeout in ms */, &vrcGuest); 948 if (RT_SUCCESS(vrc)) 949 return S_OK; 950 951 GuestErrorInfo ge(GuestErrorInfo::Type_Directory, vrcGuest, mData.mOpenInfo.mPath.c_str()); 952 return setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Rewinding guest directory failed: %s"), 953 GuestBase::getErrorAsString(ge).c_str()); 954 } 955 -
trunk/src/VBox/Main/src-client/GuestFileImpl.cpp
r98284 r98526 900 900 int GuestFile::i_queryInfo(GuestFsObjData &objData, int *prcGuest) 901 901 { 902 AssertPtr (mSession);902 AssertPtrReturn(mSession, VERR_OBJECT_DESTROYED); 903 903 return mSession->i_fsQueryInfo(mData.mOpenInfo.mFilename, FALSE /* fFollowSymlinks */, objData, prcGuest); 904 904 } … … 1576 1576 if (GuestProcess::i_isGuestError(vrc)) 1577 1577 { 1578 GuestErrorInfo ge(GuestErrorInfo::Type_ToolStat, vrcGuest, mData.mOpenInfo.mFilename.c_str()); 1578 GuestErrorInfo ge( 1579 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 1580 GuestErrorInfo::Type_ToolStat, 1581 #else 1582 GuestErrorInfo::Type_File, 1583 #endif 1584 vrcGuest, mData.mOpenInfo.mFilename.c_str()); 1579 1585 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Querying guest file information failed: %s"), 1580 1586 GuestBase::getErrorAsString(ge).c_str()); … … 1609 1615 if (GuestProcess::i_isGuestError(vrc)) 1610 1616 { 1611 GuestErrorInfo ge(GuestErrorInfo::Type_ToolStat, vrcGuest, mData.mOpenInfo.mFilename.c_str()); 1617 GuestErrorInfo ge( 1618 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 1619 GuestErrorInfo::Type_ToolStat, 1620 #else 1621 GuestErrorInfo::Type_File, 1622 #endif 1623 vrcGuest, mData.mOpenInfo.mFilename.c_str()); 1612 1624 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Querying guest file size failed: %s"), 1613 1625 GuestBase::getErrorAsString(ge).c_str()); -
trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp
r98272 r98526 2253 2253 /////////////////////////////////////////////////////////////////////////////// 2254 2254 2255 GuestProcessTool ::GuestProcessTool(void)2255 GuestProcessToolbox::GuestProcessToolbox(void) 2256 2256 : pSession(NULL), 2257 2257 pProcess(NULL) … … 2259 2259 } 2260 2260 2261 GuestProcessTool ::~GuestProcessTool(void)2261 GuestProcessToolbox::~GuestProcessToolbox(void) 2262 2262 { 2263 2263 uninit(); … … 2274 2274 * VERR_GSTCTL_GUEST_ERROR was returned. Optional. 2275 2275 */ 2276 int GuestProcessTool ::init(GuestSession *pGuestSession, const GuestProcessStartupInfo &startupInfo,2277 bool fAsync, int *pvrcGuest)2276 int GuestProcessToolbox::init(GuestSession *pGuestSession, const GuestProcessStartupInfo &startupInfo, 2277 bool fAsync, int *pvrcGuest) 2278 2278 { 2279 2279 LogFlowThisFunc(("pGuestSession=%p, exe=%s, fAsync=%RTbool\n", … … 2316 2316 * Unitializes a guest process tool by terminating it on the guest. 2317 2317 */ 2318 void GuestProcessTool ::uninit(void)2318 void GuestProcessToolbox::uninit(void) 2319 2319 { 2320 2320 /* Make sure the process is terminated and unregistered from the guest session. */ … … 2339 2339 * @param strmBlock Where to return the stream block on success. 2340 2340 */ 2341 int GuestProcessTool ::getCurrentBlock(uint32_t uHandle, GuestProcessStreamBlock &strmBlock)2342 { 2343 const Guest ProcessStream *pStream = NULL;2341 int GuestProcessToolbox::getCurrentBlock(uint32_t uHandle, GuestToolboxStreamBlock &strmBlock) 2342 { 2343 const GuestToolboxStream *pStream = NULL; 2344 2344 if (uHandle == GUEST_PROC_OUT_H_STDOUT) 2345 2345 pStream = &mStdOut; … … 2370 2370 * @returns Result code from guest process tool. 2371 2371 */ 2372 int GuestProcessTool ::getRc(void) const2372 int GuestProcessToolbox::getRc(void) const 2373 2373 { 2374 2374 LONG exitCode = -1; … … 2376 2376 AssertComRC(hrc); 2377 2377 2378 return GuestProcessTool ::exitCodeToRc(mStartupInfo, exitCode);2378 return GuestProcessToolbox::exitCodeToRc(mStartupInfo, exitCode); 2379 2379 } 2380 2380 … … 2384 2384 * @returns \c true if running, or \c false if not. 2385 2385 */ 2386 bool GuestProcessTool ::isRunning(void)2386 bool GuestProcessToolbox::isRunning(void) 2387 2387 { 2388 2388 AssertReturn(!pProcess.isNull(), false); … … 2409 2409 * occurred (exit status <> 0 or wrong process state). 2410 2410 */ 2411 bool GuestProcessTool ::isTerminatedOk(void)2411 bool GuestProcessToolbox::isTerminatedOk(void) 2412 2412 { 2413 2413 return getTerminationStatus() == VINF_SUCCESS ? true : false; … … 2428 2428 */ 2429 2429 /* static */ 2430 int GuestProcessTool ::run( GuestSession *pGuestSession,2431 const GuestProcessStartupInfo &startupInfo,2432 int *pvrcGuest /* = NULL */)2430 int GuestProcessToolbox::run( GuestSession *pGuestSession, 2431 const GuestProcessStartupInfo &startupInfo, 2432 int *pvrcGuest /* = NULL */) 2433 2433 { 2434 2434 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; … … 2442 2442 { 2443 2443 if (errorInfo.vrcGuest == VERR_GSTCTL_PROCESS_EXIT_CODE) /* Translate exit code to a meaningful error code. */ 2444 vrcGuest = GuestProcessTool ::exitCodeToRc(startupInfo, errorInfo.iExitCode);2444 vrcGuest = GuestProcessToolbox::exitCodeToRc(startupInfo, errorInfo.iExitCode); 2445 2445 else /* At least return something. */ 2446 2446 vrcGuest = errorInfo.vrcGuest; … … 2467 2467 */ 2468 2468 /* static */ 2469 int GuestProcessTool ::runErrorInfo(GuestSession*pGuestSession,2470 GuestProcessStartupInfo const&startupInfo,2471 GuestProcessToolErrorInfo&errorInfo)2469 int GuestProcessToolbox::runErrorInfo(GuestSession *pGuestSession, 2470 GuestProcessStartupInfo const &startupInfo, 2471 GuestProcessToolErrorInfo &errorInfo) 2472 2472 { 2473 2473 return runExErrorInfo(pGuestSession, startupInfo, NULL /* paStrmOutObjects */, 0 /* cStrmOutObjects */, errorInfo); … … 2486 2486 */ 2487 2487 /* static */ 2488 int GuestProcessTool ::runEx(GuestSession*pGuestSession,2489 GuestProcessStartupInfo const&startupInfo,2490 GuestCtrlStreamObjects*paStrmOutObjects,2491 uint32_tcStrmOutObjects,2492 int*pvrcGuest /* = NULL */)2488 int GuestProcessToolbox::runEx(GuestSession *pGuestSession, 2489 GuestProcessStartupInfo const &startupInfo, 2490 GuestCtrlStreamObjects *paStrmOutObjects, 2491 uint32_t cStrmOutObjects, 2492 int *pvrcGuest /* = NULL */) 2493 2493 { 2494 2494 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; 2495 2495 2496 2496 GuestProcessToolErrorInfo errorInfo = { VERR_IPE_UNINITIALIZED_STATUS, INT32_MAX }; 2497 int vrc = GuestProcessTool ::runExErrorInfo(pGuestSession, startupInfo, paStrmOutObjects, cStrmOutObjects, errorInfo);2497 int vrc = GuestProcessToolbox::runExErrorInfo(pGuestSession, startupInfo, paStrmOutObjects, cStrmOutObjects, errorInfo); 2498 2498 if (RT_SUCCESS(vrc)) 2499 2499 { … … 2502 2502 { 2503 2503 if (errorInfo.vrcGuest == VERR_GSTCTL_PROCESS_EXIT_CODE) /* Translate exit code to a meaningful error code. */ 2504 vrcGuest = GuestProcessTool ::exitCodeToRc(startupInfo, errorInfo.iExitCode);2504 vrcGuest = GuestProcessToolbox::exitCodeToRc(startupInfo, errorInfo.iExitCode); 2505 2505 else /* At least return something. */ 2506 2506 vrcGuest = errorInfo.vrcGuest; … … 2533 2533 */ 2534 2534 /* static */ 2535 int GuestProcessTool ::runExErrorInfo(GuestSession *pGuestSession,2536 GuestProcessStartupInfo const &startupInfo,2537 GuestCtrlStreamObjects *paStrmOutObjects,2538 uint32_t cStrmOutObjects,2539 GuestProcessToolErrorInfo &errorInfo)2535 int GuestProcessToolbox::runExErrorInfo(GuestSession *pGuestSession, 2536 GuestProcessStartupInfo const &startupInfo, 2537 GuestCtrlStreamObjects *paStrmOutObjects, 2538 uint32_t cStrmOutObjects, 2539 GuestProcessToolErrorInfo &errorInfo) 2540 2540 { 2541 2541 AssertPtrReturn(pGuestSession, VERR_INVALID_POINTER); … … 2544 2544 /** @todo Check if this is a valid toolbox. */ 2545 2545 2546 GuestProcessTool procTool;2546 GuestProcessToolbox procTool; 2547 2547 int vrc = procTool.init(pGuestSession, startupInfo, false /* Async */, &errorInfo.vrcGuest); 2548 2548 if (RT_SUCCESS(vrc)) … … 2552 2552 try 2553 2553 { 2554 Guest ProcessStreamBlock strmBlk;2554 GuestToolboxStreamBlock strmBlk; 2555 2555 vrc = procTool.waitEx( paStrmOutObjects 2556 2556 ? GUESTPROCESSTOOL_WAIT_FLAG_STDOUT_BLOCK … … 2590 2590 * @param piExitCode Exit code of the tool. Optional. 2591 2591 */ 2592 int GuestProcessTool ::getTerminationStatus(int32_t *piExitCode /* = NULL */)2592 int GuestProcessToolbox::getTerminationStatus(int32_t *piExitCode /* = NULL */) 2593 2593 { 2594 2594 Assert(!pProcess.isNull()); … … 2622 2622 * VERR_GSTCTL_GUEST_ERROR was returned. Optional. 2623 2623 */ 2624 int GuestProcessTool ::wait(uint32_t fToolWaitFlags, int *pvrcGuest)2624 int GuestProcessToolbox::wait(uint32_t fToolWaitFlags, int *pvrcGuest) 2625 2625 { 2626 2626 return waitEx(fToolWaitFlags, NULL /* pStrmBlkOut */, pvrcGuest); … … 2636 2636 * VERR_GSTCTL_GUEST_ERROR was returned. Optional. 2637 2637 */ 2638 int GuestProcessTool ::waitEx(uint32_t fToolWaitFlags, GuestProcessStreamBlock *pStrmBlkOut, int *pvrcGuest)2638 int GuestProcessToolbox::waitEx(uint32_t fToolWaitFlags, GuestToolboxStreamBlock *pStrmBlkOut, int *pvrcGuest) 2639 2639 { 2640 2640 LogFlowThisFunc(("fToolWaitFlags=0x%x, pStreamBlock=%p, pvrcGuest=%p\n", fToolWaitFlags, pStrmBlkOut, pvrcGuest)); … … 2830 2830 * VERR_GSTCTL_GUEST_ERROR was returned. Optional. 2831 2831 */ 2832 int GuestProcessTool ::terminate(uint32_t uTimeoutMS, int *pvrcGuest)2832 int GuestProcessToolbox::terminate(uint32_t uTimeoutMS, int *pvrcGuest) 2833 2833 { 2834 2834 LogFlowThisFuncEnter(); … … 2852 2852 */ 2853 2853 /* static */ 2854 int GuestProcessTool ::exitCodeToRc(const GuestProcessStartupInfo &startupInfo, int32_t iExitCode)2854 int GuestProcessToolbox::exitCodeToRc(const GuestProcessStartupInfo &startupInfo, int32_t iExitCode) 2855 2855 { 2856 2856 if (startupInfo.mArguments.size() == 0) … … 2871 2871 */ 2872 2872 /* static */ 2873 int GuestProcessTool ::exitCodeToRc(const char *pszTool, int32_t iExitCode)2873 int GuestProcessToolbox::exitCodeToRc(const char *pszTool, int32_t iExitCode) 2874 2874 { 2875 2875 AssertPtrReturn(pszTool, VERR_INVALID_POINTER); … … 2953 2953 */ 2954 2954 /* static */ 2955 Utf8Str GuestProcessTool ::guestErrorToString(const char *pszTool, const GuestErrorInfo &guestErrorInfo)2955 Utf8Str GuestProcessToolbox::guestErrorToString(const char *pszTool, const GuestErrorInfo &guestErrorInfo) 2956 2956 { 2957 2957 Utf8Str strErr; -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r98272 r98526 952 952 int vrc = VINF_SUCCESS; 953 953 954 GuestProcessStartupInfo procInfo; 955 procInfo.mFlags = ProcessCreateFlag_Hidden; 956 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_MKDIR); 957 958 try 959 { 960 procInfo.mArguments.push_back(procInfo.mExecutable); /* Set argv0. */ 961 962 /* Construct arguments. */ 963 if (uFlags) 964 { 965 if (uFlags & DirectoryCreateFlag_Parents) 966 procInfo.mArguments.push_back(Utf8Str("--parents")); /* We also want to create the parent directories. */ 967 else 968 vrc = VERR_INVALID_PARAMETER; 969 } 970 971 if ( RT_SUCCESS(vrc) 972 && uMode) 973 { 974 procInfo.mArguments.push_back(Utf8Str("--mode")); /* Set the creation mode. */ 975 976 char szMode[16]; 977 if (RTStrPrintf(szMode, sizeof(szMode), "%o", uMode)) 954 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 955 if (mParent->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS) 956 { 957 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 958 959 GuestWaitEvent *pEvent = NULL; 960 vrc = registerWaitEvent(mData.mSession.mID, mData.mObjectID, &pEvent); 961 if (RT_FAILURE(vrc)) 962 return vrc; 963 964 uint32_t fFlags = GSTCTL_CREATEDIRECTORY_F_NONE; 965 if (uFlags & DirectoryCreateFlag_Parents) 966 fFlags |= GSTCTL_CREATEDIRECTORY_F_PARENTS; 967 Assert(!(fFlags & ~GSTCTL_CREATEDIRECTORY_F_VALID_MASK)); 968 969 /* Prepare HGCM call. */ 970 VBOXHGCMSVCPARM paParms[4]; 971 int i = 0; 972 HGCMSvcSetU32(&paParms[i++], pEvent->ContextID()); 973 HGCMSvcSetPv (&paParms[i++], (void*)strPath.c_str(), (ULONG)strPath.length() + 1); 974 HGCMSvcSetU32(&paParms[i++], fFlags); 975 HGCMSvcSetU32(&paParms[i++], uMode); 976 977 alock.release(); /* Drop lock before sending. */ 978 979 vrc = i_sendMessage(HOST_MSG_DIR_CREATE, i, paParms); 980 if (RT_SUCCESS(vrc)) 981 { 982 vrc = pEvent->Wait(30 * 1000); 983 if (RT_SUCCESS(vrc)) 978 984 { 979 procInfo.mArguments.push_back(Utf8Str(szMode));985 // TODO 980 986 } 981 else 982 vrc = VERR_BUFFER_OVERFLOW; 983 } 984 985 procInfo.mArguments.push_back("--"); /* '--version' is a valid directory name. */ 986 procInfo.mArguments.push_back(strPath); /* The directory we want to create. */ 987 } 988 catch (std::bad_alloc &) 989 { 990 vrc = VERR_NO_MEMORY; 991 } 992 993 if (RT_SUCCESS(vrc)) 994 vrc = GuestProcessTool::run(this, procInfo, pvrcGuest); 987 } 988 } 989 else 990 { 991 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 992 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 993 GuestProcessStartupInfo procInfo; 994 procInfo.mFlags = ProcessCreateFlag_Hidden; 995 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_MKDIR); 996 997 try 998 { 999 procInfo.mArguments.push_back(procInfo.mExecutable); /* Set argv0. */ 1000 1001 /* Construct arguments. */ 1002 if (uFlags) 1003 { 1004 if (uFlags & DirectoryCreateFlag_Parents) 1005 procInfo.mArguments.push_back(Utf8Str("--parents")); /* We also want to create the parent directories. */ 1006 else 1007 vrc = VERR_INVALID_PARAMETER; 1008 } 1009 1010 if ( RT_SUCCESS(vrc) 1011 && uMode) 1012 { 1013 procInfo.mArguments.push_back(Utf8Str("--mode")); /* Set the creation mode. */ 1014 1015 char szMode[16]; 1016 if (RTStrPrintf(szMode, sizeof(szMode), "%o", uMode)) 1017 { 1018 procInfo.mArguments.push_back(Utf8Str(szMode)); 1019 } 1020 else 1021 vrc = VERR_BUFFER_OVERFLOW; 1022 } 1023 1024 procInfo.mArguments.push_back("--"); /* '--version' is a valid directory name. */ 1025 procInfo.mArguments.push_back(strPath); /* The directory we want to create. */ 1026 } 1027 catch (std::bad_alloc &) 1028 { 1029 vrc = VERR_NO_MEMORY; 1030 } 1031 1032 if (RT_SUCCESS(vrc)) 1033 vrc = GuestProcessToolbox::run(this, procInfo, pvrcGuest); 1034 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 1035 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 1036 } 1037 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 995 1038 996 1039 LogFlowFuncLeaveRC(vrc); … … 1181 1224 strTemplate.c_str(), strPath.c_str(), fDirectory, fMode, fSecure)); 1182 1225 1183 GuestProcessStartupInfo procInfo; 1184 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut; 1185 try 1186 { 1187 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_MKTEMP); 1188 procInfo.mArguments.push_back(procInfo.mExecutable); /* Set argv0. */ 1189 procInfo.mArguments.push_back(Utf8Str("--machinereadable")); 1226 int vrc; 1227 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; 1228 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 1229 if (mParent->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS) 1230 { 1231 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1232 1233 GuestWaitEvent *pEvent = NULL; 1234 vrc = registerWaitEvent(mData.mSession.mID, mData.mObjectID, &pEvent); 1235 if (RT_FAILURE(vrc)) 1236 return vrc; 1237 1238 uint32_t fFlags = GSTCTL_CREATETEMP_F_NONE; 1190 1239 if (fDirectory) 1191 procInfo.mArguments.push_back(Utf8Str("-d")); 1192 if (strPath.length()) /* Otherwise use /tmp or equivalent. */ 1193 { 1194 procInfo.mArguments.push_back(Utf8Str("-t")); 1195 procInfo.mArguments.push_back(strPath); 1196 } 1197 /* Note: Secure flag and mode cannot be specified at the same time. */ 1240 fFlags |= GSTCTL_CREATETEMP_F_DIRECTORY; 1198 1241 if (fSecure) 1199 { 1200 procInfo.mArguments.push_back(Utf8Str("--secure")); 1201 } 1202 else 1203 { 1204 procInfo.mArguments.push_back(Utf8Str("--mode")); 1205 1206 /* Note: Pass the mode unmodified down to the guest. See @ticketref{21394}. */ 1207 char szMode[16]; 1208 int vrc2 = RTStrPrintf2(szMode, sizeof(szMode), "%d", fMode); 1209 AssertRCReturn(vrc2, vrc2); 1210 procInfo.mArguments.push_back(szMode); 1211 } 1212 procInfo.mArguments.push_back("--"); /* strTemplate could be '--help'. */ 1213 procInfo.mArguments.push_back(strTemplate); 1214 } 1215 catch (std::bad_alloc &) 1216 { 1217 Log(("Out of memory!\n")); 1218 return VERR_NO_MEMORY; 1219 } 1220 1221 /** @todo Use an internal HGCM command for this operation, since 1222 * we now can run in a user-dedicated session. */ 1223 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; 1224 GuestCtrlStreamObjects stdOut; 1225 int vrc = GuestProcessTool::runEx(this, procInfo, &stdOut, 1 /* cStrmOutObjects */, &vrcGuest); 1226 if (!GuestProcess::i_isGuestError(vrc)) 1227 { 1228 GuestFsObjData objData; 1229 if (!stdOut.empty()) 1230 { 1231 vrc = objData.FromMkTemp(stdOut.at(0)); 1232 if (RT_FAILURE(vrc)) 1242 fFlags |= GSTCTL_CREATETEMP_F_SECURE; 1243 Assert(!(fFlags & ~GSTCTL_CREATETEMP_F_VALID_MASK)); 1244 1245 /* Prepare HGCM call. */ 1246 VBOXHGCMSVCPARM paParms[8]; 1247 int i = 0; 1248 HGCMSvcSetU32(&paParms[i++], pEvent->ContextID()); 1249 HGCMSvcSetStr(&paParms[i++], strTemplate.c_str()); 1250 HGCMSvcSetStr(&paParms[i++], strPath.c_str()); 1251 HGCMSvcSetU32(&paParms[i++], fFlags); 1252 HGCMSvcSetU32(&paParms[i++], fMode); 1253 1254 alock.release(); /* Drop lock before sending. */ 1255 1256 vrc = i_sendMessage(HOST_MSG_FS_CREATE_TEMP, i, paParms); 1257 if (RT_SUCCESS(vrc)) 1258 { 1259 vrc = pEvent->Wait(30 * 1000); 1260 if (RT_SUCCESS(vrc)) 1233 1261 { 1234 vrcGuest = vrc; 1235 if (pvrcGuest) 1236 *pvrcGuest = vrcGuest; 1237 vrc = VERR_GSTCTL_GUEST_ERROR; 1262 // TODO 1238 1263 } 1239 1264 } 1240 else 1241 vrc = VERR_BROKEN_PIPE; 1242 1243 if (RT_SUCCESS(vrc)) 1244 strName = objData.mName; 1245 } 1246 else if (pvrcGuest) 1247 *pvrcGuest = vrcGuest; 1265 } 1266 else 1267 { 1268 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 1269 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 1270 GuestProcessStartupInfo procInfo; 1271 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut; 1272 try 1273 { 1274 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_MKTEMP); 1275 procInfo.mArguments.push_back(procInfo.mExecutable); /* Set argv0. */ 1276 procInfo.mArguments.push_back(Utf8Str("--machinereadable")); 1277 if (fDirectory) 1278 procInfo.mArguments.push_back(Utf8Str("-d")); 1279 if (strPath.length()) /* Otherwise use /tmp or equivalent. */ 1280 { 1281 procInfo.mArguments.push_back(Utf8Str("-t")); 1282 procInfo.mArguments.push_back(strPath); 1283 } 1284 /* Note: Secure flag and mode cannot be specified at the same time. */ 1285 if (fSecure) 1286 { 1287 procInfo.mArguments.push_back(Utf8Str("--secure")); 1288 } 1289 else 1290 { 1291 procInfo.mArguments.push_back(Utf8Str("--mode")); 1292 1293 /* Note: Pass the mode unmodified down to the guest. See @ticketref{21394}. */ 1294 char szMode[16]; 1295 vrc = RTStrPrintf2(szMode, sizeof(szMode), "%d", fMode); 1296 AssertRCReturn(vrc, vrc); 1297 procInfo.mArguments.push_back(szMode); 1298 } 1299 procInfo.mArguments.push_back("--"); /* strTemplate could be '--help'. */ 1300 procInfo.mArguments.push_back(strTemplate); 1301 } 1302 catch (std::bad_alloc &) 1303 { 1304 Log(("Out of memory!\n")); 1305 return VERR_NO_MEMORY; 1306 } 1307 1308 GuestCtrlStreamObjects stdOut; 1309 vrc = GuestProcessToolbox::runEx(this, procInfo, &stdOut, 1 /* cStrmOutObjects */, &vrcGuest); 1310 if (!GuestProcess::i_isGuestError(vrc)) 1311 { 1312 GuestFsObjData objData; 1313 if (!stdOut.empty()) 1314 { 1315 vrc = objData.FromToolboxMkTemp(stdOut.at(0)); 1316 if (RT_FAILURE(vrc)) 1317 { 1318 vrcGuest = vrc; 1319 if (pvrcGuest) 1320 *pvrcGuest = vrcGuest; 1321 vrc = VERR_GSTCTL_GUEST_ERROR; 1322 } 1323 } 1324 else 1325 vrc = VERR_BROKEN_PIPE; 1326 1327 if (RT_SUCCESS(vrc)) 1328 strName = objData.mName; 1329 } 1330 else if (pvrcGuest) 1331 *pvrcGuest = vrcGuest; 1332 #else 1333 RT_NOREF(strName); 1334 vrc = VERR_NOT_SUPPORTED; 1335 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 1336 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 1337 } 1338 #endif 1248 1339 1249 1340 LogFlowThisFunc(("Returning vrc=%Rrc, vrcGuest=%Rrc\n", vrc, vrcGuest)); … … 1285 1376 } 1286 1377 1287 /* We need to release the write lock first before initializing the directory object below, 1378 /** 1379 * If VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT is enabled: 1380 * 1381 * We need to release the write lock first before opening the directory object below, 1288 1382 * as we're starting a guest process as part of it. This in turn will try to acquire the session's 1289 1383 * write lock. */ … … 1294 1388 1295 1389 vrc = pDirectory->init(pConsole, this /* Parent */, idObject, openInfo); 1390 if (RT_SUCCESS(vrc)) 1391 vrc = pDirectory->i_open(pvrcGuest); 1392 1296 1393 if (RT_FAILURE(vrc)) 1297 1394 { … … 1588 1685 LogFlowThisFunc(("strPath=%s\n", strPath.c_str())); 1589 1686 1590 GuestProcessStartupInfo procInfo; 1591 GuestProcessStream streamOut; 1592 1593 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut; 1594 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_RM); 1595 1596 try 1597 { 1598 procInfo.mArguments.push_back(procInfo.mExecutable); /* Set argv0. */ 1599 procInfo.mArguments.push_back(Utf8Str("--machinereadable")); 1600 procInfo.mArguments.push_back("--"); /* strPath could be '--help', which is a valid filename. */ 1601 procInfo.mArguments.push_back(strPath); /* The file we want to remove. */ 1602 } 1603 catch (std::bad_alloc &) 1604 { 1605 return VERR_NO_MEMORY; 1606 } 1607 1687 int vrc; 1608 1688 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; 1609 GuestCtrlStreamObjects stdOut; 1610 int vrc = GuestProcessTool::runEx(this, procInfo, &stdOut, 1 /* cStrmOutObjects */, &vrcGuest); 1611 if (GuestProcess::i_isGuestError(vrc)) 1612 { 1613 if (!stdOut.empty()) 1614 { 1615 GuestFsObjData objData; 1616 vrc = objData.FromRm(stdOut.at(0)); 1617 if (RT_FAILURE(vrc)) 1689 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 1690 if (mParent->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS) 1691 { 1692 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1693 1694 GuestWaitEvent *pEvent = NULL; 1695 vrc = registerWaitEvent(mData.mSession.mID, mData.mObjectID, &pEvent); 1696 if (RT_FAILURE(vrc)) 1697 return vrc; 1698 1699 /* Prepare HGCM call. */ 1700 VBOXHGCMSVCPARM paParms[4]; 1701 int i = 0; 1702 HGCMSvcSetU32(&paParms[i++], pEvent->ContextID()); 1703 HGCMSvcSetPv (&paParms[i++], (void*)strPath.c_str(), (ULONG)strPath.length() + 1); 1704 1705 alock.release(); /* Drop lock before sending. */ 1706 1707 vrc = i_sendMessage(HOST_MSG_FILE_REMOVE, i, paParms); 1708 if (RT_SUCCESS(vrc)) 1709 { 1710 vrc = pEvent->Wait(30 * 1000); 1711 if (RT_SUCCESS(vrc)) 1618 1712 { 1619 vrcGuest = vrc; 1620 if (pvrcGuest) 1621 *pvrcGuest = vrcGuest; 1622 vrc = VERR_GSTCTL_GUEST_ERROR; 1713 // TODO 1623 1714 } 1624 1715 } 1625 else 1626 vrc = VERR_BROKEN_PIPE; 1627 } 1628 else if (pvrcGuest) 1629 *pvrcGuest = vrcGuest; 1716 } 1717 else 1718 { 1719 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 1720 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 1721 GuestProcessStartupInfo procInfo; 1722 GuestToolboxStream streamOut; 1723 1724 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut; 1725 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_RM); 1726 1727 try 1728 { 1729 procInfo.mArguments.push_back(procInfo.mExecutable); /* Set argv0. */ 1730 procInfo.mArguments.push_back(Utf8Str("--machinereadable")); 1731 procInfo.mArguments.push_back("--"); /* strPath could be '--help', which is a valid filename. */ 1732 procInfo.mArguments.push_back(strPath); /* The file we want to remove. */ 1733 } 1734 catch (std::bad_alloc &) 1735 { 1736 return VERR_NO_MEMORY; 1737 } 1738 1739 GuestCtrlStreamObjects stdOut; 1740 vrc = GuestProcessToolbox::runEx(this, procInfo, &stdOut, 1 /* cStrmOutObjects */, &vrcGuest); 1741 if (GuestProcess::i_isGuestError(vrc)) 1742 { 1743 if (!stdOut.empty()) 1744 { 1745 GuestFsObjData objData; 1746 vrc = objData.FromToolboxRm(stdOut.at(0)); 1747 if (RT_FAILURE(vrc)) 1748 { 1749 vrcGuest = vrc; 1750 if (pvrcGuest) 1751 *pvrcGuest = vrcGuest; 1752 vrc = VERR_GSTCTL_GUEST_ERROR; 1753 } 1754 } 1755 else 1756 vrc = VERR_BROKEN_PIPE; 1757 } 1758 else if (pvrcGuest) 1759 *pvrcGuest = vrcGuest; 1760 #else 1761 RT_NOREF(pvrcGuest); 1762 vrc = VERR_NOT_SUPPORTED; 1763 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 1764 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 1765 } 1766 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 1630 1767 1631 1768 LogFlowThisFunc(("Returning vrc=%Rrc, vrcGuest=%Rrc\n", vrc, vrcGuest)); … … 1821 1958 LogFlowThisFunc(("strPath=%s\n", strPath.c_str())); 1822 1959 1823 /** @todo Merge this with IGuestFile::queryInfo(). */ 1824 GuestProcessStartupInfo procInfo; 1825 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut; 1826 try 1827 { 1828 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_STAT); 1829 procInfo.mArguments.push_back(procInfo.mExecutable); /* Set argv0. */ 1830 procInfo.mArguments.push_back(Utf8Str("--machinereadable")); 1960 int vrc; 1961 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; 1962 1963 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 1964 if (mParent->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS) 1965 { 1966 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1967 1968 GuestWaitEvent *pEvent = NULL; 1969 vrc = registerWaitEvent(mData.mSession.mID, mData.mObjectID, &pEvent); 1970 if (RT_FAILURE(vrc)) 1971 return vrc; 1972 1973 uint32_t fFlags = GSTCTL_QUERYINFO_F_NONE; 1831 1974 if (fFollowSymlinks) 1832 procInfo.mArguments.push_back(Utf8Str("-L")); 1833 procInfo.mArguments.push_back("--"); /* strPath could be '--help', which is a valid filename. */ 1834 procInfo.mArguments.push_back(strPath); 1835 } 1836 catch (std::bad_alloc &) 1837 { 1838 Log(("Out of memory!\n")); 1839 return VERR_NO_MEMORY; 1840 } 1841 1842 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; 1843 GuestCtrlStreamObjects stdOut; 1844 int vrc = GuestProcessTool::runEx(this, procInfo, 1845 &stdOut, 1 /* cStrmOutObjects */, 1846 &vrcGuest); 1847 if (!GuestProcess::i_isGuestError(vrc)) 1848 { 1849 if (!stdOut.empty()) 1850 { 1851 vrc = objData.FromStat(stdOut.at(0)); 1852 if (RT_FAILURE(vrc)) 1975 fFlags |= GSTCTL_QUERYINFO_F_FOLLOW_LINK; 1976 1977 /* Prepare HGCM call. */ 1978 VBOXHGCMSVCPARM paParms[4]; 1979 int i = 0; 1980 HGCMSvcSetU32(&paParms[i++], pEvent->ContextID()); 1981 HGCMSvcSetPv (&paParms[i++], (void*)strPath.c_str(), (ULONG)strPath.length() + 1); 1982 HGCMSvcSetU32(&paParms[i++], GSTCTLFSOBJATTRADD_UNIX /* Implicit */); 1983 HGCMSvcSetU32(&paParms[i++], fFlags); 1984 1985 alock.release(); /* Drop lock before sending. */ 1986 1987 vrc = i_sendMessage(HOST_MSG_FS_QUERY_INFO, i, paParms); 1988 if (RT_SUCCESS(vrc)) 1989 { 1990 vrc = pEvent->Wait(30 * 1000); 1991 if (RT_SUCCESS(vrc)) 1853 1992 { 1854 vrcGuest = vrc; 1855 if (pvrcGuest) 1856 *pvrcGuest = vrcGuest; 1857 vrc = VERR_GSTCTL_GUEST_ERROR; 1993 // TODO 1994 #if 0 1995 const ComPtr<IEvent> pThisEvent = pEvent->Event(); 1996 if (pThisEvent.isNotNull()) /* Make sure that we actually have an event associated. */ 1997 { 1998 if (pType) 1999 { 2000 HRESULT hrc = pThisEvent->COMGETTER(Type)(pType); 2001 if (FAILED(hrc)) 2002 vrc = VERR_COM_UNEXPECTED; 2003 } 2004 if ( RT_SUCCESS(vrc) 2005 && ppEvent) 2006 pThisEvent.queryInterfaceTo(ppEvent); 2007 2008 unconst(pThisEvent).setNull(); 2009 } 2010 2011 if (pEvent->Payload().Size() == sizeof(GSTCTLFSOBJINFO)) 2012 { 2013 HRESULT hrc1 = pFileEvent->COMGETTER(Data)(ComSafeArrayAsOutParam(data)); 2014 ComAssertComRC(hrc1); 2015 2016 objData.Init(strPath); 2017 2018 PGSTCTLFSOBJINFO 2019 2020 objData.FromGuestFsObjInfo((PGSTCTLFSOBJINFO)pEvent->Payload().Raw()); 2021 } 2022 else 2023 vrc = VERR_INVALID_PARAMETER; 2024 #endif 1858 2025 } 1859 } 1860 else 1861 vrc = VERR_BROKEN_PIPE; 1862 } 1863 else if (pvrcGuest) 1864 *pvrcGuest = vrcGuest; 2026 else 2027 { 2028 if (vrc == VERR_GSTCTL_GUEST_ERROR) 2029 { 2030 if (pvrcGuest) 2031 *pvrcGuest = pEvent->GuestResult(); 2032 } 2033 } 2034 } 2035 unregisterWaitEvent(pEvent); 2036 } 2037 else 2038 { 2039 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 2040 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT 2041 /** @todo Merge this with IGuestFile::queryInfo(). */ 2042 GuestProcessStartupInfo procInfo; 2043 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut; 2044 try 2045 { 2046 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_STAT); 2047 procInfo.mArguments.push_back(procInfo.mExecutable); /* Set argv0. */ 2048 procInfo.mArguments.push_back(Utf8Str("--machinereadable")); 2049 if (fFollowSymlinks) 2050 procInfo.mArguments.push_back(Utf8Str("-L")); 2051 procInfo.mArguments.push_back("--"); /* strPath could be '--help', which is a valid filename. */ 2052 procInfo.mArguments.push_back(strPath); 2053 } 2054 catch (std::bad_alloc &) 2055 { 2056 Log(("Out of memory!\n")); 2057 return VERR_NO_MEMORY; 2058 } 2059 2060 GuestCtrlStreamObjects stdOut; 2061 vrc = GuestProcessToolbox::runEx(this, procInfo, &stdOut, 1 /* cStrmOutObjects */, &vrcGuest); 2062 if (!GuestProcess::i_isGuestError(vrc)) 2063 { 2064 if (!stdOut.empty()) 2065 { 2066 vrc = objData.FromToolboxStat(stdOut.at(0)); 2067 if (RT_FAILURE(vrc)) 2068 { 2069 vrcGuest = vrc; 2070 if (pvrcGuest) 2071 *pvrcGuest = vrcGuest; 2072 vrc = VERR_GSTCTL_GUEST_ERROR; 2073 } 2074 } 2075 else 2076 vrc = VERR_BROKEN_PIPE; 2077 } 2078 else if (pvrcGuest) 2079 *pvrcGuest = vrcGuest; 2080 #else 2081 RT_NOREF(fFollowSymlinks, objData, pvrcGuest); 2082 vrc = VERR_NOT_SUPPORTED; 2083 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */ 2084 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 2085 } 2086 #endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */ 1865 2087 1866 2088 LogFlowThisFunc(("Returning vrc=%Rrc, vrcGuest=%Rrc\n", vrc, vrcGuest)); … … 3802 4024 case VERR_GSTCTL_GUEST_ERROR: 3803 4025 { 3804 GuestErrorInfo ge(GuestErrorInfo::Type_ ToolMkTemp, vrcGuest, aPath.c_str());4026 GuestErrorInfo ge(GuestErrorInfo::Type_Fs, vrcGuest, aPath.c_str()); 3805 4027 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Temporary guest directory creation failed: %s"), 3806 4028 GuestBase::getErrorAsString(ge).c_str()); … … 3847 4069 default: 3848 4070 { 3849 GuestErrorInfo ge(GuestErrorInfo::Type_ ToolStat, vrcGuest, aPath.c_str());4071 GuestErrorInfo ge(GuestErrorInfo::Type_Fs, vrcGuest, aPath.c_str()); 3850 4072 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Querying directory existence failed: %s"), 3851 4073 GuestBase::getErrorAsString(ge).c_str()); … … 4190 4412 default: 4191 4413 { 4192 GuestErrorInfo ge(GuestErrorInfo::Type_ ToolStat, vrcGuest, aPath.c_str());4414 GuestErrorInfo ge(GuestErrorInfo::Type_Fs, vrcGuest, aPath.c_str()); 4193 4415 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Querying guest file existence failed: %s"), 4194 4416 GuestBase::getErrorAsString(ge).c_str()); … … 4343 4565 if (GuestProcess::i_isGuestError(vrc)) 4344 4566 { 4345 GuestErrorInfo ge(GuestErrorInfo::Type_ ToolStat, vrcGuest, aPath.c_str());4567 GuestErrorInfo ge(GuestErrorInfo::Type_Fs, vrcGuest, aPath.c_str()); 4346 4568 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Querying guest file size failed: %s"), 4347 4569 GuestBase::getErrorAsString(ge).c_str()); … … 4398 4620 else 4399 4621 { 4400 GuestErrorInfo ge(GuestErrorInfo::Type_ ToolStat, vrcGuest, aPath.c_str());4622 GuestErrorInfo ge(GuestErrorInfo::Type_Fs, vrcGuest, aPath.c_str()); 4401 4623 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Querying guest file existence information failed: %s"), 4402 4624 GuestBase::getErrorAsString(ge).c_str()); … … 4421 4643 LogFlowThisFunc(("aPath=%s, aFollowSymlinks=%RTbool\n", aPath.c_str(), RT_BOOL(aFollowSymlinks))); 4422 4644 4423 GuestFsObjData Info;4645 GuestFsObjData objData; 4424 4646 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; 4425 int vrc = i_fsQueryInfo(aPath, aFollowSymlinks != FALSE, Info, &vrcGuest);4647 int vrc = i_fsQueryInfo(aPath, aFollowSymlinks != FALSE, objData, &vrcGuest); 4426 4648 if (RT_SUCCESS(vrc)) 4427 4649 { … … 4430 4652 if (SUCCEEDED(hrc)) 4431 4653 { 4432 vrc = ptrFsObjInfo->init( Info);4654 vrc = ptrFsObjInfo->init(objData); 4433 4655 if (RT_SUCCESS(vrc)) 4434 4656 hrc = ptrFsObjInfo.queryInterfaceTo(aInfo.asOutParam()); … … 4441 4663 if (GuestProcess::i_isGuestError(vrc)) 4442 4664 { 4443 GuestErrorInfo ge(GuestErrorInfo::Type_ ToolStat, vrcGuest, aPath.c_str());4665 GuestErrorInfo ge(GuestErrorInfo::Type_Fs, vrcGuest, aPath.c_str()); 4444 4666 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Querying guest file information failed: %s"), 4445 4667 GuestBase::getErrorAsString(ge).c_str()); … … 4469 4691 if (GuestProcess::i_isGuestError(vrc)) 4470 4692 { 4471 GuestErrorInfo ge(GuestErrorInfo::Type_ ToolRm, vrcGuest, aPath.c_str());4693 GuestErrorInfo ge(GuestErrorInfo::Type_File, vrcGuest, aPath.c_str()); 4472 4694 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Removing guest file failed: %s"), 4473 4695 GuestBase::getErrorAsString(ge).c_str()); -
trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp
r98272 r98526 550 550 if (vrc == VERR_GSTCTL_GUEST_ERROR) 551 551 setProgressErrorMsg(VBOX_E_IPRT_ERROR, tr("Guest file lookup failed"), 552 GuestErrorInfo(GuestErrorInfo::Type_ ToolStat, vrcGuest, strSrc.c_str()));552 GuestErrorInfo(GuestErrorInfo::Type_Fs, vrcGuest, strSrc.c_str())); 553 553 else 554 554 setProgressErrorMsg(VBOX_E_IPRT_ERROR, … … 1247 1247 } 1248 1248 1249 int vrc2 = pDir->i_close Internal(&vrcGuest);1249 int vrc2 = pDir->i_close(&vrcGuest); 1250 1250 if (RT_SUCCESS(vrc)) 1251 1251 vrc = vrc2; … … 1544 1544 if (vrc == VERR_GSTCTL_GUEST_ERROR) 1545 1545 strErrorInfo = GuestBase::getErrorAsString(tr("Guest source lookup failed"), 1546 GuestErrorInfo(GuestErrorInfo::Type_ ToolStat, vrcGuest, strSrc.c_str()));1546 GuestErrorInfo(GuestErrorInfo::Type_Fs, vrcGuest, strSrc.c_str())); 1547 1547 else 1548 1548 strErrorInfo.printf(tr("Guest source lookup for \"%s\" failed: %Rrc"), … … 2630 2630 LogRel(("Running %s ...\n", procInfo.mName.c_str())); 2631 2631 2632 GuestProcessTool procTool;2632 GuestProcessToolbox procToRun; 2633 2633 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; 2634 int vrc = procTo ol.init(pSession, procInfo, false /* Async */, &vrcGuest);2634 int vrc = procToRun.init(pSession, procInfo, false /* Async */, &vrcGuest); 2635 2635 if (RT_SUCCESS(vrc)) 2636 2636 { 2637 2637 if (RT_SUCCESS(vrcGuest)) 2638 vrc = procTo ol.wait(GUESTPROCESSTOOL_WAIT_FLAG_NONE, &vrcGuest);2638 vrc = procToRun.wait(GUESTPROCESSTOOL_WAIT_FLAG_NONE, &vrcGuest); 2639 2639 if (RT_SUCCESS(vrc)) 2640 vrc = procTo ol.getTerminationStatus();2640 vrc = procToRun.getTerminationStatus(); 2641 2641 } 2642 2642 … … 2648 2648 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 2649 2649 Utf8StrFmt(tr("Running update file \"%s\" on guest failed: %Rrc"), 2650 procInfo.mExecutable.c_str(), procTo ol.getRc()));2650 procInfo.mExecutable.c_str(), procToRun.getRc())); 2651 2651 break; 2652 2652
Note:
See TracChangeset
for help on using the changeset viewer.