Changeset 47817 in vbox
- Timestamp:
- Aug 16, 2013 3:30:15 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 88078
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/HostServices/GuestControlSvc.h
r47697 r47817 710 710 /** UInt32: Context ID. */ 711 711 HGCMFunctionParameter context; 712 /** String:File to open. */712 /** File to open. */ 713 713 HGCMFunctionParameter filename; 714 /** String:Open mode. */714 /** Open mode. */ 715 715 HGCMFunctionParameter openmode; 716 /** String: Disposition. */716 /** Disposition mode. */ 717 717 HGCMFunctionParameter disposition; 718 /** Sharing mode. */ 719 HGCMFunctionParameter sharing; 718 720 /** UInt32: Creation mode. */ 719 721 HGCMFunctionParameter creationmode; -
trunk/include/VBox/VBoxGuestLib.h
r47697 r47817 626 626 VBGLR3DECL(int) VbglR3GuestCtrlProcGetWaitFor(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID, uint32_t *puWaitFlags, uint32_t *puTimeoutMS); 627 627 /* Guest native file handling. */ 628 VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszFileName, uint32_t cbFileName, char *pszOpenMode, uint32_t cbOpenMode, char *pszDisposition, uint32_t cbDisposition, uint32_t *puCreationMode, uint64_t *puOffset);628 VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszFileName, uint32_t cbFileName, char *pszOpenMode, uint32_t cbOpenMode, char *pszDisposition, uint32_t cbDisposition, char *pszSharing, uint32_t cbSharing, uint32_t *puCreationMode, uint64_t *puOffset); 629 629 VBGLR3DECL(int) VbglR3GuestCtrlFileGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle); 630 630 VBGLR3DECL(int) VbglR3GuestCtrlFileGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, uint32_t *puToRead); … … 637 637 VBGLR3DECL(int) VbglR3GuestCtrlFileCbOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, uint32_t uFileHandle); 638 638 VBGLR3DECL(int) VbglR3GuestCtrlFileCbClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc); 639 VBGLR3DECL(int) VbglR3GuestCtrlFileCbError(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc); 639 640 VBGLR3DECL(int) VbglR3GuestCtrlFileCbRead(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, void *pvData, uint32_t cbData); 640 641 VBGLR3DECL(int) VbglR3GuestCtrlFileCbWrite(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, uint32_t uWritten); -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestCtrl.cpp
r47695 r47817 532 532 ** @todo Docs! 533 533 */ 534 VBGLR3DECL(int) VbglR3GuestCtrlProcGetInput(PVBGLR3GUESTCTRLCMDCTX pCtx,534 VBGLR3DECL(int) VbglR3GuestCtrlProcGetInput(PVBGLR3GUESTCTRLCMDCTX pCtx, 535 535 uint32_t *puPID, uint32_t *puFlags, 536 536 void *pvData, uint32_t cbData, … … 579 579 580 580 VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, 581 char *pszFileName, uint32_t cbFileName, 582 char *pszOpenMode, uint32_t cbOpenMode, 583 char *pszDisposition, uint32_t cbDisposition, 581 char *pszFileName, uint32_t cbFileName, 582 char *pszAccess, uint32_t cbAccess, 583 char *pszDisposition, uint32_t cbDisposition, 584 char *pszSharing, uint32_t cbSharing, 584 585 uint32_t *puCreationMode, 585 586 uint64_t *puOffset) 586 587 { 587 588 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 588 AssertReturn(pCtx->uNumParms == 6, VERR_INVALID_PARAMETER);589 AssertReturn(pCtx->uNumParms == 7, VERR_INVALID_PARAMETER); 589 590 590 591 AssertPtrReturn(pszFileName, VERR_INVALID_POINTER); 591 592 AssertReturn(cbFileName, VERR_INVALID_PARAMETER); 592 AssertPtrReturn(psz OpenMode, VERR_INVALID_POINTER);593 AssertReturn(cb OpenMode, VERR_INVALID_PARAMETER);593 AssertPtrReturn(pszAccess, VERR_INVALID_POINTER); 594 AssertReturn(cbAccess, VERR_INVALID_PARAMETER); 594 595 AssertPtrReturn(pszDisposition, VERR_INVALID_POINTER); 595 596 AssertReturn(cbDisposition, VERR_INVALID_PARAMETER); 597 AssertPtrReturn(pszSharing, VERR_INVALID_POINTER); 598 AssertReturn(cbSharing, VERR_INVALID_PARAMETER); 596 599 AssertPtrReturn(puCreationMode, VERR_INVALID_POINTER); 597 600 AssertPtrReturn(puOffset, VERR_INVALID_POINTER); … … 606 609 VbglHGCMParmUInt32Set(&Msg.context, 0); 607 610 VbglHGCMParmPtrSet(&Msg.filename, pszFileName, cbFileName); 608 VbglHGCMParmPtrSet(&Msg.openmode, psz OpenMode, cbOpenMode);611 VbglHGCMParmPtrSet(&Msg.openmode, pszAccess, cbAccess); 609 612 VbglHGCMParmPtrSet(&Msg.disposition, pszDisposition, cbDisposition); 613 VbglHGCMParmPtrSet(&Msg.sharing, pszSharing, cbSharing); 610 614 VbglHGCMParmUInt32Set(&Msg.creationmode, 0); 611 615 VbglHGCMParmUInt64Set(&Msg.offset, 0); … … 1038 1042 1039 1043 1044 VBGLR3DECL(int) VbglR3GuestCtrlFileCbError(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc) 1045 { 1046 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1047 1048 HGCMReplyFileNotify Msg; 1049 1050 Msg.hdr.result = VERR_WRONG_ORDER; 1051 Msg.hdr.u32ClientID = pCtx->uClientID; 1052 Msg.hdr.u32Function = GUEST_FILE_NOTIFY; 1053 Msg.hdr.cParms = 3; 1054 1055 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID); 1056 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_ERROR); 1057 VbglHGCMParmUInt32Set(&Msg.rc, uRc); 1058 1059 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 1060 if (RT_SUCCESS(rc)) 1061 { 1062 int rc2 = Msg.hdr.result; 1063 if (RT_FAILURE(rc2)) 1064 rc = rc2; 1065 } 1066 return rc; 1067 } 1068 1069 1040 1070 VBGLR3DECL(int) VbglR3GuestCtrlFileCbRead(PVBGLR3GUESTCTRLCMDCTX pCtx, 1041 1071 uint32_t uRc, -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
r47721 r47817 225 225 if (RT_SUCCESS(rc)) 226 226 { 227 #ifdef DEBUG 228 VBoxServiceVerbose(3, "Msg=%RU32 (%RU32 parms) retrieved\n", uMsg, cParms); 229 #endif 227 VBoxServiceVerbose(4, "Msg=%RU32 (%RU32 parms) retrieved\n", uMsg, cParms); 228 230 229 /* Set number of parameters for current host context. */ 231 230 ctxHost.uNumParms = cParms; -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r47695 r47817 103 103 104 104 105 /** @todo No locking done yet! */ 105 106 static PVBOXSERVICECTRLFILE gstcntlSessionFileGetLocked(const PVBOXSERVICECTRLSESSION pSession, 106 107 uint32_t uHandle) … … 127 128 128 129 char szFile[RTPATH_MAX]; 129 char sz OpenMode[64];130 char szAccess[64]; 130 131 char szDisposition[64]; 132 char szSharing[64]; 131 133 uint32_t uCreationMode = 0; 132 134 uint64_t uOffset = 0; 133 134 135 uint32_t uHandle = 0; 136 135 137 int rc = VbglR3GuestCtrlFileGetOpen(pHostCtx, 136 138 /* File to open. */ 137 139 szFile, sizeof(szFile), 138 140 /* Open mode. */ 139 sz OpenMode, sizeof(szOpenMode),141 szAccess, sizeof(szAccess), 140 142 /* Disposition. */ 141 143 szDisposition, sizeof(szDisposition), 144 /* Sharing. */ 145 szSharing, sizeof(szSharing), 142 146 /* Creation mode. */ 143 147 &uCreationMode, 144 148 /* Offset. */ 145 149 &uOffset); 150 #ifdef DEBUG 151 VBoxServiceVerbose(4, "[File %s]: szAccess=%s, szDisposition=%s, szSharing=%s, rc=%Rrc\n", 152 szFile, szAccess, szDisposition, szSharing, rc); 153 #endif 146 154 if (RT_SUCCESS(rc)) 147 155 { … … 149 157 if (pFile) 150 158 { 151 if (!RTStrPrintf(pFile->szName, sizeof(pFile->szName), "%s", szFile)) 152 rc = VERR_BUFFER_OVERFLOW; 159 if (!strlen(szFile)) 160 rc = VERR_INVALID_PARAMETER; 161 162 if ( RT_SUCCESS(rc) 163 && !RTStrPrintf(pFile->szName, sizeof(pFile->szName), "%s", szFile)) 164 rc = VERR_NO_MEMORY; 153 165 154 166 if (RT_SUCCESS(rc)) 155 167 { 156 uint64_t fFlags = RTFILE_O_OPEN_CREATE | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE; /** @todo Modes! */ 157 rc = RTFileOpen(&pFile->hFile, pFile->szName, fFlags); 168 uint64_t fFlags; 169 rc = RTFileModeToFlagsEx(szAccess, szDisposition, 170 NULL /* pszSharing, not used yet */, &fFlags); 171 VBoxServiceVerbose(4, "[File %s]: Opening flags=0x%x, rc=%Rrc\n", pFile->szName, fFlags, rc); 172 if (RT_SUCCESS(rc)) 173 rc = RTFileOpen(&pFile->hFile, pFile->szName, fFlags); 158 174 if ( RT_SUCCESS(rc) 159 175 && uOffset) … … 165 181 pFile->szName, uOffset, rc); 166 182 } 167 else 183 else if (RT_FAILURE(rc)) 168 184 VBoxServiceVerbose(3, "[File %s]: Opening failed; rc=%Rrc\n", 169 185 pFile->szName, rc); … … 196 212 } 197 213 214 #ifdef DEBUG 215 VBoxServiceVerbose(4, "Opening file \"%s\" (open mode=\"%s\", disposition=\"%s\", creation mode=0x%x returned rc=%Rrc\n", 216 szFile, szAccess, szDisposition, uCreationMode, rc); 217 #endif 198 218 return rc; 199 219 } … … 206 226 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 207 227 208 uint32_t uHandle; 209 228 PVBOXSERVICECTRLFILE pFile = NULL; 229 230 uint32_t uHandle = 0; 210 231 int rc = VbglR3GuestCtrlFileGetClose(pHostCtx, &uHandle /* File handle to close */); 211 232 if (RT_SUCCESS(rc)) 212 233 { 213 PVBOXSERVICECTRLFILEpFile = gstcntlSessionFileGetLocked(pSession, uHandle);234 pFile = gstcntlSessionFileGetLocked(pSession, uHandle); 214 235 if (pFile) 215 236 { … … 227 248 } 228 249 250 #ifdef DEBUG 251 VBoxServiceVerbose(4, "Closing file \"%s\" (handle=%RU32) returned rc=%Rrc\n", 252 pFile ? pFile->szName : "<Not found>", uHandle, rc); 253 #endif 229 254 return rc; 230 255 } … … 238 263 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 239 264 240 uint32_t uHandle; 265 PVBOXSERVICECTRLFILE pFile = NULL; 266 267 uint32_t uHandle = 0; 241 268 uint32_t cbToRead; 242 243 269 int rc = VbglR3GuestCtrlFileGetRead(pHostCtx, &uHandle, &cbToRead); 244 270 if (RT_SUCCESS(rc)) … … 279 305 rc = rc2; 280 306 } 307 308 #ifdef DEBUG 309 VBoxServiceVerbose(4, "Reading file \"%s\" (handle=%RU32) returned rc=%Rrc\n", 310 pFile ? pFile->szName : "<Not found>", uHandle, rc); 311 #endif 281 312 return rc; 282 313 } … … 290 321 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 291 322 292 uint32_t uHandle; 323 PVBOXSERVICECTRLFILE pFile = NULL; 324 325 uint32_t uHandle = 0; 293 326 uint32_t cbToRead; int64_t iOffset; 294 327 295 328 int rc = VbglR3GuestCtrlFileGetReadAt(pHostCtx, 296 &uHandle, &cbToRead, (uint64_t *)&iOffset);329 &uHandle, &cbToRead, (uint64_t *)&iOffset); 297 330 if (RT_SUCCESS(rc)) 298 331 { … … 300 333 size_t cbRead = 0; 301 334 302 PVBOXSERVICECTRLFILEpFile = gstcntlSessionFileGetLocked(pSession, uHandle);335 pFile = gstcntlSessionFileGetLocked(pSession, uHandle); 303 336 if (pFile) 304 337 { … … 332 365 rc = rc2; 333 366 } 367 368 #ifdef DEBUG 369 VBoxServiceVerbose(4, "Reading file \"%s\" at offset (handle=%RU32) returned rc=%Rrc\n", 370 pFile ? pFile->szName : "<Not found>", uHandle, rc); 371 #endif 334 372 return rc; 335 373 } … … 345 383 AssertPtrReturn(cbScratchBuf, VERR_INVALID_PARAMETER); 346 384 347 uint32_t uHandle; 385 PVBOXSERVICECTRLFILE pFile = NULL; 386 387 uint32_t uHandle = 0; 348 388 uint32_t cbToWrite; 349 389 … … 354 394 { 355 395 size_t cbWritten = 0; 356 PVBOXSERVICECTRLFILEpFile = gstcntlSessionFileGetLocked(pSession, uHandle);396 pFile = gstcntlSessionFileGetLocked(pSession, uHandle); 357 397 if (pFile) 358 398 { … … 369 409 rc = rc2; 370 410 } 411 412 #ifdef DEBUG 413 VBoxServiceVerbose(4, "Writing file \"%s\" (handle=%RU32) returned rc=%Rrc\n", 414 pFile ? pFile->szName : "<Not found>", uHandle, rc); 415 #endif 371 416 return rc; 372 417 } … … 382 427 AssertPtrReturn(cbScratchBuf, VERR_INVALID_PARAMETER); 383 428 384 uint32_t uHandle; 429 PVBOXSERVICECTRLFILE pFile = NULL; 430 431 uint32_t uHandle = 0; 385 432 uint32_t cbToWrite; int64_t iOffset; 386 433 387 434 int rc = VbglR3GuestCtrlFileGetWriteAt(pHostCtx, &uHandle, 388 435 pvScratchBuf, cbScratchBuf, 389 &cbToWrite, (uint64_t *)&iOffset);436 &cbToWrite, (uint64_t *)&iOffset); 390 437 if (RT_SUCCESS(rc)) 391 438 { … … 407 454 rc = rc2; 408 455 } 456 457 #ifdef DEBUG 458 VBoxServiceVerbose(4, "Writing file \"%s\" at offset (handle=%RU32) returned rc=%Rrc\n", 459 pFile ? pFile->szName : "<Not found>", uHandle, rc); 460 #endif 409 461 return rc; 410 462 } … … 417 469 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 418 470 419 uint32_t uHandle; 471 PVBOXSERVICECTRLFILE pFile = NULL; 472 473 uint32_t uHandle = 0; 420 474 uint32_t uSeekMethod; 421 475 uint64_t uOffset; /* Will be converted to int64_t. */ … … 427 481 if (RT_SUCCESS(rc)) 428 482 { 429 PVBOXSERVICECTRLFILEpFile = gstcntlSessionFileGetLocked(pSession, uHandle);483 pFile = gstcntlSessionFileGetLocked(pSession, uHandle); 430 484 if (pFile) 431 485 { … … 464 518 rc = rc2; 465 519 } 520 521 #ifdef DEBUG 522 VBoxServiceVerbose(4, "Seeking file \"%s\" (handle=%RU32) returned rc=%Rrc\n", 523 pFile ? pFile->szName : "<Not found>", uHandle, rc); 524 #endif 466 525 return rc; 467 526 } … … 474 533 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 475 534 476 uint32_t uHandle; 535 PVBOXSERVICECTRLFILE pFile = NULL; 536 537 uint32_t uHandle = 0; 477 538 uint64_t uOffsetActual = 0; 478 539 … … 480 541 if (RT_SUCCESS(rc)) 481 542 { 482 PVBOXSERVICECTRLFILEpFile = gstcntlSessionFileGetLocked(pSession, uHandle);543 pFile = gstcntlSessionFileGetLocked(pSession, uHandle); 483 544 if (pFile) 484 545 { … … 495 556 rc = rc2; 496 557 } 558 559 #ifdef DEBUG 560 VBoxServiceVerbose(4, "Telling file \"%s\" (handle=%RU32) returned rc=%Rrc\n", 561 pFile ? pFile->szName : "<Not found>", uHandle, rc); 562 #endif 497 563 return rc; 498 564 } … … 659 725 { 660 726 fPendingClose = true; 661 #ifdef DEBUG _andy727 #ifdef DEBUG 662 728 VBoxServiceVerbose(4, "Got last process input block for PID=%RU32 (%RU32 bytes) ...\n", 663 729 uPID, cbSize); … … 679 745 } 680 746 681 682 #ifdef DEBUG_andy 747 #ifdef DEBUG 683 748 VBoxServiceVerbose(4, "Setting input for PID=%RU32 resulted in rc=%Rrc\n", 684 749 uPID, rc); … … 905 970 break; 906 971 } 972 973 if (RT_FAILURE(rc)) 974 VBoxServiceError("Error while handling message (uMsg=%RU32, cParms=%RU32), rc=%Rrc\n", 975 uMsg, pHostCtx->uNumParms, rc); 907 976 908 977 return rc; … … 1169 1238 if (RT_SUCCESS(rc)) 1170 1239 { 1171 #ifdef DEBUG 1172 VBoxServiceVerbose(3, "Msg=%RU32 (%RU32 parms) retrieved\n", uMsg, cParms); 1173 #endif 1240 VBoxServiceVerbose(4, "Msg=%RU32 (%RU32 parms) retrieved\n", uMsg, cParms); 1241 1174 1242 /* Set number of parameters for current host context. */ 1175 1243 ctxHost.uNumParms = cParms; -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r47804 r47817 10138 10138 <interface 10139 10139 name="IGuestSession" extends="$unknown" 10140 uuid=" 1afeabbd-0c0b-458c-8026-04464892ae12"10140 uuid="5b28703c-07b6-4fcb-afba-ac199b309752" 10141 10141 wsmap="managed" 10142 10142 > … … 10625 10625 <param name="disposition" type="wstring" dir="in"> 10626 10626 <desc>The file disposition.</desc> 10627 </param> 10628 <param name="creationMode" type="unsigned long" dir="in"> 10629 <desc>The file creation mode.</desc> 10630 </param> 10631 <param name="file" type="IGuestFile" dir="return"> 10632 <desc><link to="IGuestFile"/> object representing the opened file.</desc> 10633 </param> 10634 </method> 10635 10636 <method name="fileOpenEx"> 10637 <desc> 10638 Opens a file and creates a <link to="IGuestFile"/> object that 10639 can be used for further operations, extended version. 10640 10641 <result name="VBOX_E_OBJECT_NOT_FOUND"> 10642 File to open was not found. 10643 </result> 10644 <result name="VBOX_E_IPRT_ERROR"> 10645 Error while opening the file. 10646 </result> 10647 </desc> 10648 <param name="path" type="wstring" dir="in"> 10649 <desc>Full path to file to open.</desc> 10650 </param> 10651 <param name="openMode" type="wstring" dir="in"> 10652 <desc>The file open mode.</desc> 10653 </param> 10654 <param name="disposition" type="wstring" dir="in"> 10655 <desc>The file disposition.</desc> 10656 </param> 10657 <param name="sharingMode" type="wstring" dir="in"> 10658 <desc>The file sharing mode on the guest.</desc> 10627 10659 </param> 10628 10660 <param name="creationMode" type="unsigned long" dir="in"> … … 20909 20941 </attribute> 20910 20942 <!-- Note: No events for reads/writes for performance reasons. 20911 See dedi dcated events IGuestFileReadEvent and20943 See dedicated events IGuestFileReadEvent and 20912 20944 IGuestFileWriteEvent. --> 20913 20945 -
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r47627 r47817 116 116 /** The file's disposition mode. */ 117 117 Utf8Str mDisposition; 118 /** The file's sharing mode. 119 **@todo Not implemented yet.*/ 120 Utf8Str mSharingMode; 118 121 /** Octal creation mode. */ 119 122 uint32_t mCreationMode; 120 123 /** The initial offset on open. */ 121 int64_tmInitialOffset;124 uint64_t mInitialOffset; 122 125 }; 123 126 -
trunk/src/VBox/Main/include/GuestFileImpl.h
r45780 r47817 82 82 int callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); 83 83 int closeFile(int *pGuestRc); 84 static uint32_t getDispositionFromString(const Utf8Str &strDisposition);85 84 EventSource *getEventSource(void) { return mEventSource; } 86 static uint32_t getOpenModeFromString(const Utf8Str &strOpenMode);87 85 static Utf8Str guestErrorToString(int guestRc); 88 86 int onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData); 89 87 int onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData); 90 int openFile( int *pGuestRc);88 int openFile(uint32_t uTimeoutMS, int *pGuestRc); 91 89 int readData(uint32_t uSize, uint32_t uTimeoutMS, void* pvData, uint32_t cbData, uint32_t* pcbRead); 92 90 int readDataAt(uint64_t uOffset, uint32_t uSize, uint32_t uTimeoutMS, void* pvData, size_t cbData, size_t* pcbRead); … … 96 94 int waitForOffsetChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint64_t *puOffset); 97 95 int waitForRead(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbRead); 98 int waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, FileStatus_T *pFileStatus );96 int waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, FileStatus_T *pFileStatus, int *pGuestRc); 99 97 int waitForWrite(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint32_t *pcbWritten); 100 98 int writeData(uint32_t uTimeoutMS, void *pvData, uint32_t cbData, uint32_t *pcbWritten); … … 104 102 private: 105 103 106 /** The internal console object. */107 Console *mConsole;108 /** The associate session this file belongs to. */109 GuestSession *mSession;110 104 /** This can safely be used without holding any locks. 111 105 * An AutoCaller suffices to prevent it being destroy while in use and … … 123 117 /** The current file status. */ 124 118 FileStatus_T mStatus; 119 /** The last returned process status 120 * returned from the guest side. */ 121 int mLastError; 125 122 /** The file's current offset. */ 126 123 uint64_t mOffCurrent; -
trunk/src/VBox/Main/include/GuestProcessImpl.h
r47627 r47817 128 128 /** The last returned process status 129 129 * returned from the guest side. */ 130 int m RC;130 int mLastError; 131 131 } mData; 132 132 }; -
trunk/src/VBox/Main/include/GuestSessionImpl.h
r47469 r47817 303 303 STDMETHOD(FileExists)(IN_BSTR aPath, BOOL *aExists); 304 304 STDMETHOD(FileRemove)(IN_BSTR aPath); 305 STDMETHOD(FileOpen)(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile); 305 STDMETHOD(FileOpen)(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, IGuestFile **aFile); 306 STDMETHOD(FileOpenEx)(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, IN_BSTR aSharingMode, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile); 306 307 STDMETHOD(FileQueryInfo)(IN_BSTR aPath, IGuestFsObjInfo **aInfo); 307 308 STDMETHOD(FileQuerySize)(IN_BSTR aPath, LONG64 *aSize); -
trunk/src/VBox/Main/src-client/GuestFileImpl.cpp
r47469 r47817 153 153 if (RT_SUCCESS(vrc)) 154 154 { 155 mData.mID = 0; 155 mSession = pSession; 156 157 mData.mID = uFileID; 156 158 mData.mInitialSize = 0; 157 159 mData.mStatus = FileStatus_Undefined; 160 mData.mOpenInfo = openInfo; 158 161 159 162 unconst(mEventSource).createObject(); … … 273 276 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 274 277 275 *aDisposition = getDispositionFromString(mData.mOpenInfo.mDisposition); 278 uint32_t uDisposition = 0; 279 /** @todo Fix me! */ 280 *aDisposition = uDisposition; 276 281 277 282 return S_OK; … … 363 368 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 364 369 365 *aOpenMode = getOpenModeFromString(mData.mOpenInfo.mOpenMode); 370 uint32_t uOpenMode = 0; 371 /** @todo Fix me! */ 372 *aOpenMode = uOpenMode; 366 373 367 374 return S_OK; … … 398 405 AssertPtrReturn(pSvcCb, VERR_INVALID_POINTER); 399 406 400 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);401 402 407 int vrc; 403 408 switch (pCbCtx->uFunction) … … 454 459 if (RT_SUCCESS(vrc)) 455 460 vrc = waitForStatusChange(pEvent, 30 * 1000 /* Timeout in ms */, 456 NULL /* FileStatus */ );461 NULL /* FileStatus */, pGuestRc); 457 462 unregisterWaitEvent(pEvent); 458 463 459 464 LogFlowFuncLeaveRC(vrc); 460 465 return vrc; 461 }462 463 /* static */464 uint32_t GuestFile::getDispositionFromString(const Utf8Str &strDisposition)465 {466 return 0; /** @todo Implement me! */467 }468 469 /* static */470 uint32_t GuestFile::getOpenModeFromString(const Utf8Str &strOpenMode)471 {472 uint32_t uOpenMode = 0;473 474 const char *pc = strOpenMode.c_str();475 while (*pc != '\0')476 {477 switch (*pc++)478 {479 case 'r':480 uOpenMode |= RTFILE_O_READ;481 break;482 483 case 'w':484 uOpenMode |= RTFILE_O_WRITE;485 break;486 487 default:488 /* Silently skip unknown values. */489 break;490 }491 }492 493 return uOpenMode;494 466 } 495 467 … … 543 515 AssertPtrReturn(pSvcCbData, VERR_INVALID_POINTER); 544 516 517 LogFlowThisFuncEnter(); 518 545 519 if (pSvcCbData->mParms < 3) 546 520 return VERR_INVALID_PARAMETER; … … 548 522 int vrc = VINF_SUCCESS; 549 523 550 int idx = 0; /* Current parameter index. */524 int idx = 1; /* Current parameter index. */ 551 525 CALLBACKDATA_FILE_NOTIFY dataCb; 552 526 /* pSvcCb->mpaParms[0] always contains the context ID. */ … … 554 528 pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.rc); 555 529 530 FileStatus_T fileStatus = FileStatus_Undefined; 556 531 int guestRc = (int)dataCb.rc; /* uint32_t vs. int. */ 557 532 533 LogFlowFunc(("uType=%RU32, guestRc=%Rrc\n", 534 dataCb.uType, guestRc)); 535 536 if (RT_FAILURE(guestRc)) 537 { 538 int rc2 = setFileStatus(FileStatus_Error, guestRc); 539 AssertRC(rc2); 540 541 return VINF_SUCCESS; /* Report to the guest. */ 542 } 543 558 544 switch (dataCb.uType) 559 545 { 560 546 case GUEST_FILE_NOTIFYTYPE_ERROR: 561 547 { 562 AssertMsg(mData.mStatus != FileStatus_Error, ("File status already set to error\n"));563 564 548 int rc2 = setFileStatus(FileStatus_Error, guestRc); 565 549 AssertRC(rc2); … … 573 557 pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.u.open.uHandle); 574 558 575 AssertMsg(mData.mID == 0, ("File ID already set to %RU32\n", mData.mID)); 576 mData.mID = dataCb.u.open.uHandle; 577 AssertMsg(mData.mID == VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(pCbCtx->uContextID), 578 ("File ID %RU32 does not match context ID %RU32\n", mData.mID, 579 VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(pCbCtx->uContextID))); 559 { 560 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 561 AssertMsg(mData.mID == VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(pCbCtx->uContextID), 562 ("File ID %RU32 does not match context ID %RU32\n", mData.mID, 563 VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(pCbCtx->uContextID))); 564 } 580 565 581 566 /* Set the process status. */ … … 599 584 600 585 case GUEST_FILE_NOTIFYTYPE_READ: 586 { 601 587 if (pSvcCbData->mParms == 4) 602 588 { … … 606 592 if (cbRead) 607 593 { 594 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 595 608 596 mData.mOffCurrent += cbRead; 597 598 alock.release(); 609 599 610 600 com::SafeArray<BYTE> data((size_t)cbRead); 611 601 data.initFrom((BYTE*)dataCb.u.read.pvData, cbRead); 602 612 603 fireGuestFileReadEvent(mEventSource, mSession, this, mData.mOffCurrent, 613 604 cbRead, ComSafeArrayAsInParam(data)); … … 617 608 vrc = VERR_NOT_SUPPORTED; 618 609 break; 610 } 619 611 620 612 case GUEST_FILE_NOTIFYTYPE_WRITE: 613 { 621 614 if (pSvcCbData->mParms == 4) 622 615 { 623 616 pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.u.write.cbWritten); 624 617 618 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 619 625 620 mData.mOffCurrent += dataCb.u.write.cbWritten; 621 uint64_t uOffCurrent = mData.mOffCurrent; 622 623 alock.release(); 626 624 627 625 if (dataCb.u.write.cbWritten) 628 fireGuestFileWriteEvent(mEventSource, mSession, this, mData.mOffCurrent,626 fireGuestFileWriteEvent(mEventSource, mSession, this, uOffCurrent, 629 627 dataCb.u.write.cbWritten); 630 628 } … … 632 630 vrc = VERR_NOT_SUPPORTED; 633 631 break; 632 } 634 633 635 634 case GUEST_FILE_NOTIFYTYPE_SEEK: 635 { 636 636 if (pSvcCbData->mParms == 4) 637 637 { 638 638 pSvcCbData->mpaParms[idx++].getUInt64(&dataCb.u.seek.uOffActual); 639 639 640 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 641 640 642 mData.mOffCurrent = dataCb.u.seek.uOffActual; 643 uint64_t uOffCurrent = mData.mOffCurrent; 644 645 alock.release(); 641 646 642 647 if (dataCb.u.seek.uOffActual) 643 648 fireGuestFileOffsetChangedEvent(mEventSource, mSession, this, 644 mData.mOffCurrent, 0 /* Processed */);649 uOffCurrent, 0 /* Processed */); 645 650 } 646 651 else 647 652 vrc = VERR_NOT_SUPPORTED; 648 653 break; 654 } 649 655 650 656 case GUEST_FILE_NOTIFYTYPE_TELL: 657 { 651 658 if (pSvcCbData->mParms == 4) 652 659 { 653 660 pSvcCbData->mpaParms[idx++].getUInt64(&dataCb.u.tell.uOffActual); 654 661 662 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 663 655 664 if (mData.mOffCurrent != dataCb.u.tell.uOffActual) 656 665 { 657 666 mData.mOffCurrent = dataCb.u.tell.uOffActual; 667 uint64_t uOffCurrent = mData.mOffCurrent; 668 669 alock.release(); 658 670 659 671 fireGuestFileOffsetChangedEvent(mEventSource, mSession, this, 660 mData.mOffCurrent, 0 /* Processed */);672 uOffCurrent, 0 /* Processed */); 661 673 } 662 674 } … … 664 676 vrc = VERR_NOT_SUPPORTED; 665 677 break; 678 } 666 679 667 680 default: … … 670 683 } 671 684 672 LogFlowThisFunc(("strName=%s, uType=%RU32, guestRc=%Rrc\n", 673 mData.mOpenInfo.mFileName.c_str(), dataCb.uType, dataCb.rc)); 674 675 if (RT_SUCCESS(vrc)) 676 { 677 /* Nothing to do here yet. */ 678 } 679 else if (vrc == VERR_NOT_SUPPORTED) 680 { 681 /* Also let the callback know. */ 682 guestRc = VERR_NOT_SUPPORTED; 683 } 685 LogFlowThisFunc(("uType=%RU32, guestRc=%Rrc\n", 686 dataCb.uType, dataCb.rc)); 684 687 685 688 LogFlowFuncLeaveRC(vrc); … … 692 695 AssertPtrReturn(pSvcCbData, VERR_INVALID_POINTER); 693 696 694 LogFlowThisFunc(("strFile=%s\n",695 mData.mOpenInfo.mFileName.c_str()));696 697 697 int vrc = setFileStatus(FileStatus_Down, VINF_SUCCESS); 698 698 … … 701 701 } 702 702 703 int GuestFile::openFile(int *pGuestRc) 704 { 705 LogFlowThisFunc(("strFile=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%RU32\n", 703 int GuestFile::openFile(uint32_t uTimeoutMS, int *pGuestRc) 704 { 705 LogFlowThisFuncEnter(); 706 707 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 708 709 LogFlowThisFunc(("strFile=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%RU32, uOffset=%RU64\n", 706 710 mData.mOpenInfo.mFileName.c_str(), mData.mOpenInfo.mOpenMode.c_str(), 707 mData.mOpenInfo.mDisposition.c_str(), mData.mOpenInfo.mCreationMode ));711 mData.mOpenInfo.mDisposition.c_str(), mData.mOpenInfo.mCreationMode, mData.mOpenInfo.mInitialOffset)); 708 712 int vrc; 709 713 … … 734 738 paParms[i++].setPointer((void*)mData.mOpenInfo.mDisposition.c_str(), 735 739 (ULONG)mData.mOpenInfo.mDisposition.length() + 1); 740 paParms[i++].setPointer((void*)mData.mOpenInfo.mSharingMode.c_str(), 741 (ULONG)mData.mOpenInfo.mSharingMode.length() + 1); 736 742 paParms[i++].setUInt32(mData.mOpenInfo.mCreationMode); 737 743 paParms[i++].setUInt64(mData.mOpenInfo.mInitialOffset); 738 744 745 alock.release(); /* Drop read lock before sending. */ 746 739 747 vrc = sendCommand(HOST_FILE_OPEN, i, paParms); 740 748 if (RT_SUCCESS(vrc)) 741 vrc = waitForStatusChange(pEvent, 30 * 1000 /* Timeout in ms */,742 NULL /* FileStatus */ );749 vrc = waitForStatusChange(pEvent, uTimeoutMS, 750 NULL /* FileStatus */, pGuestRc); 743 751 744 752 unregisterWaitEvent(pEvent); … … 903 911 } 904 912 905 /* Does not do locking; caller is responsible for that! */906 913 int GuestFile::setFileStatus(FileStatus_T fileStatus, int fileRc) 907 914 { 915 LogFlowThisFuncEnter(); 916 917 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 918 908 919 LogFlowThisFunc(("oldStatus=%ld, newStatus=%ld, fileRc=%Rrc\n", 909 920 mData.mStatus, fileStatus, fileRc)); … … 920 931 if (mData.mStatus != fileStatus) 921 932 { 922 mData.mStatus = fileStatus; 933 mData.mStatus = fileStatus; 934 mData.mLastError = fileRc; 923 935 924 936 ComObjPtr<VirtualBoxErrorInfo> errorInfo; … … 927 939 if (RT_FAILURE(fileRc)) 928 940 { 929 int rc2 = errorInfo->initEx(VBOX_E_IPRT_ERROR, fileRc, 930 COM_IIDOF(IGuestFile), getComponentName(), 931 guestErrorToString(fileRc)); 932 AssertRC(rc2); 933 } 941 hr = errorInfo->initEx(VBOX_E_IPRT_ERROR, fileRc, 942 COM_IIDOF(IGuestFile), getComponentName(), 943 guestErrorToString(fileRc)); 944 ComAssertComRC(hr); 945 } 946 947 /* Copy over necessary data before releasing lock again. */ 948 FileStatus_T fileStatus = mData.mStatus; 949 950 alock.release(); /* Release lock before firing off event. */ 934 951 935 952 fireGuestFileStateChangedEvent(mEventSource, mSession, 936 this, mData.mStatus, errorInfo);953 this, fileStatus, errorInfo); 937 954 } 938 955 … … 1013 1030 } 1014 1031 1015 int GuestFile::waitForStatusChange(GuestWaitEvent *pEvent, 1016 uint32_t uTimeoutMS, FileStatus_T *pFileStatus)1032 int GuestFile::waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, 1033 FileStatus_T *pFileStatus, int *pGuestRc) 1017 1034 { 1018 1035 AssertPtrReturn(pEvent, VERR_INVALID_POINTER); 1036 /* pFileStatus is optional. */ 1019 1037 1020 1038 VBoxEventType_T evtType; … … 1028 1046 Assert(!pFileEvent.isNull()); 1029 1047 1030 HRESULT hr = pFileEvent->COMGETTER(Status)(pFileStatus); 1048 HRESULT hr; 1049 if (pFileStatus) 1050 { 1051 hr = pFileEvent->COMGETTER(Status)(pFileStatus); 1052 ComAssertComRC(hr); 1053 } 1054 1055 ComPtr<IVirtualBoxErrorInfo> errorInfo; 1056 hr = pFileEvent->COMGETTER(Error)(errorInfo.asOutParam()); 1031 1057 ComAssertComRC(hr); 1058 1059 LONG lGuestRc; 1060 hr = errorInfo->COMGETTER(ResultDetail)(&lGuestRc); 1061 ComAssertComRC(hr); 1062 1063 LogFlowThisFunc(("resultDetail=%RI32 (rc=%Rrc)\n", 1064 lGuestRc, lGuestRc)); 1065 1066 if (RT_FAILURE((int)lGuestRc)) 1067 vrc = VERR_GSTCTL_GUEST_ERROR; 1068 1069 if (pGuestRc) 1070 *pGuestRc = (int)lGuestRc; 1032 1071 } 1033 1072 … … 1197 1236 rc = rc2; 1198 1237 1199 /*1200 * Release autocaller before calling uninit.1201 */1202 autoCaller.release();1203 1204 uninit();1205 1206 LogFlowFuncLeaveRC(rc);1207 1238 if (RT_FAILURE(rc)) 1208 1239 { … … 1214 1245 } 1215 1246 1247 LogFlowThisFunc(("Returning rc=%Rrc\n", rc)); 1216 1248 return S_OK; 1217 1249 #endif /* VBOX_WITH_GUEST_CONTROL */ -
trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp
r47630 r47817 239 239 mData.mExitCode = 0; 240 240 mData.mPID = 0; 241 mData.m RC= VINF_SUCCESS;241 mData.mLastError = VINF_SUCCESS; 242 242 mData.mStatus = ProcessStatus_Undefined; 243 243 /* Everything else will be set by the actual starting routine. */ … … 967 967 /* Do not allow overwriting an already set error. If this happens 968 968 * this means we forgot some error checking/locking somewhere. */ 969 AssertMsg(RT_SUCCESS(mData.m RC), ("Guest rc already set (to %Rrc)\n", mData.mRC));969 AssertMsg(RT_SUCCESS(mData.mLastError), ("Guest rc already set (to %Rrc)\n", mData.mLastError)); 970 970 } 971 971 else … … 976 976 if (mData.mStatus != procStatus) /* Was there a process status change? */ 977 977 { 978 mData.mStatus = procStatus;979 mData.m RC= procRc;978 mData.mStatus = procStatus; 979 mData.mLastError = procRc; 980 980 981 981 ComObjPtr<VirtualBoxErrorInfo> errorInfo; 982 982 HRESULT hr = errorInfo.createObject(); 983 983 ComAssertComRC(hr); 984 if (RT_FAILURE(mData.m RC))985 { 986 int rc2 = errorInfo->initEx(VBOX_E_IPRT_ERROR, mData.mRC,987 988 guestErrorToString(mData.mRC));989 AssertRC(rc2);984 if (RT_FAILURE(mData.mLastError)) 985 { 986 hr = errorInfo->initEx(VBOX_E_IPRT_ERROR, mData.mLastError, 987 COM_IIDOF(IGuestProcess), getComponentName(), 988 guestErrorToString(mData.mLastError)); 989 ComAssertComRC(hr); 990 990 } 991 991 992 992 /* Copy over necessary data before releasing lock again. */ 993 993 uint32_t uPID = mData.mPID; 994 ProcessStatus_T uStatus = mData.mStatus;994 ProcessStatus_T procStatus = mData.mStatus; 995 995 /** @todo Also handle mSession? */ 996 996 … … 998 998 999 999 fireGuestProcessStateChangedEvent(mEventSource, mSession, this, 1000 uPID, uStatus, errorInfo);1000 uPID, procStatus, errorInfo); 1001 1001 #if 0 1002 1002 /* … … 1408 1408 1409 1409 LogFlowThisFunc(("fWaitFlags=0x%x, uTimeoutMS=%RU32, procStatus=%RU32, procRc=%Rrc, pGuestRc=%p\n", 1410 fWaitFlags, uTimeoutMS, mData.mStatus, mData.m RC, pGuestRc));1410 fWaitFlags, uTimeoutMS, mData.mStatus, mData.mLastError, pGuestRc)); 1411 1411 1412 1412 /* Did some error occur before? Then skip waiting and return. */ … … 1414 1414 { 1415 1415 waitResult = ProcessWaitResult_Error; 1416 AssertMsg(RT_FAILURE(mData.m RC), ("No error rc (%Rrc) set when guest process indicated an error\n", mData.mRC));1416 AssertMsg(RT_FAILURE(mData.mLastError), ("No error rc (%Rrc) set when guest process indicated an error\n", mData.mLastError)); 1417 1417 if (pGuestRc) 1418 *pGuestRc = mData.m RC; /* Return last set error. */1418 *pGuestRc = mData.mLastError; /* Return last set error. */ 1419 1419 return VERR_GSTCTL_GUEST_ERROR; 1420 1420 } … … 1427 1427 { 1428 1428 if (pGuestRc) 1429 *pGuestRc = mData.m RC; /* Return last set error (if any). */1430 return RT_SUCCESS(mData.m RC) ? VINF_SUCCESS : VERR_GSTCTL_GUEST_ERROR;1429 *pGuestRc = mData.mLastError; /* Return last set error (if any). */ 1430 return RT_SUCCESS(mData.mLastError) ? VINF_SUCCESS : VERR_GSTCTL_GUEST_ERROR; 1431 1431 } 1432 1432 -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r47781 r47817 1005 1005 Utf8Str(strName).c_str(), mData.mSession.mID, mData.mFiles.size() - 1, mData.mNumObjects - 1)); 1006 1006 1007 itFiles->second->Release(); 1007 pFile->cancelWaitEvents(); 1008 pFile->Release(); 1008 1009 1009 1010 mData.mFiles.erase(itFiles); … … 1054 1055 int GuestSession::fileOpenInternal(const GuestFileOpenInfo &openInfo, ComObjPtr<GuestFile> &pFile, int *pGuestRc) 1055 1056 { 1056 LogFlowThisFunc(("strPath=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%x, iOffset=%RI64\n",1057 LogFlowThisFunc(("strPath=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%x, uOffset=%RU64\n", 1057 1058 openInfo.mFileName.c_str(), openInfo.mOpenMode.c_str(), openInfo.mDisposition.c_str(), 1058 1059 openInfo.mCreationMode, openInfo.mInitialOffset)); … … 1111 1112 return rc; 1112 1113 1113 int guestRc; 1114 rc = pFile->openFile(&guestRc); 1114 /* 1115 * Since this is a synchronous guest call we have to 1116 * register the file object first, releasing the session's 1117 * lock and then proceed with the actual opening command 1118 * -- otherwise the file's opening callback would hang 1119 * because the session's lock still is in place. 1120 */ 1121 try 1122 { 1123 /* Add the created file to our vector. */ 1124 mData.mFiles[uNewFileID] = pFile; 1125 mData.mNumObjects++; 1126 Assert(mData.mNumObjects <= VBOX_GUESTCTRL_MAX_OBJECTS); 1127 1128 LogFlowFunc(("Added new guest file \"%s\" (Session: %RU32) (now total %ld files, %ld objects)\n", 1129 openInfo.mFileName.c_str(), mData.mSession.mID, mData.mFiles.size(), mData.mNumObjects)); 1130 1131 alock.release(); /* Release lock before firing off event. */ 1132 1133 fireGuestFileRegisteredEvent(mEventSource, this, pFile, 1134 true /* Registered */); 1135 } 1136 catch (std::bad_alloc &) 1137 { 1138 rc = VERR_NO_MEMORY; 1139 } 1140 1115 1141 if (RT_SUCCESS(rc)) 1116 1142 { 1117 try 1118 { 1119 /* Add the created file to our vector. */ 1120 mData.mFiles[uNewFileID] = pFile; 1121 mData.mNumObjects++; 1122 Assert(mData.mNumObjects <= VBOX_GUESTCTRL_MAX_OBJECTS); 1123 1124 LogFlowFunc(("Added new guest file \"%s\" (Session: %RU32) (now total %ld files, %ld objects)\n", 1125 openInfo.mFileName.c_str(), mData.mSession.mID, mData.mFiles.size(), mData.mNumObjects)); 1126 1127 alock.release(); /* Release lock before firing off event. */ 1128 1129 fireGuestFileRegisteredEvent(mEventSource, this, pFile, 1130 true /* Registered */); 1131 if (pGuestRc) 1132 *pGuestRc = guestRc; 1133 } 1134 catch (std::bad_alloc &) 1135 { 1136 rc = VERR_NO_MEMORY; 1143 int guestRc; 1144 rc = pFile->openFile(30 * 1000 /* 30s timeout */, &guestRc); 1145 if ( rc == VERR_GSTCTL_GUEST_ERROR 1146 && pGuestRc) 1147 { 1148 *pGuestRc = guestRc; 1137 1149 } 1138 1150 } … … 2728 2740 } 2729 2741 2730 STDMETHODIMP GuestSession::FileOpen(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile) 2742 STDMETHODIMP GuestSession::FileOpen(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, IGuestFile **aFile) 2743 { 2744 #ifndef VBOX_WITH_GUEST_CONTROL 2745 ReturnComNotImplemented(); 2746 #else 2747 LogFlowThisFuncEnter(); 2748 2749 Bstr strSharingMode = ""; /* Sharing mode is ignored. */ 2750 2751 return FileOpenEx(aPath, aOpenMode, aDisposition, strSharingMode.raw(), aCreationMode, 2752 0 /* aOffset */, aFile); 2753 #endif /* VBOX_WITH_GUEST_CONTROL */ 2754 } 2755 2756 STDMETHODIMP GuestSession::FileOpenEx(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, IN_BSTR aSharingMode, 2757 ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile) 2731 2758 { 2732 2759 #ifndef VBOX_WITH_GUEST_CONTROL … … 2741 2768 if (RT_UNLIKELY((aDisposition) == NULL || *(aDisposition) == '\0')) 2742 2769 return setError(E_INVALIDARG, tr("No disposition mode specified")); 2770 /* aSharingMode is optional. */ 2743 2771 2744 2772 CheckComArgOutPointerValid(aFile); … … 2750 2778 if (FAILED(hr)) 2751 2779 return hr; 2752 2753 /** @todo Validate open mode. */2754 /** @todo Validate disposition mode. */2755 2780 2756 2781 /** @todo Validate creation mode. */ … … 2761 2786 openInfo.mOpenMode = Utf8Str(aOpenMode); 2762 2787 openInfo.mDisposition = Utf8Str(aDisposition); 2788 openInfo.mSharingMode = Utf8Str(aSharingMode); 2763 2789 openInfo.mCreationMode = aCreationMode; 2764 2790 openInfo.mInitialOffset = aOffset; 2765 2791 2792 uint64_t uFlagsIgnored; 2793 int vrc = RTFileModeToFlagsEx(openInfo.mOpenMode.c_str(), 2794 openInfo.mDisposition.c_str(), 2795 openInfo.mSharingMode.c_str(), 2796 &uFlagsIgnored); 2797 if (RT_FAILURE(vrc)) 2798 return setError(E_INVALIDARG, tr("Invalid open mode / disposition / sharing mode specified")); 2799 2766 2800 ComObjPtr <GuestFile> pFile; int guestRc; 2767 intvrc = fileOpenInternal(openInfo, pFile, &guestRc);2801 vrc = fileOpenInternal(openInfo, pFile, &guestRc); 2768 2802 if (RT_SUCCESS(vrc)) 2769 2803 {
Note:
See TracChangeset
for help on using the changeset viewer.