VirtualBox

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

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

The Big Sun Rebranding Header Change

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