1 | /** @file
|
---|
2 | * VBox HDD Container, Virtual Disk Image (VDI) API.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License as published by the Free Software Foundation,
|
---|
12 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
13 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
14 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef ___VBox_VBoxHDD_h
|
---|
18 | #define ___VBox_VBoxHDD_h
|
---|
19 |
|
---|
20 | #include <VBox/cdefs.h>
|
---|
21 | #include <VBox/types.h>
|
---|
22 | #include <VBox/param.h>
|
---|
23 | #include <VBox/pdm.h>
|
---|
24 | #include <VBox/vmapi.h>
|
---|
25 |
|
---|
26 | __BEGIN_DECLS
|
---|
27 |
|
---|
28 | #ifdef IN_RING0
|
---|
29 | # error "There are no VDI APIs available in Ring-0 Host Context!"
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | /** @defgroup grp_vbox_hdd VBox HDD Container
|
---|
33 | * @{
|
---|
34 | */
|
---|
35 |
|
---|
36 | /** Image info, not handled anyhow.
|
---|
37 | * Must be less than 64 bytes in length, including the trailing 0.
|
---|
38 | */
|
---|
39 | #define VDI_IMAGE_FILE_INFO "<<< innotek VirtualBox Disk Image >>>\n"
|
---|
40 |
|
---|
41 | /** Current image major version. */
|
---|
42 | #define VDI_IMAGE_VERSION_MAJOR (0x0001)
|
---|
43 | /** Current image minor version. */
|
---|
44 | #define VDI_IMAGE_VERSION_MINOR (0x0001)
|
---|
45 | /** Current image version. */
|
---|
46 | #define VDI_IMAGE_VERSION ((VDI_IMAGE_VERSION_MAJOR << 16) | VDI_IMAGE_VERSION_MINOR)
|
---|
47 |
|
---|
48 | /** Get major version from combined version. */
|
---|
49 | #define VDI_GET_VERSION_MAJOR(uVer) ((uVer) >> 16)
|
---|
50 | /** Get minor version from combined version. */
|
---|
51 | #define VDI_GET_VERSION_MINOR(uVer) ((uVer) & 0xffff)
|
---|
52 |
|
---|
53 | /** @name VDI image types
|
---|
54 | * @{ */
|
---|
55 | typedef enum VDIIMAGETYPE
|
---|
56 | {
|
---|
57 | /** Normal dynamically growing base image file. */
|
---|
58 | VDI_IMAGE_TYPE_NORMAL = 1,
|
---|
59 | /** Preallocated base image file of a fixed size. */
|
---|
60 | VDI_IMAGE_TYPE_FIXED,
|
---|
61 | /** Dynamically growing image file for undo/commit changes support. */
|
---|
62 | VDI_IMAGE_TYPE_UNDO,
|
---|
63 | /** Dynamically growing image file for differencing support. */
|
---|
64 | VDI_IMAGE_TYPE_DIFF,
|
---|
65 |
|
---|
66 | /** First valid image type value. */
|
---|
67 | VDI_IMAGE_TYPE_FIRST = VDI_IMAGE_TYPE_NORMAL,
|
---|
68 | /** Last valid image type value. */
|
---|
69 | VDI_IMAGE_TYPE_LAST = VDI_IMAGE_TYPE_DIFF
|
---|
70 | } VDIIMAGETYPE;
|
---|
71 | /** Pointer to VDI image type. */
|
---|
72 | typedef VDIIMAGETYPE *PVDIIMAGETYPE;
|
---|
73 | /** @} */
|
---|
74 |
|
---|
75 | /** @name VDI image flags
|
---|
76 | * @{ */
|
---|
77 | /** No flags. */
|
---|
78 | #define VDI_IMAGE_FLAGS_NONE (0x00)
|
---|
79 | /** Fill new blocks with zeroes while expanding image file. */
|
---|
80 | #define VDI_IMAGE_FLAGS_ZERO_EXPAND (0x01)
|
---|
81 |
|
---|
82 | /** Mask of valid image flags. */
|
---|
83 | #define VDI_IMAGE_FLAGS_MASK (VDI_IMAGE_FLAGS_NONE | VDI_IMAGE_FLAGS_ZERO_EXPAND)
|
---|
84 |
|
---|
85 | /** Default image flags. */
|
---|
86 | #define VDI_IMAGE_FLAGS_DEFAULT (VDI_IMAGE_FLAGS_NONE)
|
---|
87 | /** @} */
|
---|
88 |
|
---|
89 | /** @name VDI image open mode flags
|
---|
90 | * @{
|
---|
91 | */
|
---|
92 | /** Try to open image in read/write exclusive access mode if possible, or in read-only elsewhere. */
|
---|
93 | #define VDI_OPEN_FLAGS_NORMAL (0)
|
---|
94 | /** Open image in read-only mode with sharing access with others. */
|
---|
95 | #define VDI_OPEN_FLAGS_READONLY (1)
|
---|
96 | /** Mask of valid flags. */
|
---|
97 | #define VDI_OPEN_FLAGS_MASK (VDI_OPEN_FLAGS_NORMAL | VDI_OPEN_FLAGS_READONLY)
|
---|
98 | /** @}*/
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * VBox VDI disk Container main structure.
|
---|
102 | */
|
---|
103 | /* Forward declaration, VDIDISK structure is visible only inside VDI module. */
|
---|
104 | struct VDIDISK;
|
---|
105 | typedef struct VDIDISK VDIDISK;
|
---|
106 | typedef VDIDISK *PVDIDISK;
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * Creates a new base image file.
|
---|
110 | *
|
---|
111 | * @returns VBox status code.
|
---|
112 | * @param pszFilename Name of the image file to create.
|
---|
113 | * @param enmType Image type, only base image types are acceptable.
|
---|
114 | * @param cbSize Image size in bytes.
|
---|
115 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
116 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
117 | * @param pvUser User argument for the progress callback.
|
---|
118 | */
|
---|
119 | VBOXDDU_DECL(int) VDICreateBaseImage(const char *pszFilename, VDIIMAGETYPE enmType, uint64_t cbSize, const char *pszComment,
|
---|
120 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * Creates a differencing dynamically growing image file for specified parent image.
|
---|
124 | *
|
---|
125 | * @returns VBox status code.
|
---|
126 | * @param pszFilename Name of the differencing image file to create.
|
---|
127 | * @param pszParent Name of the parent image file. May be base or diff image type.
|
---|
128 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
129 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
130 | * @param pvUser User argument for the progress callback.
|
---|
131 | */
|
---|
132 | VBOXDDU_DECL(int) VDICreateDifferenceImage(const char *pszFilename, const char *pszParent, const char *pszComment,
|
---|
133 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Checks if image is available and not broken, returns some useful image parameters if requested.
|
---|
137 | *
|
---|
138 | * @returns VBox status code.
|
---|
139 | * @param pszFilename Name of the image file to check.
|
---|
140 | * @param puVersion Where to store the version of image. NULL is ok.
|
---|
141 | * @param penmType Where to store the type of image. NULL is ok.
|
---|
142 | * @param pcbSize Where to store the size of image in bytes. NULL is ok.
|
---|
143 | * @param pUuid Where to store the uuid of image creation. NULL is ok.
|
---|
144 | * @param pParentUuid Where to store the uuid of the parent image (if any). NULL is ok.
|
---|
145 | * @param pszComment Where to store the comment string of image. NULL is ok.
|
---|
146 | * @param cbComment The size of pszComment buffer. 0 is ok.
|
---|
147 | */
|
---|
148 | VBOXDDU_DECL(int) VDICheckImage(const char *pszFilename,
|
---|
149 | unsigned *puVersion,
|
---|
150 | PVDIIMAGETYPE penmType,
|
---|
151 | uint64_t *pcbSize,
|
---|
152 | PRTUUID pUuid,
|
---|
153 | PRTUUID pParentUuid,
|
---|
154 | char *pszComment,
|
---|
155 | unsigned cbComment);
|
---|
156 |
|
---|
157 | /**
|
---|
158 | * Changes an image's comment string.
|
---|
159 | *
|
---|
160 | * @returns VBox status code.
|
---|
161 | * @param pszFilename Name of the image file to operate on.
|
---|
162 | * @param pszComment New comment string (UTF-8). NULL is allowed to reset the comment.
|
---|
163 | */
|
---|
164 | VBOXDDU_DECL(int) VDISetImageComment(const char *pszFilename, const char *pszComment);
|
---|
165 |
|
---|
166 | /**
|
---|
167 | * Deletes a valid image file. Fails if specified file is not an image.
|
---|
168 | *
|
---|
169 | * @returns VBox status code.
|
---|
170 | * @param pszFilename Name of the image file to check.
|
---|
171 | */
|
---|
172 | VBOXDDU_DECL(int) VDIDeleteImage(const char *pszFilename);
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * Makes a copy of image file with a new (other) creation uuid.
|
---|
176 | *
|
---|
177 | * @returns VBox status code.
|
---|
178 | * @param pszDstFilename Name of the image file to create.
|
---|
179 | * @param pszSrcFilename Name of the image file to copy from.
|
---|
180 | * @param pszComment Pointer to image comment. If NULL, the comment
|
---|
181 | * will be copied from the source image.
|
---|
182 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
183 | * @param pvUser User argument for the progress callback.
|
---|
184 | */
|
---|
185 | VBOXDDU_DECL(int) VDICopyImage(const char *pszDstFilename, const char *pszSrcFilename, const char *pszComment,
|
---|
186 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
187 |
|
---|
188 | /**
|
---|
189 | * Converts image file from older VDI formats to current one.
|
---|
190 | *
|
---|
191 | * @returns VBox status code.
|
---|
192 | * @param pszFilename Name of the image file to convert.
|
---|
193 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
194 | * @param pvUser User argument for the progress callback.
|
---|
195 | */
|
---|
196 | VBOXDDU_DECL(int) VDIConvertImage(const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
197 |
|
---|
198 | /**
|
---|
199 | * Shrinks growing image file by removing zeroed data blocks.
|
---|
200 | *
|
---|
201 | * @returns VBox status code.
|
---|
202 | * @param pszFilename Name of the image file to shrink.
|
---|
203 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
204 | * @param pvUser User argument for the progress callback.
|
---|
205 | */
|
---|
206 | VBOXDDU_DECL(int) VDIShrinkImage(const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
207 |
|
---|
208 | /**
|
---|
209 | * Queries the image's UUID and parent UUIDs.
|
---|
210 | *
|
---|
211 | * @returns VBox status code.
|
---|
212 | * @param pszFilename Name of the image file to operate on.
|
---|
213 | * @param pUuid Where to store image UUID (can be NULL).
|
---|
214 | * @param pModificationUuid Where to store modification UUID (can be NULL).
|
---|
215 | * @param pParentUuuid Where to store parent UUID (can be NULL).
|
---|
216 | * @param pParentModificationUuid Where to store parent modification UUID (can be NULL).
|
---|
217 | */
|
---|
218 | VBOXDDU_DECL(int) VDIGetImageUUIDs(const char *pszFilename,
|
---|
219 | PRTUUID pUuid, PRTUUID pModificationUuid,
|
---|
220 | PRTUUID pParentUuid, PRTUUID pParentModificationUuid);
|
---|
221 |
|
---|
222 |
|
---|
223 | /**
|
---|
224 | * Changes the image's UUID and parent UUIDs.
|
---|
225 | *
|
---|
226 | * @returns VBox status code.
|
---|
227 | * @param pszFilename Name of the image file to operate on.
|
---|
228 | * @param pUuid Optional parameter, new UUID of the image.
|
---|
229 | * @param pModificationUuid Optional parameter, new modification UUID of the image.
|
---|
230 | * @param pParentUuuid Optional parameter, new parent UUID of the image.
|
---|
231 | * @param pParentModificationUuid Optional parameter, new parent modification UUID of the image.
|
---|
232 | */
|
---|
233 | VBOXDDU_DECL(int) VDISetImageUUIDs(const char *pszFilename,
|
---|
234 | PCRTUUID pUuid, PCRTUUID pModificationUuid,
|
---|
235 | PCRTUUID pParentUuid, PCRTUUID pParentModificationUuid);
|
---|
236 |
|
---|
237 | /**
|
---|
238 | * Merges two images having a parent/child relationship (both directions).
|
---|
239 | *
|
---|
240 | * @returns VBox status code.
|
---|
241 | * @param pszFilenameFrom Name of the image file to merge from.
|
---|
242 | * @param pszFilenameTo Name of the image file to merge into.
|
---|
243 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
244 | * @param pvUser User argument for the progress callback.
|
---|
245 | */
|
---|
246 | VBOXDDU_DECL(int) VDIMergeImage(const char *pszFilenameFrom, const char *pszFilenameTo,
|
---|
247 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
248 |
|
---|
249 |
|
---|
250 | /**
|
---|
251 | * Allocates and initializes an empty VDI HDD container.
|
---|
252 | * No image files are opened.
|
---|
253 | *
|
---|
254 | * @returns Pointer to newly created empty HDD container.
|
---|
255 | * @returns NULL on failure, typically out of memory.
|
---|
256 | */
|
---|
257 | VBOXDDU_DECL(PVDIDISK) VDIDiskCreate(void);
|
---|
258 |
|
---|
259 | /**
|
---|
260 | * Destroys the VDI HDD container. If container has opened image files they will be closed.
|
---|
261 | *
|
---|
262 | * @param pDisk Pointer to VDI HDD container.
|
---|
263 | */
|
---|
264 | VBOXDDU_DECL(void) VDIDiskDestroy(PVDIDISK pDisk);
|
---|
265 |
|
---|
266 | /**
|
---|
267 | * Opens an image file.
|
---|
268 | *
|
---|
269 | * The first opened image file in a HDD container must have a base image type,
|
---|
270 | * others (next opened images) must be a differencing or undo images.
|
---|
271 | * Linkage is checked for differencing image to be in consistence with the previously opened image.
|
---|
272 | * When a next differencing image is opened and the last image was opened in read/write access
|
---|
273 | * mode, then the last image is reopened in read-only with deny write sharing mode. This allows
|
---|
274 | * other processes to use images in read-only mode too.
|
---|
275 | *
|
---|
276 | * Note that the image can be opened in read-only mode if a read/write open is not possible.
|
---|
277 | * Use VDIDiskIsReadOnly to check open mode.
|
---|
278 | *
|
---|
279 | * @returns VBox status code.
|
---|
280 | * @param pDisk Pointer to VDI HDD container.
|
---|
281 | * @param pszFilename Name of the image file to open.
|
---|
282 | * @param fOpen Image file open mode, see VDI_OPEN_FLAGS_* constants.
|
---|
283 | */
|
---|
284 | VBOXDDU_DECL(int) VDIDiskOpenImage(PVDIDISK pDisk, const char *pszFilename, unsigned fOpen);
|
---|
285 |
|
---|
286 | /**
|
---|
287 | * Creates and opens a new differencing image file in HDD container.
|
---|
288 | * See comments for VDIDiskOpenImage function about differencing images.
|
---|
289 | *
|
---|
290 | * @returns VBox status code.
|
---|
291 | * @param pDisk Pointer to VDI HDD container.
|
---|
292 | * @param pszFilename Name of the image file to create and open.
|
---|
293 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
294 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
295 | * @param pvUser User argument for the progress callback.
|
---|
296 | */
|
---|
297 | VBOXDDU_DECL(int) VDIDiskCreateOpenDifferenceImage(PVDIDISK pDisk, const char *pszFilename, const char *pszComment,
|
---|
298 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
299 |
|
---|
300 | /**
|
---|
301 | * Closes the last opened image file in the HDD container. Leaves all changes inside it.
|
---|
302 | * If previous image file was opened in read-only mode (that is normal) and closing image
|
---|
303 | * was opened in read-write mode (the whole disk was in read-write mode) - the previous image
|
---|
304 | * will be reopened in read/write mode.
|
---|
305 | *
|
---|
306 | * @param pDisk Pointer to VDI HDD container.
|
---|
307 | */
|
---|
308 | VBOXDDU_DECL(void) VDIDiskCloseImage(PVDIDISK pDisk);
|
---|
309 |
|
---|
310 | /**
|
---|
311 | * Closes all opened image files in HDD container.
|
---|
312 | *
|
---|
313 | * @param pDisk Pointer to VDI HDD container.
|
---|
314 | */
|
---|
315 | VBOXDDU_DECL(void) VDIDiskCloseAllImages(PVDIDISK pDisk);
|
---|
316 |
|
---|
317 | /**
|
---|
318 | * Commits last opened differencing/undo image file of the HDD container to previous image.
|
---|
319 | * If the previous image file was opened in read-only mode (that must be always so) it is reopened
|
---|
320 | * as read/write to do commit operation.
|
---|
321 | * After successfull commit the previous image file again reopened in read-only mode, last opened
|
---|
322 | * image file is cleared of data and remains open and active in HDD container.
|
---|
323 | * If you want to delete image after commit you must do it manually by VDIDiskCloseImage and
|
---|
324 | * VDIDeleteImage calls.
|
---|
325 | *
|
---|
326 | * Note that in case of unrecoverable error all images of HDD container will be closed.
|
---|
327 | *
|
---|
328 | * @returns VBox status code.
|
---|
329 | * @param pDisk Pointer to VDI HDD container.
|
---|
330 | * @param pfnProgress Progress callback. Optional.
|
---|
331 | * @param pvUser User argument for the progress callback.
|
---|
332 | */
|
---|
333 | VBOXDDU_DECL(int) VDIDiskCommitLastDiff(PVDIDISK pDisk, PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
334 |
|
---|
335 | /**
|
---|
336 | * Get read/write mode of VDI HDD.
|
---|
337 | *
|
---|
338 | * @returns Disk ReadOnly status.
|
---|
339 | * @returns true if no one VDI image is opened in HDD container.
|
---|
340 | */
|
---|
341 | VBOXDDU_DECL(bool) VDIDiskIsReadOnly(PVDIDISK pDisk);
|
---|
342 |
|
---|
343 | /**
|
---|
344 | * Get total disk size of the VDI HDD container.
|
---|
345 | *
|
---|
346 | * @returns Virtual disk size in bytes.
|
---|
347 | * @returns 0 if no one VDI image is opened in HDD container.
|
---|
348 | */
|
---|
349 | VBOXDDU_DECL(uint64_t) VDIDiskGetSize(PVDIDISK pDisk);
|
---|
350 |
|
---|
351 | /**
|
---|
352 | * Get block size of the VDI HDD container.
|
---|
353 | *
|
---|
354 | * @returns VDI image block size in bytes.
|
---|
355 | * @returns 0 if no one VDI image is opened in HDD container.
|
---|
356 | */
|
---|
357 | VBOXDDU_DECL(unsigned) VDIDiskGetBlockSize(PVDIDISK pDisk);
|
---|
358 |
|
---|
359 | /**
|
---|
360 | * Get working buffer size of the VDI HDD container.
|
---|
361 | *
|
---|
362 | * @returns Working buffer size in bytes.
|
---|
363 | */
|
---|
364 | VBOXDDU_DECL(unsigned) VDIDiskGetBufferSize(PVDIDISK pDisk);
|
---|
365 |
|
---|
366 | /**
|
---|
367 | * Get virtual disk geometry stored in image file.
|
---|
368 | *
|
---|
369 | * @returns VBox status code.
|
---|
370 | * @returns VERR_VDI_NOT_OPENED if no one VDI image is opened in HDD container.
|
---|
371 | * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the HDD container.
|
---|
372 | * @param pDisk Pointer to VDI HDD container.
|
---|
373 | * @param pcCylinders Where to store the number of cylinders. NULL is ok.
|
---|
374 | * @param pcHeads Where to store the number of heads. NULL is ok.
|
---|
375 | * @param pcSectors Where to store the number of sectors. NULL is ok.
|
---|
376 | */
|
---|
377 | VBOXDDU_DECL(int) VDIDiskGetGeometry(PVDIDISK pDisk, unsigned *pcCylinders, unsigned *pcHeads, unsigned *pcSectors);
|
---|
378 |
|
---|
379 | /**
|
---|
380 | * Store virtual disk geometry into base image file of HDD container.
|
---|
381 | *
|
---|
382 | * Note that in case of unrecoverable error all images of HDD container will be closed.
|
---|
383 | *
|
---|
384 | * @returns VBox status code.
|
---|
385 | * @returns VERR_VDI_NOT_OPENED if no one VDI image is opened in HDD container.
|
---|
386 | * @param pDisk Pointer to VDI HDD container.
|
---|
387 | * @param cCylinders Number of cylinders.
|
---|
388 | * @param cHeads Number of heads.
|
---|
389 | * @param cSectors Number of sectors.
|
---|
390 | */
|
---|
391 | VBOXDDU_DECL(int) VDIDiskSetGeometry(PVDIDISK pDisk, unsigned cCylinders, unsigned cHeads, unsigned cSectors);
|
---|
392 |
|
---|
393 | /**
|
---|
394 | * Get virtual disk translation mode stored in image file.
|
---|
395 | *
|
---|
396 | * @returns VBox status code.
|
---|
397 | * @returns VERR_VDI_NOT_OPENED if no one VDI image is opened in HDD container.
|
---|
398 | * @param pDisk Pointer to VDI HDD container.
|
---|
399 | * @param penmTranslation Where to store the translation mode (see pdm.h).
|
---|
400 | */
|
---|
401 | VBOXDDU_DECL(int) VDIDiskGetTranslation(PVDIDISK pDisk, PPDMBIOSTRANSLATION penmTranslation);
|
---|
402 |
|
---|
403 | /**
|
---|
404 | * Store virtual disk translation mode into base image file of HDD container.
|
---|
405 | *
|
---|
406 | * Note that in case of unrecoverable error all images of HDD container will be closed.
|
---|
407 | *
|
---|
408 | * @returns VBox status code.
|
---|
409 | * @returns VERR_VDI_NOT_OPENED if no one VDI image is opened in HDD container.
|
---|
410 | * @param pDisk Pointer to VDI HDD container.
|
---|
411 | * @param enmTranslation Translation mode (see pdm.h).
|
---|
412 | */
|
---|
413 | VBOXDDU_DECL(int) VDIDiskSetTranslation(PVDIDISK pDisk, PDMBIOSTRANSLATION enmTranslation);
|
---|
414 |
|
---|
415 | /**
|
---|
416 | * Get number of opened images in HDD container.
|
---|
417 | *
|
---|
418 | * @returns Number of opened images for HDD container. 0 if no images has been opened.
|
---|
419 | * @param pDisk Pointer to VDI HDD container.
|
---|
420 | */
|
---|
421 | VBOXDDU_DECL(int) VDIDiskGetImagesCount(PVDIDISK pDisk);
|
---|
422 |
|
---|
423 | /**
|
---|
424 | * Get version of opened image of HDD container.
|
---|
425 | *
|
---|
426 | * @returns VBox status code.
|
---|
427 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
428 | * @param pDisk Pointer to VDI HDD container.
|
---|
429 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
430 | * @param puVersion Where to store the image version.
|
---|
431 | */
|
---|
432 | VBOXDDU_DECL(int) VDIDiskGetImageVersion(PVDIDISK pDisk, int nImage, unsigned *puVersion);
|
---|
433 |
|
---|
434 | /**
|
---|
435 | * Get type of opened image of HDD container.
|
---|
436 | *
|
---|
437 | * @returns VBox status code.
|
---|
438 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
439 | * @param pDisk Pointer to VDI HDD container.
|
---|
440 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
441 | * @param penmType Where to store the image type.
|
---|
442 | */
|
---|
443 | VBOXDDU_DECL(int) VDIDiskGetImageType(PVDIDISK pDisk, int nImage, PVDIIMAGETYPE penmType);
|
---|
444 |
|
---|
445 | /**
|
---|
446 | * Get flags of opened image of HDD container.
|
---|
447 | *
|
---|
448 | * @returns VBox status code.
|
---|
449 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
450 | * @param pDisk Pointer to VDI HDD container.
|
---|
451 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
452 | * @param pfFlags Where to store the image flags.
|
---|
453 | */
|
---|
454 | VBOXDDU_DECL(int) VDIDiskGetImageFlags(PVDIDISK pDisk, int nImage, unsigned *pfFlags);
|
---|
455 |
|
---|
456 | /**
|
---|
457 | * Get filename of opened image of HDD container.
|
---|
458 | *
|
---|
459 | * @returns VBox status code.
|
---|
460 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
461 | * @returns VERR_BUFFER_OVERFLOW if pszFilename buffer too small to hold filename.
|
---|
462 | * @param pDisk Pointer to VDI HDD container.
|
---|
463 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
464 | * @param pszFilename Where to store the image file name.
|
---|
465 | * @param cbFilename Size of buffer pszFilename points to.
|
---|
466 | */
|
---|
467 | VBOXDDU_DECL(int) VDIDiskGetImageFilename(PVDIDISK pDisk, int nImage, char *pszFilename, unsigned cbFilename);
|
---|
468 |
|
---|
469 | /**
|
---|
470 | * Get the comment line of opened image of HDD container.
|
---|
471 | *
|
---|
472 | * @returns VBox status code.
|
---|
473 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
474 | * @returns VERR_BUFFER_OVERFLOW if pszComment buffer too small to hold comment text.
|
---|
475 | * @param pDisk Pointer to VDI HDD container.
|
---|
476 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
477 | * @param pszComment Where to store the comment string of image. NULL is ok.
|
---|
478 | * @param cbComment The size of pszComment buffer. 0 is ok.
|
---|
479 | */
|
---|
480 | VBOXDDU_DECL(int) VDIDiskGetImageComment(PVDIDISK pDisk, int nImage, char *pszComment, unsigned cbComment);
|
---|
481 |
|
---|
482 | /**
|
---|
483 | * Get Uuid of opened image of HDD container.
|
---|
484 | *
|
---|
485 | * @returns VBox status code.
|
---|
486 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
487 | * @param pDisk Pointer to VDI HDD container.
|
---|
488 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
489 | * @param pUuid Where to store the image creation uuid.
|
---|
490 | */
|
---|
491 | VBOXDDU_DECL(int) VDIDiskGetImageUuid(PVDIDISK pDisk, int nImage, PRTUUID pUuid);
|
---|
492 |
|
---|
493 | /**
|
---|
494 | * Get last modification Uuid of opened image of HDD container.
|
---|
495 | *
|
---|
496 | * @returns VBox status code.
|
---|
497 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
498 | * @param pDisk Pointer to VDI HDD container.
|
---|
499 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
500 | * @param pUuid Where to store the image modification uuid.
|
---|
501 | */
|
---|
502 | VBOXDDU_DECL(int) VDIDiskGetImageModificationUuid(PVDIDISK pDisk, int nImage, PRTUUID pUuid);
|
---|
503 |
|
---|
504 | /**
|
---|
505 | * Get Uuid of opened image's parent image.
|
---|
506 | *
|
---|
507 | * @returns VBox status code.
|
---|
508 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
509 | * @param pDisk Pointer to VDI HDD container.
|
---|
510 | * @param nImage Image number, counts from 0. 0 is always base image of the container.
|
---|
511 | * @param pUuid Where to store the image creation uuid.
|
---|
512 | */
|
---|
513 | VBOXDDU_DECL(int) VDIDiskGetParentImageUuid(PVDIDISK pDisk, int nImage, PRTUUID pUuid);
|
---|
514 |
|
---|
515 | /**
|
---|
516 | * Read data from virtual HDD.
|
---|
517 | *
|
---|
518 | * @returns VBox status code.
|
---|
519 | * @param pDisk Pointer to VDI HDD container.
|
---|
520 | * @param offStart Offset of first reading byte from start of disk.
|
---|
521 | * @param pvBuf Pointer to buffer for reading data.
|
---|
522 | * @param cbToRead Number of bytes to read.
|
---|
523 | */
|
---|
524 | VBOXDDU_DECL(int) VDIDiskRead(PVDIDISK pDisk, uint64_t offStart, void *pvBuf, unsigned cbToRead);
|
---|
525 |
|
---|
526 | /**
|
---|
527 | * Write data to virtual HDD.
|
---|
528 | *
|
---|
529 | * @returns VBox status code.
|
---|
530 | * @param pDisk Pointer to VDI HDD container.
|
---|
531 | * @param offStart Offset of first writing byte from start of HDD.
|
---|
532 | * @param pvBuf Pointer to buffer of writing data.
|
---|
533 | * @param cbToWrite Number of bytes to write.
|
---|
534 | */
|
---|
535 | VBOXDDU_DECL(int) VDIDiskWrite(PVDIDISK pDisk, uint64_t offStart, const void *pvBuf, unsigned cbToWrite);
|
---|
536 |
|
---|
537 |
|
---|
538 |
|
---|
539 | /**
|
---|
540 | * Debug helper - dumps all opened images of HDD container into the log file.
|
---|
541 | *
|
---|
542 | * @param pDisk Pointer to VDI HDD container.
|
---|
543 | */
|
---|
544 | VBOXDDU_DECL(void) VDIDiskDumpImages(PVDIDISK pDisk);
|
---|
545 |
|
---|
546 | __END_DECLS
|
---|
547 |
|
---|
548 | /** @} */
|
---|
549 |
|
---|
550 | #endif
|
---|