VirtualBox

Changeset 47817 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Aug 16, 2013 3:30:15 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
88078
Message:

GuestCtrl: Update for IGuestFile; some renaming.

Location:
trunk/src/VBox/Main/src-client
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/GuestFileImpl.cpp

    r47469 r47817  
    153153    if (RT_SUCCESS(vrc))
    154154    {
    155         mData.mID = 0;
     155        mSession = pSession;
     156
     157        mData.mID = uFileID;
    156158        mData.mInitialSize = 0;
    157159        mData.mStatus = FileStatus_Undefined;
     160        mData.mOpenInfo = openInfo;
    158161
    159162        unconst(mEventSource).createObject();
     
    273276    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    274277
    275     *aDisposition = getDispositionFromString(mData.mOpenInfo.mDisposition);
     278    uint32_t uDisposition = 0;
     279    /** @todo Fix me! */
     280    *aDisposition = uDisposition;
    276281
    277282    return S_OK;
     
    363368    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    364369
    365     *aOpenMode = getOpenModeFromString(mData.mOpenInfo.mOpenMode);
     370    uint32_t uOpenMode = 0;
     371    /** @todo Fix me! */
     372    *aOpenMode = uOpenMode;
    366373
    367374    return S_OK;
     
    398405    AssertPtrReturn(pSvcCb, VERR_INVALID_POINTER);
    399406
    400     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    401 
    402407    int vrc;
    403408    switch (pCbCtx->uFunction)
     
    454459    if (RT_SUCCESS(vrc))
    455460        vrc = waitForStatusChange(pEvent, 30 * 1000 /* Timeout in ms */,
    456                                   NULL /* FileStatus */);
     461                                  NULL /* FileStatus */, pGuestRc);
    457462    unregisterWaitEvent(pEvent);
    458463
    459464    LogFlowFuncLeaveRC(vrc);
    460465    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;
    494466}
    495467
     
    543515    AssertPtrReturn(pSvcCbData, VERR_INVALID_POINTER);
    544516
     517    LogFlowThisFuncEnter();
     518
    545519    if (pSvcCbData->mParms < 3)
    546520        return VERR_INVALID_PARAMETER;
     
    548522    int vrc = VINF_SUCCESS;
    549523
    550     int idx = 0; /* Current parameter index. */
     524    int idx = 1; /* Current parameter index. */
    551525    CALLBACKDATA_FILE_NOTIFY dataCb;
    552526    /* pSvcCb->mpaParms[0] always contains the context ID. */
     
    554528    pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.rc);
    555529
     530    FileStatus_T fileStatus = FileStatus_Undefined;
    556531    int guestRc = (int)dataCb.rc; /* uint32_t vs. int. */
    557532
     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
    558544    switch (dataCb.uType)
    559545    {
    560546        case GUEST_FILE_NOTIFYTYPE_ERROR:
    561547        {
    562             AssertMsg(mData.mStatus != FileStatus_Error, ("File status already set to error\n"));
    563 
    564548            int rc2 = setFileStatus(FileStatus_Error, guestRc);
    565549            AssertRC(rc2);
     
    573557                pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.u.open.uHandle);
    574558
    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                }
    580565
    581566                /* Set the process status. */
     
    599584
    600585        case GUEST_FILE_NOTIFYTYPE_READ:
     586        {
    601587            if (pSvcCbData->mParms == 4)
    602588            {
     
    606592                if (cbRead)
    607593                {
     594                    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     595
    608596                    mData.mOffCurrent += cbRead;
     597
     598                    alock.release();
    609599
    610600                    com::SafeArray<BYTE> data((size_t)cbRead);
    611601                    data.initFrom((BYTE*)dataCb.u.read.pvData, cbRead);
     602
    612603                    fireGuestFileReadEvent(mEventSource, mSession, this, mData.mOffCurrent,
    613604                                           cbRead, ComSafeArrayAsInParam(data));
     
    617608                vrc = VERR_NOT_SUPPORTED;
    618609            break;
     610        }
    619611
    620612        case GUEST_FILE_NOTIFYTYPE_WRITE:
     613        {
    621614            if (pSvcCbData->mParms == 4)
    622615            {
    623616                pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.u.write.cbWritten);
    624617
     618                AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     619
    625620                mData.mOffCurrent += dataCb.u.write.cbWritten;
     621                uint64_t uOffCurrent = mData.mOffCurrent;
     622
     623                alock.release();
    626624
    627625                if (dataCb.u.write.cbWritten)
    628                     fireGuestFileWriteEvent(mEventSource, mSession, this, mData.mOffCurrent,
     626                    fireGuestFileWriteEvent(mEventSource, mSession, this, uOffCurrent,
    629627                                            dataCb.u.write.cbWritten);
    630628            }
     
    632630                vrc = VERR_NOT_SUPPORTED;
    633631            break;
     632        }
    634633
    635634        case GUEST_FILE_NOTIFYTYPE_SEEK:
     635        {
    636636            if (pSvcCbData->mParms == 4)
    637637            {
    638638                pSvcCbData->mpaParms[idx++].getUInt64(&dataCb.u.seek.uOffActual);
    639639
     640                AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     641
    640642                mData.mOffCurrent = dataCb.u.seek.uOffActual;
     643                uint64_t uOffCurrent = mData.mOffCurrent;
     644
     645                alock.release();
    641646
    642647                if (dataCb.u.seek.uOffActual)
    643648                    fireGuestFileOffsetChangedEvent(mEventSource, mSession, this,
    644                                                     mData.mOffCurrent, 0 /* Processed */);
     649                                                    uOffCurrent, 0 /* Processed */);
    645650            }
    646651            else
    647652                vrc = VERR_NOT_SUPPORTED;
    648653            break;
     654        }
    649655
    650656        case GUEST_FILE_NOTIFYTYPE_TELL:
     657        {
    651658            if (pSvcCbData->mParms == 4)
    652659            {
    653660                pSvcCbData->mpaParms[idx++].getUInt64(&dataCb.u.tell.uOffActual);
    654661
     662                AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     663
    655664                if (mData.mOffCurrent != dataCb.u.tell.uOffActual)
    656665                {
    657666                    mData.mOffCurrent = dataCb.u.tell.uOffActual;
     667                    uint64_t uOffCurrent = mData.mOffCurrent;
     668
     669                    alock.release();
    658670
    659671                    fireGuestFileOffsetChangedEvent(mEventSource, mSession, this,
    660                                                     mData.mOffCurrent, 0 /* Processed */);
     672                                                    uOffCurrent, 0 /* Processed */);
    661673                }
    662674            }
     
    664676                vrc = VERR_NOT_SUPPORTED;
    665677            break;
     678        }
    666679
    667680        default:
     
    670683    }
    671684
    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));
    684687
    685688    LogFlowFuncLeaveRC(vrc);
     
    692695    AssertPtrReturn(pSvcCbData, VERR_INVALID_POINTER);
    693696
    694     LogFlowThisFunc(("strFile=%s\n",
    695                      mData.mOpenInfo.mFileName.c_str()));
    696 
    697697    int vrc = setFileStatus(FileStatus_Down, VINF_SUCCESS);
    698698
     
    701701}
    702702
    703 int GuestFile::openFile(int *pGuestRc)
    704 {
    705     LogFlowThisFunc(("strFile=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%RU32\n",
     703int 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",
    706710                     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));
    708712    int vrc;
    709713
     
    734738    paParms[i++].setPointer((void*)mData.mOpenInfo.mDisposition.c_str(),
    735739                            (ULONG)mData.mOpenInfo.mDisposition.length() + 1);
     740    paParms[i++].setPointer((void*)mData.mOpenInfo.mSharingMode.c_str(),
     741                            (ULONG)mData.mOpenInfo.mSharingMode.length() + 1);
    736742    paParms[i++].setUInt32(mData.mOpenInfo.mCreationMode);
    737743    paParms[i++].setUInt64(mData.mOpenInfo.mInitialOffset);
    738744
     745    alock.release(); /* Drop read lock before sending. */
     746
    739747    vrc = sendCommand(HOST_FILE_OPEN, i, paParms);
    740748    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);
    743751
    744752    unregisterWaitEvent(pEvent);
     
    903911}
    904912
    905 /* Does not do locking; caller is responsible for that! */
    906913int GuestFile::setFileStatus(FileStatus_T fileStatus, int fileRc)
    907914{
     915    LogFlowThisFuncEnter();
     916
     917    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     918
    908919    LogFlowThisFunc(("oldStatus=%ld, newStatus=%ld, fileRc=%Rrc\n",
    909920                     mData.mStatus, fileStatus, fileRc));
     
    920931    if (mData.mStatus != fileStatus)
    921932    {
    922         mData.mStatus = fileStatus;
     933        mData.mStatus    = fileStatus;
     934        mData.mLastError = fileRc;
    923935
    924936        ComObjPtr<VirtualBoxErrorInfo> errorInfo;
     
    927939        if (RT_FAILURE(fileRc))
    928940        {
    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. */
    934951
    935952        fireGuestFileStateChangedEvent(mEventSource, mSession,
    936                                        this, mData.mStatus, errorInfo);
     953                                       this, fileStatus, errorInfo);
    937954    }
    938955
     
    10131030}
    10141031
    1015 int GuestFile::waitForStatusChange(GuestWaitEvent *pEvent,
    1016                                    uint32_t uTimeoutMS, FileStatus_T *pFileStatus)
     1032int GuestFile::waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS,
     1033                                   FileStatus_T *pFileStatus, int *pGuestRc)
    10171034{
    10181035    AssertPtrReturn(pEvent, VERR_INVALID_POINTER);
     1036    /* pFileStatus is optional. */
    10191037
    10201038    VBoxEventType_T evtType;
     
    10281046        Assert(!pFileEvent.isNull());
    10291047
    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());
    10311057        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;
    10321071    }
    10331072
     
    11971236        rc = rc2;
    11981237
    1199     /*
    1200      * Release autocaller before calling uninit.
    1201      */
    1202     autoCaller.release();
    1203 
    1204     uninit();
    1205 
    1206     LogFlowFuncLeaveRC(rc);
    12071238    if (RT_FAILURE(rc))
    12081239    {
     
    12141245    }
    12151246
     1247    LogFlowThisFunc(("Returning rc=%Rrc\n", rc));
    12161248    return S_OK;
    12171249#endif /* VBOX_WITH_GUEST_CONTROL */
  • trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp

    r47630 r47817  
    239239        mData.mExitCode = 0;
    240240        mData.mPID = 0;
    241         mData.mRC = VINF_SUCCESS;
     241        mData.mLastError = VINF_SUCCESS;
    242242        mData.mStatus = ProcessStatus_Undefined;
    243243        /* Everything else will be set by the actual starting routine. */
     
    967967        /* Do not allow overwriting an already set error. If this happens
    968968         * this means we forgot some error checking/locking somewhere. */
    969         AssertMsg(RT_SUCCESS(mData.mRC), ("Guest rc already set (to %Rrc)\n", mData.mRC));
     969        AssertMsg(RT_SUCCESS(mData.mLastError), ("Guest rc already set (to %Rrc)\n", mData.mLastError));
    970970    }
    971971    else
     
    976976    if (mData.mStatus != procStatus) /* Was there a process status change? */
    977977    {
    978         mData.mStatus = procStatus;
    979         mData.mRC    = procRc;
     978        mData.mStatus    = procStatus;
     979        mData.mLastError = procRc;
    980980
    981981        ComObjPtr<VirtualBoxErrorInfo> errorInfo;
    982982        HRESULT hr = errorInfo.createObject();
    983983        ComAssertComRC(hr);
    984         if (RT_FAILURE(mData.mRC))
    985         {
    986             int rc2 = errorInfo->initEx(VBOX_E_IPRT_ERROR, mData.mRC,
    987                                         COM_IIDOF(IGuestProcess), getComponentName(),
    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);
    990990        }
    991991
    992992        /* Copy over necessary data before releasing lock again. */
    993993        uint32_t uPID =  mData.mPID;
    994         ProcessStatus_T uStatus = mData.mStatus;
     994        ProcessStatus_T procStatus = mData.mStatus;
    995995        /** @todo Also handle mSession? */
    996996
     
    998998
    999999        fireGuestProcessStateChangedEvent(mEventSource, mSession, this,
    1000                                           uPID, uStatus, errorInfo);
     1000                                          uPID, procStatus, errorInfo);
    10011001#if 0
    10021002        /*
     
    14081408
    14091409    LogFlowThisFunc(("fWaitFlags=0x%x, uTimeoutMS=%RU32, procStatus=%RU32, procRc=%Rrc, pGuestRc=%p\n",
    1410                      fWaitFlags, uTimeoutMS, mData.mStatus, mData.mRC, pGuestRc));
     1410                     fWaitFlags, uTimeoutMS, mData.mStatus, mData.mLastError, pGuestRc));
    14111411
    14121412    /* Did some error occur before? Then skip waiting and return. */
     
    14141414    {
    14151415        waitResult = ProcessWaitResult_Error;
    1416         AssertMsg(RT_FAILURE(mData.mRC), ("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));
    14171417        if (pGuestRc)
    1418             *pGuestRc = mData.mRC; /* Return last set error. */
     1418            *pGuestRc = mData.mLastError; /* Return last set error. */
    14191419        return VERR_GSTCTL_GUEST_ERROR;
    14201420    }
     
    14271427    {
    14281428        if (pGuestRc)
    1429             *pGuestRc = mData.mRC; /* Return last set error (if any). */
    1430         return RT_SUCCESS(mData.mRC) ? 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;
    14311431    }
    14321432
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r47781 r47817  
    10051005                             Utf8Str(strName).c_str(), mData.mSession.mID, mData.mFiles.size() - 1, mData.mNumObjects - 1));
    10061006
    1007             itFiles->second->Release();
     1007            pFile->cancelWaitEvents();
     1008            pFile->Release();
    10081009
    10091010            mData.mFiles.erase(itFiles);
     
    10541055int GuestSession::fileOpenInternal(const GuestFileOpenInfo &openInfo, ComObjPtr<GuestFile> &pFile, int *pGuestRc)
    10551056{
    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",
    10571058                     openInfo.mFileName.c_str(), openInfo.mOpenMode.c_str(), openInfo.mDisposition.c_str(),
    10581059                     openInfo.mCreationMode, openInfo.mInitialOffset));
     
    11111112        return rc;
    11121113
    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
    11151141    if (RT_SUCCESS(rc))
    11161142    {
    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;
    11371149        }
    11381150    }
     
    27282740}
    27292741
    2730 STDMETHODIMP GuestSession::FileOpen(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile)
     2742STDMETHODIMP 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
     2756STDMETHODIMP GuestSession::FileOpenEx(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, IN_BSTR aSharingMode,
     2757                                      ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile)
    27312758{
    27322759#ifndef VBOX_WITH_GUEST_CONTROL
     
    27412768    if (RT_UNLIKELY((aDisposition) == NULL || *(aDisposition) == '\0'))
    27422769        return setError(E_INVALIDARG, tr("No disposition mode specified"));
     2770    /* aSharingMode is optional. */
    27432771
    27442772    CheckComArgOutPointerValid(aFile);
     
    27502778    if (FAILED(hr))
    27512779        return hr;
    2752 
    2753     /** @todo Validate open mode. */
    2754     /** @todo Validate disposition mode. */
    27552780
    27562781    /** @todo Validate creation mode. */
     
    27612786    openInfo.mOpenMode = Utf8Str(aOpenMode);
    27622787    openInfo.mDisposition = Utf8Str(aDisposition);
     2788    openInfo.mSharingMode = Utf8Str(aSharingMode);
    27632789    openInfo.mCreationMode = aCreationMode;
    27642790    openInfo.mInitialOffset = aOffset;
    27652791
     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
    27662800    ComObjPtr <GuestFile> pFile; int guestRc;
    2767     int vrc = fileOpenInternal(openInfo, pFile, &guestRc);
     2801    vrc = fileOpenInternal(openInfo, pFile, &guestRc);
    27682802    if (RT_SUCCESS(vrc))
    27692803    {
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette