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 | * Opens an image file.
|
---|
203 | *
|
---|
204 | * The first opened image file in a HDD container must have a base image type,
|
---|
205 | * others (next opened images) must be differencing or undo images.
|
---|
206 | * Linkage is checked for differencing image to be consistent with the previously opened image.
|
---|
207 | * When another differencing image is opened and the last image was opened in read/write access
|
---|
208 | * mode, then the last image is reopened in read-only with deny write sharing mode. This allows
|
---|
209 | * other processes to use images in read-only mode too.
|
---|
210 | *
|
---|
211 | * Note that the image is opened in read-only mode if a read/write open is not possible.
|
---|
212 | * Use VDIsReadOnly to check open mode.
|
---|
213 | *
|
---|
214 | * @returns VBox status code.
|
---|
215 | * @param pDisk Pointer to VBox HDD container.
|
---|
216 | * @param pszFilename Name of the image file to open.
|
---|
217 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
218 | */
|
---|
219 | VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszFilename, unsigned uOpenFlags);
|
---|
220 |
|
---|
221 | /**
|
---|
222 | * Creates and opens a new base image file.
|
---|
223 | *
|
---|
224 | * @returns VBox status code.
|
---|
225 | * @param pDisk Pointer to VBox HDD container.
|
---|
226 | * @param pszFilename Name of the image file to create.
|
---|
227 | * @param enmType Image type, only base image types are acceptable.
|
---|
228 | * @param cbSize Image size in bytes.
|
---|
229 | * @param uImageFlags Flags specifying special image features.
|
---|
230 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
231 | * @param cCylinders Number of cylinders (must be <= 16383).
|
---|
232 | * @param cHeads Number of heads (must be <= 16).
|
---|
233 | * @param cSectors Number of sectors (must be <= 63);
|
---|
234 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
235 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
236 | * @param pvUser User argument for the progress callback.
|
---|
237 | */
|
---|
238 | VBOXDDU_DECL(int) VDCreateBase(PVBOXHDD pDisk, const char *pszFilename,
|
---|
239 | VDIMAGETYPE enmType, uint64_t cbSize,
|
---|
240 | unsigned uImageFlags, const char *pszComment,
|
---|
241 | unsigned cCylinders, unsigned cHeads,
|
---|
242 | unsigned cSectors, unsigned uOpenFlags,
|
---|
243 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
244 |
|
---|
245 | /**
|
---|
246 | * Creates and opens a new differencing image file in HDD container.
|
---|
247 | * See comments for VDOpen function about differencing images.
|
---|
248 | *
|
---|
249 | * @returns VBox status code.
|
---|
250 | * @param pDisk Pointer to VBox HDD container.
|
---|
251 | * @param pszFilename Name of the differencing image file to create.
|
---|
252 | * @param uImageFlags Flags specifying special image features.
|
---|
253 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
254 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
255 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
256 | * @param pvUser User argument for the progress callback.
|
---|
257 | */
|
---|
258 | VBOXDDU_DECL(int) VDCreateDiff(PVBOXHDD pDisk, const char *pszFilename,
|
---|
259 | unsigned uImageFlags, const char *pszComment,
|
---|
260 | unsigned uOpenFlags,
|
---|
261 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
262 |
|
---|
263 | /**
|
---|
264 | * Merges two images having a parent/child relationship (both directions).
|
---|
265 | * As a side effect the source image is deleted from both the disk and
|
---|
266 | * the images in the VBox HDD container.
|
---|
267 | *
|
---|
268 | * @returns VBox status code.
|
---|
269 | * @param pDisk Pointer to VBox HDD container.
|
---|
270 | * @param nImageFrom Name of the image file to merge from.
|
---|
271 | * @param nImageTo Name of the image file to merge to.
|
---|
272 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
273 | * @param pvUser User argument for the progress callback.
|
---|
274 | */
|
---|
275 | VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom, unsigned nImageTo,
|
---|
276 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
277 |
|
---|
278 | /**
|
---|
279 | * Copies an image from one VBox HDD container to another.
|
---|
280 | * The copy is opened in the target VBox HDD container.
|
---|
281 | * It is possible to convert between different image formats, because the
|
---|
282 | * backend for the destination VBox HDD container may be different from the
|
---|
283 | * source container.
|
---|
284 | * If both the source and destination reference the same VBox HDD container,
|
---|
285 | * then the image is moved (by copying/deleting) to the new location.
|
---|
286 | * The source container is unchanged if the move operation fails, otherwise
|
---|
287 | * the image at the new location is opened in the same way as the old one was.
|
---|
288 | *
|
---|
289 | * @returns VBox status code.
|
---|
290 | * @param pDiskFrom Pointer to source VBox HDD container.
|
---|
291 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
292 | * @param pDiskTo Pointer to destination VBox HDD container.
|
---|
293 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
294 | * @param pvUser User argument for the progress callback.
|
---|
295 | */
|
---|
296 | VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo,
|
---|
297 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
298 |
|
---|
299 | /**
|
---|
300 | * Compacts a growing image file by removing zeroed data blocks.
|
---|
301 | * Optionally defragments data in the image so that ascending sector numbers
|
---|
302 | * are stored in ascending location in the image file.
|
---|
303 | *
|
---|
304 | * @todo maybe include this function in VDCopy.
|
---|
305 | *
|
---|
306 | * @returns VBox status code.
|
---|
307 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
308 | * @param pDisk Pointer to VBox HDD container.
|
---|
309 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
310 | * @param fDefragment If true, reorder file data so that sectors are stored in ascending order.
|
---|
311 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
312 | * @param pvUser User argument for the progress callback.
|
---|
313 | */
|
---|
314 | VBOXDDU_DECL(int) VDCompact(PVBOXHDD pDisk, unsigned nImage,
|
---|
315 | bool fDefragment,
|
---|
316 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
317 |
|
---|
318 | /**
|
---|
319 | * Resizes an image. Allows setting the disk size to both larger and smaller
|
---|
320 | * values than the current disk size.
|
---|
321 | *
|
---|
322 | * @returns VBox status code.
|
---|
323 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
324 | * @param pDisk Pointer to VBox HDD container.
|
---|
325 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
326 | * @param cbSize New image size in bytes.
|
---|
327 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
328 | * @param pvUser User argument for the progress callback.
|
---|
329 | */
|
---|
330 | VBOXDDU_DECL(int) VDResize(PVBOXHDD pDisk, unsigned nImage, uint64_t cbSize,
|
---|
331 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
332 |
|
---|
333 | /**
|
---|
334 | * Closes the last opened image file in the HDD container. Leaves all changes inside it.
|
---|
335 | * If previous image file was opened in read-only mode (that is normal) and closing image
|
---|
336 | * was opened in read-write mode (the whole disk was in read-write mode) - the previous image
|
---|
337 | * will be reopened in read/write mode.
|
---|
338 | *
|
---|
339 | * @param pDisk Pointer to VBox HDD container.
|
---|
340 | * @param fDelete If true, delete the image from the host disk.
|
---|
341 | */
|
---|
342 | VBOXDDU_DECL(int) VDClose(PVBOXHDD pDisk, bool fDelete);
|
---|
343 |
|
---|
344 | /**
|
---|
345 | * Closes all opened image files in HDD container.
|
---|
346 | *
|
---|
347 | * @param pDisk Pointer to VBox HDD container.
|
---|
348 | */
|
---|
349 | VBOXDDU_DECL(int) VDCloseAll(PVBOXHDD pDisk);
|
---|
350 |
|
---|
351 | /**
|
---|
352 | * Read data from virtual HDD.
|
---|
353 | *
|
---|
354 | * @returns VBox status code.
|
---|
355 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
356 | * @param pDisk Pointer to VBox HDD container.
|
---|
357 | * @param uOffset Offset of first reading byte from start of disk.
|
---|
358 | * @param pvBuf Pointer to buffer for reading data.
|
---|
359 | * @param cbRead Number of bytes to read.
|
---|
360 | */
|
---|
361 | VBOXDDU_DECL(int) VDRead(PVBOXHDD pDisk, uint64_t uOffset, void *pvBuf, size_t cbRead);
|
---|
362 |
|
---|
363 | /**
|
---|
364 | * Write data to virtual HDD.
|
---|
365 | *
|
---|
366 | * @returns VBox status code.
|
---|
367 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
368 | * @param pDisk Pointer to VBox HDD container.
|
---|
369 | * @param uOffset Offset of first writing byte from start of disk.
|
---|
370 | * @param pvBuf Pointer to buffer for writing data.
|
---|
371 | * @param cbWrite Number of bytes to write.
|
---|
372 | */
|
---|
373 | VBOXDDU_DECL(int) VDWrite(PVBOXHDD pDisk, uint64_t uOffset, const void *pvBuf, size_t cbWrite);
|
---|
374 |
|
---|
375 | /**
|
---|
376 | * Make sure the on disk representation of a virtual HDD is up to date.
|
---|
377 | *
|
---|
378 | * @returns VBox status code.
|
---|
379 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
380 | * @param pDisk Pointer to VBox HDD container.
|
---|
381 | */
|
---|
382 | VBOXDDU_DECL(int) VDFlush(PVBOXHDD pDisk);
|
---|
383 |
|
---|
384 | /**
|
---|
385 | * Get number of opened images in HDD container.
|
---|
386 | *
|
---|
387 | * @returns Number of opened images for HDD container. 0 if no images have been opened.
|
---|
388 | * @param pDisk Pointer to VBox HDD container.
|
---|
389 | */
|
---|
390 | VBOXDDU_DECL(unsigned) VDGetCount(PVBOXHDD pDisk);
|
---|
391 |
|
---|
392 | /**
|
---|
393 | * Get read/write mode of the VBox HDD container.
|
---|
394 | *
|
---|
395 | * @returns Virtual disk ReadOnly status.
|
---|
396 | * @returns true if no image is opened in HDD container.
|
---|
397 | * @param pDisk Pointer to VBox HDD container.
|
---|
398 | */
|
---|
399 | VBOXDDU_DECL(bool) VDIsReadOnly(PVBOXHDD pDisk);
|
---|
400 |
|
---|
401 | /**
|
---|
402 | * Get total disk size of the VBox HDD container.
|
---|
403 | *
|
---|
404 | * @returns Virtual disk size in bytes.
|
---|
405 | * @returns 0 if no image is opened in HDD container.
|
---|
406 | * @param pDisk Pointer to VBox HDD container.
|
---|
407 | */
|
---|
408 | VBOXDDU_DECL(uint64_t) VDGetSize(PVBOXHDD pDisk);
|
---|
409 |
|
---|
410 | /**
|
---|
411 | * Get virtual disk geometry stored in HDD container.
|
---|
412 | *
|
---|
413 | * @returns VBox status code.
|
---|
414 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
415 | * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the HDD container.
|
---|
416 | * @param pDisk Pointer to VBox HDD container.
|
---|
417 | * @param pcCylinders Where to store the number of cylinders. NULL is ok.
|
---|
418 | * @param pcHeads Where to store the number of heads. NULL is ok.
|
---|
419 | * @param pcSectors Where to store the number of sectors. NULL is ok.
|
---|
420 | */
|
---|
421 | VBOXDDU_DECL(int) VDGetGeometry(PVBOXHDD pDisk,
|
---|
422 | unsigned *pcCylinders, unsigned *pcHeads, unsigned *pcSectors);
|
---|
423 |
|
---|
424 | /**
|
---|
425 | * Store virtual disk geometry in HDD container.
|
---|
426 | *
|
---|
427 | * Note that in case of unrecoverable error all images in HDD container will be closed.
|
---|
428 | *
|
---|
429 | * @returns VBox status code.
|
---|
430 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
431 | * @param pDisk Pointer to VBox HDD container.
|
---|
432 | * @param cCylinders Number of cylinders.
|
---|
433 | * @param cHeads Number of heads.
|
---|
434 | * @param cSectors Number of sectors.
|
---|
435 | */
|
---|
436 | VBOXDDU_DECL(int) VDSetGeometry(PVBOXHDD pDisk,
|
---|
437 | unsigned cCylinders, unsigned cHeads, unsigned cSectors);
|
---|
438 |
|
---|
439 | /**
|
---|
440 | * Get virtual disk translation mode stored in HDD container.
|
---|
441 | *
|
---|
442 | * @returns VBox status code.
|
---|
443 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
444 | * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the HDD container.
|
---|
445 | * @param pDisk Pointer to VBox HDD container.
|
---|
446 | * @param penmTranslation Where to store the translation mode (see pdm.h).
|
---|
447 | */
|
---|
448 | VBOXDDU_DECL(int) VDGetTranslation(PVBOXHDD pDisk, PPDMBIOSTRANSLATION penmTranslation);
|
---|
449 |
|
---|
450 | /**
|
---|
451 | * Store virtual disk translation mode in HDD container.
|
---|
452 | *
|
---|
453 | * Note that in case of unrecoverable error all images in HDD container will be closed.
|
---|
454 | *
|
---|
455 | * @returns VBox status code.
|
---|
456 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
457 | * @param pDisk Pointer to VBox HDD container.
|
---|
458 | * @param enmTranslation Translation mode (see pdm.h).
|
---|
459 | */
|
---|
460 | VBOXDDU_DECL(int) VDSetTranslation(PVBOXHDD pDisk, PDMBIOSTRANSLATION enmTranslation);
|
---|
461 |
|
---|
462 | /**
|
---|
463 | * Get version of image in HDD container.
|
---|
464 | *
|
---|
465 | * @returns VBox status code.
|
---|
466 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
467 | * @param pDisk Pointer to VBox HDD container.
|
---|
468 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
469 | * @param puVersion Where to store the image version.
|
---|
470 | */
|
---|
471 | VBOXDDU_DECL(int) VDGetVersion(PVBOXHDD pDisk, unsigned nImage, unsigned *puVersion);
|
---|
472 |
|
---|
473 | /**
|
---|
474 | * Get type of image in HDD container.
|
---|
475 | *
|
---|
476 | * @returns VBox status code.
|
---|
477 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
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 penmType Where to store the image type.
|
---|
481 | */
|
---|
482 | VBOXDDU_DECL(int) VDGetImageType(PVBOXHDD pDisk, unsigned nImage, PVDIMAGETYPE penmType);
|
---|
483 |
|
---|
484 | /**
|
---|
485 | * Get flags of image in HDD container.
|
---|
486 | *
|
---|
487 | * @returns VBox status code.
|
---|
488 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
489 | * @param pDisk Pointer to VBox HDD container.
|
---|
490 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
491 | * @param puImageFlags Where to store the image flags.
|
---|
492 | */
|
---|
493 | VBOXDDU_DECL(int) VDGetImageFlags(PVBOXHDD pDisk, unsigned nImage, unsigned *puImageFlags);
|
---|
494 |
|
---|
495 | /**
|
---|
496 | * Get open flags of last opened image in HDD container.
|
---|
497 | *
|
---|
498 | * @returns VBox status code.
|
---|
499 | * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
|
---|
500 | * @param pDisk Pointer to VBox HDD container.
|
---|
501 | * @param puOpenFlags Where to store the image open flags.
|
---|
502 | */
|
---|
503 | VBOXDDU_DECL(int) VDGetOpenFlags(PVBOXHDD pDisk, unsigned *puOpenFlags);
|
---|
504 |
|
---|
505 | /**
|
---|
506 | * Set open flags of last opened image in HDD container.
|
---|
507 | * This operation may cause file locking changes and/or files being reopened.
|
---|
508 | * Note that in case of unrecoverable error all images in HDD container will be closed.
|
---|
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 uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
514 | */
|
---|
515 | VBOXDDU_DECL(int) VDSetOpenFlags(PVBOXHDD pDisk, unsigned uOpenFlags);
|
---|
516 |
|
---|
517 | /**
|
---|
518 | * Get base filename of image in HDD container. Some image formats use
|
---|
519 | * other filenames as well, so don't use this for anything but for informational
|
---|
520 | * purposes.
|
---|
521 | *
|
---|
522 | * @returns VBox status code.
|
---|
523 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
524 | * @returns VERR_BUFFER_OVERFLOW if pszFilename buffer too small to hold filename.
|
---|
525 | * @param pDisk Pointer to VBox HDD container.
|
---|
526 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
527 | * @param pszFilename Where to store the image file name.
|
---|
528 | * @param cbFilename Size of buffer pszFilename points to.
|
---|
529 | */
|
---|
530 | VBOXDDU_DECL(int) VDGetFilename(PVBOXHDD pDisk, unsigned nImage, char *pszFilename, unsigned cbFilename);
|
---|
531 |
|
---|
532 | /**
|
---|
533 | * Get the comment line of image in HDD container.
|
---|
534 | *
|
---|
535 | * @returns VBox status code.
|
---|
536 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
537 | * @returns VERR_BUFFER_OVERFLOW if pszComment buffer too small to hold comment text.
|
---|
538 | * @param pDisk Pointer to VBox HDD container.
|
---|
539 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
540 | * @param pszComment Where to store the comment string of image. NULL is ok.
|
---|
541 | * @param cbComment The size of pszComment buffer. 0 is ok.
|
---|
542 | */
|
---|
543 | VBOXDDU_DECL(int) VDGetComment(PVBOXHDD pDisk, unsigned nImage, char *pszComment, unsigned cbComment);
|
---|
544 |
|
---|
545 | /**
|
---|
546 | * Changes the comment line of image in HDD container.
|
---|
547 | *
|
---|
548 | * @returns VBox status code.
|
---|
549 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
550 | * @param pDisk Pointer to VBox HDD container.
|
---|
551 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
552 | * @param pszComment New comment string (UTF-8). NULL is allowed to reset the comment.
|
---|
553 | */
|
---|
554 | VBOXDDU_DECL(int) VDSetComment(PVBOXHDD pDisk, unsigned nImage, const char *pszComment);
|
---|
555 |
|
---|
556 | /**
|
---|
557 | * Get UUID of image in HDD container.
|
---|
558 | *
|
---|
559 | * @returns VBox status code.
|
---|
560 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
561 | * @param pDisk Pointer to VBox HDD container.
|
---|
562 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
563 | * @param pUuid Where to store the image UUID.
|
---|
564 | */
|
---|
565 | VBOXDDU_DECL(int) VDGetUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
|
---|
566 |
|
---|
567 | /**
|
---|
568 | * Set the image's UUID. Should not be used by normal applications.
|
---|
569 | *
|
---|
570 | * @returns VBox status code.
|
---|
571 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
572 | * @param pDisk Pointer to VBox HDD container.
|
---|
573 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
574 | * @param pUuid Optional parameter, new UUID of the image.
|
---|
575 | */
|
---|
576 | VBOXDDU_DECL(int) VDSetUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
|
---|
577 |
|
---|
578 | /**
|
---|
579 | * Get last modification UUID of image in HDD container.
|
---|
580 | *
|
---|
581 | * @returns VBox status code.
|
---|
582 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
583 | * @param pDisk Pointer to VBox HDD container.
|
---|
584 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
585 | * @param pUuid Where to store the image modification UUID.
|
---|
586 | */
|
---|
587 | VBOXDDU_DECL(int) VDGetModificationUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
|
---|
588 |
|
---|
589 | /**
|
---|
590 | * Set the image's last modification UUID. Should not be used by normal applications.
|
---|
591 | *
|
---|
592 | * @returns VBox status code.
|
---|
593 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
594 | * @param pDisk Pointer to VBox HDD container.
|
---|
595 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
596 | * @param pUuid Optional parameter, new last modification UUID of the image.
|
---|
597 | */
|
---|
598 | VBOXDDU_DECL(int) VDSetModificationUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
|
---|
599 |
|
---|
600 | /**
|
---|
601 | * Get parent UUID of image in HDD container.
|
---|
602 | *
|
---|
603 | * @returns VBox status code.
|
---|
604 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
605 | * @param pDisk Pointer to VBox HDD container.
|
---|
606 | * @param nImage Image number, counts from 0. 0 is always base image of the container.
|
---|
607 | * @param pUuid Where to store the parent image UUID.
|
---|
608 | */
|
---|
609 | VBOXDDU_DECL(int) VDGetParentUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
|
---|
610 |
|
---|
611 | /**
|
---|
612 | * Set the image's parent UUID. Should not be used by normal applications.
|
---|
613 | *
|
---|
614 | * @returns VBox status code.
|
---|
615 | * @param pDisk Pointer to VBox HDD container.
|
---|
616 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
617 | * @param pUuid Optional parameter, new parent UUID of the image.
|
---|
618 | */
|
---|
619 | VBOXDDU_DECL(int) VDSetParentUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
|
---|
620 |
|
---|
621 |
|
---|
622 | /**
|
---|
623 | * Debug helper - dumps all opened images in HDD container into the log file.
|
---|
624 | *
|
---|
625 | * @param pDisk Pointer to VBox HDD container.
|
---|
626 | */
|
---|
627 | VBOXDDU_DECL(void) VDDumpImages(PVBOXHDD pDisk);
|
---|
628 |
|
---|
629 | __END_DECLS
|
---|
630 |
|
---|
631 | /** @} */
|
---|
632 |
|
---|
633 | #endif
|
---|