VirtualBox

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


Ignore:
Timestamp:
Jul 22, 2010 2:45:41 PM (15 years ago)
Author:
vboxsync
Message:

First support for auto-mounted Shared Folders (Windows only yet).

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

Legend:

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

    r28800 r31002  
    171171
    172172/*
    173  *
    174173 * We are always executed from one specific HGCM thread. So thread safe.
    175  *
    176174 */
    177 int vbsfMappingsAdd (PSHFLSTRING pFolderName, PSHFLSTRING pMapName, uint32_t fWritable)
     175int vbsfMappingsAdd (PSHFLSTRING pFolderName, PSHFLSTRING pMapName,
     176                     uint32_t    fWritable,   uint32_t    fAutoMount)
    178177{
    179178    unsigned i;
     
    218217            memcpy(FolderMapping[i].pMapName->String.ucs2, pMapName->String.ucs2, pMapName->u16Size);
    219218
    220             FolderMapping[i].fValid    = true;
    221             FolderMapping[i].cMappings = 0;
    222             FolderMapping[i].fWritable = !!fWritable;
     219            FolderMapping[i].fValid     = true;
     220            FolderMapping[i].cMappings  = 0;
     221            FolderMapping[i].fWritable  = !!fWritable;
     222            FolderMapping[i].fAutoMount = !!fAutoMount;
    223223
    224224            /* Check if the host file system is case sensitive */
     
    343343    {
    344344        MAPPING *pFolderMapping = vbsfMappingGetByRoot(i);
    345         if (pFolderMapping != NULL && pFolderMapping->fValid == true)
    346         {
     345        if (   pFolderMapping != NULL
     346            && pFolderMapping->fValid == true)
     347        {
     348            /* Skip mappings which are not marked for auto-mounting if
     349             * the SHFL_MF_AUTOMOUNT flag ist set. */
     350            if (   (pClient->fu32Flags & SHFL_MF_AUTOMOUNT)
     351                && !pFolderMapping->fAutoMount)
     352                continue;
     353
    347354            pMappings[*pcMappings].u32Status = SHFL_MS_NEW;
    348355            pMappings[*pcMappings].root = i;
     
    350357        }
    351358    }
    352 
    353359    LogFlow(("vbsfMappingsQuery: return rc = %Rrc\n", rc));
    354 
    355360    return rc;
    356361}
     
    371376    if (BIT_FLAG(pClient->fu32Flags, SHFL_CF_UTF8))
    372377    {
    373         /* not implemented */
     378        /* Not implemented. */
    374379        AssertFailed();
    375380        return VERR_INVALID_PARAMETER;
     
    412417}
    413418
     419int vbsfMappingsQueryAutoMount (SHFLCLIENTDATA *pClient, SHFLROOT root, bool *fAutoMount)
     420{
     421    int rc = VINF_SUCCESS;
     422
     423    LogFlow(("vbsfMappingsQueryAutoMount: pClient = %p, root = %d\n",
     424             pClient, root));
     425
     426    MAPPING *pFolderMapping = vbsfMappingGetByRoot(root);
     427    if (pFolderMapping == NULL)
     428    {
     429        return VERR_INVALID_PARAMETER;
     430    }
     431
     432    if (pFolderMapping->fValid == true)
     433        *fAutoMount = pFolderMapping->fAutoMount;
     434    else
     435        rc = VERR_FILE_NOT_FOUND;
     436
     437    LogFlow(("vbsfMappingsQueryAutoMount:Writable return rc = %Rrc\n", rc));
     438
     439    return rc;
     440}
     441
    414442int vbsfMapFolder (SHFLCLIENTDATA *pClient, PSHFLSTRING pszMapName, RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot)
    415443{
  • trunk/src/VBox/HostServices/SharedFolders/mappings.h

    r28800 r31002  
    44
    55/*
    6  * Copyright (C) 2006-2007 Oracle Corporation
     6 * Copyright (C) 2006-2010 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3030    bool        fGuestCaseSensitive;
    3131    bool        fWritable;
     32    bool        fAutoMount;
    3233} MAPPING, *PMAPPING;
    3334
     
    3637bool vbsfMappingQuery(uint32_t iMapping, PMAPPING *pMapping);
    3738
    38 int vbsfMappingsAdd (PSHFLSTRING pFolderName, PSHFLSTRING pMapName, uint32_t fWritable);
    39 int vbsfMappingsRemove (PSHFLSTRING pMapName);
     39int vbsfMappingsAdd(PSHFLSTRING pFolderName, PSHFLSTRING pMapName, uint32_t fWritable, uint32_t fAutoMount);
     40int vbsfMappingsRemove(PSHFLSTRING pMapName);
    4041
    41 int vbsfMappingsQuery (SHFLCLIENTDATA *pClient, SHFLMAPPING *pMappings, uint32_t *pcMappings);
    42 int vbsfMappingsQueryName (SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pString);
    43 int vbsfMappingsQueryWritable (SHFLCLIENTDATA *pClient, SHFLROOT root, bool *fWritable);
     42int vbsfMappingsQuery(SHFLCLIENTDATA *pClient, SHFLMAPPING *pMappings, uint32_t *pcMappings);
     43int vbsfMappingsQueryName(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pString);
     44int vbsfMappingsQueryWritable(SHFLCLIENTDATA *pClient, SHFLROOT root, bool *fWritable);
    4445
    45 int vbsfMapFolder (SHFLCLIENTDATA *pClient, PSHFLSTRING pszMapName, RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot);
    46 int vbsfUnmapFolder (SHFLCLIENTDATA *pClient, SHFLROOT root);
     46int vbsfMapFolder(SHFLCLIENTDATA *pClient, PSHFLSTRING pszMapName, RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot);
     47int vbsfUnmapFolder(SHFLCLIENTDATA *pClient, SHFLROOT root);
    4748
    48 PCRTUTF16     vbsfMappingsQueryHostRoot (SHFLROOT root, uint32_t *pcbRoot);
    49 bool          vbsfIsGuestMappingCaseSensitive (SHFLROOT root);
    50 bool          vbsfIsHostMappingCaseSensitive (SHFLROOT root);
     49PCRTUTF16 vbsfMappingsQueryHostRoot (SHFLROOT root, uint32_t *pcbRoot);
     50bool vbsfIsGuestMappingCaseSensitive (SHFLROOT root);
     51bool vbsfIsHostMappingCaseSensitive (SHFLROOT root);
    5152
    5253int vbsfMappingLoaded (const MAPPING *pLoadedMapping, SHFLROOT root);
  • trunk/src/VBox/HostServices/SharedFolders/service.cpp

    r30502 r31002  
    310310
    311311                /* Verify parameters values. */
    312                 if (   (fu32Flags & ~SHFL_MF_UTF8) != 0
    313                     || cbMappings / sizeof (SHFLMAPPING) < cMappings
     312                if (   (fu32Flags & ~SHFL_MF_MASK) != 0
     313                    || cbMappings / sizeof (SHFLMAPPING) != cMappings
    314314                   )
    315315                {
     
    320320                    /* Execute the function. */
    321321                    if (fu32Flags & SHFL_MF_UTF8)
    322                     {
    323322                        pClient->fu32Flags |= SHFL_CF_UTF8;
    324                     }
    325 
    326                     rc = vbsfMappingsQuery (pClient, pMappings, &cMappings);
    327 
    328                     if (RT_SUCCESS(rc))
    329                     {
    330                         /* Update parameters.*/
     323                    if (fu32Flags & SHFL_MF_AUTOMOUNT)
     324                        pClient->fu32Flags |= SHFL_MF_AUTOMOUNT;
     325
     326                    rc = vbsfMappingsQuery(pClient, pMappings, &cMappings);
     327                    if (RT_SUCCESS(rc))
     328                    {
     329                        /* Update parameters. */
    331330                        paParms[1].u.uint32 = cMappings;
    332331                    }
     
    346345                rc = VERR_INVALID_PARAMETER;
    347346            }
    348             else if (   paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */
    349                      || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR     /* name */
     347            else if (   paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* Root. */
     348                     || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR   /* Name. */
    350349                    )
    351350            {
     
    366365                {
    367366                    /* Execute the function. */
    368                     rc = vbsfMappingsQueryName (pClient, root, pString);
     367                    rc = vbsfMappingsQueryName(pClient, root, pString);
    369368
    370369                    if (RT_SUCCESS(rc))
    371370                    {
    372371                        /* Update parameters.*/
    373                         ; /* none */
     372                        ; /* None. */
    374373                    }
    375374                }
     
    11621161
    11631162        /* Verify parameter count and types. */
    1164         if (cParms != SHFL_CPARMS_ADD_MAPPING)
     1163        if (   (cParms != SHFL_CPARMS_ADD_MAPPING)
     1164            && (cParms != SHFL_CPARMS_ADD_MAPPING2) /* With auto-mount flag. */
     1165           )
    11651166        {
    11661167            rc = VERR_INVALID_PARAMETER;
     
    11691170                 || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR     /* guest map name */
    11701171                 || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT   /* fWritable */
    1171                 )
     1172                 /* With auto-mount flag? */
     1173                 || (   cParms == SHFL_CPARMS_ADD_MAPPING2
     1174                     && paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT))
    11721175        {
    11731176            rc = VERR_INVALID_PARAMETER;
     
    11791182            SHFLSTRING *pMapName    = (SHFLSTRING *)paParms[1].u.pointer.addr;
    11801183            uint32_t fWritable      = paParms[2].u.uint32;
     1184            uint32_t fAutoMount     = 0; /* Disabled by default. */
     1185
     1186            /* Handle auto-mount flag if present. */
     1187            if (cParms == SHFL_CPARMS_ADD_MAPPING2)
     1188                fAutoMount = paParms[3].u.uint32;
    11811189
    11821190            /* Verify parameters values. */
     
    11901198            {
    11911199                /* Execute the function. */
    1192                 rc = vbsfMappingsAdd (pFolderName, pMapName, fWritable);
    1193 
     1200                rc = vbsfMappingsAdd(pFolderName, pMapName, fWritable, fAutoMount);
    11941201                if (RT_SUCCESS(rc))
    11951202                {
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