1 | /** @file
|
---|
2 | * VBox HDD Container API.
|
---|
3 | * Will replace VBoxHDD.h.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek 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 |
|
---|
18 | #ifndef ___VBox_VD_h
|
---|
19 | #define ___VBox_VD_h
|
---|
20 |
|
---|
21 | #include <VBox/cdefs.h>
|
---|
22 | #include <VBox/types.h>
|
---|
23 | #include <VBox/pdm.h>
|
---|
24 |
|
---|
25 | __BEGIN_DECLS
|
---|
26 |
|
---|
27 | #ifdef IN_RING0
|
---|
28 | # error "There are no VBox HDD Container APIs available in Ring-0 Host Context!"
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | /** @defgroup grp_vd VBox HDD Container
|
---|
32 | * @{
|
---|
33 | */
|
---|
34 |
|
---|
35 | /** Current VMDK image version. */
|
---|
36 | #define VMDK_IMAGE_VERSION (0x0001)
|
---|
37 |
|
---|
38 | /** Current VDI image major version. */
|
---|
39 | #define VDI_IMAGE_VERSION_MAJOR (0x0001)
|
---|
40 | /** Current VDI image minor version. */
|
---|
41 | #define VDI_IMAGE_VERSION_MINOR (0x0001)
|
---|
42 | /** Current VDI image version. */
|
---|
43 | #define VDI_IMAGE_VERSION ((VDI_IMAGE_VERSION_MAJOR << 16) | VDI_IMAGE_VERSION_MINOR)
|
---|
44 |
|
---|
45 | /** Get VDI major version from combined version. */
|
---|
46 | #define VDI_GET_VERSION_MAJOR(uVer) ((uVer) >> 16)
|
---|
47 | /** Get VDI minor version from combined version. */
|
---|
48 | #define VDI_GET_VERSION_MINOR(uVer) ((uVer) & 0xffff)
|
---|
49 |
|
---|
50 | /** @name VBox HDD container image types
|
---|
51 | * @{ */
|
---|
52 | typedef enum VDIMAGETYPE
|
---|
53 | {
|
---|
54 | /** Normal dynamically growing base image file. */
|
---|
55 | VD_IMAGE_TYPE_NORMAL = 1,
|
---|
56 | /** Preallocated base image file of a fixed size. */
|
---|
57 | VD_IMAGE_TYPE_FIXED,
|
---|
58 | /** Dynamically growing image file for undo/commit changes support. */
|
---|
59 | VD_IMAGE_TYPE_UNDO,
|
---|
60 | /** Dynamically growing image file for differencing support. */
|
---|
61 | VD_IMAGE_TYPE_DIFF,
|
---|
62 |
|
---|
63 | /** First valid image type value. */
|
---|
64 | VD_IMAGE_TYPE_FIRST = VD_IMAGE_TYPE_NORMAL,
|
---|
65 | /** Last valid image type value. */
|
---|
66 | VD_IMAGE_TYPE_LAST = VD_IMAGE_TYPE_DIFF
|
---|
67 | } VDIMAGETYPE;
|
---|
68 | /** Pointer to VBox HDD container image type. */
|
---|
69 | typedef VDIMAGETYPE *PVDIMAGETYPE;
|
---|
70 | /** @} */
|
---|
71 |
|
---|
72 | /** @name VBox HDD container image flags
|
---|
73 | * @{
|
---|
74 | */
|
---|
75 | /** No flags. */
|
---|
76 | #define VD_IMAGE_FLAGS_NONE (0)
|
---|
77 | /** VMDK: Split image into 2GB extents. */
|
---|
78 | #define VD_VMDK_IMAGE_FLAGS_SPLIT_2G (0x0001)
|
---|
79 | /** VMDK: Raw disk image (giving access to a number of host partitions). */
|
---|
80 | #define VD_VMDK_IMAGE_FLAGS_RAWDISK (0x0002)
|
---|
81 | /** VDI: Fill new blocks with zeroes while expanding image file. Only valid
|
---|
82 | * for newly created images, never set for opened existing images. */
|
---|
83 | #define VD_VDI_IMAGE_FLAGS_ZERO_EXPAND (0x0100)
|
---|
84 |
|
---|
85 | /** Mask of valid image flags for VMDK. */
|
---|
86 | #define VD_VMDK_IMAGE_FLAGS_MASK (VD_IMAGE_FLAGS_NONE | VD_VMDK_IMAGE_FLAGS_SPLIT_2G | VD_VMDK_IMAGE_FLAGS_RAWDISK)
|
---|
87 |
|
---|
88 | /** Mask of valid image flags for VDI. */
|
---|
89 | #define VD_VDI_IMAGE_FLAGS_MASK (VD_IMAGE_FLAGS_NONE | VD_VDI_IMAGE_FLAGS_ZERO_EXPAND)
|
---|
90 |
|
---|
91 | /** Default image flags. */
|
---|
92 | #define VD_IMAGE_FLAGS_DEFAULT (VD_IMAGE_FLAGS_NONE)
|
---|
93 | /** @} */
|
---|
94 |
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * Auxiliary type for describing partitions on raw disks.
|
---|
98 | */
|
---|
99 | typedef struct VBOXHDDRAWPART
|
---|
100 | {
|
---|
101 | /** Device to use for this partition. Can be the disk device if the offset
|
---|
102 | * field is set appropriately. If this is NULL, then this partition will
|
---|
103 | * not be accessible to the guest. The size of the partition must still
|
---|
104 | * be set correctly. */
|
---|
105 | const char *pszRawDevice;
|
---|
106 | /** Offset where the partition data starts in this device. */
|
---|
107 | uint64_t uPartitionStartOffset;
|
---|
108 | /** Offset where the partition data starts in the disk. */
|
---|
109 | uint64_t uPartitionStart;
|
---|
110 | /** Size of the partition. */
|
---|
111 | uint64_t cbPartition;
|
---|
112 | /** Size of the partitioning info to prepend. */
|
---|
113 | uint64_t cbPartitionData;
|
---|
114 | /** Offset where the partitioning info starts in the disk. */
|
---|
115 | uint64_t uPartitionDataStart;
|
---|
116 | /** Pointer to the partitioning info to prepend. */
|
---|
117 | const void *pvPartitionData;
|
---|
118 | } VBOXHDDRAWPART, *PVBOXHDDRAWPART;
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * Auxiliary data structure for creating raw disks.
|
---|
122 | */
|
---|
123 | typedef struct VBOXHDDRAW
|
---|
124 | {
|
---|
125 | /** Flag whether access to full disk should be given (ignoring the
|
---|
126 | * partition information below). */
|
---|
127 | bool fRawDisk;
|
---|
128 | /** Filename for the raw disk. Ignored for partitioned raw disks.
|
---|
129 | * For Linux e.g. /dev/sda, and for Windows e.g. \\.\PhysicalDisk0. */
|
---|
130 | const char *pszRawDisk;
|
---|
131 | /** Number of entries in the partitions array. */
|
---|
132 | unsigned cPartitions;
|
---|
133 | /** Pointer to the partitions array. */
|
---|
134 | PVBOXHDDRAWPART pPartitions;
|
---|
135 | } VBOXHDDRAW, *PVBOXHDDRAW;
|
---|
136 |
|
---|
137 | /** @name VBox HDD container image open mode flags
|
---|
138 | * @{
|
---|
139 | */
|
---|
140 | /** Try to open image in read/write exclusive access mode if possible, or in read-only elsewhere. */
|
---|
141 | #define VD_OPEN_FLAGS_NORMAL 0
|
---|
142 | /** Open image in read-only mode with sharing access with others. */
|
---|
143 | #define VD_OPEN_FLAGS_READONLY RT_BIT(0)
|
---|
144 | /** Honor zero block writes instead of ignoring them whenever possible.
|
---|
145 | * This is not supported by all formats. It is silently ignored in this case. */
|
---|
146 | #define VD_OPEN_FLAGS_HONOR_ZEROES RT_BIT(1)
|
---|
147 | /** Honor writes of the same data instead of ignoring whenever possible.
|
---|
148 | * This is handled generically, and is only meaningful for differential image
|
---|
149 | * formats. It is silently ignored otherwise. */
|
---|
150 | #define VD_OPEN_FLAGS_HONOR_SAME RT_BIT(2)
|
---|
151 | /** Do not perform the base/diff image check on open. This internally implies
|
---|
152 | * opening the image as readonly. Images opened with this flag should only be
|
---|
153 | * used for querying information, and nothing else. */
|
---|
154 | #define VD_OPEN_FLAGS_INFO RT_BIT(3)
|
---|
155 | /** Mask of valid flags. */
|
---|
156 | #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)
|
---|
157 | /** @}*/
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * Error message callback.
|
---|
161 | *
|
---|
162 | * @param pvUser The opaque data passed on container creation.
|
---|
163 | * @param rc The VBox error code.
|
---|
164 | * @param RT_SRC_POS_DECL Use RT_SRC_POS.
|
---|
165 | * @param pszFormat Error message format string.
|
---|
166 | * @param va Error message arguments.
|
---|
167 | */
|
---|
168 | typedef DECLCALLBACK(void) FNVDERROR(void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va);
|
---|
169 | /** Pointer to a FNVDERROR(). */
|
---|
170 | typedef FNVDERROR *PFNVDERROR;
|
---|
171 |
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * VBox HDD Container main structure.
|
---|
175 | */
|
---|
176 | /* Forward declaration, VBOXHDD structure is visible only inside VBox HDD module. */
|
---|
177 | struct VBOXHDD;
|
---|
178 | typedef struct VBOXHDD VBOXHDD;
|
---|
179 | typedef VBOXHDD *PVBOXHDD;
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * Allocates and initializes an empty VBox HDD container.
|
---|
183 | * No image files are opened.
|
---|
184 | *
|
---|
185 | * @returns VBox status code.
|
---|
186 | * @param pszBackend Name of the image file backend to use.
|
---|
187 | * @param pfnError Callback for setting extended error information.
|
---|
188 | * @param pvErrorUser Opaque parameter for pfnError.
|
---|
189 | * @param ppDisk Where to store the reference to the VBox HDD container.
|
---|
190 | */
|
---|
191 | VBOXDDU_DECL(int) VDCreate(const char *pszBackend, PFNVDERROR pfnError, void *pvErrorUser, PVBOXHDD *ppDisk);
|
---|
192 |
|
---|
193 | /**
|
---|
194 | * Destroys the VBox HDD container.
|
---|
195 | * If container has opened image files they will be closed.
|
---|
196 | *
|
---|
197 | * @param pDisk Pointer to VBox HDD container.
|
---|
198 | */
|
---|
199 | VBOXDDU_DECL(void) VDDestroy(PVBOXHDD pDisk);
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * Try to get the backend name which can use this image.
|
---|
203 | *
|
---|
204 | * @returns VBox status code.
|
---|
205 | * @param pszFilename Name of the image file for which the backend is queried.
|
---|
206 | * @param ppszFormat Where to store the name of the plugin.
|
---|
207 | */
|
---|
208 | VBOXDDU_DECL(int) VDGetFormat(const char *pszFilename, char **ppszFormat);
|
---|
209 |
|
---|
210 | /**
|
---|
211 | * Opens an image file.
|
---|
212 | *
|
---|
213 | * The first opened image file in a HDD container must have a base image type,
|
---|
214 | * others (next opened images) must be differencing or undo images.
|
---|
215 | * Linkage is checked for differencing image to be consistent with the previously opened image.
|
---|
216 | * When another differencing image is opened and the last image was opened in read/write access
|
---|
217 | * mode, then the last image is reopened in read-only with deny write sharing mode. This allows
|
---|
218 | * other processes to use images in read-only mode too.
|
---|
219 | *
|
---|
220 | * Note that the image is opened in read-only mode if a read/write open is not possible.
|
---|
221 | * Use VDIsReadOnly to check open mode.
|
---|
222 | *
|
---|
223 | * @returns VBox status code.
|
---|
224 | * @param pDisk Pointer to VBox HDD container.
|
---|
225 | * @param pszFilename Name of the image file to open.
|
---|
226 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
227 | */
|
---|
228 | VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszFilename, unsigned uOpenFlags);
|
---|
229 |
|
---|
230 | /**
|
---|
231 | * Creates and opens a new base image file.
|
---|
232 | *
|
---|
233 | * @returns VBox status code.
|
---|
234 | * @param pDisk Pointer to VBox HDD container.
|
---|
235 | * @param pszFilename Name of the image file to create.
|
---|
236 | * @param enmType Image type, only base image types are acceptable.
|
---|
237 | * @param cbSize Image size in bytes.
|
---|
238 | * @param uImageFlags Flags specifying special image features.
|
---|
239 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
240 | * @param cCylinders Number of cylinders (must be <= 16383).
|
---|
241 | * @param cHeads Number of heads (must be <= 16).
|
---|
242 | * @param cSectors Number of sectors (must be <= 63);
|
---|
243 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
244 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
245 | * @param pvUser User argument for the progress callback.
|
---|
246 | */
|
---|
247 | VBOXDDU_DECL(int) VDCreateBase(PVBOXHDD pDisk, const char *pszFilename,
|
---|
248 | VDIMAGETYPE enmType, uint64_t cbSize,
|
---|
249 | unsigned uImageFlags, const char *pszComment,
|
---|
250 | unsigned cCylinders, unsigned cHeads,
|
---|
251 | unsigned cSectors, unsigned uOpenFlags,
|
---|
252 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
253 |
|
---|
254 | /**
|
---|
255 | * Creates and opens a new differencing image file in HDD container.
|
---|
256 | * See comments for VDOpen function about differencing images.
|
---|
257 | *
|
---|
258 | * @returns VBox status code.
|
---|
259 | * @param pDisk Pointer to VBox HDD container.
|
---|
260 | * @param pszFilename Name of the differencing image file to create.
|
---|
261 | * @param uImageFlags Flags specifying special image features.
|
---|
262 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
263 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
264 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
265 | * @param pvUser User argument for the progress callback.
|
---|
266 | */
|
---|
267 | VBOXDDU_DECL(int) VDCreateDiff(PVBOXHDD pDisk, const char *pszFilename,
|
---|
268 | unsigned uImageFlags, const char *pszComment,
|
---|
269 | unsigned uOpenFlags,
|
---|
270 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
271 |
|
---|
272 | /**
|
---|
273 | * Merges two images having a parent/child relationship (both directions).
|
---|
274 | * As a side effect the source image is deleted from both the disk and
|
---|
275 | * the images in the VBox HDD container.
|
---|
276 | *
|
---|
277 | * @returns VBox status code.
|
---|
278 | * @param pDisk Pointer to VBox HDD container.
|
---|
279 | * @param nImageFrom Name of the image file to merge from.
|
---|
280 | * @param nImageTo Name of the image file to merge to.
|
---|
281 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
282 | * @param pvUser User argument for the progress callback.
|
---|
283 | */
|
---|
284 | VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom, unsigned nImageTo,
|
---|
285 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
286 |
|
---|
287 | /**
|
---|
288 | * Copies an image from one VBox HDD container to another.
|
---|
289 | * The copy is opened in the target VBox HDD container.
|
---|
290 | * It is possible to convert between different image formats, because the
|
---|
291 | * backend for the destination VBox HDD container may be different from the
|
---|
292 | * source container.
|
---|
293 | * If both the source and destination reference the same VBox HDD container,
|
---|
294 | * then the image is moved (by copying/deleting) to the new location.
|
---|
295 | * The source container is unchanged if the move operation fails, otherwise
|
---|
296 | * the image at the new location is opened in the same way as the old one was.
|
---|
297 | *
|
---|
298 | * @returns VBox status code.
|
---|
299 | * @param pDiskFrom Pointer to source VBox HDD container.
|
---|
300 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
301 | * @param pDiskTo Pointer to destination VBox HDD container.
|
---|
302 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
303 | * @param pvUser User argument for the progress callback.
|
---|
304 | */
|
---|
305 | VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo,
|
---|
306 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
307 |
|
---|
308 | /**
|
---|
309 | * Compacts a growing image file by removing zeroed data blocks.
|
---|
310 | * Optionally defragments data in the image so that ascending sector numbers
|
---|
311 | * are stored in ascending location in the image file.
|
---|
312 | *
|
---|
313 | * @todo maybe include this function in VDCopy.
|
---|
314 | *
|
---|
315 | * @returns VBox status code.
|
---|
316 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
317 | * @param pDisk Pointer to VBox HDD container.
|
---|
318 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
319 | * @param fDefragment If true, reorder file data so that sectors are stored in ascending order.
|
---|
320 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
321 | * @param pvUser User argument for the progress callback.
|
---|
322 | */
|
---|
323 | VBOXDDU_DECL(int) VDCompact(PVBOXHDD pDisk, unsigned nImage,
|
---|
324 | bool fDefragment,
|
---|
325 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
326 |
|
---|
327 | /**
|
---|
328 | * Resizes an image. Allows setting the disk size to both larger and smaller
|
---|
329 | * values than the current disk size.
|
---|
330 | *
|
---|
331 | * @returns VBox status code.
|
---|
332 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
333 | * @param pDisk Pointer to VBox HDD container.
|
---|
334 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
335 | * @param cbSize New image size in bytes.
|
---|
336 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
337 | * @param pvUser User argument for the progress callback.
|
---|
338 | */
|
---|
339 | VBOXDDU_DECL(int) VDResize(PVBOXHDD pDisk, unsigned nImage, uint64_t cbSize,
|
---|
340 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
341 |
|
---|
342 | /**
|
---|
343 | * Closes the last opened image file in the HDD container. Leaves all changes inside it.
|
---|
344 | * If previous image file was opened in read-only mode (that is normal) and closing image
|
---|
345 | * was opened in read-write mode (the whole disk was in read-write mode) - the previous image
|
---|
346 | * will be reopened in read/write mode.
|
---|
347 | *
|
---|
348 | * @param pDisk Pointer to VBox HDD container.
|
---|
349 | * @param fDelete If true, delete the image from the host disk.
|
---|
350 | */
|
---|
351 | VBOXDDU_DECL(int) VDClose(PVBOXHDD pDisk, bool fDelete);
|
---|
352 |
|
---|
353 | /**
|
---|
354 | * Closes all opened image files in HDD container.
|
---|
355 | *
|
---|
356 | * @param pDisk Pointer to VBox HDD container.
|
---|
357 | */
|
---|
358 | VBOXDDU_DECL(int) VDCloseAll(PVBOXHDD pDisk);
|
---|
359 |
|
---|
360 | /**
|
---|
361 | * Read data from virtual HDD.
|
---|
362 | *
|
---|
363 | * @returns VBox status code.
|
---|
364 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
365 | * @param pDisk Pointer to VBox HDD container.
|
---|
366 | * @param uOffset Offset of first reading byte from start of disk.
|
---|
367 | * @param pvBuf Pointer to buffer for reading data.
|
---|
368 | * @param cbRead Number of bytes to read.
|
---|
369 | */
|
---|
370 | VBOXDDU_DECL(int) VDRead(PVBOXHDD pDisk, uint64_t uOffset, void *pvBuf, size_t cbRead);
|
---|
371 |
|
---|
372 | /**
|
---|
373 | * Write data to virtual HDD.
|
---|
374 | *
|
---|
375 | * @returns VBox status code.
|
---|
376 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
377 | * @param pDisk Pointer to VBox HDD container.
|
---|
378 | * @param uOffset Offset of first writing byte from start of disk.
|
---|
379 | * @param pvBuf Pointer to buffer for writing data.
|
---|
380 | * @param cbWrite Number of bytes to write.
|
---|
381 | */
|
---|
382 | VBOXDDU_DECL(int) VDWrite(PVBOXHDD pDisk, uint64_t uOffset, const void *pvBuf, size_t cbWrite);
|
---|
383 |
|
---|
384 | /**
|
---|
385 | * Make sure the on disk representation of a virtual HDD is up to date.
|
---|
386 | *
|
---|
387 | * @returns VBox status code.
|
---|
388 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
389 | * @param pDisk Pointer to VBox HDD container.
|
---|
390 | */
|
---|
391 | VBOXDDU_DECL(int) VDFlush(PVBOXHDD pDisk);
|
---|
392 |
|
---|
393 | /**
|
---|
394 | * Get number of opened images in HDD container.
|
---|
395 | *
|
---|
396 | * @returns Number of opened images for HDD container. 0 if no images have been opened.
|
---|
397 | * @param pDisk Pointer to VBox HDD container.
|
---|
398 | */
|
---|
399 | VBOXDDU_DECL(unsigned) VDGetCount(PVBOXHDD pDisk);
|
---|
400 |
|
---|
401 | /**
|
---|
402 | * Get read/write mode of the VBox HDD container.
|
---|
403 | *
|
---|
404 | * @returns Virtual disk ReadOnly status.
|
---|
405 | * @returns true if no image is opened in HDD container.
|
---|
406 | * @param pDisk Pointer to VBox HDD container.
|
---|
407 | */
|
---|
408 | VBOXDDU_DECL(bool) VDIsReadOnly(PVBOXHDD pDisk);
|
---|
409 |
|
---|
410 | /**
|
---|
411 | * Get total disk size of the VBox HDD container.
|
---|
412 | *
|
---|
413 | * @returns Virtual disk size in bytes.
|
---|
414 | * @returns 0 if no image is opened in HDD container.
|
---|
415 | * @param pDisk Pointer to VBox HDD container.
|
---|
416 | */
|
---|
417 | VBOXDDU_DECL(uint64_t) VDGetSize(PVBOXHDD pDisk);
|
---|
418 |
|
---|
419 | /**
|
---|
420 | * Get virtual disk geometry stored in HDD container.
|
---|
421 | *
|
---|
422 | * @returns VBox status code.
|
---|
423 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
424 | * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the HDD container.
|
---|
425 | * @param pDisk Pointer to VBox HDD container.
|
---|
426 | * @param pcCylinders Where to store the number of cylinders. NULL is ok.
|
---|
427 | * @param pcHeads Where to store the number of heads. NULL is ok.
|
---|
428 | * @param pcSectors Where to store the number of sectors. NULL is ok.
|
---|
429 | */
|
---|
430 | VBOXDDU_DECL(int) VDGetGeometry(PVBOXHDD pDisk,
|
---|
431 | unsigned *pcCylinders, unsigned *pcHeads, unsigned *pcSectors);
|
---|
432 |
|
---|
433 | /**
|
---|
434 | * Store virtual disk geometry in HDD container.
|
---|
435 | *
|
---|
436 | * Note that in case of unrecoverable error all images in HDD container will be closed.
|
---|
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 cCylinders Number of cylinders.
|
---|
442 | * @param cHeads Number of heads.
|
---|
443 | * @param cSectors Number of sectors.
|
---|
444 | */
|
---|
445 | VBOXDDU_DECL(int) VDSetGeometry(PVBOXHDD pDisk,
|
---|
446 | unsigned cCylinders, unsigned cHeads, unsigned cSectors);
|
---|
447 |
|
---|
448 | /**
|
---|
449 | * Get virtual disk translation mode stored in HDD container.
|
---|
450 | *
|
---|
451 | * @returns VBox status code.
|
---|
452 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
453 | * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the HDD container.
|
---|
454 | * @param pDisk Pointer to VBox HDD container.
|
---|
455 | * @param penmTranslation Where to store the translation mode (see pdm.h).
|
---|
456 | */
|
---|
457 | VBOXDDU_DECL(int) VDGetTranslation(PVBOXHDD pDisk, PPDMBIOSTRANSLATION penmTranslation);
|
---|
458 |
|
---|
459 | /**
|
---|
460 | * Store virtual disk translation mode in HDD container.
|
---|
461 | *
|
---|
462 | * Note that in case of unrecoverable error all images in HDD container will be closed.
|
---|
463 | *
|
---|
464 | * @returns VBox status code.
|
---|
465 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
466 | * @param pDisk Pointer to VBox HDD container.
|
---|
467 | * @param enmTranslation Translation mode (see pdm.h).
|
---|
468 | */
|
---|
469 | VBOXDDU_DECL(int) VDSetTranslation(PVBOXHDD pDisk, PDMBIOSTRANSLATION enmTranslation);
|
---|
470 |
|
---|
471 | /**
|
---|
472 | * Get version of image in HDD container.
|
---|
473 | *
|
---|
474 | * @returns VBox status code.
|
---|
475 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
476 | * @param pDisk Pointer to VBox HDD container.
|
---|
477 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
478 | * @param puVersion Where to store the image version.
|
---|
479 | */
|
---|
480 | VBOXDDU_DECL(int) VDGetVersion(PVBOXHDD pDisk, unsigned nImage, unsigned *puVersion);
|
---|
481 |
|
---|
482 | /**
|
---|
483 | * Get type of image in 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 VBox HDD container.
|
---|
488 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
489 | * @param penmType Where to store the image type.
|
---|
490 | */
|
---|
491 | VBOXDDU_DECL(int) VDGetImageType(PVBOXHDD pDisk, unsigned nImage, PVDIMAGETYPE penmType);
|
---|
492 |
|
---|
493 | /**
|
---|
494 | * Get flags of image in 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 VBox HDD container.
|
---|
499 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
500 | * @param puImageFlags Where to store the image flags.
|
---|
501 | */
|
---|
502 | VBOXDDU_DECL(int) VDGetImageFlags(PVBOXHDD pDisk, unsigned nImage, unsigned *puImageFlags);
|
---|
503 |
|
---|
504 | /**
|
---|
505 | * Get open flags of last opened image in HDD container.
|
---|
506 | *
|
---|
507 | * @returns VBox status code.
|
---|
508 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
509 | * @param pDisk Pointer to VBox HDD container.
|
---|
510 | * @param puOpenFlags Where to store the image open flags.
|
---|
511 | */
|
---|
512 | VBOXDDU_DECL(int) VDGetOpenFlags(PVBOXHDD pDisk, unsigned *puOpenFlags);
|
---|
513 |
|
---|
514 | /**
|
---|
515 | * Set open flags of last opened image in HDD container.
|
---|
516 | * This operation may cause file locking changes and/or files being reopened.
|
---|
517 | * Note that in case of unrecoverable error all images in HDD container will be closed.
|
---|
518 | *
|
---|
519 | * @returns VBox status code.
|
---|
520 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
521 | * @param pDisk Pointer to VBox HDD container.
|
---|
522 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
523 | */
|
---|
524 | VBOXDDU_DECL(int) VDSetOpenFlags(PVBOXHDD pDisk, unsigned uOpenFlags);
|
---|
525 |
|
---|
526 | /**
|
---|
527 | * Get base filename of image in HDD container. Some image formats use
|
---|
528 | * other filenames as well, so don't use this for anything but for informational
|
---|
529 | * purposes.
|
---|
530 | *
|
---|
531 | * @returns VBox status code.
|
---|
532 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
533 | * @returns VERR_BUFFER_OVERFLOW if pszFilename buffer too small to hold filename.
|
---|
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 pszFilename Where to store the image file name.
|
---|
537 | * @param cbFilename Size of buffer pszFilename points to.
|
---|
538 | */
|
---|
539 | VBOXDDU_DECL(int) VDGetFilename(PVBOXHDD pDisk, unsigned nImage, char *pszFilename, unsigned cbFilename);
|
---|
540 |
|
---|
541 | /**
|
---|
542 | * Get the comment line of image in HDD container.
|
---|
543 | *
|
---|
544 | * @returns VBox status code.
|
---|
545 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
546 | * @returns VERR_BUFFER_OVERFLOW if pszComment buffer too small to hold comment text.
|
---|
547 | * @param pDisk Pointer to VBox HDD container.
|
---|
548 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
549 | * @param pszComment Where to store the comment string of image. NULL is ok.
|
---|
550 | * @param cbComment The size of pszComment buffer. 0 is ok.
|
---|
551 | */
|
---|
552 | VBOXDDU_DECL(int) VDGetComment(PVBOXHDD pDisk, unsigned nImage, char *pszComment, unsigned cbComment);
|
---|
553 |
|
---|
554 | /**
|
---|
555 | * Changes the comment line of image in HDD container.
|
---|
556 | *
|
---|
557 | * @returns VBox status code.
|
---|
558 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
559 | * @param pDisk Pointer to VBox HDD container.
|
---|
560 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
561 | * @param pszComment New comment string (UTF-8). NULL is allowed to reset the comment.
|
---|
562 | */
|
---|
563 | VBOXDDU_DECL(int) VDSetComment(PVBOXHDD pDisk, unsigned nImage, const char *pszComment);
|
---|
564 |
|
---|
565 | /**
|
---|
566 | * Get UUID of image in HDD container.
|
---|
567 | *
|
---|
568 | * @returns VBox status code.
|
---|
569 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
570 | * @param pDisk Pointer to VBox HDD container.
|
---|
571 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
572 | * @param pUuid Where to store the image UUID.
|
---|
573 | */
|
---|
574 | VBOXDDU_DECL(int) VDGetUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
|
---|
575 |
|
---|
576 | /**
|
---|
577 | * Set the image's UUID. Should not be used by normal applications.
|
---|
578 | *
|
---|
579 | * @returns VBox status code.
|
---|
580 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
581 | * @param pDisk Pointer to VBox HDD container.
|
---|
582 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
583 | * @param pUuid Optional parameter, new UUID of the image.
|
---|
584 | */
|
---|
585 | VBOXDDU_DECL(int) VDSetUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
|
---|
586 |
|
---|
587 | /**
|
---|
588 | * Get last modification UUID of image in HDD container.
|
---|
589 | *
|
---|
590 | * @returns VBox status code.
|
---|
591 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
592 | * @param pDisk Pointer to VBox HDD container.
|
---|
593 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
594 | * @param pUuid Where to store the image modification UUID.
|
---|
595 | */
|
---|
596 | VBOXDDU_DECL(int) VDGetModificationUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
|
---|
597 |
|
---|
598 | /**
|
---|
599 | * Set the image's last modification UUID. Should not be used by normal applications.
|
---|
600 | *
|
---|
601 | * @returns VBox status code.
|
---|
602 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
603 | * @param pDisk Pointer to VBox HDD container.
|
---|
604 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
605 | * @param pUuid Optional parameter, new last modification UUID of the image.
|
---|
606 | */
|
---|
607 | VBOXDDU_DECL(int) VDSetModificationUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
|
---|
608 |
|
---|
609 | /**
|
---|
610 | * Get parent UUID of image in HDD container.
|
---|
611 | *
|
---|
612 | * @returns VBox status code.
|
---|
613 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
614 | * @param pDisk Pointer to VBox HDD container.
|
---|
615 | * @param nImage Image number, counts from 0. 0 is always base image of the container.
|
---|
616 | * @param pUuid Where to store the parent image UUID.
|
---|
617 | */
|
---|
618 | VBOXDDU_DECL(int) VDGetParentUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
|
---|
619 |
|
---|
620 | /**
|
---|
621 | * Set the image's parent UUID. Should not be used by normal applications.
|
---|
622 | *
|
---|
623 | * @returns VBox status code.
|
---|
624 | * @param pDisk Pointer to VBox HDD container.
|
---|
625 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
626 | * @param pUuid Optional parameter, new parent UUID of the image.
|
---|
627 | */
|
---|
628 | VBOXDDU_DECL(int) VDSetParentUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
|
---|
629 |
|
---|
630 |
|
---|
631 | /**
|
---|
632 | * Debug helper - dumps all opened images in HDD container into the log file.
|
---|
633 | *
|
---|
634 | * @param pDisk Pointer to VBox HDD container.
|
---|
635 | */
|
---|
636 | VBOXDDU_DECL(void) VDDumpImages(PVBOXHDD pDisk);
|
---|
637 |
|
---|
638 | __END_DECLS
|
---|
639 |
|
---|
640 | /** @} */
|
---|
641 |
|
---|
642 | #endif
|
---|