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