DrvMediaISO.cpp revision 1e1273b11e17928ec3c3a8fff45121aa7a169413
/* $Id$ */
/** @file
* VBox storage devices: ISO image media driver
*/
/*
* 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_DRV_ISO
#include "VBoxDD.h"
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** Converts a pointer to MEDIAISO::IMedia to a PRDVMEDIAISO. */
#define PDMIMEDIA_2_DRVMEDIAISO(pInterface) ( (PDRVMEDIAISO)((uintptr_t)pInterface - RT_OFFSETOF(DRVMEDIAISO, IMedia)) )
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* Block driver instance data.
*
* @implements PDMIMEDIA
*/
typedef struct DRVMEDIAISO
{
/** The media interface. */
/** Pointer to the driver instance. */
/** Pointer to the filename. (Freed by MM) */
char *pszFilename;
/** File handle of the ISO file. */
} DRVMEDIAISO, *PDRVMEDIAISO;
/* -=-=-=-=- PDMIMEDIA -=-=-=-=- */
/** @copydoc PDMIMEDIA::pfnGetSize */
{
if (RT_SUCCESS(rc))
{
return cbFile;
}
return 0;
}
/** @copydoc PDMIMEDIA::pfnBiosGetPCHSGeometry */
static DECLCALLBACK(int) drvMediaISOBiosGetPCHSGeometry(PPDMIMEDIA pInterface, PPDMMEDIAGEOMETRY pPCHSGeometry)
{
return VERR_NOT_IMPLEMENTED;
}
/** @copydoc PDMIMEDIA::pfnBiosSetPCHSGeometry */
static DECLCALLBACK(int) drvMediaISOBiosSetPCHSGeometry(PPDMIMEDIA pInterface, PCPDMMEDIAGEOMETRY pPCHSGeometry)
{
return VERR_NOT_IMPLEMENTED;
}
/** @copydoc PDMIMEDIA::pfnBiosGetLCHSGeometry */
static DECLCALLBACK(int) drvMediaISOBiosGetLCHSGeometry(PPDMIMEDIA pInterface, PPDMMEDIAGEOMETRY pLCHSGeometry)
{
return VERR_NOT_IMPLEMENTED;
}
/** @copydoc PDMIMEDIA::pfnBiosSetLCHSGeometry */
static DECLCALLBACK(int) drvMediaISOBiosSetLCHSGeometry(PPDMIMEDIA pInterface, PCPDMMEDIAGEOMETRY pLCHSGeometry)
{
return VERR_NOT_IMPLEMENTED;
}
/**
* Read bits.
*
* @see PDMIMEDIA::pfnRead for details.
*/
static DECLCALLBACK(int) drvMediaISORead(PPDMIMEDIA pInterface, uint64_t off, void *pvBuf, size_t cbRead)
{
LogFlow(("drvMediaISORead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n", off, pvBuf, cbRead, pThis->pszFilename));
/*
* Seek to the position and read.
*/
if (RT_SUCCESS(rc))
Log2(("drvMediaISORead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n"
"%16.*Rhxd\n",
else
AssertMsgFailed(("RTFileReadAt(%RTfile, %#llx, %p, %#x) -> %Rrc ('%s')\n",
return rc;
}
/** @copydoc PDMIMEDIA::pfnWrite */
static DECLCALLBACK(int) drvMediaISOWrite(PPDMIMEDIA pInterface, uint64_t off, const void *pvBuf, size_t cbWrite)
{
AssertMsgFailed(("Attempt to write to an ISO file!\n"));
return VERR_NOT_IMPLEMENTED;
}
/** @copydoc PDMIMEDIA::pfnFlush */
{
/* No buffered data that still needs to be written. */
return VINF_SUCCESS;
}
/** @copydoc PDMIMEDIA::pfnGetUuid */
{
LogFlow(("drvMediaISOGetUuid: returns VERR_NOT_IMPLEMENTED\n"));
return VERR_NOT_IMPLEMENTED;
}
/** @copydoc PDMIMEDIA::pfnIsReadOnly */
{
return true;
}
/* -=-=-=-=- PDMIBASE -=-=-=-=- */
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
{
return NULL;
}
/* -=-=-=-=- PDMDRVREG -=-=-=-=- */
/**
* Destruct a 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->pszFilename)
{
}
}
/**
* Construct a ISO media driver instance.
*
* @copydoc FNPDMDRVCONSTRUCT
*/
{
/*
* Init the static parts.
*/
/* IBase */
/* IMedia */
/*
* Read the configuration.
*/
char *pszName;
if (RT_FAILURE(rc))
/*
* Open the image.
*/
if (RT_SUCCESS(rc))
{
}
else
{
}
return rc;
}
/**
* ISO media driver registration record.
*/
const PDMDRVREG g_DrvMediaISO =
{
/* u32Version */
/* szName */
"MediaISO",
/* szRCMod */
"",
/* szR0Mod */
"",
/* pszDescription */
"ISO media access driver.",
/* fFlags */
/* fClass. */
/* cMaxInstances */
~0U,
/* cbInstance */
sizeof(DRVMEDIAISO),
/* pfnConstruct */
/* pfnDestruct */
/* pfnRelocate */
NULL,
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
NULL,
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnAttach */
NULL,
/* pfnDetach */
NULL,
/* pfnPowerOff */
NULL,
/* pfnSoftReset */
NULL,
/* u32EndVersion */
};