VirtualBox

Changeset 55613 in vbox


Ignore:
Timestamp:
May 3, 2015 4:12:35 AM (9 years ago)
Author:
vboxsync
Message:

IGuestSession: Added a pathStyle attribute (read-only) that translates the OS type reported by the guest additions into a DOS, UNIX or Unknown path styles values. Added two methods fsExists and fsQueryInfo that aren't as narrow minded as fileQueryInfo and directoryQueryInfo and has parameters for how to treat symbolic links.

Location:
trunk/src/VBox/Main
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r55611 r55613  
    1036810368
    1036910369  <enum
     10370    name="PathStyle"
     10371    uuid="97303a5b-42e8-0a55-d16f-d2a92c295261"
     10372    >
     10373    <desc>
     10374      The path style of a system.
     10375      (Values matches the RTPATH_STR_F_STYLE_XXX defines in iprt/path.h!)
     10376    </desc>
     10377    <const name="DOS"     value="1">
     10378      <desc>DOS-style paths with forward and backward slashes, drive
     10379      letters and UNC.  Known from DOS, OS/2 and Windows.</desc>
     10380    </const>
     10381    <const name="UNIX"    value="2">
     10382      <desc>UNIX-style paths with forward slashes only.</desc>
     10383    </const>
     10384    <const name="Unknown" value="8">
     10385      <desc>
     10386        The path style is not known, most likely because the guest additions
     10387        aren't active yet.
     10388      </desc>
     10389    </const>
     10390  </enum>
     10391
     10392  <enum
    1037010393    name="FileStatus"
    1037110394    uuid="8c86468b-b97b-4080-8914-e29f5b0abd2c"
     
    1077610799  <interface
    1077710800    name="IGuestSession" extends="$unknown"
    10778     uuid="bb890975-4903-38f8-4bc2-f39341f95533"
     10801    uuid="c003c35e-4dc4-4111-4771-51befc3c1d30"
    1077910802    wsmap="managed"
    1078010803    >
     
    1088710910      <desc>
    1088810911        Returns all current guest processes.
     10912      </desc>
     10913    </attribute>
     10914    <attribute name="pathStyle" type="PathStyle" readonly="yes">
     10915      <desc>
     10916        The style of paths used by the guest.  Handy for giving the right kind
     10917        of path specifications to <link to="fileOpen"/> and similar methods.
    1088910918      </desc>
    1089010919    </attribute>
     
    1146211491      <param name="acl" type="wstring" dir="in">
    1146311492        <desc>Actual ACL string to set. Must comply with the guest OS.</desc>
     11493      </param>
     11494    </method>
     11495
     11496    <method name="fsExists">
     11497      <desc>
     11498        Checks whether a file system object (file, directory, etc) exists in
     11499        the guest or not.
     11500
     11501        <result name="VBOX_E_IPRT_ERROR">
     11502          Error while checking existence of the file specified.
     11503        </result>
     11504      </desc>
     11505      <param name="path" type="wstring" dir="in">
     11506        <desc>Path to the file system object to check the existance of.</desc>
     11507      </param>
     11508      <param name="followSymlinks" type="boolean" dir="in">
     11509        <desc>
     11510           If @c true symbolic links will be followed and the target must
     11511           exists and be accessible, otherwise, if @c false we'll be happy
     11512           with a dangling symbolic link.
     11513         </desc>
     11514      </param>
     11515      <param name="exists" type="boolean" dir="return">
     11516        <desc>Returns @c true if the file exists, @c false if not.</desc>
     11517      </param>
     11518    </method>
     11519
     11520    <method name="fsQueryInfo">
     11521      <desc>
     11522        Queries information about a file system object (file, directory, etc)
     11523        in the guest.
     11524
     11525        <result name="VBOX_E_OBJECT_NOT_FOUND">
     11526          The file system object was not found.
     11527        </result>
     11528        <result name="VBOX_E_IPRT_ERROR">
     11529          Error while querying information.
     11530        </result>
     11531      </desc>
     11532      <param name="path" type="wstring" dir="in">
     11533        <desc>Path to the file system object to gather information about</desc>
     11534      </param>
     11535      <param name="followSymlinks" type="boolean" dir="in">
     11536        <desc>
     11537           Information about symbolic links is returned if @c false.  Otherwise,
     11538           symbolic links are followed and the returned information concerns
     11539           itself with the symlink target if @c true.
     11540         </desc>
     11541      </param>
     11542      <param name="info" type="IGuestFsObjInfo" dir="return">
     11543        <desc><link to="IGuestFsObjInfo"/> object containing the information.</desc>
    1146411544      </param>
    1146511545    </method>
  • trunk/src/VBox/Main/include/GuestImpl.h

    r55401 r55613  
    9999    int         i_dispatchToSession(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
    100100    uint32_t    i_getAdditionsVersion(void) { return mData.mAdditionsVersionFull; }
     101    VBOXOSTYPE  i_getGuestOSType(void) { return mData.mOSType; }
    101102    int         i_sessionRemove(GuestSession *pSession);
    102103    int         i_sessionCreate(const GuestSessionStartupInfo &ssInfo, const GuestCredentials &guestCreds,
     
    178179    struct Data
    179180    {
    180         Data() : mAdditionsRunLevel(AdditionsRunLevelType_None)
     181        Data() : mOSType(VBOXOSTYPE_Unknown),  mAdditionsRunLevel(AdditionsRunLevelType_None)
    181182            , mAdditionsVersionFull(0), mAdditionsRevision(0), mAdditionsFeatures(0)
    182183        { }
    183184
     185        VBOXOSTYPE                  mOSType;        /**@< For internal used. VBOXOSTYPE_Unknown if not reported. */
    184186        Utf8Str                     mOSTypeId;
    185187        FacilityMap                 mFacilityMap;
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r55592 r55613  
    272272    HRESULT getEnvironmentBase(std::vector<com::Utf8Str> &aEnvironmentBase);
    273273    HRESULT getProcesses(std::vector<ComPtr<IGuestProcess> > &aProcesses);
     274    HRESULT getPathStyle(PathStyle_T *aPathStyle);
    274275    HRESULT getDirectories(std::vector<ComPtr<IGuestDirectory> > &aDirectories);
    275276    HRESULT getFiles(std::vector<ComPtr<IGuestFile> > &aFiles);
     
    349350    HRESULT fileSetACL(const com::Utf8Str &aFile,
    350351                       const com::Utf8Str &aAcl);
     352    HRESULT fsExists(const com::Utf8Str &aPath,
     353                     BOOL aFollowSymlinks,
     354                     BOOL *pfExists);
     355    HRESULT fsQueryInfo(const com::Utf8Str &aPath,
     356                        BOOL aFollowSymlinks,
     357                        ComPtr<IGuestFsObjInfo> &aInfo);
    351358    HRESULT processCreate(const com::Utf8Str &aCommand,
    352359                          const std::vector<com::Utf8Str> &aArguments,
     
    404411    int                     i_directoryOpenInternal(const GuestDirectoryOpenInfo &openInfo,
    405412                                                    ComObjPtr<GuestDirectory> &pDirectory, int *pGuestRc);
    406     int                     i_directoryQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc);
     413    int                     i_directoryQueryInfoInternal(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
    407414    int                     i_dispatchToDirectory(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
    408415    int                     i_dispatchToFile(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
     
    414421    int                     i_fileRemoveInternal(const Utf8Str &strPath, int *pGuestRc);
    415422    int                     i_fileOpenInternal(const GuestFileOpenInfo &openInfo, ComObjPtr<GuestFile> &pFile, int *pGuestRc);
    416     int                     i_fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc);
     423    int                     i_fileQueryInfoInternal(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
    417424    int                     i_fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize, int *pGuestRc);
    418     int                     i_fsQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc);
     425    int                     i_fsQueryInfoInternal(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
    419426    const GuestCredentials &i_getCredentials(void);
    420427    EventSource            *i_getEventSource(void) { return mEventSource; }
  • trunk/src/VBox/Main/src-client/GuestFsObjInfoImpl.cpp

    r50528 r55613  
    6363    /* Enclose the state transition NotReady->InInit->Ready. */
    6464    AutoInitSpan autoInitSpan(this);
    65     AssertReturn(autoInitSpan.isOk(), E_FAIL);
     65    AssertReturn(autoInitSpan.isOk(), E_FAIL); /** @todo r=bird: returning COM or IPRT status codes here?*/
    6666
    6767    mData = objData;
  • trunk/src/VBox/Main/src-client/GuestImpl.cpp

    r55180 r55613  
    898898     * its real status when using new(er) Guest Additions.
    899899     */
     900    mData.mOSType = aOsType;
    900901    mData.mOSTypeId = Global::OSTypeId(aOsType);
    901902}
  • trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp

    r55599 r55613  
    20652065}
    20662066
     2067/**
     2068 * <Someone write documentation, pretty please!>
     2069 *
     2070 * @param   pGuestRc        Optional.  Will be set to VINF_SUCCESS,
     2071 *                          VERR_NOT_EQUAL or VERR_INVALID_STATE if the
     2072 *                          process completed.  Should it fail earlier that,
     2073 *                          you're feel free to enlighten the rest of us...
     2074 */
    20672075/* static */
    20682076int GuestProcessTool::i_runEx(      GuestSession            *pGuestSession,
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r55592 r55613  
    549549}
    550550
     551HRESULT GuestSession::getPathStyle(PathStyle_T *aPathStyle)
     552{
     553#ifndef VBOX_WITH_GUEST_CONTROL
     554    ReturnComNotImplemented();
     555#else
     556    VBOXOSTYPE enmOsType = mParent->i_getGuestOSType();
     557    if (    enmOsType < VBOXOSTYPE_DOS)
     558    {
     559        *aPathStyle = PathStyle_Unknown;
     560        LogFlowFunc(("returns PathStyle_Unknown\n"));
     561    }
     562    else if (enmOsType < VBOXOSTYPE_Linux)
     563    {
     564        *aPathStyle = PathStyle_DOS;
     565        LogFlowFunc(("returns PathStyle_DOS\n"));
     566    }
     567    else
     568    {
     569        *aPathStyle = PathStyle_UNIX;
     570        LogFlowFunc(("returns PathStyle_UNIX\n"));
     571    }
     572    return S_OK;
     573#endif
     574}
     575
    551576HRESULT GuestSession::getDirectories(std::vector<ComPtr<IGuestDirectory> > &aDirectories)
    552577{
     
    734759}
    735760
    736 int GuestSession::i_directoryQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc)
    737 {
    738     LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
    739 
    740     int vrc = i_fsQueryInfoInternal(strPath, objData, pGuestRc);
     761int GuestSession::i_directoryQueryInfoInternal(const Utf8Str &strPath, bool fFollowSymlinks,
     762                                               GuestFsObjData &objData, int *pGuestRc)
     763{
     764    LogFlowThisFunc(("strPath=%s fFollowSymlinks=%RTbool\n", strPath.c_str(), fFollowSymlinks));
     765
     766    int vrc = i_fsQueryInfoInternal(strPath, fFollowSymlinks, objData, pGuestRc);
    741767    if (RT_SUCCESS(vrc))
    742768    {
     
    13601386}
    13611387
    1362 int GuestSession::i_fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc)
    1363 {
    1364     LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
    1365 
    1366     int vrc = i_fsQueryInfoInternal(strPath, objData, pGuestRc);
     1388int GuestSession::i_fileQueryInfoInternal(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc)
     1389{
     1390    LogFlowThisFunc(("strPath=%s fFollowSymlinks=%RTbool\n", strPath.c_str(), fFollowSymlinks));
     1391
     1392    int vrc = i_fsQueryInfoInternal(strPath, fFollowSymlinks, objData, pGuestRc);
    13671393    if (RT_SUCCESS(vrc))
    13681394    {
     
    13801406
    13811407    GuestFsObjData objData;
    1382     int vrc = i_fileQueryInfoInternal(strPath, objData, pGuestRc);
     1408    int vrc = i_fileQueryInfoInternal(strPath, false /*fFollowSymlinks*/, objData, pGuestRc);
    13831409    if (RT_SUCCESS(vrc))
    13841410        *pllSize = objData.mObjectSize;
     
    13871413}
    13881414
    1389 int GuestSession::i_fsQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc)
     1415/**
     1416 * <Someone write documentation, pretty please!>
     1417 *
     1418 * @param   pGuestRc        Optional.  Will be set to VINF_SUCCESS,
     1419 *                          VERR_NOT_EQUAL or VERR_INVALID_STATE if the
     1420 *                          process completed.  May probably be set to a lot of
     1421 *                          other things.  Not sure if these things are related
     1422 *                          to the process we ran or what, really.  :-(
     1423 */
     1424int GuestSession::i_fsQueryInfoInternal(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc)
    13901425{
    13911426    LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
     
    14091444    }
    14101445
    1411     int guestRc; GuestCtrlStreamObjects stdOut;
     1446    int guestRc;
     1447    GuestCtrlStreamObjects stdOut;
    14121448    if (RT_SUCCESS(vrc))
    14131449        vrc = GuestProcessTool::i_runEx(this, procInfo,
     
    26482684
    26492685    GuestFsObjData objData; int guestRc;
    2650     int rc = i_directoryQueryInfoInternal(aPath, objData, &guestRc);
     2686    int rc = i_directoryQueryInfoInternal(aPath, false /*fFollowSymlinks*/, objData, &guestRc);
    26512687    if (RT_SUCCESS(rc))
    26522688        *aExists = objData.mType == FsObjType_Directory;
     
    27442780
    27452781    GuestFsObjData objData; int guestRc;
    2746     int vrc = i_directoryQueryInfoInternal(aPath, objData, &guestRc);
     2782    int vrc = i_directoryQueryInfoInternal(aPath, false /*fFollowSymlinks*/, objData, &guestRc);
    27472783    if (RT_SUCCESS(vrc))
    27482784    {
     
    31073143
    31083144    GuestFsObjData objData; int guestRc;
    3109     int vrc = i_fileQueryInfoInternal(aPath, objData, &guestRc);
     3145    int vrc = i_fileQueryInfoInternal(aPath, false /*fFollowSymlinks*/, objData, &guestRc);
    31103146    if (RT_SUCCESS(vrc))
    31113147    {
     
    32683304
    32693305    GuestFsObjData objData; int guestRc;
    3270     int vrc = i_fileQueryInfoInternal(aPath, objData, &guestRc);
     3306    int vrc = i_fileQueryInfoInternal(aPath, false /*fFollowSymlinks*/, objData, &guestRc);
    32713307    if (RT_SUCCESS(vrc))
    32723308    {
     
    33873423#endif /* VBOX_WITH_GUEST_CONTROL */
    33883424}
     3425
    33893426HRESULT GuestSession::fileSetACL(const com::Utf8Str &aFile, const com::Utf8Str &aAcl)
    33903427{
     
    33953432
    33963433    ReturnComNotImplemented();
     3434#endif /* VBOX_WITH_GUEST_CONTROL */
     3435}
     3436
     3437HRESULT GuestSession::fsExists(const com::Utf8Str &aPath, BOOL aFollowSymlinks, BOOL *aExists)
     3438{
     3439#ifndef VBOX_WITH_GUEST_CONTROL
     3440    ReturnComNotImplemented();
     3441#else
     3442    LogFlowThisFuncEnter();
     3443
     3444    HRESULT hrc = S_OK;
     3445    *aExists = false;
     3446    if (RT_LIKELY(aPath.isNotEmpty()))
     3447    {
     3448        GuestFsObjData objData;
     3449        int rcGuest;
     3450        int vrc = i_fsQueryInfoInternal(aPath, aFollowSymlinks != FALSE, objData, &rcGuest);
     3451        if (RT_SUCCESS(vrc))
     3452            *aExists = TRUE;
     3453        else if (   vrc == VERR_NOT_A_FILE
     3454                 || vrc == VERR_PATH_NOT_FOUND
     3455                 || vrc == VERR_FILE_NOT_FOUND
     3456                 || vrc == VERR_INVALID_NAME)
     3457            hrc = S_OK; /* Ignore these vrc values. */
     3458        else if (vrc == VERR_GSTCTL_GUEST_ERROR) /** @todo What _is_ rcGuest, really? Stuff like VERR_NOT_A_FILE too?? */
     3459            hrc = GuestProcess::i_setErrorExternal(this, rcGuest);
     3460        else
     3461            hrc = setErrorVrc(vrc, tr("Querying file information for \"%s\" failed: %Rrc"), aPath.c_str(), vrc);
     3462    }
     3463    /* else: If the file name is empty, there is no way it can exists. So, don't
     3464       be a tedious and return E_INVALIDARG, simply return FALSE. */
     3465    LogFlowThisFuncLeave();
     3466    return hrc;
     3467#endif /* VBOX_WITH_GUEST_CONTROL */
     3468}
     3469
     3470HRESULT GuestSession::fsQueryInfo(const com::Utf8Str &aPath, BOOL aFollowSymlinks, ComPtr<IGuestFsObjInfo> &aInfo)
     3471{
     3472#ifndef VBOX_WITH_GUEST_CONTROL
     3473    ReturnComNotImplemented();
     3474#else
     3475    LogFlowThisFuncEnter();
     3476
     3477    HRESULT hrc = S_OK;
     3478    if (RT_LIKELY(aPath.isNotEmpty()))
     3479    {
     3480        GuestFsObjData Info;
     3481        int rcGuest;
     3482        int vrc = i_fsQueryInfoInternal(aPath, aFollowSymlinks != FALSE, Info, &rcGuest);
     3483        if (RT_SUCCESS(vrc))
     3484        {
     3485            ComObjPtr<GuestFsObjInfo> ptrFsObjInfo;
     3486            hrc = ptrFsObjInfo.createObject();
     3487            if (SUCCEEDED(hrc))
     3488            {
     3489                vrc = ptrFsObjInfo->init(Info);
     3490                if (RT_SUCCESS(vrc))
     3491                    hrc = ptrFsObjInfo.queryInterfaceTo(aInfo.asOutParam());
     3492                else
     3493                    hrc = setErrorVrc(vrc);
     3494            }
     3495        }
     3496        else if (vrc == VERR_GSTCTL_GUEST_ERROR)
     3497            hrc = GuestProcess::i_setErrorExternal(this, rcGuest);
     3498        else
     3499            hrc = setErrorVrc(vrc, tr("Querying file information for \"%s\" failed: %Rrc"), aPath.c_str(), vrc);
     3500    }
     3501    /* else: If the file name is empty, there is no way it can exists. So, don't
     3502       be a tedious and return E_INVALIDARG, simply return FALSE. */
     3503    LogFlowThisFuncLeave();
     3504    return hrc;
    33973505#endif /* VBOX_WITH_GUEST_CONTROL */
    33983506}
  • trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp

    r55535 r55613  
    607607     */
    608608    GuestFsObjData objData; int guestRc;
    609     int rc = pSession->i_fileQueryInfoInternal(Utf8Str(mSource), objData, &guestRc);
     609    int rc = pSession->i_fileQueryInfoInternal(Utf8Str(mSource), false /*fFollowSymlinks*/, objData, &guestRc);
    610610    if (RT_FAILURE(rc))
    611611    {
Note: See TracChangeset for help on using the changeset viewer.

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