VirtualBox

source: vbox/trunk/include/VBox/VBoxHDD-new.h@ 5605

Last change on this file since 5605 was 5121, checked in by vboxsync, 17 years ago

Fix comment

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette