VBoxGuestR3LibSharedFolders.cpp revision 84f633d28fd1840520118fcc4ff7c726aeaa9184
/* $Id$ */
/** @file
* VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, shared folders.
*/
/*
* Copyright (C) 2010-2012 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.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "VBGLR3Internal.h"
/**
* Connects to the shared folder service.
*
* @returns VBox status code
* @param pu32ClientId Where to put the client id on success. The client id
* must be passed to all the other calls to the service.
*/
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
}
return rc;
}
/**
* Disconnect from the shared folder service.
*
* @returns VBox status code.
* @param u32ClientId The client id returned by VbglR3InfoSvcConnect().
*/
{
if (RT_SUCCESS(rc))
return rc;
}
/**
* Checks whether a shared folder share exists or not.
*
* @returns True if shared folder exists, false if not.
* @param u32ClientId The client id returned by VbglR3InfoSvcConnect().
* @param pszShareName Shared folder name to check.
*/
{
/** @todo Use some caching here? */
bool fFound = false;
&paMappings, &cMappings);
if (RT_SUCCESS(rc))
{
{
if ( RT_SUCCESS(rc)
&& *pszName)
{
fFound = true;
}
}
}
return fFound;
}
/**
* Get the list of available shared folders.
*
* @returns VBox status code.
* @param u32ClientId The client id returned by VbglR3SharedFolderConnect().
* @param fAutoMountOnly Flag whether only auto-mounted shared folders
* should be reported.
* @param ppaMappings Allocated array which will retrieve the mapping info. Needs
* to be freed with VbglR3SharedFolderFreeMappings() later.
* @param pcMappings The number of mappings returned in @a ppaMappings.
*/
{
*pcMappings = 0;
*ppaMappings = NULL;
/* Set the mapping flags. */
if (fAutoMountOnly) /* We only want the mappings which get auto-mounted. */
/*
* Prepare and get the actual mappings from the host service.
*/
int rc = VINF_SUCCESS;
if (!ppaMappingsTemp)
return VERR_NO_MEMORY;
do
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
/* Do we have more mappings than we have allocated space for? */
if (rc == VINF_BUFFER_OVERFLOW)
{
cMappings = *pcMappings;
}
}
}
} while (rc == VINF_BUFFER_OVERFLOW);
if ( RT_FAILURE(rc)
|| !*pcMappings)
{
}
/* In this case, just return success with 0 mappings */
if ( rc == VERR_INVALID_PARAMETER
&& fAutoMountOnly)
rc = VINF_SUCCESS;
return rc;
}
/**
* Frees the shared folder mappings allocated by
* VbglR3SharedFolderGetMappings() before.
*
* @param paMappings What
*/
{
if (paMappings)
}
/**
* Get the real name of a shared folder.
*
* @returns VBox status code.
* @param u32ClientId The client id returned by VbglR3InvsSvcConnect().
* @param u32Root Root ID of shared folder to get the name for.
* @param ppszName Where to return the name string. This shall be
* freed by calling RTStrFree.
*/
{
int rc;
if (pString)
{
{
return VERR_INVALID_PARAMETER;
}
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
}
}
}
else
return rc;
}
/**
* Retrieves the prefix for a shared folder mount point. If no prefix
* is set in the guest properties "sf_" is returned.
*
* @returns VBox status code.
* @param ppszPrefix Where to return the prefix string. This shall be
* freed by calling RTStrFree.
*/
{
int rc;
#ifdef VBOX_WITH_GUEST_PROPS
if (RT_SUCCESS(rc))
{
rc = VbglR3GuestPropReadValueAlloc(u32ClientIdGuestProp, "/VirtualBox/GuestAdd/SharedFolders/MountPrefix", ppszPrefix);
{
#endif
#ifdef VBOX_WITH_GUEST_PROPS
}
}
#endif
return rc;
}
/**
* Retrieves the mount root directory for auto-mounted shared
* folders. mount point. If no string is set (VERR_NOT_FOUND)
* it's up on the caller (guest) to decide where to mount.
*
* @returns VBox status code.
* @param ppszDir Where to return the directory
* string. This shall be freed by
* calling RTStrFree.
*/
{
int rc;
#ifdef VBOX_WITH_GUEST_PROPS
if (RT_SUCCESS(rc))
{
rc = VbglR3GuestPropReadValueAlloc(u32ClientIdGuestProp, "/VirtualBox/GuestAdd/SharedFolders/MountDir", ppszDir);
}
#endif
return rc;
}