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