/** @file
* VD Container API - internal interfaces.
*/
/*
* Copyright (C) 2011-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.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___VBox_VD_Interfaces_Internal_h
#define ___VBox_VD_Interfaces_Internal_h
/**
* Interface to get the parent state.
*
* Per-operation interface. Optional, present only if there is a parent, and
* used only internally for compacting.
*/
typedef struct VDINTERFACEPARENTSTATE
{
/**
* Common interface header.
*/
/**
* Read data callback.
*
* @return VBox status code.
* @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
* @param pvUser The opaque data passed for the operation.
* @param uOffset Offset of first reading byte from start of disk.
* Must be aligned to a sector boundary.
* @param pvBuffer Pointer to buffer for reading data.
* @param cbBuffer Number of bytes to read.
* Must be aligned to a sector boundary.
*/
DECLR3CALLBACKMEMBER(int, pfnParentRead, (void *pvUser, uint64_t uOffset, void *pvBuffer, size_t cbBuffer));
/**
* Get parent state interface from interface list.
*
* @return Pointer to the first parent state interface in the list.
* @param pVDIfs Pointer to the interface list.
*/
{
/* Check that the interface descriptor is a progress interface. */
("Not a parent state interface"), NULL);
return (PVDINTERFACEPARENTSTATE)pIf;
}
/** Forward declaration. Only visible in the VBoxHDD module. */
/** I/O context */
/** Storage backend handle. */
/** Pointer to a storage backend handle. */
/**
*
* @return VBox status code.
* VINF_SUCCESS if everything was successful and the transfer can continue.
* VERR_VD_ASYNC_IO_IN_PROGRESS if there is another data transfer pending.
* @param pBackendData The opaque backend data.
* @param pIoCtx I/O context associated with this request.
* @param rcReq Status code for the completed request.
*/
typedef DECLCALLBACK(int) FNVDXFERCOMPLETED(void *pBackendData, PVDIOCTX pIoCtx, void *pvUser, int rcReq);
/** Pointer to FNVDXFERCOMPLETED() */
/** Metadata transfer handle. */
/** Pointer to a metadata transfer handle. */
/**
* Internal I/O interface between the generic VD layer and the backends.
*
* Per-image. Always passed to backends.
*/
typedef struct VDINTERFACEIOINT
{
/**
* Common interface header.
*/
/**
* Open callback
*
* @return VBox status code.
* @param pvUser The opaque data passed on container creation.
* @param pszLocation Name of the location to open.
* @param fOpen Flags for opening the backend.
* See RTFILE_O_* #defines, inventing another set
* of open flags is not worth the mapping effort.
* @param ppStorage Where to store the storage handle.
*/
/**
* Close callback.
*
* @return VBox status code.
* @param pvUser The opaque data passed on container creation.
* @param pStorage The storage handle to close.
*/
/**
* Delete callback.
*
* @return VBox status code.
* @param pvUser The opaque data passed on container creation.
* @param pcszFilename Name of the file to delete.
*/
/**
* Move callback.
*
* @return VBox status code.
* @param pvUser The opaque data passed on container creation.
* @param pcszSrc The path to the source file.
* @param pcszDst The path to the destination file.
* This file will be created.
* @param fMove A combination of the RTFILEMOVE_* flags.
*/
DECLR3CALLBACKMEMBER(int, pfnMove, (void *pvUser, const char *pcszSrc, const char *pcszDst, unsigned fMove));
/**
* Returns the free space on a disk.
*
* @return VBox status code.
* @param pvUser The opaque data passed on container creation.
* @param pcszFilename Name of a file to identify the disk.
* @param pcbFreeSpace Where to store the free space of the disk.
*/
DECLR3CALLBACKMEMBER(int, pfnGetFreeSpace, (void *pvUser, const char *pcszFilename, int64_t *pcbFreeSpace));
/**
* Returns the last modification timestamp of a file.
*
* @return VBox status code.
* @param pvUser The opaque data passed on container creation.
* @param pcszFilename Name of a file to identify the disk.
* @param pModificationTime Where to store the timestamp of the file.
*/
DECLR3CALLBACKMEMBER(int, pfnGetModificationTime, (void *pvUser, const char *pcszFilename, PRTTIMESPEC pModificationTime));
/**
* Returns the size of the opened storage backend.
*
* @return VBox status code.
* @param pvUser The opaque data passed on container creation.
* @param pStorage The storage handle to get the size from.
* @param pcbSize Where to store the size of the storage backend.
*/
/**
* Sets the size of the opened storage backend if possible.
*
* @return VBox status code.
* @retval VERR_NOT_SUPPORTED if the backend does not support this operation.
* @param pvUser The opaque data passed on container creation.
* @param pStorage The storage handle.
* @param cbSize The new size of the image.
*/
/**
* Initiate a read request for user data.
*
* @return VBox status code.
* @param pvUser The opaque user data passed on container creation.
* @param pStorage The storage handle.
* @param uOffset The offset to start reading from.
* @param cbRead How many bytes to read.
*/
/**
* Initiate a write request for user data.
*
* @return VBox status code.
* @param pvUser The opaque user data passed on container creation.
* @param pStorage The storage handle.
* @param uOffset The offset to start writing to.
* @param cbWrite How many bytes to write.
* @param pfnCompleted Completion callback.
* @param pvCompleteUser Opaque user data passed in the completion callback.
*/
void *pvCompleteUser));
/**
* Reads metadata from storage.
* The current I/O context will be halted.
*
* @returns VBox status code.
* @param pvUser The opaque user data passed on container creation.
* @param pStorage The storage handle.
* @param uOffset Offset to start reading from.
* @param pvBuffer Where to store the data.
* @param cbBuffer How many bytes to read.
* @param pIoCtx The I/O context which triggered the read.
* @param ppMetaXfer Where to store the metadata transfer handle on success.
* @param pfnCompleted Completion callback.
* @param pvCompleteUser Opaque user data passed in the completion callback.
*
* @notes If pIoCtx is NULL the metadata read is handled synchronously
* i.e. the call returns only if the data is available in the given
* buffer. ppMetaXfer, pfnCompleted and pvCompleteUser are ignored in that case.
* or when doing certain operations like resizing, compacting or repairing
* the disk.
*/
void *pvCompleteUser));
/**
* Writes metadata to storage.
*
* @returns VBox status code.
* @param pvUser The opaque user data passed on container creation.
* @param pStorage The storage handle.
* @param uOffset Offset to start writing to.
* @param pvBuffer Written data.
* @param cbBuffer How many bytes to write.
* @param pIoCtx The I/O context which triggered the write.
* @param pfnCompleted Completion callback.
* @param pvCompleteUser Opaque user data passed in the completion callback.
*
* @notes See pfnReadMeta().
*/
void *pvCompleteUser));
/**
* Releases a metadata transfer handle.
* The free space can be used for another transfer.
*
* @returns nothing.
* @param pvUser The opaque user data passed on container creation.
* @param pMetaXfer The metadata transfer handle to release.
*/
/**
* Initiates a flush request.
*
* @return VBox status code.
* @param pvUser The opaque data passed on container creation.
* @param pStorage The storage handle to flush.
* @param pIoCtx I/O context which triggered the flush.
* @param pfnCompleted Completion callback.
* @param pvCompleteUser Opaque user data passed in the completion callback.
*
* @notes See pfnReadMeta().
*/
void *pvCompleteUser));
/**
* Copies a buffer into the I/O context.
*
* @return Number of bytes copied.
* @param pvUser The opaque user data passed on container creation.
* @param pIoCtx I/O context to copy the data to.
* @param pvBuffer Buffer to copy.
* @param cbBuffer Number of bytes to copy.
*/
/**
* Copies data from the I/O context into a buffer.
*
* @return Number of bytes copied.
* @param pvUser The opaque user data passed on container creation.
* @param pIoCtx I/O context to copy the data from.
* @param pvBuffer Destination buffer.
* @param cbBuffer Number of bytes to copy.
*/
/**
* Sets the buffer of the given context to a specific byte.
*
* @return Number of bytes set.
* @param pvUser The opaque user data passed on container creation.
* @param pIoCtx I/O context to copy the data from.
* @param ch The byte to set.
* @param cbSet Number of bytes to set.
*/
/**
* Creates a segment array from the I/O context data buffer.
*
* @returns Number of bytes the array describes.
* @param pvUser The opaque user data passed on container creation.
* @param pIoCtx I/O context to copy the data from.
* @param paSeg The uninitialized segment array.
* If NULL pcSeg will contain the number of segments needed
* to describe the requested amount of data.
* @param pcSeg The number of segments the given array has.
* This will hold the actual number of entries needed upon return.
* @param cbData Number of bytes the new array should describe.
*/
/**
* Marks the given number of bytes as completed and continues the I/O context.
*
* @returns nothing.
* @param pvUser The opaque user data passed on container creation.
* @param pIoCtx The I/O context.
* @param rcReq Status code the request completed with.
* @param cbCompleted Number of bytes completed.
*/
/**
* Returns whether the given I/O context must be treated synchronously.
*
* @returns true if the I/O context must be processed synchronously
* false otherwise.
* @param pvUser The opaque user data passed on container creation.
* @param pIoCtx The I/O context.
*/
/**
* Returns whether the user buffer of the I/O context is complete zero
* from to current position upto the given number of bytes.
*
* @returns true if the I/O context user buffer consists solely of zeros
* false otherwise.
* @param pvUser The opaque user data passed on container creation.
* @param pIoCtx The I/O context.
* @param cbCheck Number of bytes to check for zeros.
* @param fAdvance Flag whether to advance the buffer pointer if true
* is returned.
*/
/**
* Returns the data unit size, i.e. the smallest size for a transfer.
* (similar to the sector size of disks).
*
* @returns The data unit size.
* @param pvUser The opaque user data passed on container creation.
* @param pIoCtx The I/O context.
*/
/**
* Get internal I/O interface from interface list.
*
* @return Pointer to the first internal I/O interface in the list.
* @param pVDIfs Pointer to the interface list.
*/
{
/* Check that the interface descriptor is a progress interface. */
("Not an internal I/O interface"), NULL);
return (PVDINTERFACEIOINT)pIf;
}
{
}
{
}
{
}
{
}
{
}
DECLINLINE(int) vdIfIoIntFileGetModificationTime(PVDINTERFACEIOINT pIfIoInt, const char *pcszFilename,
{
}
{
}
{
}
{
}
{
}
{
}
{
}
void *pvCompleteUser)
{
}
void *pvCompleteUser)
{
}
void *pvCompleteUser)
{
}
{
}
void *pvCompleteUser)
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
/**
* Interface for the metadata traverse callback.
*
* Per-operation interface. Present only for the metadata traverse callback.
*/
typedef struct VDINTERFACETRAVERSEMETADATA
{
/**
* Common interface header.
*/
/**
* Traverse callback.
*
* @returns VBox status code.
* @param pvUser The opaque data passed for the operation.
* @param pvMetadataChunk Pointer to a chunk of the image metadata.
* @param cbMetadataChunk Size of the metadata chunk
*/
/**
* Get parent state interface from interface list.
*
* @return Pointer to the first parent state interface in the list.
* @param pVDIfs Pointer to the interface list.
*/
{
/* Check that the interface descriptor the correct interface. */
("Not a traverse metadata interface"), NULL);
return (PVDINTERFACETRAVERSEMETADATA)pIf;
}
/** @} */
#endif