DrvRawFile.cpp revision 1e1273b11e17928ec3c3a8fff45121aa7a169413
/* $Id$ */
/** @file
* VBox stream drivers - Raw file output.
*/
/*
* Copyright (C) 2006-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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_DEFAULT
#include <iprt/semaphore.h>
#include "VBoxDD.h"
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** Converts a pointer to DRVRAWFILE::IMedia to a PDRVRAWFILE. */
#define PDMISTREAM_2_DRVRAWFILE(pInterface) ( (PDRVRAWFILE)((uintptr_t)pInterface - RT_OFFSETOF(DRVRAWFILE, IStream)) )
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* Raw file output driver instance data.
*
* @implements PDMISTREAM
*/
typedef struct DRVRAWFILE
{
/** The stream interface. */
/** Pointer to the driver instance. */
/** Pointer to the file name. (Freed by MM) */
char *pszLocation;
/** Flag whether VirtualBox represents the server or client side. */
} DRVRAWFILE, *PDRVRAWFILE;
/* -=-=-=-=- PDMISTREAM -=-=-=-=- */
/** @copydoc PDMISTREAM::pfnWrite */
static DECLCALLBACK(int) drvRawFileWrite(PPDMISTREAM pInterface, const void *pvBuf, size_t *pcbWrite)
{
int rc = VINF_SUCCESS;
{
#if 0
/* don't flush here, takes too long and we will loose characters */
if (RT_SUCCESS(rc))
#endif
}
return rc;
}
/* -=-=-=-=- PDMIBASE -=-=-=-=- */
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
{
return NULL;
}
/* -=-=-=-=- PDMDRVREG -=-=-=-=- */
/**
* Power off a raw output stream driver instance.
*
* This does most of the destruction work, to avoid ordering dependencies.
*
* @param pDrvIns The driver instance data.
*/
{
}
/**
* Destruct a raw output stream driver instance.
*
* Most VM resources are freed by the VM. This callback is provided so that
* any non-VM resources can be freed correctly.
*
* @param pDrvIns The driver instance data.
*/
{
if (pThis->pszLocation)
{
}
}
/**
* Construct a raw output stream driver instance.
*
* @copydoc FNPDMDRVCONSTRUCT
*/
{
/*
* Init the static parts.
*/
/* IBase */
/* IStream */
/*
* Read the configuration.
*/
if (RT_FAILURE(rc))
/*
* Open the raw file.
*/
rc = RTFileOpen(&pThis->hOutputFile, pThis->pszLocation, RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_NONE);
if (RT_FAILURE(rc))
{
return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("RawFile#%d failed to create the raw output file %s"), pDrvIns->iInstance, pThis->pszLocation);
}
return VINF_SUCCESS;
}
/**
* Raw file driver registration record.
*/
const PDMDRVREG g_DrvRawFile =
{
/* u32Version */
/* szName */
"RawFile",
/* szRCMod */
"",
/* szR0Mod */
"",
/* pszDescription */
"RawFile stream driver.",
/* fFlags */
/* fClass. */
/* cMaxInstances */
~0U,
/* cbInstance */
sizeof(DRVRAWFILE),
/* pfnConstruct */
/* pfnDestruct */
/* pfnRelocate */
NULL,
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
NULL,
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnAttach */
NULL,
/* pfnDetach */
NULL,
/* pfnPowerOff */
/* pfnSoftReset */
NULL,
/* u32EndVersion */
};