1 | /** @file
|
---|
2 | * VBox HDD Container API.
|
---|
3 | * Will replace VBoxHDD.h.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef __VBox_VD_h__
|
---|
23 | #define __VBox_VD_h__
|
---|
24 |
|
---|
25 | #include <VBox/cdefs.h>
|
---|
26 | #include <VBox/types.h>
|
---|
27 | #include <VBox/pdm.h>
|
---|
28 |
|
---|
29 | __BEGIN_DECLS
|
---|
30 |
|
---|
31 | #ifdef IN_RING0
|
---|
32 | # error "There are no VBox HDD Container APIs available in Ring-0 Host Context!"
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | /** @defgroup grp_vd VBox HDD Container
|
---|
36 | * @{
|
---|
37 | */
|
---|
38 |
|
---|
39 | /** Current VMDK image version. */
|
---|
40 | #define VMDK_IMAGE_VERSION (0x0001)
|
---|
41 |
|
---|
42 | /** Current VDI image major version. */
|
---|
43 | #define VDI_IMAGE_VERSION_MAJOR (0x0001)
|
---|
44 | /** Current VDI image minor version. */
|
---|
45 | #define VDI_IMAGE_VERSION_MINOR (0x0001)
|
---|
46 | /** Current VDI image version. */
|
---|
47 | #define VDI_IMAGE_VERSION ((VDI_IMAGE_VERSION_MAJOR << 16) | VDI_IMAGE_VERSION_MINOR)
|
---|
48 |
|
---|
49 | /** Get VDI major version from combined version. */
|
---|
50 | #define VDI_GET_VERSION_MAJOR(uVer) ((uVer) >> 16)
|
---|
51 | /** Get VDI minor version from combined version. */
|
---|
52 | #define VDI_GET_VERSION_MINOR(uVer) ((uVer) & 0xffff)
|
---|
53 |
|
---|
54 | /** @name VBox HDD container image types
|
---|
55 | * @{ */
|
---|
56 | typedef enum VDIMAGETYPE
|
---|
57 | {
|
---|
58 | /** Normal dynamically growing base image file. */
|
---|
59 | VD_IMAGE_TYPE_NORMAL = 1,
|
---|
60 | /** Preallocated base image file of a fixed size. */
|
---|
61 | VD_IMAGE_TYPE_FIXED,
|
---|
62 | /** Dynamically growing image file for undo/commit changes support. */
|
---|
63 | VD_IMAGE_TYPE_UNDO,
|
---|
64 | /** Dynamically growing image file for differencing support. */
|
---|
65 | VD_IMAGE_TYPE_DIFF,
|
---|
66 |
|
---|
67 | /** First valid image type value. */
|
---|
68 | VD_IMAGE_TYPE_FIRST = VD_IMAGE_TYPE_NORMAL,
|
---|
69 | /** Last valid image type value. */
|
---|
70 | VD_IMAGE_TYPE_LAST = VD_IMAGE_TYPE_DIFF
|
---|
71 | } VDIMAGETYPE;
|
---|
72 | /** Pointer to VBox HDD container image type. */
|
---|
73 | typedef VDIMAGETYPE *PVDIMAGETYPE;
|
---|
74 | /** @} */
|
---|
75 |
|
---|
76 | /** @name VBox HDD container image flags
|
---|
77 | * @{
|
---|
78 | */
|
---|
79 | /** No flags. */
|
---|
80 | #define VD_IMAGE_FLAGS_NONE (0)
|
---|
81 | /** VMDK: Split image into 2GB extents. */
|
---|
82 | #define VD_VMDK_IMAGE_FLAGS_SPLIT_2G (0x0001)
|
---|
83 | /** VMDK: Split image into 2GB extents. */
|
---|
84 | #define VD_VMDK_IMAGE_FLAGS_RAWDISK (0x0002)
|
---|
85 | /** VDI: Fill new blocks with zeroes while expanding image file. */
|
---|
86 | #define VD_VDI_IMAGE_FLAGS_ZERO_EXPAND (0x0100)
|
---|
87 |
|
---|
88 | /** Mask of valid image flags for VMDK. */
|
---|
89 | #define VD_VMDK_IMAGE_FLAGS_MASK (VD_IMAGE_FLAGS_NONE | VD_VMDK_IMAGE_FLAGS_SPLIT_2G | VD_VMDK_IMAGE_FLAGS_RAWDISK)
|
---|
90 |
|
---|
91 | /** Mask of valid image flags for VDI. */
|
---|
92 | #define VD_VDI_IMAGE_FLAGS_MASK (VD_IMAGE_FLAGS_NONE | VD_VDI_IMAGE_FLAGS_ZERO_EXPAND)
|
---|
93 |
|
---|
94 | /** Default image flags. */
|
---|
95 | #define VD_IMAGE_FLAGS_DEFAULT (VD_IMAGE_FLAGS_NONE)
|
---|
96 | /** @} */
|
---|
97 |
|
---|
98 | /** @name VBox HDD container image open mode flags
|
---|
99 | * @{
|
---|
100 | */
|
---|
101 | /** Try to open image in read/write exclusive access mode if possible, or in read-only elsewhere. */
|
---|
102 | #define VD_OPEN_FLAGS_NORMAL (0)
|
---|
103 | /** Open image in read-only mode with sharing access with others. */
|
---|
104 | #define VD_OPEN_FLAGS_READONLY (1)
|
---|
105 | /** Honor zero block writes instead of ignoring them whenever possible.
|
---|
106 | * This is not supported by all formats. It is silently ignored in this case. */
|
---|
107 | #define VD_OPEN_FLAGS_HONOR_ZEROES (2)
|
---|
108 | /** Mask of valid flags. */
|
---|
109 | #define VD_OPEN_FLAGS_MASK (VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_HONOR_ZEROES)
|
---|
110 | /** @}*/
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * VBox HDD Container main structure.
|
---|
114 | */
|
---|
115 | /* Forward declaration, VBOXHDD structure is visible only inside VBox HDD module. */
|
---|
116 | struct VBOXHDD;
|
---|
117 | typedef struct VBOXHDD VBOXHDD;
|
---|
118 | typedef VBOXHDD *PVBOXHDD;
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * Allocates and initializes an empty VBox HDD container.
|
---|
122 | * No image files are opened.
|
---|
123 | *
|
---|
124 | * @returns VBox status code.
|
---|
125 | * @param pszBackend Name of the image file backend to use.
|
---|
126 | * @param ppDisk Where to store the reference to the VBox HDD container.
|
---|
127 | */
|
---|
128 | VBOXDDU_DECL(int) VDCreate(const char *pszBackend, PVBOXHDD *ppDisk);
|
---|
129 |
|
---|
130 | /**
|
---|
131 | * Destroys the VBox HDD container.
|
---|
132 | * If container has opened image files they will be closed.
|
---|
133 | *
|
---|
134 | * @param pDisk Pointer to VBox HDD container.
|
---|
135 | */
|
---|
136 | VBOXDDU_DECL(void) VDDestroy(PVBOXHDD pDisk);
|
---|
137 |
|
---|
138 | /**
|
---|
139 | * Opens an image file.
|
---|
140 | *
|
---|
141 | * The first opened image file in a HDD container must have a base image type,
|
---|
142 | * others (next opened images) must be differencing or undo images.
|
---|
143 | * Linkage is checked for differencing image to be consistent with the previously opened image.
|
---|
144 | * When another differencing image is opened and the last image was opened in read/write access
|
---|
145 | * mode, then the last image is reopened in read-only with deny write sharing mode. This allows
|
---|
146 | * other processes to use images in read-only mode too.
|
---|
147 | *
|
---|
148 | * Note that the image is opened in read-only mode if a read/write open is not possible.
|
---|
149 | * Use VDIsReadOnly to check open mode.
|
---|
150 | *
|
---|
151 | * @returns VBox status code.
|
---|
152 | * @param pDisk Pointer to VBox HDD container.
|
---|
153 | * @param pszFilename Name of the image file to open.
|
---|
154 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
155 | */
|
---|
156 | VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszFilename, unsigned uOpenFlags);
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * Creates and opens a new base image file.
|
---|
160 | *
|
---|
161 | * @returns VBox status code.
|
---|
162 | * @param pDisk Pointer to VBox HDD container.
|
---|
163 | * @param pszFilename Name of the image file to create.
|
---|
164 | * @param enmType Image type, only base image types are acceptable.
|
---|
165 | * @param cbSize Image size in bytes.
|
---|
166 | * @param uImageFlags Flags specifying special image features.
|
---|
167 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
168 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
169 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
170 | * @param pvUser User argument for the progress callback.
|
---|
171 | */
|
---|
172 | VBOXDDU_DECL(int) VDCreateBase(PVBOXHDD pDisk, const char *pszFilename,
|
---|
173 | VDIMAGETYPE enmType, uint64_t cbSize,
|
---|
174 | unsigned uImageFlags, const char *pszComment,
|
---|
175 | unsigned uOpenFlags,
|
---|
176 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
177 |
|
---|
178 | /**
|
---|
179 | * Creates and opens a new differencing image file in HDD container.
|
---|
180 | * See comments for VDOpen function about differencing images.
|
---|
181 | *
|
---|
182 | * @returns VBox status code.
|
---|
183 | * @param pDisk Pointer to VBox HDD container.
|
---|
184 | * @param pszFilename Name of the differencing image file to create.
|
---|
185 | * @param uImageFlags Flags specifying special image features.
|
---|
186 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
187 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
188 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
189 | * @param pvUser User argument for the progress callback.
|
---|
190 | */
|
---|
191 | VBOXDDU_DECL(int) VDCreateDiff(PVBOXHDD pDisk, const char *pszFilename,
|
---|
192 | unsigned uImageFlags, const char *pszComment,
|
---|
193 | unsigned uOpenFlags,
|
---|
194 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * Merges two images having a parent/child relationship (both directions).
|
---|
198 | * As a side effect the source image is deleted from both the disk and
|
---|
199 | * the images in the VBox HDD container.
|
---|
200 | *
|
---|
201 | * @returns VBox status code.
|
---|
202 | * @param pDisk Pointer to VBox HDD container.
|
---|
203 | * @param nImageFrom Name of the image file to merge from.
|
---|
204 | * @param nImageTo Name of the image file to merge to.
|
---|
205 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
206 | * @param pvUser User argument for the progress callback.
|
---|
207 | */
|
---|
208 | VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom, unsigned nImageTo,
|
---|
209 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * Copies an image from one VBox HDD container to another.
|
---|
213 | * The copy is opened in the target VBox HDD container.
|
---|
214 | * It is possible to convert between different image formats, because the
|
---|
215 | * backend for the destination VBox HDD container may be different from the
|
---|
216 | * source container.
|
---|
217 | * If both the source and destination reference the same VBox HDD container,
|
---|
218 | * then the image is moved (by copying/deleting) to the new location.
|
---|
219 | * The source container is unchanged if the move operation fails, otherwise
|
---|
220 | * the image at the new location is opened in the same way as the old one was.
|
---|
221 | *
|
---|
222 | * @returns VBox status code.
|
---|
223 | * @param pDiskFrom Pointer to source VBox HDD container.
|
---|
224 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
225 | * @param pDiskTo Pointer to destination VBox HDD container.
|
---|
226 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
227 | * @param pvUser User argument for the progress callback.
|
---|
228 | */
|
---|
229 | VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo,
|
---|
230 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
231 |
|
---|
232 | /**
|
---|
233 | * Compacts a growing image file by removing zeroed data blocks.
|
---|
234 | * Optionally defragments data in the image so that ascending sector numbers
|
---|
235 | * are stored in ascending location in the image file.
|
---|
236 | *
|
---|
237 | * @returns VBox status code.
|
---|
238 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
239 | * @param pDisk Pointer to VBox HDD container.
|
---|
240 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
241 | * @param fDefragment If true, reorder file data so that sectors are stored in ascending order.
|
---|
242 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
243 | * @param pvUser User argument for the progress callback.
|
---|
244 | */
|
---|
245 | VBOXDDU_DECL(int) VDCompact(PVBOXHDD pDisk, unsigned nImage,
|
---|
246 | bool fDefragment,
|
---|
247 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
248 |
|
---|
249 | /**
|
---|
250 | * Resizes an image. Allows setting the disk size to both larger and smaller
|
---|
251 | * values than the current disk size.
|
---|
252 | *
|
---|
253 | * @returns VBox status code.
|
---|
254 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
255 | * @param pDisk Pointer to VBox HDD container.
|
---|
256 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
257 | * @param cbSize New image size in bytes.
|
---|
258 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
259 | * @param pvUser User argument for the progress callback.
|
---|
260 | */
|
---|
261 | VBOXDDU_DECL(int) VDResize(PVBOXHDD pDisk, unsigned nImage, uint64_t cbSize,
|
---|
262 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
263 |
|
---|
264 | /**
|
---|
265 | * Closes the last opened image file in the HDD container. Leaves all changes inside it.
|
---|
266 | * If previous image file was opened in read-only mode (that is normal) and closing image
|
---|
267 | * was opened in read-write mode (the whole disk was in read-write mode) - the previous image
|
---|
268 | * will be reopened in read/write mode.
|
---|
269 | *
|
---|
270 | * @param pDisk Pointer to VBox HDD container.
|
---|
271 | * @param fDelete If true, delete the image from the host disk.
|
---|
272 | */
|
---|
273 | VBOXDDU_DECL(void) VDClose(PVBOXHDD pDisk, bool fDelete);
|
---|
274 |
|
---|
275 | /**
|
---|
276 | * Closes all opened image files in HDD container.
|
---|
277 | *
|
---|
278 | * @param pDisk Pointer to VBox HDD container.
|
---|
279 | */
|
---|
280 | VBOXDDU_DECL(void) VDCloseAll(PVBOXHDD pDisk);
|
---|
281 |
|
---|
282 | /**
|
---|
283 | * Read data from virtual HDD.
|
---|
284 | *
|
---|
285 | * @returns VBox status code.
|
---|
286 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
287 | * @param pDisk Pointer to VBox HDD container.
|
---|
288 | * @param off Offset of first reading byte from start of disk.
|
---|
289 | * @param pvBuf Pointer to buffer for reading data.
|
---|
290 | * @param cbRead Number of bytes to read.
|
---|
291 | */
|
---|
292 | VBOXDDU_DECL(int) VDRead(PVBOXHDD pDisk, uint64_t off, void *pvBuf, unsigned cbRead);
|
---|
293 |
|
---|
294 | /**
|
---|
295 | * Write data to virtual HDD.
|
---|
296 | *
|
---|
297 | * @returns VBox status code.
|
---|
298 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
299 | * @param pDisk Pointer to VBox HDD container.
|
---|
300 | * @param off Offset of first writing byte from start of disk.
|
---|
301 | * @param pvBuf Pointer to buffer for writing data.
|
---|
302 | * @param cbWrite Number of bytes to write.
|
---|
303 | */
|
---|
304 | VBOXDDU_DECL(int) VDWrite(PVBOXHDD pDisk, uint64_t off, const void *pvBuf, unsigned cbWrite);
|
---|
305 |
|
---|
306 | /**
|
---|
307 | * Make sure the on disk representation of a virtual HDD is up to date.
|
---|
308 | *
|
---|
309 | * @returns VBox status code.
|
---|
310 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
311 | * @param pDisk Pointer to VBox HDD container.
|
---|
312 | */
|
---|
313 | VBOXDDU_DECL(int) VDFlush(PVBOXHDD pDisk);
|
---|
314 |
|
---|
315 | /**
|
---|
316 | * Get number of opened images in HDD container.
|
---|
317 | *
|
---|
318 | * @returns Number of opened images for HDD container. 0 if no images have been opened.
|
---|
319 | * @param pDisk Pointer to VBox HDD container.
|
---|
320 | */
|
---|
321 | VBOXDDU_DECL(unsigned) VDGetCount(PVBOXHDD pDisk);
|
---|
322 |
|
---|
323 | /**
|
---|
324 | * Get read/write mode of the VBox HDD container.
|
---|
325 | *
|
---|
326 | * @returns Virtual disk ReadOnly status.
|
---|
327 | * @returns true if no image is opened in HDD container.
|
---|
328 | * @param pDisk Pointer to VBox HDD container.
|
---|
329 | */
|
---|
330 | VBOXDDU_DECL(bool) VDIsReadOnly(PVBOXHDD pDisk);
|
---|
331 |
|
---|
332 | /**
|
---|
333 | * Get total disk size of the VBox HDD container.
|
---|
334 | *
|
---|
335 | * @returns Virtual disk size in bytes.
|
---|
336 | * @returns 0 if no image is opened in HDD container.
|
---|
337 | * @param pDisk Pointer to VBox HDD container.
|
---|
338 | */
|
---|
339 | VBOXDDU_DECL(uint64_t) VDGetSize(PVBOXHDD pDisk);
|
---|
340 |
|
---|
341 | /**
|
---|
342 | * Get block size of the VBox HDD container.
|
---|
343 | *
|
---|
344 | * @returns Virtual disk block size in bytes.
|
---|
345 | * @returns 0 if no image is opened in HDD container.
|
---|
346 | * @param pDisk Pointer to VBox HDD container.
|
---|
347 | */
|
---|
348 | VBOXDDU_DECL(unsigned) VDGetBlockSize(PVBOXHDD pDisk);
|
---|
349 |
|
---|
350 | /**
|
---|
351 | * Get virtual disk geometry stored in HDD container.
|
---|
352 | *
|
---|
353 | * @returns VBox status code.
|
---|
354 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
355 | * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the HDD container.
|
---|
356 | * @param pDisk Pointer to VBox HDD container.
|
---|
357 | * @param pcCylinders Where to store the number of cylinders. NULL is ok.
|
---|
358 | * @param pcHeads Where to store the number of heads. NULL is ok.
|
---|
359 | * @param pcSectors Where to store the number of sectors. NULL is ok.
|
---|
360 | */
|
---|
361 | VBOXDDU_DECL(int) VDGetGeometry(PVBOXHDD pDisk,
|
---|
362 | unsigned *pcCylinders, unsigned *pcHeads, unsigned *pcSectors);
|
---|
363 |
|
---|
364 | /**
|
---|
365 | * Store virtual disk geometry in HDD container.
|
---|
366 | *
|
---|
367 | * Note that in case of unrecoverable error all images in HDD container will be closed.
|
---|
368 | *
|
---|
369 | * @returns VBox status code.
|
---|
370 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
371 | * @param pDisk Pointer to VBox HDD container.
|
---|
372 | * @param cCylinders Number of cylinders.
|
---|
373 | * @param cHeads Number of heads.
|
---|
374 | * @param cSectors Number of sectors.
|
---|
375 | */
|
---|
376 | VBOXDDU_DECL(int) VDSetGeometry(PVBOXHDD pDisk,
|
---|
377 | unsigned cCylinders, unsigned cHeads, unsigned cSectors);
|
---|
378 |
|
---|
379 | /**
|
---|
380 | * Get virtual disk translation mode stored in HDD container.
|
---|
381 | *
|
---|
382 | * @returns VBox status code.
|
---|
383 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
384 | * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the HDD container.
|
---|
385 | * @param pDisk Pointer to VBox HDD container.
|
---|
386 | * @param penmTranslation Where to store the translation mode (see pdm.h).
|
---|
387 | */
|
---|
388 | VBOXDDU_DECL(int) VDGetTranslation(PVBOXHDD pDisk, PPDMBIOSTRANSLATION penmTranslation);
|
---|
389 |
|
---|
390 | /**
|
---|
391 | * Store virtual disk translation mode in HDD container.
|
---|
392 | *
|
---|
393 | * Note that in case of unrecoverable error all images in HDD container will be closed.
|
---|
394 | *
|
---|
395 | * @returns VBox status code.
|
---|
396 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
397 | * @param pDisk Pointer to VBox HDD container.
|
---|
398 | * @param enmTranslation Translation mode (see pdm.h).
|
---|
399 | */
|
---|
400 | VBOXDDU_DECL(int) VDSetTranslation(PVBOXHDD pDisk, PDMBIOSTRANSLATION enmTranslation);
|
---|
401 |
|
---|
402 | /**
|
---|
403 | * Get version of image in HDD container.
|
---|
404 | *
|
---|
405 | * @returns VBox status code.
|
---|
406 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
407 | * @param pDisk Pointer to VBox HDD container.
|
---|
408 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
409 | * @param puVersion Where to store the image version.
|
---|
410 | */
|
---|
411 | VBOXDDU_DECL(int) VDGetVersion(PVBOXHDD pDisk, unsigned nImage, unsigned *puVersion);
|
---|
412 |
|
---|
413 | /**
|
---|
414 | * Get type of image in HDD container.
|
---|
415 | *
|
---|
416 | * @returns VBox status code.
|
---|
417 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
418 | * @param pDisk Pointer to VBox HDD container.
|
---|
419 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
420 | * @param penmType Where to store the image type.
|
---|
421 | */
|
---|
422 | VBOXDDU_DECL(int) VDGetImageType(PVBOXHDD pDisk, unsigned nImage, PVDIMAGETYPE penmType);
|
---|
423 |
|
---|
424 | /**
|
---|
425 | * Get flags of image in HDD container.
|
---|
426 | *
|
---|
427 | * @returns VBox status code.
|
---|
428 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
429 | * @param pDisk Pointer to VBox HDD container.
|
---|
430 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
431 | * @param puImageFlags Where to store the image flags.
|
---|
432 | */
|
---|
433 | VBOXDDU_DECL(int) VDGetImageFlags(PVBOXHDD pDisk, unsigned nImage, unsigned *puImageFlags);
|
---|
434 |
|
---|
435 | /**
|
---|
436 | * Get open flags of last opened image in HDD container.
|
---|
437 | *
|
---|
438 | * @returns VBox status code.
|
---|
439 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
440 | * @param pDisk Pointer to VBox HDD container.
|
---|
441 | * @param puOpenFlags Where to store the image open flags.
|
---|
442 | */
|
---|
443 | VBOXDDU_DECL(int) VDGetOpenFlags(PVBOXHDD pDisk, unsigned *puOpenFlags);
|
---|
444 |
|
---|
445 | /**
|
---|
446 | * Set open flags of last opened image in HDD container.
|
---|
447 | * This operation may cause file locking changes and/or files being reopened.
|
---|
448 | * Note that in case of unrecoverable error all images in HDD container will be closed.
|
---|
449 | *
|
---|
450 | * @returns VBox status code.
|
---|
451 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
452 | * @param pDisk Pointer to VBox HDD container.
|
---|
453 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
454 | */
|
---|
455 | VBOXDDU_DECL(int) VDSetOpenFlags(PVBOXHDD pDisk, unsigned uOpenFlags);
|
---|
456 |
|
---|
457 | /**
|
---|
458 | * Get base filename of image in HDD container. Some image formats use
|
---|
459 | * other filenames as well, so don't use this for anything but for informational
|
---|
460 | * purposes.
|
---|
461 | *
|
---|
462 | * @returns VBox status code.
|
---|
463 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
464 | * @returns VERR_BUFFER_OVERFLOW if pszFilename buffer too small to hold filename.
|
---|
465 | * @param pDisk Pointer to VBox HDD container.
|
---|
466 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
467 | * @param pszFilename Where to store the image file name.
|
---|
468 | * @param cbFilename Size of buffer pszFilename points to.
|
---|
469 | */
|
---|
470 | VBOXDDU_DECL(int) VDGetFilename(PVBOXHDD pDisk, unsigned nImage, char *pszFilename, unsigned cbFilename);
|
---|
471 |
|
---|
472 | /**
|
---|
473 | * Get the comment line of image in HDD container.
|
---|
474 | *
|
---|
475 | * @returns VBox status code.
|
---|
476 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
477 | * @returns VERR_BUFFER_OVERFLOW if pszComment buffer too small to hold comment text.
|
---|
478 | * @param pDisk Pointer to VBox HDD container.
|
---|
479 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
480 | * @param pszComment Where to store the comment string of image. NULL is ok.
|
---|
481 | * @param cbComment The size of pszComment buffer. 0 is ok.
|
---|
482 | */
|
---|
483 | VBOXDDU_DECL(int) VDGetComment(PVBOXHDD pDisk, unsigned nImage, char *pszComment, unsigned cbComment);
|
---|
484 |
|
---|
485 | /**
|
---|
486 | * Changes the comment line of image in HDD container.
|
---|
487 | *
|
---|
488 | * @returns VBox status code.
|
---|
489 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
490 | * @param pDisk Pointer to VBox HDD container.
|
---|
491 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
492 | * @param pszComment New comment string (UTF-8). NULL is allowed to reset the comment.
|
---|
493 | */
|
---|
494 | VBOXDDU_DECL(int) VDSetComment(PVBOXHDD pDisk, unsigned nImage, const char *pszComment);
|
---|
495 |
|
---|
496 | /**
|
---|
497 | * Get UUID of image in HDD container.
|
---|
498 | *
|
---|
499 | * @returns VBox status code.
|
---|
500 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
501 | * @param pDisk Pointer to VBox HDD container.
|
---|
502 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
503 | * @param pUuid Where to store the image uuid.
|
---|
504 | */
|
---|
505 | VBOXDDU_DECL(int) VDGetUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
|
---|
506 |
|
---|
507 | /**
|
---|
508 | * Set the image's UUID. Should not be used by normal applications.
|
---|
509 | *
|
---|
510 | * @returns VBox status code.
|
---|
511 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
512 | * @param pDisk Pointer to VBox HDD container.
|
---|
513 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
514 | * @param pUuid Optional parameter, new UUID of the image.
|
---|
515 | */
|
---|
516 | VBOXDDU_DECL(int) VDSetUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
|
---|
517 |
|
---|
518 | /**
|
---|
519 | * Get last modification UUID of image in HDD container.
|
---|
520 | *
|
---|
521 | * @returns VBox status code.
|
---|
522 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
523 | * @param pDisk Pointer to VBox HDD container.
|
---|
524 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
525 | * @param pUuid Where to store the image modification uuid.
|
---|
526 | */
|
---|
527 | VBOXDDU_DECL(int) VDGetModificationUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
|
---|
528 |
|
---|
529 | /**
|
---|
530 | * Set the image's last modification UUID. Should not be used by normal applications.
|
---|
531 | *
|
---|
532 | * @returns VBox status code.
|
---|
533 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
534 | * @param pDisk Pointer to VBox HDD container.
|
---|
535 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
536 | * @param pUuid Optional parameter, new last modification UUID of the image.
|
---|
537 | */
|
---|
538 | VBOXDDU_DECL(int) VDSetModificationUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
|
---|
539 |
|
---|
540 | /**
|
---|
541 | * Get parent UUID of image in HDD container.
|
---|
542 | *
|
---|
543 | * @returns VBox status code.
|
---|
544 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
545 | * @param pDisk Pointer to VBox HDD container.
|
---|
546 | * @param nImage Image number, counts from 0. 0 is always base image of the container.
|
---|
547 | * @param pUuid Where to store the parent image uuid.
|
---|
548 | */
|
---|
549 | VBOXDDU_DECL(int) VDGetParentUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
|
---|
550 |
|
---|
551 | /**
|
---|
552 | * Set the image's parent UUID. Should not be used by normal applications.
|
---|
553 | *
|
---|
554 | * @returns VBox status code.
|
---|
555 | * @param pDisk Pointer to VBox HDD container.
|
---|
556 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
557 | * @param pUuid Optional parameter, new parent UUID of the image.
|
---|
558 | */
|
---|
559 | VBOXDDU_DECL(int) VDSetParentUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
|
---|
560 |
|
---|
561 |
|
---|
562 |
|
---|
563 | /**
|
---|
564 | * Debug helper - dumps all opened images in HDD container into the log file.
|
---|
565 | *
|
---|
566 | * @param pDisk Pointer to VBox HDD container.
|
---|
567 | */
|
---|
568 | VBOXDDU_DECL(void) VDDumpImages(PVBOXHDD pDisk);
|
---|
569 |
|
---|
570 | __END_DECLS
|
---|
571 |
|
---|
572 | /** @} */
|
---|
573 |
|
---|
574 | #endif
|
---|