VirtualBox

Changeset 99262 in vbox for trunk/src


Ignore:
Timestamp:
Apr 3, 2023 3:17:07 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
156645
Message:

Guest Control: Implements IGuestSession::fsQueryInfo() and IGuestSession::fsQueryFreeSpace(). bugref:10414

Location:
trunk/src/VBox
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibGuestCtrl.cpp

    r99257 r99262  
    12601260#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
    12611261/**
     1262 * Retrieves a HOST_MSG_FS_QUERY_INFO message.
     1263 *
     1264 * @returns VBox status code.
     1265 * @param   pCtx                Guest control command context to use.
     1266 * @param   pszPath             Where to return the path of the file system object to query.
     1267 * @param   cbPath              Size (in bytes) of \a pszPath.
     1268 */
     1269VBGLR3DECL(int) VbglR3GuestCtrlFsGetQueryInfo(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszPath, uint32_t cbPath)
     1270{
     1271    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     1272
     1273    AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
     1274    AssertReturn(cbPath, VERR_INVALID_PARAMETER);
     1275
     1276    int rc;
     1277    do
     1278    {
     1279        HGCMMsgFsQueryInfo Msg;
     1280        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms);
     1281        VbglHGCMParmUInt32Set(&Msg.context, HOST_MSG_FS_QUERY_INFO);
     1282        VbglHGCMParmPtrSet(&Msg.path, pszPath, cbPath);
     1283
     1284        rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
     1285        if (RT_SUCCESS(rc))
     1286            Msg.context.GetUInt32(&pCtx->uContextID);
     1287
     1288    } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel);
     1289    return rc;
     1290}
     1291
     1292/**
    12621293 * Retrieves a HOST_MSG_FS_OBJ_QUERY_INFO message.
    12631294 *
     
    26832714    VBGL_HGCM_HDR_INIT(&Msg.reply_hdr.hdr, pCtx->uClientID, GUEST_MSG_FS_NOTIFY, GSTCTL_HGCM_REPLY_HDR_PARMS + 3);
    26842715    VbglHGCMParmUInt32Set(&Msg.reply_hdr.context, pCtx->uContextID);
    2685     VbglHGCMParmUInt32Set(&Msg.reply_hdr.type, GUEST_FS_NOTIFYTYPE_QUERY_INFO);
     2716    VbglHGCMParmUInt32Set(&Msg.reply_hdr.type, GUEST_FS_NOTIFYTYPE_QUERY_OBJ_INFO);
    26862717    VbglHGCMParmUInt32Set(&Msg.reply_hdr.rc, uRc);
    26872718
    2688     VbglHGCMParmPtrSet      (&Msg.u.queryinfo.obj_info, pFsObjInfo, sizeof(GSTCTLFSOBJINFO));
    2689     VbglHGCMParmPtrSetString(&Msg.u.queryinfo.user,   pszUser);
    2690     VbglHGCMParmPtrSetString(&Msg.u.queryinfo.groups, pszGroups);
     2719    VbglHGCMParmPtrSet      (&Msg.u.queryobjinfo.obj_info, pFsObjInfo, sizeof(GSTCTLFSOBJINFO));
     2720    VbglHGCMParmPtrSetString(&Msg.u.queryobjinfo.user,   pszUser);
     2721    VbglHGCMParmPtrSetString(&Msg.u.queryobjinfo.groups, pszGroups);
    26912722
    26922723    return VbglR3HGCMCall(&Msg.reply_hdr.hdr, RT_UOFFSET_AFTER(HGCMReplyFsNotify, u.queryinfo));
     
    27322763
    27332764    return VbglR3HGCMCall(&Msg.reply_hdr.hdr, RT_UOFFSET_AFTER(HGCMReplyFsNotify, u.createtemp));
     2765}
     2766
     2767/**
     2768 * Replies to a HOST_MSG_FS_QUERY_INFO message.
     2769 *
     2770 * @returns VBox status code.
     2771 * @param   pCtx                Guest control command context to use.
     2772 * @param   uRc                 Guest rc of operation (note: IPRT-style signed int).
     2773 * @param   pFsInfo             File system information to return.
     2774 * @param   cbFsInfo            Size (in bytes) of \a pFsInfo.
     2775 */
     2776VBGLR3DECL(int) VbglR3GuestCtrlFsCbQueryInfo(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, PGSTCTLFSINFO pFsInfo, uint32_t cbFsInfo)
     2777{
     2778    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     2779    AssertPtrReturn(pFsInfo, VERR_INVALID_POINTER);
     2780    AssertReturn(cbFsInfo, VERR_INVALID_PARAMETER);
     2781
     2782    HGCMReplyFsNotify Msg;
     2783    VBGL_HGCM_HDR_INIT(&Msg.reply_hdr.hdr, pCtx->uClientID, GUEST_MSG_FS_NOTIFY, GSTCTL_HGCM_REPLY_HDR_PARMS + 1);
     2784    VbglHGCMParmUInt32Set(&Msg.reply_hdr.context, pCtx->uContextID);
     2785    VbglHGCMParmUInt32Set(&Msg.reply_hdr.type, GUEST_FS_NOTIFYTYPE_QUERY_INFO);
     2786    VbglHGCMParmUInt32Set(&Msg.reply_hdr.rc, uRc);
     2787
     2788    VbglHGCMParmPtrSet(&Msg.u.queryinfo.fs_info, pFsInfo, cbFsInfo);
     2789
     2790    return VbglR3HGCMCall(&Msg.reply_hdr.hdr, RT_UOFFSET_AFTER(HGCMReplyFsNotify, u.queryinfo));
    27342791}
    27352792#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r99257 r99262  
    19751975
    19761976#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
     1977static int vgsvcGstCtrlSessionHandleFsQueryInfo(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx)
     1978{
     1979    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
     1980    AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
     1981
     1982    /*
     1983     * Retrieve the request.
     1984     */
     1985    char szPath[RTPATH_MAX];
     1986    int rc = VbglR3GuestCtrlFsGetQueryInfo(pHostCtx, szPath, sizeof(szPath));
     1987    if (RT_SUCCESS(rc))
     1988    {
     1989        GSTCTLFSINFO fsInfo;
     1990        RT_ZERO(fsInfo);
     1991
     1992        /* Query as much as we can; ignore any errors and continue. */
     1993        int rc2 = RTFsQuerySizes(szPath, (RTFOFF *)&fsInfo.cbTotalSize, (RTFOFF *)&fsInfo.cbFree,
     1994                                 &fsInfo.cbBlockSize, &fsInfo.cbSectorSize);
     1995        if (RT_FAILURE(rc2))
     1996            VGSvcError("Error calling RTFsQuerySizes() for fsqueryinfo operation: %Rrc\n", rc2);
     1997
     1998        RTFSPROPERTIES fsProps;
     1999        rc2 = RTFsQueryProperties(szPath, &fsProps);
     2000        if (RT_SUCCESS(rc2))
     2001        {
     2002            /* Regular (status) flags. */
     2003            fsInfo.cMaxComponent = fsProps.cbMaxComponent;
     2004            if (fsProps.fRemote)
     2005                fsInfo.fFlags |= GSTCTLFSINFO_F_IS_REMOTE;
     2006            if (fsProps.fCaseSensitive)
     2007                fsInfo.fFlags |= GSTCTLFSINFO_F_IS_CASE_SENSITIVE;
     2008            if (fsProps.fReadOnly)
     2009                fsInfo.fFlags |= GSTCTLFSINFO_F_IS_READ_ONLY;
     2010            if (fsProps.fCompressed)
     2011                fsInfo.fFlags |= GSTCTLFSINFO_F_IS_COMPRESSED;
     2012
     2013            /* Feature flags. */
     2014            if (fsProps.fSupportsUnicode)
     2015                fsInfo.fFeatures |= GSTCTLFSINFO_FEATURE_F_UNICODE;
     2016            if (fsProps.fFileCompression)
     2017                fsInfo.fFeatures |= GSTCTLFSINFO_FEATURE_F_FILE_COMPRESSION;
     2018        }
     2019        else
     2020            VGSvcError("Error calling RTFsQueryProperties() for fsqueryinfo operation: %Rrc\n", rc2);
     2021
     2022        rc2 = RTFsQuerySerial(szPath, &fsInfo.uSerialNumber);
     2023        if (RT_FAILURE(rc2))
     2024            VGSvcError("Error calling RTFsQuerySerial() for fsqueryinfo operation: %Rrc\n", rc2);
     2025
     2026#if 0 /** @todo Enable as soon as RTFsQueryLabel() is implemented. */
     2027        rc2 = RTFsQueryLabel(szPath, fsInfo.szLabel, sizeof(fsInfo.szLabel));
     2028        if (RT_FAILURE(rc2))
     2029            VGSvcError("Error calling RTFsQueryLabel() for fsqueryinfo operation: %Rrc\n", rc2);
     2030#endif
     2031
     2032        RTFSTYPE enmFsType;
     2033        rc2 = RTFsQueryType(szPath, &enmFsType);
     2034        if (RT_SUCCESS(rc2))
     2035        {
     2036            if (RTStrPrintf2(fsInfo.szName, sizeof(fsInfo.szName), "%s", RTFsTypeName(enmFsType)) <= 0)
     2037                VGSvcError("Error printing type returned by RTFsQueryType()\n");
     2038        }
     2039        else
     2040            VGSvcError("Error calling RTFsQueryType() for fsqueryinfo operation: %Rrc\n", rc2);
     2041
     2042#if 0 /** @todo Enable as soon as RTFsQueryMountpoint() is implemented. */
     2043        char szMountpoint[RTPATH_MAX];
     2044        rc2 = RTFsQueryMountpoint(szPath, szMountpoint, sizeof(szMountpoint));
     2045        if (RT_SUCCESS(rc2))
     2046        {
     2047            #error "Implement me"
     2048        }
     2049        else
     2050            VGSvcError("Error calling RTFsQueryMountpoint() for fsqueryinfo operation: %Rrc\n", rc2);
     2051#endif
     2052
     2053        if (RT_SUCCESS(rc))
     2054        {
     2055            VGSvcVerbose(3, "cbTotalSize=%RU64, cbFree=%RU64, cbBlockSize=%RU32, cbSectorSize=%RU32, fFlags=%#x, fFeatures=%#x\n",
     2056                         fsInfo.cbTotalSize, fsInfo.cbFree, fsInfo.cbBlockSize, fsInfo.cbSectorSize,
     2057                         fsInfo.fFlags, fsInfo.fFeatures);
     2058            VGSvcVerbose(3, "szName=%s, szLabel=%s\n", fsInfo.szName, fsInfo.szLabel);
     2059        }
     2060
     2061        uint32_t const cbFsInfo = sizeof(GSTCTLFSINFO); /** @todo Needs tweaking as soon as we resolve the mountpoint above. */
     2062
     2063        rc2 = VbglR3GuestCtrlFsCbQueryInfo(pHostCtx, rc, &fsInfo, cbFsInfo);
     2064        if (RT_FAILURE(rc2))
     2065        {
     2066            VGSvcError("Failed to reply to fsobjquerinfo request %Rrc, rc=%Rrc\n", rc, rc2);
     2067            if (RT_SUCCESS(rc))
     2068                rc = rc2;
     2069        }
     2070    }
     2071    else
     2072    {
     2073        VGSvcError("Error fetching parameters for fsqueryinfo operation: %Rrc\n", rc);
     2074        VbglR3GuestCtrlMsgSkip(pHostCtx->uClientID, rc, UINT32_MAX);
     2075    }
     2076    return rc;
     2077}
     2078
    19772079static int vgsvcGstCtrlSessionHandleFsObjQueryInfo(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx)
    19782080{
     
    22402342            if (fImpersonated)
    22412343                rc = vgsvcGstCtrlSessionHandleFsCreateTemp(pSession, pHostCtx);
     2344            break;
     2345
     2346        case HOST_MSG_FS_QUERY_INFO:
     2347            if (fImpersonated)
     2348                rc = vgsvcGstCtrlSessionHandleFsQueryInfo(pSession, pHostCtx);
    22422349            break;
    22432350#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
  • trunk/src/VBox/HostServices/GuestControl/VBoxGuestControlSvc.cpp

    r99253 r99262  
    16651665                    case HOST_MSG_FS_CREATE_TEMP:
    16661666                        RT_FALL_THROUGH();
     1667                    case HOST_MSG_FS_QUERY_INFO:
     1668                        RT_FALL_THROUGH();
    16671669                    case HOST_MSG_FILE_REMOVE:
    16681670                        RT_FALL_THROUGH();
  • trunk/src/VBox/Main/Makefile.kmk

    r99040 r99262  
    12031203        src-client/GuestDirectoryImpl.cpp \
    12041204        src-client/GuestFileImpl.cpp \
     1205        src-client/GuestFsInfoImpl.cpp \
    12051206        src-client/GuestFsObjInfoImpl.cpp \
    12061207        src-client/GuestProcessImpl.cpp \
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r99150 r99262  
    1589915899      <desc>
    1590015900        Returns the free space (in bytes) of a given path.
    15901 
    15902         <result name="E_NOTIMPL">
    15903           The method is not implemented yet.
    15904         </result>
    1590515901      </desc>
    1590615902      <param name="path" type="wstring" dir="in">
     
    1591515911      <desc>
    1591615912        Returns file system information for a given path.
    15917 
    15918         <result name="E_NOTIMPL">
    15919           The method is not implemented yet.
    15920         </result>
    1592115913      </desc>
    1592215914
  • trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h

    r99120 r99262  
    17131713    union
    17141714    {
     1715        /** Holds information for GUEST_FS_NOTIFYTYPE_CREATE_TEMP. */
     1716        struct
     1717        {
     1718            /** Path of created temporary file / directory. */
     1719            char    *pszPath;
     1720            /** Size (in bytes) of \a pszPath. */
     1721            uint32_t cbPath;
     1722        } CreateTemp;
     1723        /** Holds information for GUEST_FS_NOTIFYTYPE_QUERY_OBJ_INFO. */
    17151724        struct
    17161725        {
     
    17241733            /** Size (in bytes) of \a pszGroups. */
    17251734            uint32_t        cbGroups;
     1735        } QueryObjInfo;
     1736        /** Holds information for GUEST_FS_NOTIFYTYPE_QUERY_INFO. */
     1737        struct
     1738        {
     1739            /** The actual filesystem information. */
     1740            GSTCTLFSINFO    fsInfo;
    17261741        } QueryInfo;
    1727         struct
    1728         {
    1729             /** Path of created temporary file / directory. */
    1730             char    *pszPath;
    1731             /** Size (in bytes) of \a pszPath. */
    1732             uint32_t cbPath;
    1733         } CreateTemp;
    17341742    } u;
    17351743} CALLBACKDATA_FS_NOTIFY;
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r99258 r99262  
    318318    int                     i_fsCreateTemp(const Utf8Str &strTemplate, const Utf8Str &strPath, bool fDirectory,
    319319                                           Utf8Str &strName, uint32_t fMode, bool fSecure, int *pvrcGuest);
     320    int                     i_fsQueryInfo(const Utf8Str &strPath, PGSTCTLFSINFO pFsInfo, int *pvrcGuest);
    320321    int                     i_fsObjQueryInfo(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pvrcGuest);
    321322    const GuestCredentials &i_getCredentials(void);
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r99258 r99262  
    3939#include "GuestSessionImpl.h"
    4040#include "GuestSessionImplTasks.h"
     41#include "GuestFsInfoImpl.h"
    4142#include "GuestCtrlImplPrivate.h"
    4243#include "VirtualBoxErrorInfoImpl.h"
     
    20712072
    20722073/**
    2073  * Queries information of a file system object (file, directory, ...).
     2074 * Queries information of a guest file system.
    20742075 *
    20752076 * @return  IPRT status code.
    20762077 * @param   strPath             Path to file system object to query information for.
    2077  * @param   fFollowSymlinks     Whether to follow symbolic links or not.
    2078  * @param   objData             Where to return the file system object data, if found.
     2078 * @param   pFsInfo             Where to return the file system information on success.
    20792079 * @param   pvrcGuest           Guest VBox status code, when returning
    20802080 *                              VERR_GSTCTL_GUEST_ERROR. Any other return code
    20812081 *                              indicates some host side error.
    20822082 */
    2083 int GuestSession::i_fsObjQueryInfo(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pvrcGuest)
     2083int GuestSession::i_fsQueryInfo(const Utf8Str &strPath, PGSTCTLFSINFO pFsInfo, int *pvrcGuest)
    20842084{
    20852085    LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
     
    20962096            return vrc;
    20972097
    2098         uint32_t const fFlags = fFollowSymlinks ? GSTCTL_PATH_F_FOLLOW_LINK : GSTCTL_PATH_F_ON_LINK;
    2099 
    21002098        /* Prepare HGCM call. */
    2101         VBOXHGCMSVCPARM paParms[4];
     2099        VBOXHGCMSVCPARM paParms[2];
    21022100        int i = 0;
    21032101        HGCMSvcSetU32(&paParms[i++], pEvent->ContextID());
    21042102        HGCMSvcSetStr(&paParms[i++], strPath.c_str());
    2105         HGCMSvcSetU32(&paParms[i++], GSTCTLFSOBJATTRADD_UNIX /* Implicit */);
    2106         HGCMSvcSetU32(&paParms[i++], fFlags);
    21072103
    21082104        alock.release(); /* Drop lock before sending. */
    21092105
    2110         vrc = i_sendMessage(HOST_MSG_FS_OBJ_QUERY_INFO, i, paParms);
     2106        vrc = i_sendMessage(HOST_MSG_FS_QUERY_INFO, i, paParms);
    21112107        if (RT_SUCCESS(vrc))
    21122108        {
     
    21202116                {
    21212117                    AssertReturn(pFsNotify->uType == GUEST_FS_NOTIFYTYPE_QUERY_INFO, VERR_INVALID_PARAMETER);
    2122                     objData.Init(strPath);
    2123                     vrc = objData.FromGuestFsObjInfo(&pFsNotify->u.QueryInfo.objInfo);
    2124                     RTStrFree(pFsNotify->u.QueryInfo.pszUser);
    2125                     RTStrFree(pFsNotify->u.QueryInfo.pszGroups);
     2118                    memcpy(pFsInfo, &pFsNotify->u.QueryInfo.fsInfo, sizeof(GSTCTLFSINFO));
    21262119                }
    21272120                else
     
    21432136#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
    21442137    {
     2138        vrc = VERR_NOT_SUPPORTED;
     2139    }
     2140
     2141    LogFlowThisFunc(("Returning vrc=%Rrc, vrcGuest=%Rrc\n", vrc, pvrcGuest ? *pvrcGuest : VERR_IPE_UNINITIALIZED_STATUS));
     2142    return vrc;
     2143}
     2144
     2145/**
     2146 * Queries information of a file system object (file, directory, ...).
     2147 *
     2148 * @return  IPRT status code.
     2149 * @param   strPath             Path to file system object to query information for.
     2150 * @param   fFollowSymlinks     Whether to follow symbolic links or not.
     2151 * @param   objData             Where to return the file system object data, if found.
     2152 * @param   pvrcGuest           Guest VBox status code, when returning
     2153 *                              VERR_GSTCTL_GUEST_ERROR. Any other return code
     2154 *                              indicates some host side error.
     2155 */
     2156int GuestSession::i_fsObjQueryInfo(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pvrcGuest)
     2157{
     2158    LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
     2159
     2160    int vrc;
     2161#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
     2162    if (mParent->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS)
     2163    {
     2164        AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     2165
     2166        GuestWaitEvent *pEvent = NULL;
     2167        vrc = registerWaitEvent(mData.mSession.mID, mData.mObjectID, &pEvent);
     2168        if (RT_FAILURE(vrc))
     2169            return vrc;
     2170
     2171        uint32_t const fFlags = fFollowSymlinks ? GSTCTL_PATH_F_FOLLOW_LINK : GSTCTL_PATH_F_ON_LINK;
     2172
     2173        /* Prepare HGCM call. */
     2174        VBOXHGCMSVCPARM paParms[4];
     2175        int i = 0;
     2176        HGCMSvcSetU32(&paParms[i++], pEvent->ContextID());
     2177        HGCMSvcSetStr(&paParms[i++], strPath.c_str());
     2178        HGCMSvcSetU32(&paParms[i++], GSTCTLFSOBJATTRADD_UNIX /* Implicit */);
     2179        HGCMSvcSetU32(&paParms[i++], fFlags);
     2180
     2181        alock.release(); /* Drop lock before sending. */
     2182
     2183        vrc = i_sendMessage(HOST_MSG_FS_OBJ_QUERY_INFO, i, paParms);
     2184        if (RT_SUCCESS(vrc))
     2185        {
     2186            vrc = pEvent->Wait(30 * 1000);
     2187            if (RT_SUCCESS(vrc))
     2188            {
     2189                PCALLBACKDATA_FS_NOTIFY const pFsNotify = (PCALLBACKDATA_FS_NOTIFY)pEvent->Payload().Raw();
     2190                AssertPtrReturn(pFsNotify, VERR_INVALID_POINTER);
     2191                int vrcGuest = (int)pFsNotify->rc;
     2192                if (RT_SUCCESS(vrcGuest))
     2193                {
     2194                    AssertReturn(pFsNotify->uType == GUEST_FS_NOTIFYTYPE_QUERY_OBJ_INFO, VERR_INVALID_PARAMETER);
     2195                    objData.Init(strPath);
     2196                    vrc = objData.FromGuestFsObjInfo(&pFsNotify->u.QueryObjInfo.objInfo);
     2197                    RTStrFree(pFsNotify->u.QueryObjInfo.pszUser);
     2198                    RTStrFree(pFsNotify->u.QueryObjInfo.pszGroups);
     2199                }
     2200                else
     2201                {
     2202                    if (pvrcGuest)
     2203                        *pvrcGuest = vrcGuest;
     2204                    vrc = VERR_GSTCTL_GUEST_ERROR;
     2205                }
     2206            }
     2207            else
     2208            {
     2209                if (pEvent->HasGuestError() && pvrcGuest)
     2210                    *pvrcGuest = pEvent->GuestResult();
     2211            }
     2212        }
     2213        unregisterWaitEvent(pEvent);
     2214    }
     2215    else
     2216#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
     2217    {
    21452218        vrc = i_fsObjQueryInfoViaToolbox(strPath, fFollowSymlinks, objData, pvrcGuest);
    21462219    }
     
    23482421        switch (dataCb.uType)
    23492422        {
    2350             case GUEST_FS_NOTIFYTYPE_QUERY_INFO:
    2351             {
    2352                 AssertBreakStmt(pSvcCbData->mParms >= 6, vrc = VERR_INVALID_PARAMETER);
    2353                 PGSTCTLFSOBJINFO pObjInfo;
    2354                 uint32_t         cbObjInfo;
    2355                 vrc = HGCMSvcGetPv(&pSvcCbData->mpaParms[3], (void **)&pObjInfo, &cbObjInfo);
    2356                 AssertRCBreak(vrc);
    2357                 AssertBreakStmt(cbObjInfo == sizeof(GSTCTLFSOBJINFO), vrc = VERR_INVALID_PARAMETER);
    2358                 memcpy(&dataCb.u.QueryInfo.objInfo, pObjInfo, sizeof(GSTCTLFSOBJINFO));
    2359 
    2360                 char    *pszUser;
    2361                 uint32_t cbUser;
    2362                 vrc = HGCMSvcGetStr(&pSvcCbData->mpaParms[4], &pszUser, &cbUser);
    2363                 AssertRCBreak(vrc);
    2364                 dataCb.u.QueryInfo.pszUser = RTStrDup(pszUser);
    2365                 AssertPtrBreakStmt(dataCb.u.QueryInfo.pszUser, vrc = VERR_NO_MEMORY);
    2366                 dataCb.u.QueryInfo.cbUser  = cbUser;
    2367 
    2368                 char    *pszGroups;
    2369                 uint32_t cbGroups;
    2370                 vrc = HGCMSvcGetStr(&pSvcCbData->mpaParms[5], &pszGroups, &cbGroups);
    2371                 AssertRCBreak(vrc);
    2372                 dataCb.u.QueryInfo.pszGroups = RTStrDup(pszGroups);
    2373                 AssertPtrBreakStmt(dataCb.u.QueryInfo.pszGroups, vrc = VERR_NO_MEMORY);
    2374                 dataCb.u.QueryInfo.cbGroups  = cbGroups;
    2375                 break;
    2376             }
    2377 
    23782423            case GUEST_FS_NOTIFYTYPE_CREATE_TEMP:
    23792424            {
     
    23852430                AssertPtrBreakStmt(dataCb.u.CreateTemp.pszPath, vrc = VERR_NO_MEMORY);
    23862431                dataCb.u.CreateTemp.cbPath  = cbPath;
     2432                break;
     2433            }
     2434
     2435            case GUEST_FS_NOTIFYTYPE_QUERY_OBJ_INFO:
     2436            {
     2437                AssertBreakStmt(pSvcCbData->mParms >= 6, vrc = VERR_INVALID_PARAMETER);
     2438                PGSTCTLFSOBJINFO pObjInfo;
     2439                uint32_t         cbObjInfo;
     2440                vrc = HGCMSvcGetPv(&pSvcCbData->mpaParms[3], (void **)&pObjInfo, &cbObjInfo);
     2441                AssertRCBreak(vrc);
     2442                AssertBreakStmt(cbObjInfo == sizeof(GSTCTLFSOBJINFO), vrc = VERR_INVALID_PARAMETER);
     2443                memcpy(&dataCb.u.QueryObjInfo.objInfo, pObjInfo, sizeof(GSTCTLFSOBJINFO));
     2444
     2445                char    *pszUser;
     2446                uint32_t cbUser;
     2447                vrc = HGCMSvcGetStr(&pSvcCbData->mpaParms[4], &pszUser, &cbUser);
     2448                AssertRCBreak(vrc);
     2449                dataCb.u.QueryObjInfo.pszUser = RTStrDup(pszUser);
     2450                AssertPtrBreakStmt(dataCb.u.QueryObjInfo.pszUser, vrc = VERR_NO_MEMORY);
     2451                dataCb.u.QueryObjInfo.cbUser  = cbUser;
     2452
     2453                char    *pszGroups;
     2454                uint32_t cbGroups;
     2455                vrc = HGCMSvcGetStr(&pSvcCbData->mpaParms[5], &pszGroups, &cbGroups);
     2456                AssertRCBreak(vrc);
     2457                dataCb.u.QueryObjInfo.pszGroups = RTStrDup(pszGroups);
     2458                AssertPtrBreakStmt(dataCb.u.QueryObjInfo.pszGroups, vrc = VERR_NO_MEMORY);
     2459                dataCb.u.QueryObjInfo.cbGroups  = cbGroups;
     2460                break;
     2461            }
     2462
     2463            case GUEST_FS_NOTIFYTYPE_QUERY_INFO:
     2464            {
     2465                AssertBreakStmt(pSvcCbData->mParms >= 2, vrc = VERR_INVALID_PARAMETER);
     2466                PGSTCTLFSINFO pFsInfo;
     2467                uint32_t      cbFsInfo;
     2468                vrc = HGCMSvcGetPv(&pSvcCbData->mpaParms[3], (void **)&pFsInfo, &cbFsInfo);
     2469                AssertRCBreak(vrc);
     2470                AssertBreakStmt(cbFsInfo == sizeof(GSTCTLFSINFO), vrc = VERR_INVALID_PARAMETER);
     2471                memcpy(&dataCb.u.QueryInfo.fsInfo, pFsInfo, sizeof(GSTCTLFSINFO));
    23872472                break;
    23882473            }
     
    47224807HRESULT GuestSession::fsQueryFreeSpace(const com::Utf8Str &aPath, LONG64 *aFreeSpace)
    47234808{
    4724     RT_NOREF(aPath, aFreeSpace);
    4725 
    4726     return E_NOTIMPL;
     4809    ComPtr<IGuestFsInfo> pFsInfo;
     4810    HRESULT hrc = fsQueryInfo(aPath, pFsInfo);
     4811    if (SUCCEEDED(hrc))
     4812        hrc = pFsInfo->COMGETTER(FreeSize)(aFreeSpace);
     4813
     4814    return hrc;
    47274815}
    47284816
    47294817HRESULT GuestSession::fsQueryInfo(const com::Utf8Str &aPath, ComPtr<IGuestFsInfo> &aInfo)
    47304818{
    4731     RT_NOREF(aPath, aInfo);
    4732 
    4733     return E_NOTIMPL;
     4819    if (aPath.isEmpty())
     4820        return setError(E_INVALIDARG, tr("No path specified"));
     4821
     4822    HRESULT hrc = i_isStartedExternal();
     4823    if (FAILED(hrc))
     4824        return hrc;
     4825
     4826    GSTCTLFSINFO fsInfo;
     4827    int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS;
     4828    int vrc = i_fsQueryInfo(aPath, &fsInfo, &vrcGuest);
     4829    if (RT_SUCCESS(vrc))
     4830    {
     4831        ComObjPtr<GuestFsInfo> ptrFsInfo;
     4832        hrc = ptrFsInfo.createObject();
     4833        if (SUCCEEDED(hrc))
     4834        {
     4835            vrc = ptrFsInfo->init(&fsInfo);
     4836            if (RT_SUCCESS(vrc))
     4837                hrc = ptrFsInfo.queryInterfaceTo(aInfo.asOutParam());
     4838            else
     4839                hrc = setErrorVrc(vrc);
     4840        }
     4841    }
     4842    else
     4843    {
     4844        if (GuestProcess::i_isGuestError(vrc))
     4845        {
     4846            GuestErrorInfo ge(GuestErrorInfo::Type_Fs, vrcGuest, aPath.c_str());
     4847            hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Querying guest filesystem information failed: %s"),
     4848                               GuestBase::getErrorAsString(ge).c_str());
     4849        }
     4850        else
     4851            hrc = setErrorVrc(vrc, tr("Querying guest filesystem information for \"%s\" failed: %Rrc"), aPath.c_str(), vrc);
     4852    }
     4853
     4854    return hrc;
    47344855}
    47354856
     
    48074928        {
    48084929            GuestErrorInfo ge(GuestErrorInfo::Type_Fs, vrcGuest, aPath.c_str());
    4809             hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Querying guest file information failed: %s"),
     4930            hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Querying guest filesystem object information failed: %s"),
    48104931                               GuestBase::getErrorAsString(ge).c_str());
    48114932        }
    48124933        else
    4813             hrc = setErrorVrc(vrc, tr("Querying guest file information for \"%s\" failed: %Rrc"), aPath.c_str(), vrc);
     4934            hrc = setErrorVrc(vrc, tr("Querying guest filesystem object information for \"%s\" failed: %Rrc"), aPath.c_str(), vrc);
    48144935    }
    48154936
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