VirtualBox

Changeset 75405 in vbox


Ignore:
Timestamp:
Nov 12, 2018 7:43:51 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
126547
Message:

add/os2/VBoxSF: Added support for attach tag string.

Location:
trunk/src/VBox/Additions/os2/VBoxSF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/os2/VBoxSF/VBoxSF.cpp

    r75337 r75405  
    359359 * @returns VBox status code.
    360360 * @param   pName       The name of the folder to map.
     361 * @param   pszTag      Folder tag (for the VBoxService automounter).  Optional.
    361362 * @param   ppFolder    Where to return the folder structure on success.
    362363 *
    363364 * @remarks Caller owns g_MtxFolder exclusively!
    364365 */
    365 static int vboxSfOs2MapFolder(PSHFLSTRING pName, PVBOXSFFOLDER *ppFolder)
     366static int vboxSfOs2MapFolder(PSHFLSTRING pName, const char *pszTag, PVBOXSFFOLDER *ppFolder)
    366367{
    367368    int rc;
    368     PVBOXSFFOLDER pNew = (PVBOXSFFOLDER)RTMemAlloc(RT_UOFFSETOF_DYN(VBOXSFFOLDER, szName[pName->u16Length + 1]));
     369    size_t const  cbTag = pszTag ? strlen(pszTag) + 1 :  NULL;
     370    PVBOXSFFOLDER pNew  = (PVBOXSFFOLDER)RTMemAlloc(RT_UOFFSETOF_DYN(VBOXSFFOLDER, szName[pName->u16Length + 1 + cbTag]));
    369371    if (pNew != NULL)
    370372    {
     
    375377        RT_ZERO(pNew->hHostFolder);
    376378        pNew->hVpb          = 0;
     379        pNew->cbNameAndTag  = pName->u16Length + (uint16_t)cbTag;
     380        pNew->cchName       = (uint8_t)pName->u16Length;
    377381        pNew->cchName       = (uint8_t)pName->u16Length;
    378382        memcpy(pNew->szName, pName->String.utf8, pName->u16Length);
    379383        pNew->szName[pName->u16Length] = '\0';
     384        if (cbTag)
     385            memcpy(&pNew->szName[pName->u16Length + 1], pszTag, cbTag);
    380386
    381387        rc = VbglR0SfMapFolder(&g_SfClient, pName, &pNew->hHostFolder);
     
    552558             * Do the attaching.
    553559             */
    554             rc = vboxSfOs2MapFolder(pStrName, ppFolder);
     560            rc = vboxSfOs2MapFolder(pStrName, NULL, ppFolder);
    555561            vboxSfOs2StrFree(pStrName);
    556562            if (RT_SUCCESS(rc))
     
    764770    }
    765771
    766     /* Make sure it's only ascii and contains not weird stuff. */
    767     unsigned off = pStrName->u16Length;
     772    /* Make sure it's only ascii and contains not weird stuff.
     773       Note! There could be a 2nd tag string, so identify that one. */
     774    const char *pszTag = NULL;
     775    unsigned    off = pStrName->u16Length;
    768776    while (off-- > 0)
    769777    {
     
    771779        if (ch < 0x20 || ch >= 0x7f || ch == ':' || ch == '\\' || ch == '/')
    772780        {
    773             LogRel(("vboxSfOs2Attach: Malformed folder name: %.*Rhxs (off %#x)\n", pStrName->u16Length, pStrName->String.utf8, off));
    774             return ERROR_INVALID_PARAMETER;
    775         }
    776     }
     781            if (ch == '\0' && !pszTag && off + 1 < pStrName->u16Length && off > 0)
     782            {
     783                pszTag = &pStrName->String.ach[off + 1];
     784                pStrName->u16Length = (uint16_t)off;
     785            }
     786            else
     787            {
     788                LogRel(("vboxSfOs2Attach: Malformed folder name: %.*Rhxs (off %#x)\n", pStrName->u16Length, pStrName->String.utf8, off));
     789                return ERROR_INVALID_PARAMETER;
     790            }
     791        }
     792    }
     793
     794    /* Is there a tag following the name? */
    777795
    778796    if (!pVpFsd)
     
    794812            rc = vboxSfOs2EnsureConnected();
    795813            if (RT_SUCCESS(rc))
    796                 rc = vboxSfOs2MapFolder(pStrName, &pFolder);
     814                rc = vboxSfOs2MapFolder(pStrName, pszTag, &pFolder);
    797815        }
    798816        if (pFolder && RT_SUCCESS(rc))
     
    919937
    920938        /* Try copy out the data. */
    921         if (cbParam >= sizeof(USHORT) + pFolder->cchName + 1)
    922         {
    923             *pcbParam = (uint16_t)sizeof(USHORT) + pFolder->cchName + 1;
     939        if (cbParam >= sizeof(USHORT) + pFolder->cbNameAndTag)
     940        {
     941            *pcbParam = (uint16_t)sizeof(USHORT) + pFolder->cbNameAndTag;
    924942            cbParam = pFolder->cchName + 1;
    925943            rc = KernCopyOut(pbData, &cbParam, sizeof(cbParam));
    926944            if (rc != NO_ERROR)
    927                 rc = KernCopyOut(pbData + sizeof(USHORT), pFolder->szName, pFolder->cchName + 1);
     945                rc = KernCopyOut(pbData + sizeof(USHORT), pFolder->szName, pFolder->cbNameAndTag);
    928946        }
    929947        else
  • trunk/src/VBox/Additions/os2/VBoxSF/VBoxSFInternal.h

    r75337 r75405  
    7878    USHORT              hVpb;
    7979
     80    /** The length of the name and tag, including zero terminators and such. */
     81    uint16_t            cbNameAndTag;
    8082    /** The length of the folder name. */
    8183    uint8_t             cchName;
    82     /** The shared folder name. */
     84    /** The shared folder name.  If there is a tag it follows as a second string. */
    8385    char                szName[RT_FLEXIBLE_ARRAY];
    8486} VBOXSFFOLDER;
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