VirtualBox

Changeset 78698 in vbox for trunk/src/VBox/HostServices


Ignore:
Timestamp:
May 23, 2019 4:44:05 PM (6 years ago)
Author:
vboxsync
Message:

SharedFoldersSvc: Adding function that lets the guest set the error code style. The idea is that the host will do a some error code adjustments when the guest and host OSes differ, as this is much more effient than the guest doing it. The deman is chiefly for windows guests. bugref:9172

Location:
trunk/src/VBox/HostServices/SharedFolders
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedFolders/VBoxSharedFoldersSvc.cpp

    r78467 r78698  
    4040#define SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16       2
    4141#define SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT   3
    42 #define SHFL_SAVED_STATE_VERSION                        4
     42#define SHFL_SAVED_STATE_VERSION_PRE_ERROR_STYLE        4
     43#define SHFL_SAVED_STATE_VERSION                        5
    4344
    4445
     
    9293static STAMPROFILE g_StatFlush;
    9394static STAMPROFILE g_StatFlushFail;
     95static STAMPROFILE g_StatSetErrorStyle;
    9496static STAMPROFILE g_StatSetUtf8;
    9597static STAMPROFILE g_StatSetFileSize;
     
    170172
    171173    pClient->fHasMappingCounts = true;
     174    pClient->enmErrorStyle = SHFLERRORSTYLE_NATIVE;
    172175    return VINF_SUCCESS;
    173176}
     
    257260    uint32_t        nrMappings;
    258261    SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient;
    259     uint32_t        len, version;
     262    uint32_t        len;
    260263
    261264    Log(("SharedFolders host service: loading state, u32ClientID = %u\n", u32ClientID));
    262265
    263     int rc = SSMR3GetU32(pSSM, &version);
     266    uint32_t uShfVersion = 0;
     267    int rc = SSMR3GetU32(pSSM, &uShfVersion);
    264268    AssertRCReturn(rc, rc);
    265269
    266     if (   version > SHFL_SAVED_STATE_VERSION
    267         || version < SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16)
    268         return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
     270    if (   uShfVersion > SHFL_SAVED_STATE_VERSION
     271        || uShfVersion < SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16)
     272        return SSMR3SetLoadError(pSSM, VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION, RT_SRC_POS,
     273                                 "Unknown shared folders state version %u!", uShfVersion);
    269274
    270275    rc = SSMR3GetU32(pSSM, &nrMappings);
     
    281286    else if (len != sizeof(*pClient))
    282287        return SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    283                                  "Saved SHFLCLIENTDATA size %u differs from current %u!\n", len, sizeof(*pClient));
     288                                 "Saved SHFLCLIENTDATA size %u differs from current %u!", len, sizeof(*pClient));
    284289
    285290    rc = SSMR3GetMem(pSSM, pClient, len);
    286291    AssertRCReturn(rc, rc);
    287292
     293    /* For older saved state, use the default native error style, otherwise
     294       check that the restored value makes sense to us. */
     295    if (uShfVersion <= SHFL_SAVED_STATE_VERSION_PRE_ERROR_STYLE)
     296        pClient->enmErrorStyle = SHFLERRORSTYLE_NATIVE;
     297    else if (   pClient->enmErrorStyle <= kShflErrorStyle_Invalid
     298             || pClient->enmErrorStyle >= kShflErrorStyle_End)
     299        return SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     300                                 "Saved SHFLCLIENTDATA enmErrorStyle value %d is not known/valid!", pClient->enmErrorStyle);
     301
    288302    /* We don't actually (fully) restore the state; we simply check if the current state is as we it expect it to be. */
    289     for (int i=0;i<SHFL_MAX_MAPPINGS;i++)
     303    for (size_t i = 0; i < SHFL_MAX_MAPPINGS; i++)
    290304    {
    291305        /* Load the saved mapping description and try to find it in the mappings. */
     
    302316        if (mapping.fValid)
    303317        {
     318            /* Load the host path name. */
    304319            uint32_t cb;
    305 
    306             /* Load the host path name. */
    307320            rc = SSMR3GetU32(pSSM, &cb);
    308321            AssertRCReturn(rc, rc);
    309322
    310323            char *pszFolderName;
    311             if (version == SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16)
     324            if (uShfVersion == SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16) /* (See version range check above.) */
    312325            {
    313326                AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
    314                              SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad folder name size: %#x\n", cb));
     327                             SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad folder name size: %#x", cb));
    315328                PSHFLSTRING pFolderName = (PSHFLSTRING)RTMemAlloc(cb);
    316329                AssertReturn(pFolderName != NULL, VERR_NO_MEMORY);
     
    320333                AssertReturn(pFolderName->u16Size < cb && pFolderName->u16Length < pFolderName->u16Size,
    321334                             SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    322                                                "Bad folder name string: %#x/%#x cb=%#x\n",
     335                                               "Bad folder name string: %#x/%#x cb=%#x",
    323336                                               pFolderName->u16Size, pFolderName->u16Length, cb));
    324337
     
    341354            AssertRCReturn(rc, rc);
    342355            AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
    343                          SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad map name size: %#x\n", cb));
     356                         SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad map name size: %#x", cb));
    344357
    345358            PSHFLSTRING pMapName = (PSHFLSTRING)RTMemAlloc(cb);
     
    350363            AssertReturn(pMapName->u16Size < cb && pMapName->u16Length < pMapName->u16Size,
    351364                         SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    352                                            "Bad map name string: %#x/%#x cb=%#x\n",
     365                                           "Bad map name string: %#x/%#x cb=%#x",
    353366                                           pMapName->u16Size, pMapName->u16Length, cb));
    354367
     
    362375            /* Load the auto mount point. */
    363376            PSHFLSTRING pAutoMountPoint;
    364             if (version > SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT)
     377            if (uShfVersion > SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT)
    365378            {
    366379                rc = SSMR3GetU32(pSSM, &cb);
    367380                AssertRCReturn(rc, rc);
    368381                AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
    369                              SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad auto mount point size: %#x\n", cb));
     382                             SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad auto mount point size: %#x", cb));
    370383
    371384                pAutoMountPoint = (PSHFLSTRING)RTMemAlloc(cb);
     
    376389                AssertReturn(pAutoMountPoint->u16Size < cb && pAutoMountPoint->u16Length < pAutoMountPoint->u16Size,
    377390                             SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    378                                                "Bad auto mount point string: %#x/%#x cb=%#x\n",
     391                                               "Bad auto mount point string: %#x/%#x cb=%#x",
    379392                                               pAutoMountPoint->u16Size, pAutoMountPoint->u16Length, cb));
    380393
     
    15661579                                  paParms[3].u.uint32, paParms[4].u.uint64, paParms[5].u.uint64,
    15671580                                  &paParms[6].u.uint64, paParms[7].u.uint64);
     1581            break;
     1582        }
     1583
     1584        case SHFL_FN_SET_ERROR_STYLE:
     1585        {
     1586            pStatFail = pStat = &g_StatSetErrorStyle;
     1587
     1588            /* Validate input: */
     1589            ASSERT_GUEST_STMT_BREAK(cParms == SHFL_CPARMS_SET_ERROR_STYLE, rc = VERR_WRONG_PARAMETER_COUNT);
     1590            ASSERT_GUEST_STMT_BREAK(paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* enm32Style  */
     1591            ASSERT_GUEST_STMT_BREAK(   paParms[0].u.uint32 > (uint32_t)kShflErrorStyle_Invalid
     1592                                    && paParms[0].u.uint32 < (uint32_t)kShflErrorStyle_End, rc = VERR_WRONG_PARAMETER_TYPE);
     1593            ASSERT_GUEST_STMT_BREAK(paParms[1].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* u32Reserved */
     1594            ASSERT_GUEST_STMT_BREAK(paParms[1].u.uint32 == 0, rc = VERR_WRONG_PARAMETER_TYPE);
     1595
     1596            /* Do the work: */
     1597            pClient->enmErrorStyle = (uint8_t)paParms[0].u.uint32;
     1598            rc = VINF_SUCCESS;
    15681599            break;
    15691600        }
     
    18731904             HGCMSvcHlpStamRegister(g_pHelpers, &g_StatFlush,                     STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_FLUSH successes",                   "/HGCM/VBoxSharedFolders/FnFlush");
    18741905             HGCMSvcHlpStamRegister(g_pHelpers, &g_StatFlushFail,                 STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_FLUSH failures",                    "/HGCM/VBoxSharedFolders/FnFlushFail");
     1906             HGCMSvcHlpStamRegister(g_pHelpers, &g_StatSetErrorStyle,             STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_SET_ERROR_STYLE",                   "/HGCM/VBoxSharedFolders/FnSetErrorStyle");
    18751907             HGCMSvcHlpStamRegister(g_pHelpers, &g_StatSetUtf8,                   STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_SET_UTF8",                          "/HGCM/VBoxSharedFolders/FnSetUtf8");
    18761908             HGCMSvcHlpStamRegister(g_pHelpers, &g_StatSymlink,                   STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_SYMLINK successes",                 "/HGCM/VBoxSharedFolders/FnSymlink");
  • trunk/src/VBox/HostServices/SharedFolders/shfl.h

    r76570 r78698  
    2727#include <VBox/log.h>
    2828
    29 /**
    30  * Shared Folders client flags.
     29/** Shared Folders client flags.
    3130 * @{
    3231 */
    33 
    34 /** Client has queried mappings at least once and, therefore,
    35  *  the service can process its other requests too.
    36  */
     32/** Client has queried mappings at least once and, therefore, the service can
     33 * process its other requests too. */
    3734#define SHFL_CF_MAPPINGS_QUERIED (0x00000001)
    38 
    3935/** Mappings have been changed since last query. */
    4036#define SHFL_CF_MAPPINGS_CHANGED (0x00000002)
    41 
    4237/** Client uses UTF8 encoding, if not set then unicode 16 bit (UCS2) is used. */
    4338#define SHFL_CF_UTF8             (0x00000004)
    44 
    4539/** Client both supports and wants to use symlinks. */
    4640#define SHFL_CF_SYMLINKS         (0x00000008)
    47 
    4841/** The call to SHFL_FN_WAIT_FOR_MAPPINGS_CHANGES will return immediately
    4942 *  because of a SHFL_FN_CANCEL_MAPPINGS_CHANGES_WAITS call. */
    5043#define SHFL_CF_CANCEL_NEXT_WAIT (0x00000010)
    51 
    5244/** @} */
    5345
    54 typedef struct _SHFLCLIENTDATA
     46/**
     47 * @note This structure is dumped directly into the saved state, so care must be
     48 *       taken when extending it!
     49 */
     50typedef struct SHFLCLIENTDATA
    5551{
    5652    /** Client flags */
     
    5854    /** Path delimiter. */
    5955    RTUTF16  PathDelimiter;
    60     /** Currently unused.  */
    61     uint8_t  bPadding;
     56    /** The error style, SHFLERRORSTYLE. */
     57    uint8_t  enmErrorStyle;
    6258    /** Set if the client has mapping usage counts.
    6359     * This is for helping with saved state. */
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