mappings.cpp revision db6431d7b73ab0741bc1f6d0dd7624e848b89a78
/** @file
* Shared Folders: Mappings support.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include "mappings.h"
/* Shared folders order in the saved state and in the FolderMapping can differ.
* So a translation array of root handle is needed.
*/
void vbsfMappingInit(void)
{
int root;
{
aIndexFromRoot[root] = ~0;
}
}
{
/* Mapping loaded from the saved state with the index. Which means
* the guest uses the iMapping as root handle for this folder.
* Check whether there is the same mapping in FolderMapping and
* update the aIndexFromRoot.
*
* Also update the mapping properties, which were lost: cMappings.
*/
if (root >= SHFL_MAX_MAPPINGS)
{
return VERR_INVALID_PARAMETER;
}
int i;
for (i = 0; i < RT_ELEMENTS(FolderMapping); i++)
{
/* Equal? */
&& memcmp(pLoadedMapping->pMapName, pMapping->pMapName, ShflStringSizeOfBuffer(pMapping->pMapName)) == 0)
{
/* Actual index is i. */
aIndexFromRoot[root] = i;
/* Update the mapping properties. */
return VINF_SUCCESS;
}
}
return VERR_INVALID_PARAMETER;
}
{
{
{
return &FolderMapping[iMapping];
}
}
return NULL;
}
{
int root;
{
{
return root;
}
}
return ~0;
}
{
int i;
for (i=0;i<SHFL_MAX_MAPPINGS;i++)
{
if (FolderMapping[i].fValid == true)
{
{
if (root != ~0)
{
if (pRoot)
{
}
return &FolderMapping[i];
}
else
{
AssertFailed();
}
}
}
}
return NULL;
}
static void vbsfRootHandleAdd(int iMapping)
{
int root;
{
if (aIndexFromRoot[root] == ~0)
{
return;
}
}
AssertFailed();
return;
}
static void vbsfRootHandleRemove(int iMapping)
{
int root;
{
{
aIndexFromRoot[root] = ~0;
return;
}
}
AssertFailed();
return;
}
/*
*
* We are always executed from one specific HGCM thread. So thread safe.
*
*/
{
int i;
/* check for duplicates */
for (i=0;i<SHFL_MAX_MAPPINGS;i++)
{
if (FolderMapping[i].fValid == true)
{
{
return VERR_ALREADY_EXISTS;
}
}
}
for (i=0;i<SHFL_MAX_MAPPINGS;i++)
{
if (FolderMapping[i].fValid == false)
{
return VERR_NO_MEMORY;
return VERR_NO_MEMORY;
FolderMapping[i].fValid = true;
FolderMapping[i].cMappings = 0;
/* Check if the host file system is case sensitive */
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
}
}
break;
}
}
if (i == SHFL_MAX_MAPPINGS)
{
AssertMsgFailed(("vbsfMappingsAdd: no more room to add mapping %ls to %ls!!\n", pFolderName->String.ucs2, pMapName->String.ucs2));
return VERR_TOO_MUCH_DATA;
}
Log(("vbsfMappingsAdd: added mapping %ls to %ls\n", pFolderName->String.ucs2, pMapName->String.ucs2));
return VINF_SUCCESS;
}
{
int i;
for (i=0;i<SHFL_MAX_MAPPINGS;i++)
{
if (FolderMapping[i].fValid == true)
{
{
if (FolderMapping[i].cMappings != 0)
{
return VERR_PERMISSION_DENIED;
}
FolderMapping[i].fValid = false;
break;
}
}
}
if (i == SHFL_MAX_MAPPINGS)
{
return VERR_FILE_NOT_FOUND;
}
return VINF_SUCCESS;
}
{
if (pFolderMapping == NULL)
{
AssertFailed();
return NULL;
}
}
{
if (pFolderMapping == NULL)
{
AssertFailed();
return false;
}
return pFolderMapping->fGuestCaseSensitive;
}
{
if (pFolderMapping == NULL)
{
AssertFailed();
return false;
}
return pFolderMapping->fHostCaseSensitive;
}
{
int rc = VINF_SUCCESS;
LogFlow(("vbsfMappingsQuery: pClient = %p, pMappings = %p, pcMappings = %p, *pcMappings = %d\n",
*pcMappings = 0;
for (uint32_t i=0;i<cMaxMappings;i++)
{
{
}
}
return rc;
}
{
int rc = VINF_SUCCESS;
LogFlow(("vbsfMappingsQuery: pClient = %p, root = %d, *pString = %p\n",
if (pFolderMapping == NULL)
{
return VERR_INVALID_PARAMETER;
}
{
/* not implemented */
AssertFailed();
return VERR_INVALID_PARAMETER;
}
if (pFolderMapping->fValid == true)
{
}
else
return rc;
}
{
int rc = VINF_SUCCESS;
LogFlow(("vbsfMappingsQueryWritable: pClient = %p, root = %d\n",
if (pFolderMapping == NULL)
{
return VERR_INVALID_PARAMETER;
}
if (pFolderMapping->fValid == true)
else
return rc;
}
int vbsfMapFolder (SHFLCLIENTDATA *pClient, PSHFLSTRING pszMapName, RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot)
{
{
}
else
{
}
if (pClient->PathDelimiter == 0)
{
}
else
{
}
{
int rc;
if (RT_FAILURE (rc))
return rc;
}
else
{
}
if (!pFolderMapping)
{
return VERR_FILE_NOT_FOUND;
}
return VINF_SUCCESS;
}
{
int rc = VINF_SUCCESS;
if (pFolderMapping == NULL)
{
AssertFailed();
return VERR_FILE_NOT_FOUND;
}
if (pFolderMapping->cMappings > 0)
Log(("vbsfUnmapFolder\n"));
return rc;
}