VirtualBox

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

Last change on this file since 2734 was 2718, checked in by vboxsync, 18 years ago

Implemented raw partition access.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 25.9 KB
Line 
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 * @{ */
56typedef 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. */
73typedef 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 */
102typedef 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 /** Offset where the partition data starts in the disk. */
112 uint64_t uPartitionStart;
113 /** Size of the partition. */
114 uint64_t cbPartition;
115 /** Size of the partitioning info to prepend. */
116 uint64_t cbPartitionData;
117 /** Offset where the partitioning info starts in the disk. */
118 uint64_t uPartitionDataStart;
119 /** Pointer to the partitioning info to prepend. */
120 const void *pvPartitionData;
121} VBOXHDDRAWPART, *PVBOXHDDRAWPART;
122
123/**
124 * Auxiliary data structure for creating raw disks.
125 */
126typedef struct VBOXHDDRAW
127{
128 /** Flag whether access to full disk should be given (ignoring the
129 * partition information below). */
130 bool fRawDisk;
131 /** Filename for the raw disk. Ignored for partitioned raw disks.
132 * For Linux e.g. /dev/sda, and for Windows e.g. \\.\PhysicalDisk0. */
133 const char *pszRawDisk;
134 /** Number of entries in the partitions array. */
135 unsigned cPartitions;
136 /** Pointer to the partitions array. */
137 PVBOXHDDRAWPART pPartitions;
138} VBOXHDDRAW, *PVBOXHDDRAW;
139
140/** @name VBox HDD container image open mode flags
141 * @{
142 */
143/** Try to open image in read/write exclusive access mode if possible, or in read-only elsewhere. */
144#define VD_OPEN_FLAGS_NORMAL 0
145/** Open image in read-only mode with sharing access with others. */
146#define VD_OPEN_FLAGS_READONLY RT_BIT(0)
147/** Honor zero block writes instead of ignoring them whenever possible.
148 * This is not supported by all formats. It is silently ignored in this case. */
149#define VD_OPEN_FLAGS_HONOR_ZEROES RT_BIT(1)
150/** Honor writes of the same data instead of ignoring whenever possible.
151 * This is handled generically, and is only meaningful for differential image
152 * formats. It is silently ignored otherwise. */
153#define VD_OPEN_FLAGS_HONOR_SAME RT_BIT(2)
154/** Mask of valid flags. */
155#define VD_OPEN_FLAGS_MASK (VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_HONOR_ZEROES | VD_OPEN_FLAGS_HONOR_SAME)
156/** @}*/
157
158/**
159 * Error message callback.
160 *
161 * @param pvUser The opaque data passed on container creation.
162 * @param rc The VBox error code.
163 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
164 * @param pszFormat Error message format string.
165 * @param va Error message arguments.
166 */
167typedef DECLCALLBACK(void) FNVDERROR(void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va);
168/** Pointer to a FNVDERROR(). */
169typedef FNVDERROR *PFNVDERROR;
170
171
172/**
173 * VBox HDD Container main structure.
174 */
175/* Forward declaration, VBOXHDD structure is visible only inside VBox HDD module. */
176struct VBOXHDD;
177typedef struct VBOXHDD VBOXHDD;
178typedef VBOXHDD *PVBOXHDD;
179
180/**
181 * Allocates and initializes an empty VBox HDD container.
182 * No image files are opened.
183 *
184 * @returns VBox status code.
185 * @param pszBackend Name of the image file backend to use.
186 * @param pfnError Callback for setting extended error information.
187 * @param pvErrorUser Opaque parameter for pfnError.
188 * @param ppDisk Where to store the reference to the VBox HDD container.
189 */
190VBOXDDU_DECL(int) VDCreate(const char *pszBackend, PFNVDERROR pfnError, void *pvErrorUser, PVBOXHDD *ppDisk);
191
192/**
193 * Destroys the VBox HDD container.
194 * If container has opened image files they will be closed.
195 *
196 * @param pDisk Pointer to VBox HDD container.
197 */
198VBOXDDU_DECL(void) VDDestroy(PVBOXHDD pDisk);
199
200/**
201 * Opens an image file.
202 *
203 * The first opened image file in a HDD container must have a base image type,
204 * others (next opened images) must be differencing or undo images.
205 * Linkage is checked for differencing image to be consistent with the previously opened image.
206 * When another differencing image is opened and the last image was opened in read/write access
207 * mode, then the last image is reopened in read-only with deny write sharing mode. This allows
208 * other processes to use images in read-only mode too.
209 *
210 * Note that the image is opened in read-only mode if a read/write open is not possible.
211 * Use VDIsReadOnly to check open mode.
212 *
213 * @returns VBox status code.
214 * @param pDisk Pointer to VBox HDD container.
215 * @param pszFilename Name of the image file to open.
216 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
217 */
218VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszFilename, unsigned uOpenFlags);
219
220/**
221 * Creates and opens a new base image file.
222 *
223 * @returns VBox status code.
224 * @param pDisk Pointer to VBox HDD container.
225 * @param pszFilename Name of the image file to create.
226 * @param enmType Image type, only base image types are acceptable.
227 * @param cbSize Image size in bytes.
228 * @param uImageFlags Flags specifying special image features.
229 * @param pszComment Pointer to image comment. NULL is ok.
230 * @param cCylinders Number of cylinders (must be <= 16383).
231 * @param cHeads Number of heads (must be <= 16).
232 * @param cSectors Number of sectors (must be <= 63);
233 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
234 * @param pfnProgress Progress callback. Optional. NULL if not to be used.
235 * @param pvUser User argument for the progress callback.
236 */
237VBOXDDU_DECL(int) VDCreateBase(PVBOXHDD pDisk, const char *pszFilename,
238 VDIMAGETYPE enmType, uint64_t cbSize,
239 unsigned uImageFlags, const char *pszComment,
240 unsigned cCylinders, unsigned cHeads,
241 unsigned cSectors, unsigned uOpenFlags,
242 PFNVMPROGRESS pfnProgress, void *pvUser);
243
244/**
245 * Creates and opens a new differencing image file in HDD container.
246 * See comments for VDOpen function about differencing images.
247 *
248 * @returns VBox status code.
249 * @param pDisk Pointer to VBox HDD container.
250 * @param pszFilename Name of the differencing image file to create.
251 * @param uImageFlags Flags specifying special image features.
252 * @param pszComment Pointer to image comment. NULL is ok.
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) VDCreateDiff(PVBOXHDD pDisk, const char *pszFilename,
258 unsigned uImageFlags, const char *pszComment,
259 unsigned uOpenFlags,
260 PFNVMPROGRESS pfnProgress, void *pvUser);
261
262/**
263 * Merges two images having a parent/child relationship (both directions).
264 * As a side effect the source image is deleted from both the disk and
265 * the images in the VBox HDD container.
266 *
267 * @returns VBox status code.
268 * @param pDisk Pointer to VBox HDD container.
269 * @param nImageFrom Name of the image file to merge from.
270 * @param nImageTo Name of the image file to merge to.
271 * @param pfnProgress Progress callback. Optional. NULL if not to be used.
272 * @param pvUser User argument for the progress callback.
273 */
274VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom, unsigned nImageTo,
275 PFNVMPROGRESS pfnProgress, void *pvUser);
276
277/**
278 * Copies an image from one VBox HDD container to another.
279 * The copy is opened in the target VBox HDD container.
280 * It is possible to convert between different image formats, because the
281 * backend for the destination VBox HDD container may be different from the
282 * source container.
283 * If both the source and destination reference the same VBox HDD container,
284 * then the image is moved (by copying/deleting) to the new location.
285 * The source container is unchanged if the move operation fails, otherwise
286 * the image at the new location is opened in the same way as the old one was.
287 *
288 * @returns VBox status code.
289 * @param pDiskFrom Pointer to source VBox HDD container.
290 * @param nImage Image number, counts from 0. 0 is always base image of container.
291 * @param pDiskTo Pointer to destination VBox HDD container.
292 * @param pfnProgress Progress callback. Optional. NULL if not to be used.
293 * @param pvUser User argument for the progress callback.
294 */
295VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo,
296 PFNVMPROGRESS pfnProgress, void *pvUser);
297
298/**
299 * Compacts a growing image file by removing zeroed data blocks.
300 * Optionally defragments data in the image so that ascending sector numbers
301 * are stored in ascending location in the image file.
302 *
303 * @todo maybe include this function in VDCopy.
304 *
305 * @returns VBox status code.
306 * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
307 * @param pDisk Pointer to VBox HDD container.
308 * @param nImage Image number, counts from 0. 0 is always base image of container.
309 * @param fDefragment If true, reorder file data so that sectors are stored in ascending order.
310 * @param pfnProgress Progress callback. Optional. NULL if not to be used.
311 * @param pvUser User argument for the progress callback.
312 */
313VBOXDDU_DECL(int) VDCompact(PVBOXHDD pDisk, unsigned nImage,
314 bool fDefragment,
315 PFNVMPROGRESS pfnProgress, void *pvUser);
316
317/**
318 * Resizes an image. Allows setting the disk size to both larger and smaller
319 * values than the current disk size.
320 *
321 * @returns VBox status code.
322 * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
323 * @param pDisk Pointer to VBox HDD container.
324 * @param nImage Image number, counts from 0. 0 is always base image of container.
325 * @param cbSize New image size in bytes.
326 * @param pfnProgress Progress callback. Optional. NULL if not to be used.
327 * @param pvUser User argument for the progress callback.
328 */
329VBOXDDU_DECL(int) VDResize(PVBOXHDD pDisk, unsigned nImage, uint64_t cbSize,
330 PFNVMPROGRESS pfnProgress, void *pvUser);
331
332/**
333 * Closes the last opened image file in the HDD container. Leaves all changes inside it.
334 * If previous image file was opened in read-only mode (that is normal) and closing image
335 * was opened in read-write mode (the whole disk was in read-write mode) - the previous image
336 * will be reopened in read/write mode.
337 *
338 * @param pDisk Pointer to VBox HDD container.
339 * @param fDelete If true, delete the image from the host disk.
340 */
341VBOXDDU_DECL(int) VDClose(PVBOXHDD pDisk, bool fDelete);
342
343/**
344 * Closes all opened image files in HDD container.
345 *
346 * @param pDisk Pointer to VBox HDD container.
347 */
348VBOXDDU_DECL(int) VDCloseAll(PVBOXHDD pDisk);
349
350/**
351 * Read data from virtual HDD.
352 *
353 * @returns VBox status code.
354 * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
355 * @param pDisk Pointer to VBox HDD container.
356 * @param uOffset Offset of first reading byte from start of disk.
357 * @param pvBuf Pointer to buffer for reading data.
358 * @param cbRead Number of bytes to read.
359 */
360VBOXDDU_DECL(int) VDRead(PVBOXHDD pDisk, uint64_t uOffset, void *pvBuf, size_t cbRead);
361
362/**
363 * Write data to virtual HDD.
364 *
365 * @returns VBox status code.
366 * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
367 * @param pDisk Pointer to VBox HDD container.
368 * @param uOffset Offset of first writing byte from start of disk.
369 * @param pvBuf Pointer to buffer for writing data.
370 * @param cbWrite Number of bytes to write.
371 */
372VBOXDDU_DECL(int) VDWrite(PVBOXHDD pDisk, uint64_t uOffset, const void *pvBuf, size_t cbWrite);
373
374/**
375 * Make sure the on disk representation of a virtual HDD is up to date.
376 *
377 * @returns VBox status code.
378 * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
379 * @param pDisk Pointer to VBox HDD container.
380 */
381VBOXDDU_DECL(int) VDFlush(PVBOXHDD pDisk);
382
383/**
384 * Get number of opened images in HDD container.
385 *
386 * @returns Number of opened images for HDD container. 0 if no images have been opened.
387 * @param pDisk Pointer to VBox HDD container.
388 */
389VBOXDDU_DECL(unsigned) VDGetCount(PVBOXHDD pDisk);
390
391/**
392 * Get read/write mode of the VBox HDD container.
393 *
394 * @returns Virtual disk ReadOnly status.
395 * @returns true if no image is opened in HDD container.
396 * @param pDisk Pointer to VBox HDD container.
397 */
398VBOXDDU_DECL(bool) VDIsReadOnly(PVBOXHDD pDisk);
399
400/**
401 * Get total disk size of the VBox HDD container.
402 *
403 * @returns Virtual disk size in bytes.
404 * @returns 0 if no image is opened in HDD container.
405 * @param pDisk Pointer to VBox HDD container.
406 */
407VBOXDDU_DECL(uint64_t) VDGetSize(PVBOXHDD pDisk);
408
409/**
410 * Get virtual disk geometry stored in HDD container.
411 *
412 * @returns VBox status code.
413 * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
414 * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the HDD container.
415 * @param pDisk Pointer to VBox HDD container.
416 * @param pcCylinders Where to store the number of cylinders. NULL is ok.
417 * @param pcHeads Where to store the number of heads. NULL is ok.
418 * @param pcSectors Where to store the number of sectors. NULL is ok.
419 */
420VBOXDDU_DECL(int) VDGetGeometry(PVBOXHDD pDisk,
421 unsigned *pcCylinders, unsigned *pcHeads, unsigned *pcSectors);
422
423/**
424 * Store virtual disk geometry in HDD container.
425 *
426 * Note that in case of unrecoverable error all images in HDD container will be closed.
427 *
428 * @returns VBox status code.
429 * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
430 * @param pDisk Pointer to VBox HDD container.
431 * @param cCylinders Number of cylinders.
432 * @param cHeads Number of heads.
433 * @param cSectors Number of sectors.
434 */
435VBOXDDU_DECL(int) VDSetGeometry(PVBOXHDD pDisk,
436 unsigned cCylinders, unsigned cHeads, unsigned cSectors);
437
438/**
439 * Get virtual disk translation mode stored in HDD container.
440 *
441 * @returns VBox status code.
442 * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
443 * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the HDD container.
444 * @param pDisk Pointer to VBox HDD container.
445 * @param penmTranslation Where to store the translation mode (see pdm.h).
446 */
447VBOXDDU_DECL(int) VDGetTranslation(PVBOXHDD pDisk, PPDMBIOSTRANSLATION penmTranslation);
448
449/**
450 * Store virtual disk translation mode in HDD container.
451 *
452 * Note that in case of unrecoverable error all images in HDD container will be closed.
453 *
454 * @returns VBox status code.
455 * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
456 * @param pDisk Pointer to VBox HDD container.
457 * @param enmTranslation Translation mode (see pdm.h).
458 */
459VBOXDDU_DECL(int) VDSetTranslation(PVBOXHDD pDisk, PDMBIOSTRANSLATION enmTranslation);
460
461/**
462 * Get version of image in HDD container.
463 *
464 * @returns VBox status code.
465 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
466 * @param pDisk Pointer to VBox HDD container.
467 * @param nImage Image number, counts from 0. 0 is always base image of container.
468 * @param puVersion Where to store the image version.
469 */
470VBOXDDU_DECL(int) VDGetVersion(PVBOXHDD pDisk, unsigned nImage, unsigned *puVersion);
471
472/**
473 * Get type 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 penmType Where to store the image type.
480 */
481VBOXDDU_DECL(int) VDGetImageType(PVBOXHDD pDisk, unsigned nImage, PVDIMAGETYPE penmType);
482
483/**
484 * Get flags 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 puImageFlags Where to store the image flags.
491 */
492VBOXDDU_DECL(int) VDGetImageFlags(PVBOXHDD pDisk, unsigned nImage, unsigned *puImageFlags);
493
494/**
495 * Get open flags of last opened image in HDD container.
496 *
497 * @returns VBox status code.
498 * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
499 * @param pDisk Pointer to VBox HDD container.
500 * @param puOpenFlags Where to store the image open flags.
501 */
502VBOXDDU_DECL(int) VDGetOpenFlags(PVBOXHDD pDisk, unsigned *puOpenFlags);
503
504/**
505 * Set open flags of last opened image in HDD container.
506 * This operation may cause file locking changes and/or files being reopened.
507 * Note that in case of unrecoverable error all images in HDD container will be closed.
508 *
509 * @returns VBox status code.
510 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
511 * @param pDisk Pointer to VBox HDD container.
512 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
513 */
514VBOXDDU_DECL(int) VDSetOpenFlags(PVBOXHDD pDisk, unsigned uOpenFlags);
515
516/**
517 * Get base filename of image in HDD container. Some image formats use
518 * other filenames as well, so don't use this for anything but for informational
519 * purposes.
520 *
521 * @returns VBox status code.
522 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
523 * @returns VERR_BUFFER_OVERFLOW if pszFilename buffer too small to hold filename.
524 * @param pDisk Pointer to VBox HDD container.
525 * @param nImage Image number, counts from 0. 0 is always base image of container.
526 * @param pszFilename Where to store the image file name.
527 * @param cbFilename Size of buffer pszFilename points to.
528 */
529VBOXDDU_DECL(int) VDGetFilename(PVBOXHDD pDisk, unsigned nImage, char *pszFilename, unsigned cbFilename);
530
531/**
532 * Get the comment line of image in HDD container.
533 *
534 * @returns VBox status code.
535 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
536 * @returns VERR_BUFFER_OVERFLOW if pszComment buffer too small to hold comment text.
537 * @param pDisk Pointer to VBox HDD container.
538 * @param nImage Image number, counts from 0. 0 is always base image of container.
539 * @param pszComment Where to store the comment string of image. NULL is ok.
540 * @param cbComment The size of pszComment buffer. 0 is ok.
541 */
542VBOXDDU_DECL(int) VDGetComment(PVBOXHDD pDisk, unsigned nImage, char *pszComment, unsigned cbComment);
543
544/**
545 * Changes the comment line of image in HDD container.
546 *
547 * @returns VBox status code.
548 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
549 * @param pDisk Pointer to VBox HDD container.
550 * @param nImage Image number, counts from 0. 0 is always base image of container.
551 * @param pszComment New comment string (UTF-8). NULL is allowed to reset the comment.
552 */
553VBOXDDU_DECL(int) VDSetComment(PVBOXHDD pDisk, unsigned nImage, const char *pszComment);
554
555/**
556 * Get UUID 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 pUuid Where to store the image UUID.
563 */
564VBOXDDU_DECL(int) VDGetUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
565
566/**
567 * Set the image's UUID. Should not be used by normal applications.
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 Optional parameter, new UUID of the image.
574 */
575VBOXDDU_DECL(int) VDSetUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
576
577/**
578 * Get last modification UUID of image in HDD container.
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 Where to store the image modification UUID.
585 */
586VBOXDDU_DECL(int) VDGetModificationUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
587
588/**
589 * Set the image's last modification UUID. Should not be used by normal applications.
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 Optional parameter, new last modification UUID of the image.
596 */
597VBOXDDU_DECL(int) VDSetModificationUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
598
599/**
600 * Get parent UUID of image in HDD container.
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 the container.
606 * @param pUuid Where to store the parent image UUID.
607 */
608VBOXDDU_DECL(int) VDGetParentUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
609
610/**
611 * Set the image's parent UUID. Should not be used by normal applications.
612 *
613 * @returns VBox status code.
614 * @param pDisk Pointer to VBox HDD container.
615 * @param nImage Image number, counts from 0. 0 is always base image of container.
616 * @param pUuid Optional parameter, new parent UUID of the image.
617 */
618VBOXDDU_DECL(int) VDSetParentUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
619
620
621/**
622 * Debug helper - dumps all opened images in HDD container into the log file.
623 *
624 * @param pDisk Pointer to VBox HDD container.
625 */
626VBOXDDU_DECL(void) VDDumpImages(PVBOXHDD pDisk);
627
628__END_DECLS
629
630/** @} */
631
632#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