VirtualBox

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

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

The Giant CDDL Dual-License Header Change.

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