DrvDiskIntegrity.cpp revision fb7b8c126ea3bc0adf9dd2b2b6a43870ee41853a
/* $Id$ */
/** @file
* VBox storage devices: Disk integrity check.
*/
/*
* Copyright (C) 2006-2010 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "Builtins.h"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* Disk segment.
*/
typedef struct DRVDISKSEGMENT
{
/** AVL core. */
/** Size of the segment */
/** Data for this segment */
/**
* Disk integrity driver instance data.
*
* @implements PDMIMEDIA
*/
typedef struct DRVDISKINTEGRITY
{
/** Pointer driver instance. */
/** Pointer to the media driver below us.
* This is NULL if the media is not mounted. */
/** Our media interface */
/** AVL tree containing the disk blocks to check. */
/* -=-=-=-=- IMedia -=-=-=-=- */
/** Makes a PDRVDISKINTEGRITY out of a PPDMIMEDIA. */
#define PDMIMEDIA_2_DRVDISKINTEGRITY(pInterface) ( (PDRVDISKINTEGRITY)((uintptr_t)pInterface - RT_OFFSETOF(DRVDISKINTEGRITY, IMedia)) )
/*******************************************************************************
* Media interface methods *
*******************************************************************************/
/** @copydoc PDMIMEDIA::pfnRead */
{
if (RT_FAILURE(rc))
return rc;
/* Compare read data */
while (cbLeft)
{
bool fCmp = false;
unsigned offSeg = 0;
if (!pSeg)
{
/* Get next segment */
if (!pSeg)
{
/* No data in the tree for this read. Assume everything is ok. */
}
else
}
else
{
fCmp = true;
}
if ( fCmp
{
unsigned offWrong = 0;
AssertMsgFailed(("Corrupted disk at offset %llu (%u bytes in the current read buffer)!\n",
}
}
return rc;
}
/** @copydoc PDMIMEDIA::pfnWrite */
{
if (RT_FAILURE(rc))
return rc;
/* Update the segments */
while (cbLeft)
{
bool fSet = false;
unsigned offSeg = 0;
if (!pSeg)
{
/* Get next segment */
if ( !pSeg
else
/* Create new segment */
if (pSeg)
{
else
{
fSet = true;
}
}
}
else
{
fSet = true;
}
if (fSet)
{
}
}
return rc;
}
/** @copydoc PDMIMEDIA::pfnFlush */
{
}
/** @copydoc PDMIMEDIA::pfnGetSize */
{
}
/** @copydoc PDMIMEDIA::pfnIsReadOnly */
{
}
/** @copydoc PDMIMEDIA::pfnBiosGetPCHSGeometry */
{
}
/** @copydoc PDMIMEDIA::pfnBiosSetPCHSGeometry */
{
}
/** @copydoc PDMIMEDIA::pfnBiosGetLCHSGeometry */
{
}
/** @copydoc PDMIMEDIA::pfnBiosSetLCHSGeometry */
{
}
/** @copydoc PDMIMEDIA::pfnGetUuid */
{
}
/* -=-=-=-=- IBase -=-=-=-=- */
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
{
return NULL;
}
/* -=-=-=-=- driver interface -=-=-=-=- */
{
return VINF_SUCCESS;
}
/**
* @copydoc FNPDMDRVDESTRUCT
*/
{
if (pThis->pTreeSegments)
{
}
}
/**
* Construct a disk integrity driver instance.
*
* @copydoc FNPDMDRVCONSTRUCT
*/
{
/*
* Validate configuration.
*/
/*
* Initialize most of the data members.
*/
/* IBase. */
/* IMedia */
/*
* Try attach driver below and query it's media interface.
*/
if (RT_FAILURE(rc))
N_("No media or async media interface below"));
/** Create the AVL tree. */
if (!pThis->pTreeSegments)
rc = VERR_NO_MEMORY;
return VINF_SUCCESS;
}
/**
* Block driver registration record.
*/
const PDMDRVREG g_DrvDiskIntegrity =
{
/* u32Version */
/* szName */
"DiskIntegrity",
/* szRCMod */
"",
/* szR0Mod */
"",
/* pszDescription */
"Disk integrity driver.",
/* fFlags */
/* fClass. */
/* cMaxInstances */
~0,
/* cbInstance */
sizeof(DRVDISKINTEGRITY),
/* pfnConstruct */
/* pfnDestruct */
/* pfnRelocate */
NULL,
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
NULL,
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnAttach */
NULL,
/* pfnDetach */
NULL,
/* pfnPowerOff */
NULL,
/* pfnSoftReset */
NULL,
/* u32EndVersion */
};