VirtualBox

source: vbox/trunk/src/VBox/Devices/Storage/VBoxHDD-newInternal.h@ 2589

Last change on this file since 2589 was 2564, checked in by vboxsync, 18 years ago

Many VMDK block splitup fixes and the start of the create image
function.

File size: 10.9 KB
Line 
1/** @file
2 * Internal header file for VBox HDD Container.
3 */
4
5/*
6 * Copyright (C) 2006 InnoTek Systemberatung GmbH
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License as published by the Free Software Foundation,
12 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 * distribution. VirtualBox OSE is distributed in the hope that it will
14 * be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * If you received this file as part of a commercial VirtualBox
17 * distribution, then only the terms of your commercial VirtualBox
18 * license agreement apply instead of the previous paragraph.
19 */
20
21#ifndef __VBoxHDD_newInternal_h__
22
23
24#include <VBox/pdm.h>
25#include <VBox/VBoxHDD-new.h>
26
27
28/**
29 * Image format backend interface used by VBox HDD Container implementation.
30 */
31typedef struct VBOXHDDBACKEND
32{
33 /**
34 * Open a disk image.
35 *
36 * @returns VBox status code.
37 * @param pszFilename Name of the image file to open. Guaranteed to be available and
38 * unchanged during the lifetime of this image.
39 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
40 * @param pfnError Callback for setting extended error information.
41 * @param pvErrorUser Opaque parameter for pfnError.
42 * @param ppvBackendData Opaque state data for this image.
43 */
44 DECLR3CALLBACKMEMBER(int, pfnOpen, (const char *pszFilename, unsigned uOpenFlags, PFNVDERROR pfnError, void *pvErrorUser, void **ppvBackendData));
45
46 /**
47 * Create a disk image.
48 *
49 * @returns VBox status code.
50 * @param pszFilename Name of the image file to create. Guaranteed to be available and
51 * unchanged during the lifetime of this image.
52 * @param penmType Image type. Both base and diff image types are valid.
53 * @param cbSize Image size in bytes.
54 * @param uImageFlags Flags specifying special image features.
55 * @param pszComment Pointer to image comment. NULL is ok.
56 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
57 * @param pfnProgress Progress callback. Optional. NULL if not to be used.
58 * @param pvUser User argument for the progress callback.
59 * @param pfnError Callback for setting extended error information.
60 * @param pvErrorUser Opaque parameter for pfnError.
61 * @param ppvBackendData Opaque state data for this image.
62 */
63 DECLR3CALLBACKMEMBER(int, pfnCreate, (const char *pszFilename, VDIMAGETYPE penmType, uint64_t cbSize, unsigned uImageFlags, const char *pszComment, unsigned uOpenFlags, PFNVMPROGRESS pfnProgress, void *pvUser, PFNVDERROR pfnError, void *pvErrorUser, void **ppvBackendData));
64
65 /**
66 * Close a disk image.
67 *
68 * @returns VBox status code.
69 * @param pvBackendData Opaque state data for this image.
70 */
71 DECLR3CALLBACKMEMBER(int, pfnClose, (void *pvBackendData));
72
73 /**
74 * Read data from a disk image. The area read never crosses a block
75 * boundary.
76 *
77 * @returns VBox status code.
78 * @returns VINF_VDI_BLOCK_FREE if this image contains no data for this block.
79 * @param pvBackendData Opaque state data for this image.
80 * @param off Offset to start reading from.
81 * @param pvBuf Where to store the read bits.
82 * @param cbRead Number of bytes to read.
83 * @param pcbActuallyRead Pointer to returned number of bytes read.
84 */
85 DECLR3CALLBACKMEMBER(int, pfnRead, (void *pvBackendData, uint64_t off, void *pvBuf, size_t cbRead, size_t *pcbActuallyRead));
86
87 /**
88 * Write data to a disk image. The area written never crosses a block
89 * boundary.
90 *
91 * @returns VBox status code.
92 * @returns VINF_VDI_BLOCK_FREE if this image contains no data for this block and
93 * this is not a full-block write. The write must be repeated with
94 * the correct amount of prefix/postfix data read from the images below
95 * in the image stack. This might not be the most convenient interface,
96 * but it works with arbitrary block sizes, especially when the image
97 * stack uses different block sizes.
98 * @param pvBackendData Opaque state data for this image.
99 * @param off Offset to start writing to.
100 * @param pvBuf Where to retrieve the written bits.
101 * @param cbWrite Number of bytes to write.
102 * @param pcbWriteProcess Pointer to returned number of bytes that could
103 * be processed. In case the function returned
104 * VINF_VDI_BLOCK_FREE this is the number of bytes
105 * that could be written in a full block write,
106 * when prefixed/postfixed by the appropriate
107 * amount of (previously read) padding data.
108 * @param pcbPreRead Pointer to the returned amount of data that must
109 * be prefixed to perform a full block write.
110 * @param pcbPostRead Pointer to the returned amount of data that must
111 * be postfixed to perform a full block write.
112 */
113 DECLR3CALLBACKMEMBER(int, pfnWrite, (void *pvBackendData, uint64_t off, const void *pvBuf, size_t cbWrite, size_t *pcbWriteProcess, size_t *pcbPreRead, size_t *pcbPostRead));
114
115 /**
116 * Flush data to disk.
117 *
118 * @returns VBox status code.
119 * @param pvBackendData Opaque state data for this image.
120 */
121 DECLR3CALLBACKMEMBER(int, pfnFlush, (void *pvBackendData));
122
123 /**
124 * Get the type information for a disk image.
125 *
126 * @returns VBox status code.
127 * @param pvBackendData Opaque state data for this image.
128 * @param penmType Image type of this image.
129 */
130 DECLR3CALLBACKMEMBER(int, pfnGetImageType, (void *pvBackendData, PVDIMAGETYPE penmType));
131
132 /**
133 * Get the size of a disk image.
134 *
135 * @returns size of disk image.
136 * @param pvBackendData Opaque state data for this image.
137 */
138 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize, (void *pvBackendData));
139
140 /**
141 * Get virtual disk geometry stored in a disk image.
142 *
143 * @returns VBox status code.
144 * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the image.
145 * @param pvBackendData Opaque state data for this image.
146 * @param pcCylinders Where to store the number of cylinders. Never NULL.
147 * @param pcHeads Where to store the number of heads. Never NULL.
148 * @param pcSectors Where to store the number of sectors. Never NULL.
149 */
150 DECLR3CALLBACKMEMBER(int, pfnGetGeometry, (void *pvBackendData, unsigned *pcCylinders, unsigned *pcHeads, unsigned *pcSectors));
151
152 /**
153 * Set virtual disk geometry stored in a disk image.
154 * Only called if geometry is different than before.
155 *
156 * @returns VBox status code.
157 * @param pvBackendData Opaque state data for this image.
158 * @param cCylinders Number of cylinders.
159 * @param cHeads Number of heads.
160 * @param cSectors Number of sectors.
161 */
162 DECLR3CALLBACKMEMBER(int, pfnSetGeometry, (void *pvBackendData, unsigned cCylinders, unsigned cHeads, unsigned cSectors));
163
164 /**
165 * Get virtual disk translation mode stored in a disk image.
166 *
167 * @returns VBox status code.
168 * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the image.
169 * @param pvBackendData Opaque state data for this image.
170 * @param penmTranslation Where to store the translation mode. Never NULL.
171 */
172 DECLR3CALLBACKMEMBER(int, pfnGetTranslation, (void *pvBackendData, PPDMBIOSTRANSLATION penmTranslation));
173
174 /**
175 * Set virtual disk translation mode stored in a disk image.
176 * Only called if translation mode is different than before.
177 *
178 * @returns VBox status code.
179 * @param pvBackendData Opaque state data for this image.
180 * @param enmTranslation New translation mode.
181 */
182 DECLR3CALLBACKMEMBER(int, pfnSetTranslation, (void *pvBackendData, PDMBIOSTRANSLATION enmTranslation));
183
184 /**
185 * Get the open flags of a disk image.
186 *
187 * @returns open flags of disk image.
188 * @param pvBackendData Opaque state data for this image.
189 */
190 DECLR3CALLBACKMEMBER(unsigned, pfnGetOpenFlags, (void *pvBackendData));
191
192 /**
193 * Set the open flags of a disk image. May cause the image to be locked
194 * in a different mode or be reopened (which can fail).
195 *
196 * @returns VBox status code.
197 * @param pvBackendData Opaque state data for this image.
198 * @param uOpenFlags New open flags for this image.
199 */
200 DECLR3CALLBACKMEMBER(int, pfnSetOpenFlags, (void *pvBackendData, unsigned uOpenFlags));
201
202 /**
203 * Get UUID of a disk image.
204 *
205 * @returns VBox status code.
206 * @param pvBackendData Opaque state data for this image.
207 * @param pUuid Where to store the image UUID.
208 */
209 DECLR3CALLBACKMEMBER(int, pfnGetUuid, (void *pvBackendData, PRTUUID pUuid));
210
211 /**
212 * Set UUID of a disk image.
213 *
214 * @returns VBox status code.
215 * @param pvBackendData Opaque state data for this image.
216 * @param pUuid Where to get the image UUID from.
217 */
218 DECLR3CALLBACKMEMBER(int, pfnSetUuid, (void *pvBackendData, PCRTUUID pUuid));
219
220 /**
221 * Get last modification UUID of a disk image.
222 *
223 * @returns VBox status code.
224 * @param pvBackendData Opaque state data for this image.
225 * @param pUuid Where to store the image modification UUID.
226 */
227 DECLR3CALLBACKMEMBER(int, pfnGetModificationUuid, (void *pvBackendData, PRTUUID pUuid));
228
229 /**
230 * Set last modification UUID of a disk image.
231 *
232 * @returns VBox status code.
233 * @param pvBackendData Opaque state data for this image.
234 * @param pUuid Where to get the image modification UUID from.
235 */
236 DECLR3CALLBACKMEMBER(int, pfnSetModificationUuid, (void *pvBackendData, PCRTUUID pUuid));
237
238 /**
239 * Get parent UUID of a disk image.
240 *
241 * @returns VBox status code.
242 * @param pvBackendData Opaque state data for this image.
243 * @param pUuid Where to store the parent image UUID.
244 */
245 DECLR3CALLBACKMEMBER(int, pfnGetParentUuid, (void *pvBackendData, PRTUUID pUuid));
246
247 /**
248 * Set parent UUID of a disk image.
249 *
250 * @returns VBox status code.
251 * @param pvBackendData Opaque state data for this image.
252 * @param pUuid Where to get the parent image UUID from.
253 */
254 DECLR3CALLBACKMEMBER(int, pfnSetParentUuid, (void *pvBackendData, PCRTUUID pUuid));
255
256} VBOXHDDBACKEND, *PVBOXHDDBACKEND;
257
258
259#endif
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette