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