1 | /** @file
|
---|
2 | * VBox HDD Container API.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2011 Oracle Corporation
|
---|
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 (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___VBox_VD_h
|
---|
27 | #define ___VBox_VD_h
|
---|
28 |
|
---|
29 | #include <iprt/assert.h>
|
---|
30 | #include <iprt/string.h>
|
---|
31 | #include <iprt/mem.h>
|
---|
32 | #include <iprt/file.h>
|
---|
33 | #include <iprt/net.h>
|
---|
34 | #include <iprt/sg.h>
|
---|
35 | #include <iprt/vfs.h>
|
---|
36 | #include <VBox/cdefs.h>
|
---|
37 | #include <VBox/types.h>
|
---|
38 | #include <VBox/err.h>
|
---|
39 | #include <VBox/vd-ifs.h>
|
---|
40 |
|
---|
41 | RT_C_DECLS_BEGIN
|
---|
42 |
|
---|
43 | #ifdef IN_RING0
|
---|
44 | # error "There are no VBox HDD Container APIs available in Ring-0 Host Context!"
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | /** @defgroup grp_vd VBox HDD Container
|
---|
48 | * @{
|
---|
49 | */
|
---|
50 |
|
---|
51 | /** Current VMDK image version. */
|
---|
52 | #define VMDK_IMAGE_VERSION (0x0001)
|
---|
53 |
|
---|
54 | /** Current VDI image major version. */
|
---|
55 | #define VDI_IMAGE_VERSION_MAJOR (0x0001)
|
---|
56 | /** Current VDI image minor version. */
|
---|
57 | #define VDI_IMAGE_VERSION_MINOR (0x0001)
|
---|
58 | /** Current VDI image version. */
|
---|
59 | #define VDI_IMAGE_VERSION ((VDI_IMAGE_VERSION_MAJOR << 16) | VDI_IMAGE_VERSION_MINOR)
|
---|
60 |
|
---|
61 | /** Get VDI major version from combined version. */
|
---|
62 | #define VDI_GET_VERSION_MAJOR(uVer) ((uVer) >> 16)
|
---|
63 | /** Get VDI minor version from combined version. */
|
---|
64 | #define VDI_GET_VERSION_MINOR(uVer) ((uVer) & 0xffff)
|
---|
65 |
|
---|
66 | /** Placeholder for specifying the last opened image. */
|
---|
67 | #define VD_LAST_IMAGE 0xffffffffU
|
---|
68 |
|
---|
69 | /** Placeholder for VDCopyEx to indicate that the image content is unknown. */
|
---|
70 | #define VD_IMAGE_CONTENT_UNKNOWN 0xffffffffU
|
---|
71 |
|
---|
72 | /** @name VBox HDD container image flags
|
---|
73 | * @{
|
---|
74 | */
|
---|
75 | /** No flags. */
|
---|
76 | #define VD_IMAGE_FLAGS_NONE (0)
|
---|
77 | /** Fixed image. */
|
---|
78 | #define VD_IMAGE_FLAGS_FIXED (0x10000)
|
---|
79 | /** Diff image. Mutually exclusive with fixed image. */
|
---|
80 | #define VD_IMAGE_FLAGS_DIFF (0x20000)
|
---|
81 | /** VMDK: Split image into 2GB extents. */
|
---|
82 | #define VD_VMDK_IMAGE_FLAGS_SPLIT_2G (0x0001)
|
---|
83 | /** VMDK: Raw disk image (giving access to a number of host partitions). */
|
---|
84 | #define VD_VMDK_IMAGE_FLAGS_RAWDISK (0x0002)
|
---|
85 | /** VMDK: stream optimized image, read only. */
|
---|
86 | #define VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED (0x0004)
|
---|
87 | /** VMDK: ESX variant, use in addition to other flags. */
|
---|
88 | #define VD_VMDK_IMAGE_FLAGS_ESX (0x0008)
|
---|
89 | /** VDI: Fill new blocks with zeroes while expanding image file. Only valid
|
---|
90 | * for newly created images, never set for opened existing images. */
|
---|
91 | #define VD_VDI_IMAGE_FLAGS_ZERO_EXPAND (0x0100)
|
---|
92 |
|
---|
93 | /** Mask of valid image flags for VMDK. */
|
---|
94 | #define VD_VMDK_IMAGE_FLAGS_MASK ( VD_IMAGE_FLAGS_FIXED | VD_IMAGE_FLAGS_DIFF | VD_IMAGE_FLAGS_NONE \
|
---|
95 | | VD_VMDK_IMAGE_FLAGS_SPLIT_2G | VD_VMDK_IMAGE_FLAGS_RAWDISK \
|
---|
96 | | VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED | VD_VMDK_IMAGE_FLAGS_ESX)
|
---|
97 |
|
---|
98 | /** Mask of valid image flags for VDI. */
|
---|
99 | #define VD_VDI_IMAGE_FLAGS_MASK (VD_IMAGE_FLAGS_FIXED | VD_IMAGE_FLAGS_DIFF | VD_IMAGE_FLAGS_NONE | VD_VDI_IMAGE_FLAGS_ZERO_EXPAND)
|
---|
100 |
|
---|
101 | /** Mask of all valid image flags for all formats. */
|
---|
102 | #define VD_IMAGE_FLAGS_MASK (VD_VMDK_IMAGE_FLAGS_MASK | VD_VDI_IMAGE_FLAGS_MASK)
|
---|
103 |
|
---|
104 | /** Default image flags. */
|
---|
105 | #define VD_IMAGE_FLAGS_DEFAULT (VD_IMAGE_FLAGS_NONE)
|
---|
106 | /** @} */
|
---|
107 |
|
---|
108 | /** @name VD image repair flags
|
---|
109 | * @{
|
---|
110 | */
|
---|
111 | /** Don't repair the image but check what needs to be done. */
|
---|
112 | #define VD_REPAIR_DRY_RUN RT_BIT_32(0)
|
---|
113 |
|
---|
114 | /** Mask of all valid repair flags. */
|
---|
115 | #define VD_REPAIR_FLAGS_MASK (VD_REPAIR_DRY_RUN)
|
---|
116 | /** @} */
|
---|
117 |
|
---|
118 | /** @name VD image VFS file flags
|
---|
119 | * @{
|
---|
120 | */
|
---|
121 | /** Destroy the VD disk container when the VFS file is released. */
|
---|
122 | #define VD_VFSFILE_DESTROY_ON_RELEASE RT_BIT_32(0)
|
---|
123 |
|
---|
124 | /** Mask of all valid repair flags. */
|
---|
125 | #define VD_VFSFILE_FLAGS_MASK (VD_VFSFILE_DESTROY_ON_RELEASE)
|
---|
126 | /** @} */
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Auxiliary type for describing partitions on raw disks. The entries must be
|
---|
130 | * in ascending order (as far as uStart is concerned), and must not overlap.
|
---|
131 | * Note that this does not correspond 1:1 to partitions, it is describing the
|
---|
132 | * general meaning of contiguous areas on the disk.
|
---|
133 | */
|
---|
134 | typedef struct VBOXHDDRAWPARTDESC
|
---|
135 | {
|
---|
136 | /** Device to use for this partition/data area. Can be the disk device if
|
---|
137 | * the offset field is set appropriately. If this is NULL, then this
|
---|
138 | * partition will not be accessible to the guest. The size of the data area
|
---|
139 | * must still be set correctly. */
|
---|
140 | const char *pszRawDevice;
|
---|
141 | /** Pointer to the partitioning info. NULL means this is a regular data
|
---|
142 | * area on disk, non-NULL denotes data which should be copied to the
|
---|
143 | * partition data overlay. */
|
---|
144 | const void *pvPartitionData;
|
---|
145 | /** Offset where the data starts in this device. */
|
---|
146 | uint64_t uStartOffset;
|
---|
147 | /** Offset where the data starts in the disk. */
|
---|
148 | uint64_t uStart;
|
---|
149 | /** Size of the data area. */
|
---|
150 | uint64_t cbData;
|
---|
151 | } VBOXHDDRAWPARTDESC, *PVBOXHDDRAWPARTDESC;
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * Auxiliary data structure for creating raw disks.
|
---|
155 | */
|
---|
156 | typedef struct VBOXHDDRAW
|
---|
157 | {
|
---|
158 | /** Signature for structure. Must be 'R', 'A', 'W', '\\0'. Actually a trick
|
---|
159 | * to make logging of the comment string produce sensible results. */
|
---|
160 | char szSignature[4];
|
---|
161 | /** Flag whether access to full disk should be given (ignoring the
|
---|
162 | * partition information below). */
|
---|
163 | bool fRawDisk;
|
---|
164 | /** Filename for the raw disk. Ignored for partitioned raw disks.
|
---|
165 | * For Linux e.g. /dev/sda, and for Windows e.g. \\\\.\\PhysicalDisk0. */
|
---|
166 | const char *pszRawDisk;
|
---|
167 | /** Number of entries in the partition descriptor array. */
|
---|
168 | unsigned cPartDescs;
|
---|
169 | /** Pointer to the partition descriptor array. */
|
---|
170 | PVBOXHDDRAWPARTDESC pPartDescs;
|
---|
171 | } VBOXHDDRAW, *PVBOXHDDRAW;
|
---|
172 |
|
---|
173 | /** @name VBox HDD container image open mode flags
|
---|
174 | * @{
|
---|
175 | */
|
---|
176 | /** Try to open image in read/write exclusive access mode if possible, or in read-only elsewhere. */
|
---|
177 | #define VD_OPEN_FLAGS_NORMAL 0
|
---|
178 | /** Open image in read-only mode with sharing access with others. */
|
---|
179 | #define VD_OPEN_FLAGS_READONLY RT_BIT(0)
|
---|
180 | /** Honor zero block writes instead of ignoring them whenever possible.
|
---|
181 | * This is not supported by all formats. It is silently ignored in this case. */
|
---|
182 | #define VD_OPEN_FLAGS_HONOR_ZEROES RT_BIT(1)
|
---|
183 | /** Honor writes of the same data instead of ignoring whenever possible.
|
---|
184 | * This is handled generically, and is only meaningful for differential image
|
---|
185 | * formats. It is silently ignored otherwise. */
|
---|
186 | #define VD_OPEN_FLAGS_HONOR_SAME RT_BIT(2)
|
---|
187 | /** Do not perform the base/diff image check on open. This does NOT imply
|
---|
188 | * opening the image as readonly (would break e.g. adding UUIDs to VMDK files
|
---|
189 | * created by other products). Images opened with this flag should only be
|
---|
190 | * used for querying information, and nothing else. */
|
---|
191 | #define VD_OPEN_FLAGS_INFO RT_BIT(3)
|
---|
192 | /** Open image for asynchronous access. Only available if VD_CAP_ASYNC_IO is
|
---|
193 | * set. VDOpen fails with VERR_NOT_SUPPORTED if this operation is not supported for
|
---|
194 | * this kind of image. */
|
---|
195 | #define VD_OPEN_FLAGS_ASYNC_IO RT_BIT(4)
|
---|
196 | /** Allow sharing of the image for writable images. May be ignored if the
|
---|
197 | * format backend doesn't support this type of concurrent access. */
|
---|
198 | #define VD_OPEN_FLAGS_SHAREABLE RT_BIT(5)
|
---|
199 | /** Ask the backend to switch to sequential accesses if possible. Opening
|
---|
200 | * will not fail if it cannot do this, the flag will be simply ignored. */
|
---|
201 | #define VD_OPEN_FLAGS_SEQUENTIAL RT_BIT(6)
|
---|
202 | /** Allow the discard operation if supported. Only available if VD_CAP_DISCARD
|
---|
203 | * is set. VDOpen fails with VERR_VD_DISCARD_NOT_SUPPORTED if discarding is not
|
---|
204 | * supported. */
|
---|
205 | #define VD_OPEN_FLAGS_DISCARD RT_BIT(7)
|
---|
206 | /** Ignore all flush requests to workaround certain filesystems which are slow
|
---|
207 | * when writing a lot of cached data to the medium.
|
---|
208 | * Use with extreme care as a host crash can result in completely corrupted and
|
---|
209 | * unusable images.
|
---|
210 | */
|
---|
211 | #define VD_OPEN_FLAGS_IGNORE_FLUSH RT_BIT(8)
|
---|
212 | /** Mask of valid flags. */
|
---|
213 | #define VD_OPEN_FLAGS_MASK (VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_HONOR_ZEROES | VD_OPEN_FLAGS_HONOR_SAME | VD_OPEN_FLAGS_INFO | VD_OPEN_FLAGS_ASYNC_IO | VD_OPEN_FLAGS_SHAREABLE | VD_OPEN_FLAGS_SEQUENTIAL | VD_OPEN_FLAGS_DISCARD | VD_OPEN_FLAGS_IGNORE_FLUSH)
|
---|
214 | /** @}*/
|
---|
215 |
|
---|
216 | /**
|
---|
217 | * Helper functions to handle open flags.
|
---|
218 | */
|
---|
219 |
|
---|
220 | /**
|
---|
221 | * Translate VD_OPEN_FLAGS_* to RTFile open flags.
|
---|
222 | *
|
---|
223 | * @return RTFile open flags.
|
---|
224 | * @param uOpenFlags VD_OPEN_FLAGS_* open flags.
|
---|
225 | * @param fCreate Flag that the file should be created.
|
---|
226 | */
|
---|
227 | DECLINLINE(uint32_t) VDOpenFlagsToFileOpenFlags(unsigned uOpenFlags, bool fCreate)
|
---|
228 | {
|
---|
229 | AssertMsg(!((uOpenFlags & VD_OPEN_FLAGS_READONLY) && fCreate), ("Image can't be opened readonly while being created\n"));
|
---|
230 |
|
---|
231 | uint32_t fOpen = 0;
|
---|
232 |
|
---|
233 | if (RT_UNLIKELY(uOpenFlags & VD_OPEN_FLAGS_READONLY))
|
---|
234 | fOpen |= RTFILE_O_READ | RTFILE_O_DENY_NONE;
|
---|
235 | else
|
---|
236 | {
|
---|
237 | fOpen |= RTFILE_O_READWRITE;
|
---|
238 |
|
---|
239 | if (RT_UNLIKELY(uOpenFlags & VD_OPEN_FLAGS_SHAREABLE))
|
---|
240 | fOpen |= RTFILE_O_DENY_NONE;
|
---|
241 | else
|
---|
242 | fOpen |= RTFILE_O_DENY_WRITE;
|
---|
243 | }
|
---|
244 |
|
---|
245 | if (RT_UNLIKELY(fCreate))
|
---|
246 | fOpen |= RTFILE_O_CREATE | RTFILE_O_NOT_CONTENT_INDEXED;
|
---|
247 | else
|
---|
248 | fOpen |= RTFILE_O_OPEN;
|
---|
249 |
|
---|
250 | return fOpen;
|
---|
251 | }
|
---|
252 |
|
---|
253 |
|
---|
254 | /** @name VBox HDD container backend capability flags
|
---|
255 | * @{
|
---|
256 | */
|
---|
257 | /** Supports UUIDs as expected by VirtualBox code. */
|
---|
258 | #define VD_CAP_UUID RT_BIT(0)
|
---|
259 | /** Supports creating fixed size images, allocating all space instantly. */
|
---|
260 | #define VD_CAP_CREATE_FIXED RT_BIT(1)
|
---|
261 | /** Supports creating dynamically growing images, allocating space on demand. */
|
---|
262 | #define VD_CAP_CREATE_DYNAMIC RT_BIT(2)
|
---|
263 | /** Supports creating images split in chunks of a bit less than 2GBytes. */
|
---|
264 | #define VD_CAP_CREATE_SPLIT_2G RT_BIT(3)
|
---|
265 | /** Supports being used as differencing image format backend. */
|
---|
266 | #define VD_CAP_DIFF RT_BIT(4)
|
---|
267 | /** Supports asynchronous I/O operations for at least some configurations. */
|
---|
268 | #define VD_CAP_ASYNC RT_BIT(5)
|
---|
269 | /** The backend operates on files. The caller needs to know to handle the
|
---|
270 | * location appropriately. */
|
---|
271 | #define VD_CAP_FILE RT_BIT(6)
|
---|
272 | /** The backend uses the config interface. The caller needs to know how to
|
---|
273 | * provide the mandatory configuration parts this way. */
|
---|
274 | #define VD_CAP_CONFIG RT_BIT(7)
|
---|
275 | /** The backend uses the network stack interface. The caller has to provide
|
---|
276 | * the appropriate interface. */
|
---|
277 | #define VD_CAP_TCPNET RT_BIT(8)
|
---|
278 | /** The backend supports VFS (virtual filesystem) functionality since it uses
|
---|
279 | * VDINTERFACEIO exclusively for all file operations. */
|
---|
280 | #define VD_CAP_VFS RT_BIT(9)
|
---|
281 | /** The backend supports the discard operation. */
|
---|
282 | #define VD_CAP_DISCARD RT_BIT(10)
|
---|
283 | /** @}*/
|
---|
284 |
|
---|
285 | /** @name VBox HDD container type.
|
---|
286 | * @{
|
---|
287 | */
|
---|
288 | typedef enum VDTYPE
|
---|
289 | {
|
---|
290 | /** Invalid. */
|
---|
291 | VDTYPE_INVALID = 0,
|
---|
292 | /** HardDisk */
|
---|
293 | VDTYPE_HDD,
|
---|
294 | /** CD/DVD */
|
---|
295 | VDTYPE_DVD,
|
---|
296 | /** Floppy. */
|
---|
297 | VDTYPE_FLOPPY
|
---|
298 | } VDTYPE;
|
---|
299 | /** @}*/
|
---|
300 |
|
---|
301 |
|
---|
302 | /** @name Configuration interface key handling flags.
|
---|
303 | * @{
|
---|
304 | */
|
---|
305 | /** Mandatory config key. Not providing a value for this key will cause
|
---|
306 | * the backend to fail. */
|
---|
307 | #define VD_CFGKEY_MANDATORY RT_BIT(0)
|
---|
308 | /** Expert config key. Not showing it by default in the GUI is is probably
|
---|
309 | * a good idea, as the average user won't understand it easily. */
|
---|
310 | #define VD_CFGKEY_EXPERT RT_BIT(1)
|
---|
311 | /** @}*/
|
---|
312 |
|
---|
313 |
|
---|
314 | /**
|
---|
315 | * Configuration value type for configuration information interface.
|
---|
316 | */
|
---|
317 | typedef enum VDCFGVALUETYPE
|
---|
318 | {
|
---|
319 | /** Integer value. */
|
---|
320 | VDCFGVALUETYPE_INTEGER = 1,
|
---|
321 | /** String value. */
|
---|
322 | VDCFGVALUETYPE_STRING,
|
---|
323 | /** Bytestring value. */
|
---|
324 | VDCFGVALUETYPE_BYTES
|
---|
325 | } VDCFGVALUETYPE;
|
---|
326 |
|
---|
327 |
|
---|
328 | /**
|
---|
329 | * Structure describing configuration keys required/supported by a backend
|
---|
330 | * through the config interface.
|
---|
331 | */
|
---|
332 | typedef struct VDCONFIGINFO
|
---|
333 | {
|
---|
334 | /** Key name of the configuration. */
|
---|
335 | const char *pszKey;
|
---|
336 | /** Pointer to default value (descriptor). NULL if no useful default value
|
---|
337 | * can be specified. */
|
---|
338 | const char *pszDefaultValue;
|
---|
339 | /** Value type for this key. */
|
---|
340 | VDCFGVALUETYPE enmValueType;
|
---|
341 | /** Key handling flags (a combination of VD_CFGKEY_* flags). */
|
---|
342 | uint64_t uKeyFlags;
|
---|
343 | } VDCONFIGINFO;
|
---|
344 |
|
---|
345 | /** Pointer to structure describing configuration keys. */
|
---|
346 | typedef VDCONFIGINFO *PVDCONFIGINFO;
|
---|
347 |
|
---|
348 | /** Pointer to const structure describing configuration keys. */
|
---|
349 | typedef const VDCONFIGINFO *PCVDCONFIGINFO;
|
---|
350 |
|
---|
351 | /**
|
---|
352 | * Structure describing a file extension.
|
---|
353 | */
|
---|
354 | typedef struct VDFILEEXTENSION
|
---|
355 | {
|
---|
356 | /** Pointer to the NULL-terminated string containing the extension. */
|
---|
357 | const char *pszExtension;
|
---|
358 | /** The device type the extension supports. */
|
---|
359 | VDTYPE enmType;
|
---|
360 | } VDFILEEXTENSION;
|
---|
361 |
|
---|
362 | /** Pointer to a structure describing a file extension. */
|
---|
363 | typedef VDFILEEXTENSION *PVDFILEEXTENSION;
|
---|
364 |
|
---|
365 | /** Pointer to a const structure describing a file extension. */
|
---|
366 | typedef const VDFILEEXTENSION *PCVDFILEEXTENSION;
|
---|
367 |
|
---|
368 | /**
|
---|
369 | * Data structure for returning a list of backend capabilities.
|
---|
370 | */
|
---|
371 | typedef struct VDBACKENDINFO
|
---|
372 | {
|
---|
373 | /** Name of the backend. Must be unique even with case insensitive comparison. */
|
---|
374 | const char *pszBackend;
|
---|
375 | /** Capabilities of the backend (a combination of the VD_CAP_* flags). */
|
---|
376 | uint64_t uBackendCaps;
|
---|
377 | /** Pointer to a NULL-terminated array of strings, containing the supported
|
---|
378 | * file extensions. Note that some backends do not work on files, so this
|
---|
379 | * pointer may just contain NULL. */
|
---|
380 | PCVDFILEEXTENSION paFileExtensions;
|
---|
381 | /** Pointer to an array of structs describing each supported config key.
|
---|
382 | * Terminated by a NULL config key. Note that some backends do not support
|
---|
383 | * the configuration interface, so this pointer may just contain NULL.
|
---|
384 | * Mandatory if the backend sets VD_CAP_CONFIG. */
|
---|
385 | PCVDCONFIGINFO paConfigInfo;
|
---|
386 | /** Returns a human readable hard disk location string given a
|
---|
387 | * set of hard disk configuration keys. The returned string is an
|
---|
388 | * equivalent of the full file path for image-based hard disks.
|
---|
389 | * Mandatory for backends with no VD_CAP_FILE and NULL otherwise. */
|
---|
390 | DECLR3CALLBACKMEMBER(int, pfnComposeLocation, (PVDINTERFACE pConfig, char **pszLocation));
|
---|
391 | /** Returns a human readable hard disk name string given a
|
---|
392 | * set of hard disk configuration keys. The returned string is an
|
---|
393 | * equivalent of the file name part in the full file path for
|
---|
394 | * image-based hard disks. Mandatory for backends with no
|
---|
395 | * VD_CAP_FILE and NULL otherwise. */
|
---|
396 | DECLR3CALLBACKMEMBER(int, pfnComposeName, (PVDINTERFACE pConfig, char **pszName));
|
---|
397 | } VDBACKENDINFO, *PVDBACKENDINFO;
|
---|
398 |
|
---|
399 |
|
---|
400 | /**
|
---|
401 | * Request completion callback for the async read/write API.
|
---|
402 | */
|
---|
403 | typedef void (FNVDASYNCTRANSFERCOMPLETE) (void *pvUser1, void *pvUser2, int rcReq);
|
---|
404 | /** Pointer to a transfer compelte callback. */
|
---|
405 | typedef FNVDASYNCTRANSFERCOMPLETE *PFNVDASYNCTRANSFERCOMPLETE;
|
---|
406 |
|
---|
407 | /**
|
---|
408 | * Disk geometry.
|
---|
409 | */
|
---|
410 | typedef struct VDGEOMETRY
|
---|
411 | {
|
---|
412 | /** Number of cylinders. */
|
---|
413 | uint32_t cCylinders;
|
---|
414 | /** Number of heads. */
|
---|
415 | uint32_t cHeads;
|
---|
416 | /** Number of sectors. */
|
---|
417 | uint32_t cSectors;
|
---|
418 | } VDGEOMETRY;
|
---|
419 |
|
---|
420 | /** Pointer to disk geometry. */
|
---|
421 | typedef VDGEOMETRY *PVDGEOMETRY;
|
---|
422 | /** Pointer to constant disk geometry. */
|
---|
423 | typedef const VDGEOMETRY *PCVDGEOMETRY;
|
---|
424 |
|
---|
425 | /**
|
---|
426 | * VBox HDD Container main structure.
|
---|
427 | */
|
---|
428 | /* Forward declaration, VBOXHDD structure is visible only inside VBox HDD module. */
|
---|
429 | struct VBOXHDD;
|
---|
430 | typedef struct VBOXHDD VBOXHDD;
|
---|
431 | typedef VBOXHDD *PVBOXHDD;
|
---|
432 |
|
---|
433 | /**
|
---|
434 | * Initializes HDD backends.
|
---|
435 | *
|
---|
436 | * @returns VBox status code.
|
---|
437 | */
|
---|
438 | VBOXDDU_DECL(int) VDInit(void);
|
---|
439 |
|
---|
440 | /**
|
---|
441 | * Destroys loaded HDD backends.
|
---|
442 | *
|
---|
443 | * @returns VBox status code.
|
---|
444 | */
|
---|
445 | VBOXDDU_DECL(int) VDShutdown(void);
|
---|
446 |
|
---|
447 | /**
|
---|
448 | * Lists all HDD backends and their capabilities in a caller-provided buffer.
|
---|
449 | *
|
---|
450 | * @return VBox status code.
|
---|
451 | * VERR_BUFFER_OVERFLOW if not enough space is passed.
|
---|
452 | * @param cEntriesAlloc Number of list entries available.
|
---|
453 | * @param pEntries Pointer to array for the entries.
|
---|
454 | * @param pcEntriesUsed Number of entries returned.
|
---|
455 | */
|
---|
456 | VBOXDDU_DECL(int) VDBackendInfo(unsigned cEntriesAlloc, PVDBACKENDINFO pEntries,
|
---|
457 | unsigned *pcEntriesUsed);
|
---|
458 |
|
---|
459 | /**
|
---|
460 | * Lists the capabilities of a backend identified by its name.
|
---|
461 | *
|
---|
462 | * @return VBox status code.
|
---|
463 | * @param pszBackend The backend name (case insensitive).
|
---|
464 | * @param pEntries Pointer to an entry.
|
---|
465 | */
|
---|
466 | VBOXDDU_DECL(int) VDBackendInfoOne(const char *pszBackend, PVDBACKENDINFO pEntry);
|
---|
467 |
|
---|
468 | /**
|
---|
469 | * Allocates and initializes an empty HDD container.
|
---|
470 | * No image files are opened.
|
---|
471 | *
|
---|
472 | * @return VBox status code.
|
---|
473 | * @param pVDIfsDisk Pointer to the per-disk VD interface list.
|
---|
474 | * @param enmType Type of the image container.
|
---|
475 | * @param ppDisk Where to store the reference to HDD container.
|
---|
476 | */
|
---|
477 | VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfsDisk, VDTYPE enmType, PVBOXHDD *ppDisk);
|
---|
478 |
|
---|
479 | /**
|
---|
480 | * Destroys HDD container.
|
---|
481 | * If container has opened image files they will be closed.
|
---|
482 | *
|
---|
483 | * @return VBox status code.
|
---|
484 | * @param pDisk Pointer to HDD container.
|
---|
485 | */
|
---|
486 | VBOXDDU_DECL(int) VDDestroy(PVBOXHDD pDisk);
|
---|
487 |
|
---|
488 | /**
|
---|
489 | * Try to get the backend name which can use this image.
|
---|
490 | *
|
---|
491 | * @return VBox status code.
|
---|
492 | * VINF_SUCCESS if a plugin was found.
|
---|
493 | * ppszFormat contains the string which can be used as backend name.
|
---|
494 | * VERR_NOT_SUPPORTED if no backend was found.
|
---|
495 | * @param pVDIfsDisk Pointer to the per-disk VD interface list.
|
---|
496 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
497 | * @param pszFilename Name of the image file for which the backend is queried.
|
---|
498 | * @param ppszFormat Receives pointer of the UTF-8 string which contains the format name.
|
---|
499 | * The returned pointer must be freed using RTStrFree().
|
---|
500 | * @param penmType Where to store the type of the image.
|
---|
501 | */
|
---|
502 | VBOXDDU_DECL(int) VDGetFormat(PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
|
---|
503 | const char *pszFilename, char **ppszFormat, VDTYPE *penmType);
|
---|
504 |
|
---|
505 | /**
|
---|
506 | * Opens an image file.
|
---|
507 | *
|
---|
508 | * The first opened image file in HDD container must have a base image type,
|
---|
509 | * others (next opened images) must be differencing or undo images.
|
---|
510 | * Linkage is checked for differencing image to be consistent with the previously opened image.
|
---|
511 | * When another differencing image is opened and the last image was opened in read/write access
|
---|
512 | * mode, then the last image is reopened in read-only with deny write sharing mode. This allows
|
---|
513 | * other processes to use images in read-only mode too.
|
---|
514 | *
|
---|
515 | * Note that the image is opened in read-only mode if a read/write open is not possible.
|
---|
516 | * Use VDIsReadOnly to check open mode.
|
---|
517 | *
|
---|
518 | * @return VBox status code.
|
---|
519 | * @param pDisk Pointer to HDD container.
|
---|
520 | * @param pszBackend Name of the image file backend to use (case insensitive).
|
---|
521 | * @param pszFilename Name of the image file to open.
|
---|
522 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
523 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
524 | */
|
---|
525 | VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszBackend,
|
---|
526 | const char *pszFilename, unsigned uOpenFlags,
|
---|
527 | PVDINTERFACE pVDIfsImage);
|
---|
528 |
|
---|
529 | /**
|
---|
530 | * Opens a cache image.
|
---|
531 | *
|
---|
532 | * @return VBox status code.
|
---|
533 | * @param pDisk Pointer to the HDD container which should use the cache image.
|
---|
534 | * @param pszBackend Name of the cache file backend to use (case insensitive).
|
---|
535 | * @param pszFilename Name of the cache image to open.
|
---|
536 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
537 | * @param pVDIfsCache Pointer to the per-cache VD interface list.
|
---|
538 | */
|
---|
539 | VBOXDDU_DECL(int) VDCacheOpen(PVBOXHDD pDisk, const char *pszBackend,
|
---|
540 | const char *pszFilename, unsigned uOpenFlags,
|
---|
541 | PVDINTERFACE pVDIfsCache);
|
---|
542 |
|
---|
543 | /**
|
---|
544 | * Creates and opens a new base image file.
|
---|
545 | *
|
---|
546 | * @return VBox status code.
|
---|
547 | * @param pDisk Pointer to HDD container.
|
---|
548 | * @param pszBackend Name of the image file backend to use (case insensitive).
|
---|
549 | * @param pszFilename Name of the image file to create.
|
---|
550 | * @param cbSize Image size in bytes.
|
---|
551 | * @param uImageFlags Flags specifying special image features.
|
---|
552 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
553 | * @param pPCHSGeometry Pointer to physical disk geometry <= (16383,16,63). Not NULL.
|
---|
554 | * @param pLCHSGeometry Pointer to logical disk geometry <= (x,255,63). Not NULL.
|
---|
555 | * @param pUuid New UUID of the image. If NULL, a new UUID is created.
|
---|
556 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
557 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
558 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
559 | */
|
---|
560 | VBOXDDU_DECL(int) VDCreateBase(PVBOXHDD pDisk, const char *pszBackend,
|
---|
561 | const char *pszFilename, uint64_t cbSize,
|
---|
562 | unsigned uImageFlags, const char *pszComment,
|
---|
563 | PCVDGEOMETRY pPCHSGeometry,
|
---|
564 | PCVDGEOMETRY pLCHSGeometry,
|
---|
565 | PCRTUUID pUuid, unsigned uOpenFlags,
|
---|
566 | PVDINTERFACE pVDIfsImage,
|
---|
567 | PVDINTERFACE pVDIfsOperation);
|
---|
568 |
|
---|
569 | /**
|
---|
570 | * Creates and opens a new differencing image file in HDD container.
|
---|
571 | * See comments for VDOpen function about differencing images.
|
---|
572 | *
|
---|
573 | * @return VBox status code.
|
---|
574 | * @param pDisk Pointer to HDD container.
|
---|
575 | * @param pszBackend Name of the image file backend to use (case insensitive).
|
---|
576 | * @param pszFilename Name of the differencing image file to create.
|
---|
577 | * @param uImageFlags Flags specifying special image features.
|
---|
578 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
579 | * @param pUuid New UUID of the image. If NULL, a new UUID is created.
|
---|
580 | * @param pParentUuid New parent UUID of the image. If NULL, the UUID is queried automatically.
|
---|
581 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
582 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
583 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
584 | */
|
---|
585 | VBOXDDU_DECL(int) VDCreateDiff(PVBOXHDD pDisk, const char *pszBackend,
|
---|
586 | const char *pszFilename, unsigned uImageFlags,
|
---|
587 | const char *pszComment, PCRTUUID pUuid,
|
---|
588 | PCRTUUID pParentUuid, unsigned uOpenFlags,
|
---|
589 | PVDINTERFACE pVDIfsImage,
|
---|
590 | PVDINTERFACE pVDIfsOperation);
|
---|
591 |
|
---|
592 | /**
|
---|
593 | * Creates and opens new cache image file in HDD container.
|
---|
594 | *
|
---|
595 | * @return VBox status code.
|
---|
596 | * @param pDisk Name of the cache file backend to use (case insensitive).
|
---|
597 | * @param pszFilename Name of the differencing cache file to create.
|
---|
598 | * @param cbSize Maximum size of the cache.
|
---|
599 | * @param uImageFlags Flags specifying special cache features.
|
---|
600 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
601 | * @param pUuid New UUID of the image. If NULL, a new UUID is created.
|
---|
602 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
603 | * @param pVDIfsCache Pointer to the per-cache VD interface list.
|
---|
604 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
605 | */
|
---|
606 | VBOXDDU_DECL(int) VDCreateCache(PVBOXHDD pDisk, const char *pszBackend,
|
---|
607 | const char *pszFilename, uint64_t cbSize,
|
---|
608 | unsigned uImageFlags, const char *pszComment,
|
---|
609 | PCRTUUID pUuid, unsigned uOpenFlags,
|
---|
610 | PVDINTERFACE pVDIfsCache, PVDINTERFACE pVDIfsOperation);
|
---|
611 |
|
---|
612 | /**
|
---|
613 | * Merges two images (not necessarily with direct parent/child relationship).
|
---|
614 | * As a side effect the source image and potentially the other images which
|
---|
615 | * are also merged to the destination are deleted from both the disk and the
|
---|
616 | * images in the HDD container.
|
---|
617 | *
|
---|
618 | * @return VBox status code.
|
---|
619 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
620 | * @param pDisk Pointer to HDD container.
|
---|
621 | * @param nImageFrom Image number to merge from, counts from 0. 0 is always base image of container.
|
---|
622 | * @param nImageTo Image number to merge to, counts from 0. 0 is always base image of container.
|
---|
623 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
624 | */
|
---|
625 | VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom,
|
---|
626 | unsigned nImageTo, PVDINTERFACE pVDIfsOperation);
|
---|
627 |
|
---|
628 | /**
|
---|
629 | * Copies an image from one HDD container to another - extended version.
|
---|
630 | * The copy is opened in the target HDD container.
|
---|
631 | * It is possible to convert between different image formats, because the
|
---|
632 | * backend for the destination may be different from the source.
|
---|
633 | * If both the source and destination reference the same HDD container,
|
---|
634 | * then the image is moved (by copying/deleting or renaming) to the new location.
|
---|
635 | * The source container is unchanged if the move operation fails, otherwise
|
---|
636 | * the image at the new location is opened in the same way as the old one was.
|
---|
637 | *
|
---|
638 | * @note The read/write accesses across disks are not synchronized, just the
|
---|
639 | * accesses to each disk. Once there is a use case which requires a defined
|
---|
640 | * read/write behavior in this situation this needs to be extended.
|
---|
641 | *
|
---|
642 | * @return VBox status code.
|
---|
643 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
644 | * @param pDiskFrom Pointer to source HDD container.
|
---|
645 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
646 | * @param pDiskTo Pointer to destination HDD container.
|
---|
647 | * @param pszBackend Name of the image file backend to use (may be NULL to use the same as the source, case insensitive).
|
---|
648 | * @param pszFilename New name of the image (may be NULL to specify that the
|
---|
649 | * copy destination is the destination container, or
|
---|
650 | * if pDiskFrom == pDiskTo, i.e. when moving).
|
---|
651 | * @param fMoveByRename If true, attempt to perform a move by renaming (if successful the new size is ignored).
|
---|
652 | * @param cbSize New image size (0 means leave unchanged).
|
---|
653 | * @param nImageSameFrom The number of the last image in the source chain having the same content as the
|
---|
654 | * image in the destination chain given by nImageSameTo or
|
---|
655 | * VD_IMAGE_CONTENT_UNKNOWN to indicate that the content of both containers is unknown.
|
---|
656 | * See the notes for further information.
|
---|
657 | * @param nImageSameTo The number of the last image in the destination chain having the same content as the
|
---|
658 | * image in the source chain given by nImageSameFrom or
|
---|
659 | * VD_IMAGE_CONTENT_UNKNOWN to indicate that the content of both containers is unknown.
|
---|
660 | * See the notes for further information.
|
---|
661 | * @param uImageFlags Flags specifying special destination image features.
|
---|
662 | * @param pDstUuid New UUID of the destination image. If NULL, a new UUID is created.
|
---|
663 | * This parameter is used if and only if a true copy is created.
|
---|
664 | * In all rename/move cases or copy to existing image cases the modification UUIDs are copied over.
|
---|
665 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
666 | * Only used if the destination image is created.
|
---|
667 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
668 | * @param pDstVDIfsImage Pointer to the per-image VD interface list, for the
|
---|
669 | * destination image.
|
---|
670 | * @param pDstVDIfsOperation Pointer to the per-operation VD interface list,
|
---|
671 | * for the destination operation.
|
---|
672 | *
|
---|
673 | * @note Using nImageSameFrom and nImageSameTo can lead to a significant speedup
|
---|
674 | * when copying an image but can also lead to a corrupted copy if used incorrectly.
|
---|
675 | * It is mainly useful when cloning a chain of images and it is known that
|
---|
676 | * the virtual disk content of the two chains is exactly the same upto a certain image.
|
---|
677 | * Example:
|
---|
678 | * Imagine the chain of images which consist of a base and one diff image.
|
---|
679 | * Copying the chain starts with the base image. When copying the first
|
---|
680 | * diff image VDCopy() will read the data from the diff of the source chain
|
---|
681 | * and probably from the base image again in case the diff doesn't has data
|
---|
682 | * for the block. However the block will be optimized away because VDCopy()
|
---|
683 | * reads data from the base image of the destination chain compares the to
|
---|
684 | * and suppresses the write because the data is unchanged.
|
---|
685 | * For a lot of diff images this will be a huge waste of I/O bandwidth if
|
---|
686 | * the diff images contain only few changes.
|
---|
687 | * Because it is known that the base image of the source and the destination chain
|
---|
688 | * have the same content it is enough to check the diff image for changed data
|
---|
689 | * and copy it to the destination diff image which is achieved with
|
---|
690 | * nImageSameFrom and nImageSameTo. Setting both to 0 can suppress a lot of I/O.
|
---|
691 | */
|
---|
692 | VBOXDDU_DECL(int) VDCopyEx(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo,
|
---|
693 | const char *pszBackend, const char *pszFilename,
|
---|
694 | bool fMoveByRename, uint64_t cbSize,
|
---|
695 | unsigned nImageFromSame, unsigned nImageToSame,
|
---|
696 | unsigned uImageFlags, PCRTUUID pDstUuid,
|
---|
697 | unsigned uOpenFlags, PVDINTERFACE pVDIfsOperation,
|
---|
698 | PVDINTERFACE pDstVDIfsImage,
|
---|
699 | PVDINTERFACE pDstVDIfsOperation);
|
---|
700 |
|
---|
701 | /**
|
---|
702 | * Copies an image from one HDD container to another.
|
---|
703 | * The copy is opened in the target HDD container.
|
---|
704 | * It is possible to convert between different image formats, because the
|
---|
705 | * backend for the destination may be different from the source.
|
---|
706 | * If both the source and destination reference the same HDD container,
|
---|
707 | * then the image is moved (by copying/deleting or renaming) to the new location.
|
---|
708 | * The source container is unchanged if the move operation fails, otherwise
|
---|
709 | * the image at the new location is opened in the same way as the old one was.
|
---|
710 | *
|
---|
711 | * @note The read/write accesses across disks are not synchronized, just the
|
---|
712 | * accesses to each disk. Once there is a use case which requires a defined
|
---|
713 | * read/write behavior in this situation this needs to be extended.
|
---|
714 | *
|
---|
715 | * @return VBox status code.
|
---|
716 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
717 | * @param pDiskFrom Pointer to source HDD container.
|
---|
718 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
719 | * @param pDiskTo Pointer to destination HDD container.
|
---|
720 | * @param pszBackend Name of the image file backend to use (may be NULL to use the same as the source, case insensitive).
|
---|
721 | * @param pszFilename New name of the image (may be NULL to specify that the
|
---|
722 | * copy destination is the destination container, or
|
---|
723 | * if pDiskFrom == pDiskTo, i.e. when moving).
|
---|
724 | * @param fMoveByRename If true, attempt to perform a move by renaming (if successful the new size is ignored).
|
---|
725 | * @param cbSize New image size (0 means leave unchanged).
|
---|
726 | * @param uImageFlags Flags specifying special destination image features.
|
---|
727 | * @param pDstUuid New UUID of the destination image. If NULL, a new UUID is created.
|
---|
728 | * This parameter is used if and only if a true copy is created.
|
---|
729 | * In all rename/move cases or copy to existing image cases the modification UUIDs are copied over.
|
---|
730 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
731 | * Only used if the destination image is created.
|
---|
732 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
733 | * @param pDstVDIfsImage Pointer to the per-image VD interface list, for the
|
---|
734 | * destination image.
|
---|
735 | * @param pDstVDIfsOperation Pointer to the per-operation VD interface list,
|
---|
736 | * for the destination operation.
|
---|
737 | */
|
---|
738 | VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo,
|
---|
739 | const char *pszBackend, const char *pszFilename,
|
---|
740 | bool fMoveByRename, uint64_t cbSize,
|
---|
741 | unsigned uImageFlags, PCRTUUID pDstUuid,
|
---|
742 | unsigned uOpenFlags, PVDINTERFACE pVDIfsOperation,
|
---|
743 | PVDINTERFACE pDstVDIfsImage,
|
---|
744 | PVDINTERFACE pDstVDIfsOperation);
|
---|
745 |
|
---|
746 | /**
|
---|
747 | * Optimizes the storage consumption of an image. Typically the unused blocks
|
---|
748 | * have to be wiped with zeroes to achieve a substantial reduced storage use.
|
---|
749 | * Another optimization done is reordering the image blocks, which can provide
|
---|
750 | * a significant performance boost, as reads and writes tend to use less random
|
---|
751 | * file offsets.
|
---|
752 | *
|
---|
753 | * @note Compaction is treated as a single operation with regard to thread
|
---|
754 | * synchronization, which means that it potentially blocks other activities for
|
---|
755 | * a long time. The complexity of compaction would grow even more if concurrent
|
---|
756 | * accesses have to be handled.
|
---|
757 | *
|
---|
758 | * @return VBox status code.
|
---|
759 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
760 | * @return VERR_VD_IMAGE_READ_ONLY if image is not writable.
|
---|
761 | * @return VERR_NOT_SUPPORTED if this kind of image can be compacted, but
|
---|
762 | * this isn't supported yet.
|
---|
763 | * @param pDisk Pointer to HDD container.
|
---|
764 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
765 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
766 | */
|
---|
767 | VBOXDDU_DECL(int) VDCompact(PVBOXHDD pDisk, unsigned nImage,
|
---|
768 | PVDINTERFACE pVDIfsOperation);
|
---|
769 |
|
---|
770 | /**
|
---|
771 | * Resizes the given disk image to the given size.
|
---|
772 | *
|
---|
773 | * @return VBox status
|
---|
774 | * @return VERR_VD_IMAGE_READ_ONLY if image is not writable.
|
---|
775 | * @return VERR_NOT_SUPPORTED if this kind of image can be compacted, but
|
---|
776 | *
|
---|
777 | * @param pDisk Pointer to the HDD container.
|
---|
778 | * @param cbSize New size of the image.
|
---|
779 | * @param pPCHSGeometry Pointer to the new physical disk geometry <= (16383,16,63). Not NULL.
|
---|
780 | * @param pLCHSGeometry Pointer to the new logical disk geometry <= (x,255,63). Not NULL.
|
---|
781 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
782 | */
|
---|
783 | VBOXDDU_DECL(int) VDResize(PVBOXHDD pDisk, uint64_t cbSize,
|
---|
784 | PCVDGEOMETRY pPCHSGeometry,
|
---|
785 | PCVDGEOMETRY pLCHSGeometry,
|
---|
786 | PVDINTERFACE pVDIfsOperation);
|
---|
787 |
|
---|
788 | /**
|
---|
789 | * Closes the last opened image file in HDD container.
|
---|
790 | * If previous image file was opened in read-only mode (the normal case) and
|
---|
791 | * the last opened image is in read-write mode then the previous image will be
|
---|
792 | * reopened in read/write mode.
|
---|
793 | *
|
---|
794 | * @return VBox status code.
|
---|
795 | * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
|
---|
796 | * @param pDisk Pointer to HDD container.
|
---|
797 | * @param fDelete If true, delete the image from the host disk.
|
---|
798 | */
|
---|
799 | VBOXDDU_DECL(int) VDClose(PVBOXHDD pDisk, bool fDelete);
|
---|
800 |
|
---|
801 | /**
|
---|
802 | * Closes the currently opened cache image file in HDD container.
|
---|
803 | *
|
---|
804 | * @return VBox status code.
|
---|
805 | * @return VERR_VD_NOT_OPENED if no cache is opened in HDD container.
|
---|
806 | * @param pDisk Pointer to HDD container.
|
---|
807 | * @param fDelete If true, delete the image from the host disk.
|
---|
808 | */
|
---|
809 | VBOXDDU_DECL(int) VDCacheClose(PVBOXHDD pDisk, bool fDelete);
|
---|
810 |
|
---|
811 | /**
|
---|
812 | * Closes all opened image files in HDD container.
|
---|
813 | *
|
---|
814 | * @return VBox status code.
|
---|
815 | * @param pDisk Pointer to HDD container.
|
---|
816 | */
|
---|
817 | VBOXDDU_DECL(int) VDCloseAll(PVBOXHDD pDisk);
|
---|
818 |
|
---|
819 | /**
|
---|
820 | * Read data from virtual HDD.
|
---|
821 | *
|
---|
822 | * @return VBox status code.
|
---|
823 | * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
|
---|
824 | * @param pDisk Pointer to HDD container.
|
---|
825 | * @param uOffset Offset of first reading byte from start of disk.
|
---|
826 | * Must be aligned to a sector boundary.
|
---|
827 | * @param pvBuffer Pointer to buffer for reading data.
|
---|
828 | * @param cbBuffer Number of bytes to read.
|
---|
829 | * Must be aligned to a sector boundary.
|
---|
830 | */
|
---|
831 | VBOXDDU_DECL(int) VDRead(PVBOXHDD pDisk, uint64_t uOffset, void *pvBuffer, size_t cbBuffer);
|
---|
832 |
|
---|
833 | /**
|
---|
834 | * Write data to virtual HDD.
|
---|
835 | *
|
---|
836 | * @return VBox status code.
|
---|
837 | * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
|
---|
838 | * @param pDisk Pointer to HDD container.
|
---|
839 | * @param uOffset Offset of first writing byte from start of disk.
|
---|
840 | * Must be aligned to a sector boundary.
|
---|
841 | * @param pvBuffer Pointer to buffer for writing data.
|
---|
842 | * @param cbBuffer Number of bytes to write.
|
---|
843 | * Must be aligned to a sector boundary.
|
---|
844 | */
|
---|
845 | VBOXDDU_DECL(int) VDWrite(PVBOXHDD pDisk, uint64_t uOffset, const void *pvBuffer, size_t cbBuffer);
|
---|
846 |
|
---|
847 | /**
|
---|
848 | * Make sure the on disk representation of a virtual HDD is up to date.
|
---|
849 | *
|
---|
850 | * @return VBox status code.
|
---|
851 | * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
|
---|
852 | * @param pDisk Pointer to HDD container.
|
---|
853 | */
|
---|
854 | VBOXDDU_DECL(int) VDFlush(PVBOXHDD pDisk);
|
---|
855 |
|
---|
856 | /**
|
---|
857 | * Get number of opened images in HDD container.
|
---|
858 | *
|
---|
859 | * @return Number of opened images for HDD container. 0 if no images have been opened.
|
---|
860 | * @param pDisk Pointer to HDD container.
|
---|
861 | */
|
---|
862 | VBOXDDU_DECL(unsigned) VDGetCount(PVBOXHDD pDisk);
|
---|
863 |
|
---|
864 | /**
|
---|
865 | * Get read/write mode of HDD container.
|
---|
866 | *
|
---|
867 | * @return Virtual disk ReadOnly status.
|
---|
868 | * @return true if no image is opened in HDD container.
|
---|
869 | * @param pDisk Pointer to HDD container.
|
---|
870 | */
|
---|
871 | VBOXDDU_DECL(bool) VDIsReadOnly(PVBOXHDD pDisk);
|
---|
872 |
|
---|
873 | /**
|
---|
874 | * Get total capacity of an image in HDD container.
|
---|
875 | *
|
---|
876 | * @return Virtual disk size in bytes.
|
---|
877 | * @return 0 if image with specified number was not opened.
|
---|
878 | * @param pDisk Pointer to HDD container.
|
---|
879 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
880 | */
|
---|
881 | VBOXDDU_DECL(uint64_t) VDGetSize(PVBOXHDD pDisk, unsigned nImage);
|
---|
882 |
|
---|
883 | /**
|
---|
884 | * Get total file size of an image in HDD container.
|
---|
885 | *
|
---|
886 | * @return Virtual disk size in bytes.
|
---|
887 | * @return 0 if image with specified number was not opened.
|
---|
888 | * @param pDisk Pointer to HDD container.
|
---|
889 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
890 | */
|
---|
891 | VBOXDDU_DECL(uint64_t) VDGetFileSize(PVBOXHDD pDisk, unsigned nImage);
|
---|
892 |
|
---|
893 | /**
|
---|
894 | * Get virtual disk PCHS geometry of an image in HDD container.
|
---|
895 | *
|
---|
896 | * @return VBox status code.
|
---|
897 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
898 | * @return VERR_VD_GEOMETRY_NOT_SET if no geometry present in the HDD container.
|
---|
899 | * @param pDisk Pointer to HDD container.
|
---|
900 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
901 | * @param pPCHSGeometry Where to store PCHS geometry. Not NULL.
|
---|
902 | */
|
---|
903 | VBOXDDU_DECL(int) VDGetPCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
|
---|
904 | PVDGEOMETRY pPCHSGeometry);
|
---|
905 |
|
---|
906 | /**
|
---|
907 | * Store virtual disk PCHS geometry of an image in HDD container.
|
---|
908 | *
|
---|
909 | * @return VBox status code.
|
---|
910 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
911 | * @param pDisk Pointer to HDD container.
|
---|
912 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
913 | * @param pPCHSGeometry Where to load PCHS geometry from. Not NULL.
|
---|
914 | */
|
---|
915 | VBOXDDU_DECL(int) VDSetPCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
|
---|
916 | PCVDGEOMETRY pPCHSGeometry);
|
---|
917 |
|
---|
918 | /**
|
---|
919 | * Get virtual disk LCHS geometry of an image in HDD container.
|
---|
920 | *
|
---|
921 | * @return VBox status code.
|
---|
922 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
923 | * @return VERR_VD_GEOMETRY_NOT_SET if no geometry present in the HDD container.
|
---|
924 | * @param pDisk Pointer to HDD container.
|
---|
925 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
926 | * @param pLCHSGeometry Where to store LCHS geometry. Not NULL.
|
---|
927 | */
|
---|
928 | VBOXDDU_DECL(int) VDGetLCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
|
---|
929 | PVDGEOMETRY pLCHSGeometry);
|
---|
930 |
|
---|
931 | /**
|
---|
932 | * Store virtual disk LCHS geometry of an image in HDD container.
|
---|
933 | *
|
---|
934 | * @return VBox status code.
|
---|
935 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
936 | * @param pDisk Pointer to HDD container.
|
---|
937 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
938 | * @param pLCHSGeometry Where to load LCHS geometry from. Not NULL.
|
---|
939 | */
|
---|
940 | VBOXDDU_DECL(int) VDSetLCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
|
---|
941 | PCVDGEOMETRY pLCHSGeometry);
|
---|
942 |
|
---|
943 | /**
|
---|
944 | * Get version of image in HDD container.
|
---|
945 | *
|
---|
946 | * @return VBox status code.
|
---|
947 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
948 | * @param pDisk Pointer to HDD container.
|
---|
949 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
950 | * @param puVersion Where to store the image version.
|
---|
951 | */
|
---|
952 | VBOXDDU_DECL(int) VDGetVersion(PVBOXHDD pDisk, unsigned nImage,
|
---|
953 | unsigned *puVersion);
|
---|
954 |
|
---|
955 | /**
|
---|
956 | * List the capabilities of image backend in HDD container.
|
---|
957 | *
|
---|
958 | * @return VBox status code.
|
---|
959 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
960 | * @param pDisk Pointer to the HDD container.
|
---|
961 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
962 | * @param pbackendInfo Where to store the backend information.
|
---|
963 | */
|
---|
964 | VBOXDDU_DECL(int) VDBackendInfoSingle(PVBOXHDD pDisk, unsigned nImage,
|
---|
965 | PVDBACKENDINFO pBackendInfo);
|
---|
966 |
|
---|
967 | /**
|
---|
968 | * Get flags of image in HDD container.
|
---|
969 | *
|
---|
970 | * @return VBox status code.
|
---|
971 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
972 | * @param pDisk Pointer to HDD container.
|
---|
973 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
974 | * @param puImageFlags Where to store the image flags.
|
---|
975 | */
|
---|
976 | VBOXDDU_DECL(int) VDGetImageFlags(PVBOXHDD pDisk, unsigned nImage, unsigned *puImageFlags);
|
---|
977 |
|
---|
978 | /**
|
---|
979 | * Get open flags of image in HDD container.
|
---|
980 | *
|
---|
981 | * @return VBox status code.
|
---|
982 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
983 | * @param pDisk Pointer to HDD container.
|
---|
984 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
985 | * @param puOpenFlags Where to store the image open flags.
|
---|
986 | */
|
---|
987 | VBOXDDU_DECL(int) VDGetOpenFlags(PVBOXHDD pDisk, unsigned nImage,
|
---|
988 | unsigned *puOpenFlags);
|
---|
989 |
|
---|
990 | /**
|
---|
991 | * Set open flags of image in HDD container.
|
---|
992 | * This operation may cause file locking changes and/or files being reopened.
|
---|
993 | * Note that in case of unrecoverable error all images in HDD container will be closed.
|
---|
994 | *
|
---|
995 | * @return VBox status code.
|
---|
996 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
997 | * @param pDisk Pointer to HDD container.
|
---|
998 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
999 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
1000 | */
|
---|
1001 | VBOXDDU_DECL(int) VDSetOpenFlags(PVBOXHDD pDisk, unsigned nImage,
|
---|
1002 | unsigned uOpenFlags);
|
---|
1003 |
|
---|
1004 | /**
|
---|
1005 | * Get base filename of image in HDD container. Some image formats use
|
---|
1006 | * other filenames as well, so don't use this for anything but informational
|
---|
1007 | * purposes.
|
---|
1008 | *
|
---|
1009 | * @return VBox status code.
|
---|
1010 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1011 | * @return VERR_BUFFER_OVERFLOW if pszFilename buffer too small to hold filename.
|
---|
1012 | * @param pDisk Pointer to HDD container.
|
---|
1013 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1014 | * @param pszFilename Where to store the image file name.
|
---|
1015 | * @param cbFilename Size of buffer pszFilename points to.
|
---|
1016 | */
|
---|
1017 | VBOXDDU_DECL(int) VDGetFilename(PVBOXHDD pDisk, unsigned nImage,
|
---|
1018 | char *pszFilename, unsigned cbFilename);
|
---|
1019 |
|
---|
1020 | /**
|
---|
1021 | * Get the comment line of image in HDD container.
|
---|
1022 | *
|
---|
1023 | * @return VBox status code.
|
---|
1024 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1025 | * @return VERR_BUFFER_OVERFLOW if pszComment buffer too small to hold comment text.
|
---|
1026 | * @param pDisk Pointer to HDD container.
|
---|
1027 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1028 | * @param pszComment Where to store the comment string of image. NULL is ok.
|
---|
1029 | * @param cbComment The size of pszComment buffer. 0 is ok.
|
---|
1030 | */
|
---|
1031 | VBOXDDU_DECL(int) VDGetComment(PVBOXHDD pDisk, unsigned nImage,
|
---|
1032 | char *pszComment, unsigned cbComment);
|
---|
1033 |
|
---|
1034 | /**
|
---|
1035 | * Changes the comment line of image in HDD container.
|
---|
1036 | *
|
---|
1037 | * @return VBox status code.
|
---|
1038 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1039 | * @param pDisk Pointer to HDD container.
|
---|
1040 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1041 | * @param pszComment New comment string (UTF-8). NULL is allowed to reset the comment.
|
---|
1042 | */
|
---|
1043 | VBOXDDU_DECL(int) VDSetComment(PVBOXHDD pDisk, unsigned nImage,
|
---|
1044 | const char *pszComment);
|
---|
1045 |
|
---|
1046 | /**
|
---|
1047 | * Get UUID of image in HDD container.
|
---|
1048 | *
|
---|
1049 | * @return VBox status code.
|
---|
1050 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1051 | * @param pDisk Pointer to HDD container.
|
---|
1052 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1053 | * @param pUuid Where to store the image UUID.
|
---|
1054 | */
|
---|
1055 | VBOXDDU_DECL(int) VDGetUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
|
---|
1056 |
|
---|
1057 | /**
|
---|
1058 | * Set the image's UUID. Should not be used by normal applications.
|
---|
1059 | *
|
---|
1060 | * @return VBox status code.
|
---|
1061 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1062 | * @param pDisk Pointer to HDD container.
|
---|
1063 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1064 | * @param pUuid New UUID of the image. If NULL, a new UUID is created.
|
---|
1065 | */
|
---|
1066 | VBOXDDU_DECL(int) VDSetUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
|
---|
1067 |
|
---|
1068 | /**
|
---|
1069 | * Get last modification UUID of image in HDD container.
|
---|
1070 | *
|
---|
1071 | * @return VBox status code.
|
---|
1072 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1073 | * @param pDisk Pointer to HDD container.
|
---|
1074 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1075 | * @param pUuid Where to store the image modification UUID.
|
---|
1076 | */
|
---|
1077 | VBOXDDU_DECL(int) VDGetModificationUuid(PVBOXHDD pDisk, unsigned nImage,
|
---|
1078 | PRTUUID pUuid);
|
---|
1079 |
|
---|
1080 | /**
|
---|
1081 | * Set the image's last modification UUID. Should not be used by normal applications.
|
---|
1082 | *
|
---|
1083 | * @return VBox status code.
|
---|
1084 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1085 | * @param pDisk Pointer to HDD container.
|
---|
1086 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1087 | * @param pUuid New modification UUID of the image. If NULL, a new UUID is created.
|
---|
1088 | */
|
---|
1089 | VBOXDDU_DECL(int) VDSetModificationUuid(PVBOXHDD pDisk, unsigned nImage,
|
---|
1090 | PCRTUUID pUuid);
|
---|
1091 |
|
---|
1092 | /**
|
---|
1093 | * Get parent UUID of image in HDD container.
|
---|
1094 | *
|
---|
1095 | * @return VBox status code.
|
---|
1096 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1097 | * @param pDisk Pointer to HDD container.
|
---|
1098 | * @param nImage Image number, counts from 0. 0 is always base image of the container.
|
---|
1099 | * @param pUuid Where to store the parent image UUID.
|
---|
1100 | */
|
---|
1101 | VBOXDDU_DECL(int) VDGetParentUuid(PVBOXHDD pDisk, unsigned nImage,
|
---|
1102 | PRTUUID pUuid);
|
---|
1103 |
|
---|
1104 | /**
|
---|
1105 | * Set the image's parent UUID. Should not be used by normal applications.
|
---|
1106 | *
|
---|
1107 | * @return VBox status code.
|
---|
1108 | * @param pDisk Pointer to HDD container.
|
---|
1109 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1110 | * @param pUuid New parent UUID of the image. If NULL, a new UUID is created.
|
---|
1111 | */
|
---|
1112 | VBOXDDU_DECL(int) VDSetParentUuid(PVBOXHDD pDisk, unsigned nImage,
|
---|
1113 | PCRTUUID pUuid);
|
---|
1114 |
|
---|
1115 |
|
---|
1116 | /**
|
---|
1117 | * Debug helper - dumps all opened images in HDD container into the log file.
|
---|
1118 | *
|
---|
1119 | * @param pDisk Pointer to HDD container.
|
---|
1120 | */
|
---|
1121 | VBOXDDU_DECL(void) VDDumpImages(PVBOXHDD pDisk);
|
---|
1122 |
|
---|
1123 |
|
---|
1124 | /**
|
---|
1125 | * Discards unused ranges given as a list.
|
---|
1126 | *
|
---|
1127 | * @return VBox status code.
|
---|
1128 | * @param pDisk Pointer to HDD container.
|
---|
1129 | * @param paRanges The array of ranges to discard.
|
---|
1130 | * @param cRanges Number of entries in the array.
|
---|
1131 | *
|
---|
1132 | * @note In contrast to VDCompact() the ranges are always discarded even if they
|
---|
1133 | * appear to contain data. This method is mainly used to implement TRIM support.
|
---|
1134 | */
|
---|
1135 | VBOXDDU_DECL(int) VDDiscardRanges(PVBOXHDD pDisk, PCRTRANGE paRanges, unsigned cRanges);
|
---|
1136 |
|
---|
1137 |
|
---|
1138 | /**
|
---|
1139 | * Start an asynchronous read request.
|
---|
1140 | *
|
---|
1141 | * @return VBox status code.
|
---|
1142 | * @param pDisk Pointer to the HDD container.
|
---|
1143 | * @param uOffset The offset of the virtual disk to read from.
|
---|
1144 | * @param cbRead How many bytes to read.
|
---|
1145 | * @param pcSgBuf Pointer to the S/G buffer to read into.
|
---|
1146 | * @param pfnComplete Completion callback.
|
---|
1147 | * @param pvUser User data which is passed on completion
|
---|
1148 | */
|
---|
1149 | VBOXDDU_DECL(int) VDAsyncRead(PVBOXHDD pDisk, uint64_t uOffset, size_t cbRead,
|
---|
1150 | PCRTSGBUF pcSgBuf,
|
---|
1151 | PFNVDASYNCTRANSFERCOMPLETE pfnComplete,
|
---|
1152 | void *pvUser1, void *pvUser2);
|
---|
1153 |
|
---|
1154 |
|
---|
1155 | /**
|
---|
1156 | * Start an asynchronous write request.
|
---|
1157 | *
|
---|
1158 | * @return VBox status code.
|
---|
1159 | * @param pDisk Pointer to the HDD container.
|
---|
1160 | * @param uOffset The offset of the virtual disk to write to.
|
---|
1161 | * @param cbWrtie How many bytes to write.
|
---|
1162 | * @param pcSgBuf Pointer to the S/G buffer to write from.
|
---|
1163 | * @param pfnComplete Completion callback.
|
---|
1164 | * @param pvUser User data which is passed on completion.
|
---|
1165 | */
|
---|
1166 | VBOXDDU_DECL(int) VDAsyncWrite(PVBOXHDD pDisk, uint64_t uOffset, size_t cbWrite,
|
---|
1167 | PCRTSGBUF pcSgBuf,
|
---|
1168 | PFNVDASYNCTRANSFERCOMPLETE pfnComplete,
|
---|
1169 | void *pvUser1, void *pvUser2);
|
---|
1170 |
|
---|
1171 |
|
---|
1172 | /**
|
---|
1173 | * Start an asynchronous flush request.
|
---|
1174 | *
|
---|
1175 | * @return VBox status code.
|
---|
1176 | * @param pDisk Pointer to the HDD container.
|
---|
1177 | * @param pfnComplete Completion callback.
|
---|
1178 | * @param pvUser User data which is passed on completion.
|
---|
1179 | */
|
---|
1180 | VBOXDDU_DECL(int) VDAsyncFlush(PVBOXHDD pDisk,
|
---|
1181 | PFNVDASYNCTRANSFERCOMPLETE pfnComplete,
|
---|
1182 | void *pvUser1, void *pvUser2);
|
---|
1183 |
|
---|
1184 | /**
|
---|
1185 | * Start an asynchronous discard request.
|
---|
1186 | *
|
---|
1187 | * @return VBox status code.
|
---|
1188 | * @param pDisk Pointer to HDD container.
|
---|
1189 | * @param paRanges The array of ranges to discard.
|
---|
1190 | * @param cRanges Number of entries in the array.
|
---|
1191 | * @param pfnComplete Completion callback.
|
---|
1192 | * @param pvUser1 User data which is passed on completion.
|
---|
1193 | * @param pvUser2 User data which is passed on completion.
|
---|
1194 | */
|
---|
1195 | VBOXDDU_DECL(int) VDAsyncDiscardRanges(PVBOXHDD pDisk, PCRTRANGE paRanges, unsigned cRanges,
|
---|
1196 | PFNVDASYNCTRANSFERCOMPLETE pfnComplete,
|
---|
1197 | void *pvUser1, void *pvUser);
|
---|
1198 |
|
---|
1199 | /**
|
---|
1200 | * Tries to repair a corrupted image.
|
---|
1201 | *
|
---|
1202 | * @return VBox status code.
|
---|
1203 | * @retval VERR_VD_IMAGE_REPAIR_NOT_SUPPORTED if the backend does not support repairing the image.
|
---|
1204 | * @retval VERR_VD_IMAGE_REPAIR_IMPOSSIBLE if the corruption is to severe to repair the image.
|
---|
1205 | * @param pVDIfsDisk Pointer to the per-disk VD interface list.
|
---|
1206 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
1207 | * @param pszFilename Name of the image file to repair.
|
---|
1208 | * @param pszFormat The backend to use.
|
---|
1209 | * @param fFlags Combination of the VD_REPAIR_* flags.
|
---|
1210 | */
|
---|
1211 | VBOXDDU_DECL(int) VDRepair(PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
|
---|
1212 | const char *pszFilename, const char *pszBackend,
|
---|
1213 | uint32_t fFlags);
|
---|
1214 |
|
---|
1215 | /**
|
---|
1216 | * Create a VFS file handle from the given HDD container.
|
---|
1217 | *
|
---|
1218 | * @return VBox status code.
|
---|
1219 | * @param pDisk Pointer to HDD container.
|
---|
1220 | * @param fFlags Combination of the VD_VFSFILE_* flags.
|
---|
1221 | * @param phVfsFile Where to stoer the handle to the VFS file on success.
|
---|
1222 | */
|
---|
1223 | VBOXDDU_DECL(int) VDCreateVfsFileFromDisk(PVBOXHDD pDisk, uint32_t fFlags,
|
---|
1224 | PRTVFSFILE phVfsFile);
|
---|
1225 |
|
---|
1226 | RT_C_DECLS_END
|
---|
1227 |
|
---|
1228 | /** @} */
|
---|
1229 |
|
---|
1230 | #endif
|
---|