VDIoBackend.cpp revision 14a9673ef19f6d8d49f83050d86cb444a55d4008
/** $Id$ */
/** @file
*
* VBox HDD container test utility, I/O backend API
*/
/*
* Copyright (C) 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.
*/
#include "VDIoBackend.h"
#include "VDMemDisk.h"
#include "VDIoBackendMem.h"
typedef struct VDIOBACKEND
{
/** Memory I/O backend handle. */
/** Async I/O manager. */
/** Users of the memory backend. */
volatile uint32_t cRefsIoMem;
/** Users of the file backend. */
} VDIOBACKEND;
typedef struct VDIOSTORAGE
{
/** Pointer to the I/O backend parent. */
/** Completion callback. */
/** Flag whether this storage is backed by a file or memory.disk. */
bool fMemory;
/** Type dependent data. */
union
{
/** Memory disk handle. */
struct
{
/** file handle. */
/** I/O manager file handle. */
} File;
} u;
} VDIOSTORAGE;
static DECLCALLBACK(void) vdIoBackendFileIoComplete(RTAIOMGRFILE hAioMgrFile, int rcReq, void *pvUser)
{
}
{
int rc = VINF_SUCCESS;
if (pIoBackend)
{
}
else
rc = VERR_NO_MEMORY;
return rc;
}
{
if (pIoBackend->pIoMem)
if (pIoBackend->hAioMgr)
}
{
int rc = VINF_SUCCESS;
if (pIoStorage)
{
{
pIoStorage->fMemory = true;
if (RT_SUCCESS(rc))
{
if ( cRefs == 1
&& !pIoBackend->pIoMem)
{
if (RT_FAILURE(rc))
}
}
}
{
pIoStorage->fMemory = false;
if ( cRefs == 1
if (RT_SUCCESS(rc))
{
/* Create file. */
if (RT_SUCCESS(rc))
{
/* Create file handle for I/O manager. */
if (RT_FAILURE(rc))
}
}
if (RT_FAILURE(rc))
}
else
if (RT_FAILURE(rc))
else
}
else
rc = VERR_NO_MEMORY;
return rc;
}
{
if (pIoStorage->fMemory)
{
}
else
{
}
}
{
int rc = VINF_SUCCESS;
if (pIoStorage->fMemory)
{
if (!fSync)
{
pvUser);
}
else
{
switch (enmTxDir)
{
case VDIOTXDIR_READ:
break;
case VDIOTXDIR_WRITE:
break;
case VDIOTXDIR_FLUSH:
break;
default:
}
}
}
else
{
if (!fSync)
{
switch (enmTxDir)
{
case VDIOTXDIR_READ:
break;
case VDIOTXDIR_WRITE:
break;
case VDIOTXDIR_FLUSH:
break;
default:
}
if (rc == VERR_FILE_AIO_IN_PROGRESS)
rc = VINF_SUCCESS;
}
else
{
switch (enmTxDir)
{
case VDIOTXDIR_READ:
break;
case VDIOTXDIR_WRITE:
break;
case VDIOTXDIR_FLUSH:
break;
default:
}
}
}
return rc;
}
{
int rc = VINF_SUCCESS;
if (pIoStorage->fMemory)
{
}
else
return rc;
}
{
int rc = VINF_SUCCESS;
if (pIoStorage->fMemory)
{
}
else
return rc;
}