VirtualBox

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

Last change on this file since 8155 was 8155, checked in by vboxsync, 16 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
RevLine 
[1]1/** @file
[1942]2 * VBox HDD Container API.
3 * Will replace VBoxHDD.h.
[1]4 */
5
6/*
[8155]7 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
[1]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
[5999]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.
[8155]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.
[1]29 */
30
[3632]31#ifndef ___VBox_VD_h
32#define ___VBox_VD_h
[1]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
[1942]41# error "There are no VBox HDD Container APIs available in Ring-0 Host Context!"
[1]42#endif
43
[2118]44/** @defgroup grp_vd VBox HDD Container
[1]45 * @{
46 */
47
[1942]48/** Current VMDK image version. */
49#define VMDK_IMAGE_VERSION (0x0001)
[1]50
[1942]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
[6291]63/** Placeholder for specifying the last opened image. */
64#define VD_LAST_IMAGE 0xffffffffU
65
[1942]66/** @name VBox HDD container image types
[1]67 * @{ */
[2118]68typedef enum VDIMAGETYPE
[1]69{
70 /** Normal dynamically growing base image file. */
[2118]71 VD_IMAGE_TYPE_NORMAL = 1,
[1]72 /** Preallocated base image file of a fixed size. */
[2118]73 VD_IMAGE_TYPE_FIXED,
[1]74 /** Dynamically growing image file for undo/commit changes support. */
[2118]75 VD_IMAGE_TYPE_UNDO,
[1]76 /** Dynamically growing image file for differencing support. */
[2118]77 VD_IMAGE_TYPE_DIFF,
[1]78
79 /** First valid image type value. */
[2118]80 VD_IMAGE_TYPE_FIRST = VD_IMAGE_TYPE_NORMAL,
[1]81 /** Last valid image type value. */
[2118]82 VD_IMAGE_TYPE_LAST = VD_IMAGE_TYPE_DIFF
83} VDIMAGETYPE;
[1942]84/** Pointer to VBox HDD container image type. */
[2118]85typedef VDIMAGETYPE *PVDIMAGETYPE;
[1]86/** @} */
87
[1942]88/** @name VBox HDD container image flags
[1901]89 * @{
90 */
[1]91/** No flags. */
[2118]92#define VD_IMAGE_FLAGS_NONE (0)
[1942]93/** VMDK: Split image into 2GB extents. */
[2118]94#define VD_VMDK_IMAGE_FLAGS_SPLIT_2G (0x0001)
[2650]95/** VMDK: Raw disk image (giving access to a number of host partitions). */
[2118]96#define VD_VMDK_IMAGE_FLAGS_RAWDISK (0x0002)
[2741]97/** VDI: Fill new blocks with zeroes while expanding image file. Only valid
98 * for newly created images, never set for opened existing images. */
[2118]99#define VD_VDI_IMAGE_FLAGS_ZERO_EXPAND (0x0100)
[1]100
[1942]101/** Mask of valid image flags for VMDK. */
[2118]102#define VD_VMDK_IMAGE_FLAGS_MASK (VD_IMAGE_FLAGS_NONE | VD_VMDK_IMAGE_FLAGS_SPLIT_2G | VD_VMDK_IMAGE_FLAGS_RAWDISK)
[1]103
[1942]104/** Mask of valid image flags for VDI. */
[2118]105#define VD_VDI_IMAGE_FLAGS_MASK (VD_IMAGE_FLAGS_NONE | VD_VDI_IMAGE_FLAGS_ZERO_EXPAND)
[1942]106
[6291]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
[1942]110/** Default image flags. */
[2118]111#define VD_IMAGE_FLAGS_DEFAULT (VD_IMAGE_FLAGS_NONE)
[1]112/** @} */
113
[2662]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;
[2718]127 /** Offset where the partition data starts in the disk. */
128 uint64_t uPartitionStart;
[2662]129 /** Size of the partition. */
130 uint64_t cbPartition;
131 /** Size of the partitioning info to prepend. */
132 uint64_t cbPartitionData;
[2718]133 /** Offset where the partitioning info starts in the disk. */
134 uint64_t uPartitionDataStart;
[2662]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{
[6291]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];
[2662]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
[1942]159/** @name VBox HDD container image open mode flags
[1]160 * @{
161 */
162/** Try to open image in read/write exclusive access mode if possible, or in read-only elsewhere. */
[2591]163#define VD_OPEN_FLAGS_NORMAL 0
[1]164/** Open image in read-only mode with sharing access with others. */
[2591]165#define VD_OPEN_FLAGS_READONLY RT_BIT(0)
[2118]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. */
[2591]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)
[2833]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)
[1]177/** Mask of valid flags. */
[2833]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)
[1]179/** @}*/
180
[7781]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
[1]198/**
[7781]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/**
[2358]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/**
[1942]225 * VBox HDD Container main structure.
[1]226 */
[1942]227/* Forward declaration, VBOXHDD structure is visible only inside VBox HDD module. */
228struct VBOXHDD;
229typedef struct VBOXHDD VBOXHDD;
230typedef VBOXHDD *PVBOXHDD;
[1]231
[7781]232
[1]233/**
[7781]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/**
[6291]248 * Allocates and initializes an empty HDD container.
[1942]249 * No image files are opened.
[1]250 *
[2118]251 * @returns VBox status code.
[2358]252 * @param pfnError Callback for setting extended error information.
253 * @param pvErrorUser Opaque parameter for pfnError.
[6291]254 * @param ppDisk Where to store the reference to HDD container.
[1]255 */
[7277]256VBOXDDU_DECL(int) VDCreate(PFNVDERROR pfnError, void *pvErrorUser,
257 PVBOXHDD *ppDisk);
[1]258
259/**
[6291]260 * Destroys HDD container.
[1942]261 * If container has opened image files they will be closed.
[1]262 *
[6291]263 * @param pDisk Pointer to HDD container.
[1]264 */
[2118]265VBOXDDU_DECL(void) VDDestroy(PVBOXHDD pDisk);
[1]266
267/**
[6291]268 * Try to get the backend name which can use this image.
[5103]269 *
270 * @returns VBox status code.
271 * @param pszFilename Name of the image file for which the backend is queried.
[5121]272 * @param ppszFormat Receives pointer of the UTF-8 string which contains the format name.
273 * The returned pointer must be freed using RTStrFree().
[5103]274 */
275VBOXDDU_DECL(int) VDGetFormat(const char *pszFilename, char **ppszFormat);
276
277/**
[1942]278 * Opens an image file.
[1]279 *
[6291]280 * The first opened image file in HDD container must have a base image type,
[1942]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.
[1]286 *
[1942]287 * Note that the image is opened in read-only mode if a read/write open is not possible.
[2118]288 * Use VDIsReadOnly to check open mode.
[1942]289 *
[1]290 * @returns VBox status code.
[6291]291 * @param pDisk Pointer to HDD container.
[7277]292 * @param pszBackend Name of the image file backend to use.
[1942]293 * @param pszFilename Name of the image file to open.
[2118]294 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
[1]295 */
[7277]296VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszBackend,
297 const char *pszFilename, unsigned uOpenFlags);
[1]298
299/**
[1942]300 * Creates and opens a new base image file.
[1]301 *
302 * @returns VBox status code.
[6291]303 * @param pDisk Pointer to HDD container.
[7277]304 * @param pszBackend Name of the image file backend to use.
[1942]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.
[6291]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.
[2118]312 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
[1942]313 * @param pfnProgress Progress callback. Optional. NULL if not to be used.
314 * @param pvUser User argument for the progress callback.
[1]315 */
[7277]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,
[6291]320 PCPDMMEDIAGEOMETRY pPCHSGeometry,
321 PCPDMMEDIAGEOMETRY pLCHSGeometry,
322 unsigned uOpenFlags, PFNVMPROGRESS pfnProgress,
323 void *pvUser);
[1]324
325/**
[1942]326 * Creates and opens a new differencing image file in HDD container.
[2118]327 * See comments for VDOpen function about differencing images.
[1]328 *
329 * @returns VBox status code.
[6291]330 * @param pDisk Pointer to HDD container.
[7277]331 * @param pszBackend Name of the image file backend to use.
[1942]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.
[2118]335 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
[1]336 * @param pfnProgress Progress callback. Optional. NULL if not to be used.
337 * @param pvUser User argument for the progress callback.
338 */
[7277]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);
[1]343
344/**
[6291]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.
[1]349 *
350 * @returns VBox status code.
[6291]351 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
352 * @param pDisk Pointer to HDD container.
[1942]353 * @param nImageFrom Name of the image file to merge from.
354 * @param nImageTo Name of the image file to merge to.
[1]355 * @param pfnProgress Progress callback. Optional. NULL if not to be used.
356 * @param pvUser User argument for the progress callback.
357 */
[6291]358VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom,
359 unsigned nImageTo, PFNVMPROGRESS pfnProgress,
360 void *pvUser);
[1]361
362/**
[6291]363 * Copies an image from one HDD container to another.
364 * The copy is opened in the target HDD container.
[1942]365 * It is possible to convert between different image formats, because the
[7277]366 * backend for the destination may be different from the source.
[6291]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.
[2118]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.
[1]371 *
372 * @returns VBox status code.
[6291]373 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
374 * @param pDiskFrom Pointer to source HDD container.
[1942]375 * @param nImage Image number, counts from 0. 0 is always base image of container.
[6291]376 * @param pDiskTo Pointer to destination HDD container.
[7277]377 * @param pszBackend Name of the image file backend to use (may be NULL to use the same as the source).
[6291]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).
[1942]381 * @param pfnProgress Progress callback. Optional. NULL if not to be used.
382 * @param pvUser User argument for the progress callback.
[1]383 */
[2118]384VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo,
[7277]385 const char *pszBackend, const char *pszFilename,
386 bool fMoveByRename, uint64_t cbSize,
387 PFNVMPROGRESS pfnProgress, void *pvUser);
[1]388
389/**
[6291]390 * Closes the last opened image file in HDD container.
[1942]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.
[1]394 *
[6291]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.
[1942]398 * @param fDelete If true, delete the image from the host disk.
[1]399 */
[2358]400VBOXDDU_DECL(int) VDClose(PVBOXHDD pDisk, bool fDelete);
[1]401
402/**
[1942]403 * Closes all opened image files in HDD container.
[1]404 *
[6291]405 * @returns VBox status code.
406 * @param pDisk Pointer to HDD container.
[1]407 */
[2358]408VBOXDDU_DECL(int) VDCloseAll(PVBOXHDD pDisk);
[1]409
410/**
[1942]411 * Read data from virtual HDD.
[1]412 *
413 * @returns VBox status code.
[2118]414 * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
[6291]415 * @param pDisk Pointer to HDD container.
[2358]416 * @param uOffset Offset of first reading byte from start of disk.
[1942]417 * @param pvBuf Pointer to buffer for reading data.
[2118]418 * @param cbRead Number of bytes to read.
[1]419 */
[2358]420VBOXDDU_DECL(int) VDRead(PVBOXHDD pDisk, uint64_t uOffset, void *pvBuf, size_t cbRead);
[1]421
422/**
[1942]423 * Write data to virtual HDD.
[1]424 *
425 * @returns VBox status code.
[2118]426 * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
[6291]427 * @param pDisk Pointer to HDD container.
[2358]428 * @param uOffset Offset of first writing byte from start of disk.
[2118]429 * @param pvBuf Pointer to buffer for writing data.
430 * @param cbWrite Number of bytes to write.
[1]431 */
[2358]432VBOXDDU_DECL(int) VDWrite(PVBOXHDD pDisk, uint64_t uOffset, const void *pvBuf, size_t cbWrite);
[1]433
434/**
[1949]435 * Make sure the on disk representation of a virtual HDD is up to date.
436 *
437 * @returns VBox status code.
[2118]438 * @returns VERR_VDI_NOT_OPENED if no image is opened in HDD container.
[6291]439 * @param pDisk Pointer to HDD container.
[1949]440 */
[2118]441VBOXDDU_DECL(int) VDFlush(PVBOXHDD pDisk);
[1949]442
443/**
[1942]444 * Get number of opened images in HDD container.
[1]445 *
[2118]446 * @returns Number of opened images for HDD container. 0 if no images have been opened.
[6291]447 * @param pDisk Pointer to HDD container.
[1]448 */
[2118]449VBOXDDU_DECL(unsigned) VDGetCount(PVBOXHDD pDisk);
[1]450
451/**
[6291]452 * Get read/write mode of HDD container.
[1]453 *
[1942]454 * @returns Virtual disk ReadOnly status.
455 * @returns true if no image is opened in HDD container.
[6291]456 * @param pDisk Pointer to HDD container.
[1]457 */
[2118]458VBOXDDU_DECL(bool) VDIsReadOnly(PVBOXHDD pDisk);
[1]459
460/**
[6291]461 * Get total capacity of an image in HDD container.
[1]462 *
463 * @returns Virtual disk size in bytes.
[6291]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.
[1]467 */
[6291]468VBOXDDU_DECL(uint64_t) VDGetSize(PVBOXHDD pDisk, unsigned nImage);
[1]469
470/**
[6291]471 * Get total file size of an image in HDD container.
[1]472 *
[6291]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 *
[1]483 * @returns VBox status code.
[6291]484 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
[1]485 * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the HDD container.
[6291]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.
[1]489 */
[6291]490VBOXDDU_DECL(int) VDGetPCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
491 PPDMMEDIAGEOMETRY pPCHSGeometry);
[1]492
493/**
[6291]494 * Store virtual disk PCHS geometry of an image in HDD container.
[1]495 *
496 * @returns VBox status code.
[6291]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.
[1]501 */
[6291]502VBOXDDU_DECL(int) VDSetPCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
503 PCPDMMEDIAGEOMETRY pPCHSGeometry);
[1]504
505/**
[6291]506 * Get virtual disk LCHS geometry of an image in HDD container.
[1]507 *
508 * @returns VBox status code.
[6291]509 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
[2118]510 * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the HDD container.
[6291]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.
[1]514 */
[6291]515VBOXDDU_DECL(int) VDGetLCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
516 PPDMMEDIAGEOMETRY pLCHSGeometry);
[1]517
518/**
[6291]519 * Store virtual disk LCHS geometry of an image in HDD container.
[1]520 *
521 * @returns VBox status code.
[6291]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.
[1]526 */
[6291]527VBOXDDU_DECL(int) VDSetLCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
528 PCPDMMEDIAGEOMETRY pLCHSGeometry);
[1]529
530/**
[2118]531 * Get version of image in HDD container.
[1]532 *
533 * @returns VBox status code.
534 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
[6291]535 * @param pDisk Pointer to HDD container.
[1]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 */
[6291]539VBOXDDU_DECL(int) VDGetVersion(PVBOXHDD pDisk, unsigned nImage,
540 unsigned *puVersion);
[1]541
542/**
[2118]543 * Get type of image in HDD container.
[1]544 *
545 * @returns VBox status code.
546 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
[6291]547 * @param pDisk Pointer to HDD container.
[1]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 */
[6291]551VBOXDDU_DECL(int) VDGetImageType(PVBOXHDD pDisk, unsigned nImage,
552 PVDIMAGETYPE penmType);
[1]553
554/**
[2118]555 * Get flags of image in HDD container.
[1]556 *
557 * @returns VBox status code.
558 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
[6291]559 * @param pDisk Pointer to HDD container.
[1]560 * @param nImage Image number, counts from 0. 0 is always base image of container.
[1942]561 * @param puImageFlags Where to store the image flags.
[1]562 */
[2118]563VBOXDDU_DECL(int) VDGetImageFlags(PVBOXHDD pDisk, unsigned nImage, unsigned *puImageFlags);
[1]564
565/**
[6291]566 * Get open flags of image in HDD container.
[1949]567 *
568 * @returns VBox status code.
[6291]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.
[1949]572 * @param puOpenFlags Where to store the image open flags.
573 */
[6291]574VBOXDDU_DECL(int) VDGetOpenFlags(PVBOXHDD pDisk, unsigned nImage,
575 unsigned *puOpenFlags);
[1949]576
577/**
[6291]578 * Set open flags of image in HDD container.
[1949]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.
[6291]584 * @param pDisk Pointer to HDD container.
585 * @param nImage Image number, counts from 0. 0 is always base image of container.
[2118]586 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
[1949]587 */
[6291]588VBOXDDU_DECL(int) VDSetOpenFlags(PVBOXHDD pDisk, unsigned nImage,
589 unsigned uOpenFlags);
[1949]590
591/**
[2118]592 * Get base filename of image in HDD container. Some image formats use
[6291]593 * other filenames as well, so don't use this for anything but informational
[1942]594 * purposes.
[1]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.
[6291]599 * @param pDisk Pointer to HDD container.
[1]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 */
[6291]604VBOXDDU_DECL(int) VDGetFilename(PVBOXHDD pDisk, unsigned nImage,
605 char *pszFilename, unsigned cbFilename);
[1]606
607/**
[2118]608 * Get the comment line of image in HDD container.
[1]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.
[6291]613 * @param pDisk Pointer to HDD container.
[1]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 */
[6291]618VBOXDDU_DECL(int) VDGetComment(PVBOXHDD pDisk, unsigned nImage,
619 char *pszComment, unsigned cbComment);
[1]620
621/**
[2118]622 * Changes the comment line of image in HDD container.
[1]623 *
624 * @returns VBox status code.
625 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
[6291]626 * @param pDisk Pointer to HDD container.
[1]627 * @param nImage Image number, counts from 0. 0 is always base image of container.
[1942]628 * @param pszComment New comment string (UTF-8). NULL is allowed to reset the comment.
629 */
[6291]630VBOXDDU_DECL(int) VDSetComment(PVBOXHDD pDisk, unsigned nImage,
631 const char *pszComment);
[1942]632
633/**
[2118]634 * Get UUID of image in HDD container.
[1942]635 *
636 * @returns VBox status code.
637 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
[6291]638 * @param pDisk Pointer to HDD container.
[1942]639 * @param nImage Image number, counts from 0. 0 is always base image of container.
[2358]640 * @param pUuid Where to store the image UUID.
[1]641 */
[2118]642VBOXDDU_DECL(int) VDGetUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
[1]643
644/**
[2118]645 * Set the image's UUID. Should not be used by normal applications.
[1]646 *
647 * @returns VBox status code.
648 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
[6291]649 * @param pDisk Pointer to HDD container.
[1]650 * @param nImage Image number, counts from 0. 0 is always base image of container.
[6291]651 * @param pUuid New UUID of the image. If NULL, a new UUID is created.
[1942]652 */
[2118]653VBOXDDU_DECL(int) VDSetUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
[1942]654
655/**
[2118]656 * Get last modification UUID of image in HDD container.
[1942]657 *
658 * @returns VBox status code.
659 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
[6291]660 * @param pDisk Pointer to HDD container.
[1942]661 * @param nImage Image number, counts from 0. 0 is always base image of container.
[2358]662 * @param pUuid Where to store the image modification UUID.
[1]663 */
[6291]664VBOXDDU_DECL(int) VDGetModificationUuid(PVBOXHDD pDisk, unsigned nImage,
665 PRTUUID pUuid);
[1]666
667/**
[2118]668 * Set the image's last modification UUID. Should not be used by normal applications.
[1]669 *
670 * @returns VBox status code.
671 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
[6291]672 * @param pDisk Pointer to HDD container.
[1942]673 * @param nImage Image number, counts from 0. 0 is always base image of container.
[6291]674 * @param pUuid New modification UUID of the image. If NULL, a new UUID is created.
[1]675 */
[6291]676VBOXDDU_DECL(int) VDSetModificationUuid(PVBOXHDD pDisk, unsigned nImage,
677 PCRTUUID pUuid);
[1]678
679/**
[2118]680 * Get parent UUID of image in HDD container.
[1]681 *
682 * @returns VBox status code.
[1942]683 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
[6291]684 * @param pDisk Pointer to HDD container.
[1942]685 * @param nImage Image number, counts from 0. 0 is always base image of the container.
[2358]686 * @param pUuid Where to store the parent image UUID.
[1]687 */
[6291]688VBOXDDU_DECL(int) VDGetParentUuid(PVBOXHDD pDisk, unsigned nImage,
689 PRTUUID pUuid);
[1]690
691/**
[1942]692 * Set the image's parent UUID. Should not be used by normal applications.
[1]693 *
694 * @returns VBox status code.
[6291]695 * @param pDisk Pointer to HDD container.
[1942]696 * @param nImage Image number, counts from 0. 0 is always base image of container.
[6291]697 * @param pUuid New parent UUID of the image. If NULL, a new UUID is created.
[1]698 */
[6291]699VBOXDDU_DECL(int) VDSetParentUuid(PVBOXHDD pDisk, unsigned nImage,
700 PCRTUUID pUuid);
[1]701
702
703/**
[1942]704 * Debug helper - dumps all opened images in HDD container into the log file.
[1]705 *
[6291]706 * @param pDisk Pointer to HDD container.
[1]707 */
[2118]708VBOXDDU_DECL(void) VDDumpImages(PVBOXHDD pDisk);
[1]709
710__END_DECLS
711
712/** @} */
713
714#endif
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use