mappings.cpp revision ba31bc205e96548d3557ae82087dc020a52b6a0a
/** @file
* Shared Folders: Mappings support.
*/
/*
* Copyright (C) 2006-2007 Oracle Corporation
*
* 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.
*/
#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)
{
unsigned root;
{
}
}
{
/* 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;
}
SHFLROOT 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;
}
{
{
if ( iMapping != SHFL_ROOT_NIL
{
return &FolderMapping[iMapping];
}
}
return NULL;
}
{
unsigned root;
{
{
return root;
}
}
return SHFL_ROOT_NIL;
}
{
unsigned i;
for (i=0; i<SHFL_MAX_MAPPINGS; i++)
{
if (FolderMapping[i].fValid == true)
{
{
if (root != SHFL_ROOT_NIL)
{
if (pRoot)
{
}
return &FolderMapping[i];
}
else
{
AssertFailed();
}
}
}
}
return NULL;
}
{
unsigned root;
{
{
return;
}
}
AssertFailed();
}
{
unsigned root;
{
{
return;
}
}
AssertFailed();
}
/*
* We are always executed from one specific HGCM thread. So thread safe.
*/
{
unsigned 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;
}
{
unsigned 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;
}
/**
* Note: If pMappings/*pcMappings is smaller than the actual amount of mappings
* that *could* have been returned *pcMappings contains the required buffer size
* so that the caller can retry the operation if wanted.
*/
{
int rc = VINF_SUCCESS;
LogFlow(("vbsfMappingsQuery: pClient = %p, pMappings = %p, pcMappings = %p, *pcMappings = %d\n",
for (uint32_t i = 0; i < SHFL_MAX_MAPPINGS; i++)
{
if ( pFolderMapping != NULL
&& pFolderMapping->fValid == true)
{
if (idx < *pcMappings)
{
/* Skip mappings which are not marked for auto-mounting if
* the SHFL_MF_AUTOMOUNT flag ist set. */
&& !pFolderMapping->fAutoMount)
continue;
idx++;
}
cMappings++;
}
}
/* Return actual number of mappings, regardless whether the handed in
* mapping buffer was big enough. */
*pcMappings = cMappings;
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 rc = VINF_SUCCESS;
LogFlow(("vbsfMappingsQueryAutoMount: pClient = %p, root = %d\n",
if (pFolderMapping == NULL)
{
return VERR_INVALID_PARAMETER;
}
if (pFolderMapping->fValid == true)
else
return rc;
}
{
{
}
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;
}