GuestFileImpl.cpp revision 462e60a19d02a99b2b1a5c08dff74bb0808d707c
/* $Id$ */
/** @file
* VirtualBox Main - Guest file handling.
*/
/*
* Copyright (C) 2012-2013 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "GuestFileImpl.h"
#include "GuestSessionImpl.h"
#include "GuestCtrlImplPrivate.h"
#include "ConsoleImpl.h"
#include "Global.h"
#include "AutoCaller.h"
#ifdef LOG_GROUP
#endif
#define LOG_GROUP LOG_GROUP_GUEST_CONTROL
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
{
LogFlowThisFunc(("\n"));
return BaseFinalConstruct();
}
void GuestFile::FinalRelease(void)
{
uninit();
}
// public initializer/uninitializer for internal purposes only
/////////////////////////////////////////////////////////////////////////////
int GuestFile::init(Console *pConsole, GuestSession *pSession, ULONG uFileID, const GuestFileOpenInfo &openInfo)
{
LogFlowThisFunc(("pConsole=%p, pSession=%p, uFileID=%RU32, strPath=%s\n",
/* Enclose the state transition NotReady->InInit->Ready. */
AutoInitSpan autoInitSpan(this);
if (RT_SUCCESS(vrc))
{
mData.mInitialSize = 0;
/* Confirm a successful initialization when it's the case. */
return vrc;
}
return vrc;
}
/**
* Uninitializes the instance.
* Called from FinalRelease().
*/
{
LogFlowThisFunc(("\n"));
/* Enclose the state transition Ready->InUninit->NotReady. */
AutoUninitSpan autoUninitSpan(this);
if (autoUninitSpan.uninitDone())
return;
#ifdef VBOX_WITH_GUEST_CONTROL
/*
* Cancel + remove all callbacks + waiters.
* Note: Deleting them is the job of the caller!
*/
#endif
}
/////////////////////////////////////////////////////////////////////////////
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
/** @todo For 4.3: Change ULONG* to BSTR* ?*/
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
/** @todo For 4.3: Change ULONG* to BSTR* ?*/
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
// private methods
/////////////////////////////////////////////////////////////////////////////
int GuestFile::callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
{
#ifdef DEBUG
LogFlowThisFunc(("strName=%s, uContextID=%RU32, uFunction=%RU32, pSvcCb=%p\n",
#endif
/* Get the optional callback associated to this context ID.
* The callback may not be around anymore if just kept locally by the caller when
* doing the actual HGCM sending stuff. */
{
#ifdef DEBUG
LogFlowThisFunc(("pCallback=%p, CID=%RU32, Count=%RU32\n",
#endif
}
int vrc;
{
case GUEST_DISCONNECTED:
break;
case GUEST_FILE_NOTIFY:
break;
default:
/* Silently ignore not implemented functions. */
break;
}
#ifdef DEBUG
#endif
return vrc;
}
/* static */
{
return 0; /** @todo Implement me! */
}
/* static */
{
while (*pc != '\0')
{
switch (*pc++)
{
case 'r':
break;
case 'w':
break;
default:
/* Silently skip unknown values. */
break;
}
}
return uOpenMode;
}
int GuestFile::onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, GuestCtrlCallback *pCallback, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData)
{
return VERR_INVALID_PARAMETER;
/* pSvcCb->mpaParms[0] always contains the context ID. */
LogFlowThisFunc(("strName=%s, uType=%RU32, pvData=%p, cbData=%RU32, pCallback=%p\n",
/* Signal callback in every case (if available). */
int vrc = VINF_SUCCESS;
if (pCallback)
{
if (RT_SUCCESS(vrc))
}
return vrc;
}
int GuestFile::onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, GuestCtrlCallback *pCallback, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData)
{
/* First, signal callback in every case. */
if (pCallback)
/** @todo More on onGuestDisconnected? */
int vrc = VINF_SUCCESS;
return vrc;
}
{
LogFlowThisFunc(("strFile=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%RU32\n",
/* Wait until the caller function (if kicked off by a thread)
* has returned and continue operation. */
if (uProtocol < 2)
return VERR_NOT_SUPPORTED;
int vrc = VINF_SUCCESS;
uint32_t uContextID = 0;
try
{
pCallbackOpen = new GuestCtrlCallback();
}
{
}
if (RT_SUCCESS(vrc))
{
/* Create callback and add it to the map. */
if (RT_SUCCESS(vrc))
}
if (RT_SUCCESS(vrc))
{
if (RT_SUCCESS(vrc))
{
/* Prepare HGCM call. */
int i = 0;
/* Note: Don't hold the write lock in here. */
}
/* Drop the write lock again before waiting. */
if (RT_SUCCESS(vrc))
{
/*
* Let's wait for the process being started.
*/
LogFlowThisFunc(("Waiting for callback (30s) ...\n"));
{
if (RT_SUCCESS(guestRc))
{
}
if (pGuestRc)
}
else
vrc = VERR_TIMEOUT;
}
if (RT_SUCCESS(vrc))
}
return vrc;
}
// implementation of public methods
/////////////////////////////////////////////////////////////////////////////
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
/*
* Release autocaller before calling uninit.
*/
uninit();
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
#endif /* VBOX_WITH_GUEST_CONTROL */
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestFile::ReadAt(LONG64 aOffset, ULONG aToRead, ULONG aTimeoutMS, ComSafeArrayOut(BYTE, aData))
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
#endif /* VBOX_WITH_GUEST_CONTROL */
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
#endif /* VBOX_WITH_GUEST_CONTROL */
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
#endif /* VBOX_WITH_GUEST_CONTROL */
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestFile::WriteAt(LONG64 aOffset, ComSafeArrayIn(BYTE, aData), ULONG aTimeoutMS, ULONG *aWritten)
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
#endif /* VBOX_WITH_GUEST_CONTROL */
}