VirtualBox

source: vbox/trunk/include/iprt/dvm.h@ 86716

Last change on this file since 86716 was 85894, checked in by vboxsync, 4 years ago

IPRT/Dvm: Added RTDvmMapQueryTableLocations (for VMDK). Completely untested. bugref:9224

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.5 KB
Line 
1/** @file
2 * IPRT Disk Volume Management API (DVM).
3 */
4
5/*
6 * Copyright (C) 2011-2020 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef IPRT_INCLUDED_dvm_h
27#define IPRT_INCLUDED_dvm_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/types.h>
33
34RT_C_DECLS_BEGIN
35
36
37/** @defgroup grp_dvm IPRT Disk Volume Management
38 * @{
39 */
40
41/**
42 * Volume type.
43 * Comparable to the FS type in MBR partition maps
44 * or the partition type GUIDs in GPT tables.
45 */
46typedef enum RTDVMVOLTYPE
47{
48 /** Invalid. */
49 RTDVMVOLTYPE_INVALID = 0,
50 /** Unknown. */
51 RTDVMVOLTYPE_UNKNOWN,
52 /** Volume hosts a NTFS filesystem. */
53 RTDVMVOLTYPE_NTFS,
54 /** Volume hosts a FAT12 filesystem. */
55 RTDVMVOLTYPE_FAT12,
56 /** Volume hosts a FAT16 filesystem. */
57 RTDVMVOLTYPE_FAT16,
58 /** Volume hosts a FAT32 filesystem. */
59 RTDVMVOLTYPE_FAT32,
60
61 /** EFI system partition (c12a7328-f81f-11d2-ba4b-00a0c93ec93b). */
62 RTDVMVOLTYPE_EFI_SYSTEM,
63
64 /** Volume hosts a Mac OS X HFS or HFS+ filesystem. */
65 RTDVMVOLTYPE_DARWIN_HFS,
66 /** Volume hosts a Mac OS X APFS filesystem. */
67 RTDVMVOLTYPE_DARWIN_APFS,
68
69 /** Volume hosts a Linux swap. */
70 RTDVMVOLTYPE_LINUX_SWAP,
71 /** Volume hosts a Linux filesystem. */
72 RTDVMVOLTYPE_LINUX_NATIVE,
73 /** Volume hosts a Linux LVM. */
74 RTDVMVOLTYPE_LINUX_LVM,
75 /** Volume hosts a Linux SoftRaid. */
76 RTDVMVOLTYPE_LINUX_SOFTRAID,
77
78 /** Volume hosts a FreeBSD disklabel. */
79 RTDVMVOLTYPE_FREEBSD,
80 /** Volume hosts a NetBSD disklabel. */
81 RTDVMVOLTYPE_NETBSD,
82 /** Volume hosts a OpenBSD disklabel. */
83 RTDVMVOLTYPE_OPENBSD,
84 /** Volume hosts a Solaris volume. */
85 RTDVMVOLTYPE_SOLARIS,
86
87 /** Volume hosts a Windows basic data partition . */
88 RTDVMVOLTYPE_WIN_BASIC,
89 /** Volume hosts a Microsoft reserved partition (MSR). */
90 RTDVMVOLTYPE_WIN_MSR,
91 /** Volume hosts a Windows logical disk manager (LDM) metadata partition. */
92 RTDVMVOLTYPE_WIN_LDM_META,
93 /** Volume hosts a Windows logical disk manager (LDM) data partition. */
94 RTDVMVOLTYPE_WIN_LDM_DATA,
95 /** Volume hosts a Windows recovery partition. */
96 RTDVMVOLTYPE_WIN_RECOVERY,
97 /** Volume hosts a storage spaces partition. */
98 RTDVMVOLTYPE_WIN_STORAGE_SPACES,
99
100 /** Volume hosts an IBM general parallel file system (GPFS). */
101 RTDVMVOLTYPE_IBM_GPFS,
102
103 /** End of the valid values. */
104 RTDVMVOLTYPE_END,
105 /** Usual 32bit hack. */
106 RTDVMVOLTYPE_32BIT_HACK = 0x7fffffff
107} RTDVMVOLTYPE;
108
109/** @defgroup grp_dvm_flags Flags used by RTDvmCreate.
110 * @{ */
111/** DVM flags - Blocks are always marked as unused if the volume has
112 * no block status callback set.
113 * The default is to mark them as used. */
114#define DVM_FLAGS_NO_STATUS_CALLBACK_MARK_AS_UNUSED RT_BIT_32(0)
115/** DVM flags - Space which is unused in the map will be marked as used
116 * when calling RTDvmMapQueryBlockStatus(). */
117#define DVM_FLAGS_UNUSED_SPACE_MARK_AS_USED RT_BIT_32(1)
118/** Mask of all valid flags. */
119#define DVM_FLAGS_VALID_MASK UINT32_C(0x00000003)
120/** @} */
121
122
123/** @defgroup grp_dvm_vol_flags Volume flags used by RTDvmVolumeGetFlags().
124 * @{ */
125/** Volume flags - Volume is bootable. */
126#define DVMVOLUME_FLAGS_BOOTABLE RT_BIT_64(0)
127/** Volume flags - Volume is active. */
128#define DVMVOLUME_FLAGS_ACTIVE RT_BIT_64(1)
129/** Volume is contiguous on the underlying medium and RTDvmVolumeQueryRange(). */
130#define DVMVOLUME_F_CONTIGUOUS RT_BIT_64(2)
131/** @} */
132
133/** A handle to a volume manager. */
134typedef struct RTDVMINTERNAL *RTDVM;
135/** A pointer to a volume manager handle. */
136typedef RTDVM *PRTDVM;
137/** NIL volume manager handle. */
138#define NIL_RTDVM ((RTDVM)~0)
139
140/** A handle to a volume in a volume map. */
141typedef struct RTDVMVOLUMEINTERNAL *RTDVMVOLUME;
142/** A pointer to a volume handle. */
143typedef RTDVMVOLUME *PRTDVMVOLUME;
144/** NIL volume handle. */
145#define NIL_RTDVMVOLUME ((RTDVMVOLUME)~0)
146
147/**
148 * Callback for querying the block allocation status of a volume.
149 *
150 * @returns IPRT status code.
151 * @param pvUser Opaque user data passed when setting the callback.
152 * @param off Offset relative to the start of the volume.
153 * @param cb Range to check in bytes.
154 * @param pfAllocated Where to store the allocation status on success.
155 */
156typedef DECLCALLBACKTYPE(int, FNDVMVOLUMEQUERYBLOCKSTATUS,(void *pvUser, uint64_t off, uint64_t cb, bool *pfAllocated));
157/** Pointer to a query block allocation status callback. */
158typedef FNDVMVOLUMEQUERYBLOCKSTATUS *PFNDVMVOLUMEQUERYBLOCKSTATUS;
159
160/**
161 * Create a new volume manager.
162 *
163 * @returns IPRT status.
164 * @param phVolMgr Where to store the handle to the volume manager on
165 * success.
166 * @param hVfsFile The disk/container/whatever.
167 * @param cbSector Size of one sector in bytes.
168 * @param fFlags Combination of RTDVM_FLAGS_*
169 */
170RTDECL(int) RTDvmCreate(PRTDVM phVolMgr, RTVFSFILE hVfsFile, uint32_t cbSector, uint32_t fFlags);
171
172/**
173 * Retain a given volume manager.
174 *
175 * @returns New reference count on success, UINT32_MAX on failure.
176 * @param hVolMgr The volume manager to retain.
177 */
178RTDECL(uint32_t) RTDvmRetain(RTDVM hVolMgr);
179
180/**
181 * Releases a given volume manager.
182 *
183 * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
184 * @param hVolMgr The volume manager to release.
185 */
186RTDECL(uint32_t) RTDvmRelease(RTDVM hVolMgr);
187
188/**
189 * Probes the underyling disk for the best volume manager format handler
190 * and opens it.
191 *
192 * @returns IPRT status code.
193 * @retval VERR_NOT_FOUND if no backend can handle the volume map on the disk.
194 * @param hVolMgr The volume manager handle.
195 */
196RTDECL(int) RTDvmMapOpen(RTDVM hVolMgr);
197
198/**
199 * Initializes a new volume map using the given format handler.
200 *
201 * @returns IPRT status code.
202 * @param hVolMgr The volume manager handle.
203 * @param pszFmt The format to use for the new map.
204 */
205RTDECL(int) RTDvmMapInitialize(RTDVM hVolMgr, const char *pszFmt);
206
207/**
208 * Gets the name of the currently used format of the disk map.
209 *
210 * @returns Name of the format.
211 * @param hVolMgr The volume manager handle.
212 */
213RTDECL(const char *) RTDvmMapGetFormatName(RTDVM hVolMgr);
214
215/**
216 * DVM format types.
217 */
218typedef enum RTDVMFORMATTYPE
219{
220 /** Invalid zero value. */
221 RTDVMFORMATTYPE_INVALID = 0,
222 /** Master boot record. */
223 RTDVMFORMATTYPE_MBR,
224 /** GUID partition table. */
225 RTDVMFORMATTYPE_GPT,
226 /** BSD labels. */
227 RTDVMFORMATTYPE_BSD_LABEL,
228 /** End of valid values. */
229 RTDVMFORMATTYPE_END,
230 /** 32-bit type size hack. */
231 RTDVMFORMATTYPE_32BIT_HACK = 0x7fffffff
232} RTDVMFORMATTYPE;
233
234/**
235 * Gets the format type of the current disk map.
236 *
237 * @returns Format type. RTDVMFORMATTYPE_INVALID on invalid input.
238 * @param hVolMgr The volume manager handle.
239 */
240RTDECL(RTDVMFORMATTYPE) RTDvmMapGetFormatType(RTDVM hVolMgr);
241
242/**
243 * Gets the UUID of the disk if applicable.
244 *
245 * Disks using the MBR format may return the 32-bit disk identity in the
246 * u32TimeLow field and set the rest to zero.
247 *
248 * @returns IPRT status code.
249 * @retval VERR_NOT_SUPPORTED if the partition scheme doesn't do UUIDs.
250 * @retval VINF_NOT_SUPPORTED if non-UUID disk ID is returned.
251 * @param hVolMgr The volume manager handle.
252 * @param pUuid Where to return the UUID.
253 *
254 * @todo It's quite possible this should be turned into a map-level edition of
255 * RTDvmVolumeQueryProp...
256 */
257RTDECL(int) RTDvmMapQueryDiskUuid(RTDVM hVolMgr, PRTUUID pUuid);
258
259/**
260 * Gets the number of valid partitions in the map.
261 *
262 * @returns The number of valid volumes in the map or UINT32_MAX on failure.
263 * @param hVolMgr The volume manager handle.
264 */
265RTDECL(uint32_t) RTDvmMapGetValidVolumes(RTDVM hVolMgr);
266
267/**
268 * Gets the maximum number of partitions the map can hold.
269 *
270 * @returns The maximum number of volumes in the map or UINT32_MAX on failure.
271 * @param hVolMgr The volume manager handle.
272 */
273RTDECL(uint32_t) RTDvmMapGetMaxVolumes(RTDVM hVolMgr);
274
275/**
276 * Get the first valid volume from a map.
277 *
278 * @returns IPRT status code.
279 * @param hVolMgr The volume manager handle.
280 * @param phVol Where to store the handle to the first volume on
281 * success. Release with RTDvmVolumeRelease().
282 */
283RTDECL(int) RTDvmMapQueryFirstVolume(RTDVM hVolMgr, PRTDVMVOLUME phVol);
284
285/**
286 * Get the first valid volume from a map.
287 *
288 * @returns IPRT status code.
289 * @param hVolMgr The volume manager handle.
290 * @param hVol Handle of the current volume.
291 * @param phVolNext Where to store the handle to the next volume on
292 * success. Release with RTDvmVolumeRelease().
293 */
294RTDECL(int) RTDvmMapQueryNextVolume(RTDVM hVolMgr, RTDVMVOLUME hVol, PRTDVMVOLUME phVolNext);
295
296/**
297 * Returns whether the given block on the disk is in use.
298 *
299 * @returns IPRT status code.
300 * @param hVolMgr The volume manager handle.
301 * @param off The start offset to check for.
302 * @param cb The range in bytes to check.
303 * @param pfAllocated Where to store the in-use status on success.
304 *
305 * @remark This method will return true even if a part of the range is not in use.
306 */
307RTDECL(int) RTDvmMapQueryBlockStatus(RTDVM hVolMgr, uint64_t off, uint64_t cb, bool *pfAllocated);
308
309/**
310 * Partition/map table location information.
311 * @sa RTDvmMapQueryTableLocations
312 */
313typedef struct RTDVMTABLELOCATION
314{
315 /** The byte offset on the underlying media. */
316 uint64_t off;
317 /** The table size in bytes. */
318 uint64_t cb;
319 /** Number of padding bytes / free space between the actual table and
320 * first partition. */
321 uint64_t cbPadding;
322} RTDVMTABLELOCATION;
323/** Pointer to partition table location info. */
324typedef RTDVMTABLELOCATION *PRTDVMTABLELOCATION;
325/** Pointer to const partition table location info. */
326typedef RTDVMTABLELOCATION const *PCRTDVMTABLELOCATION;
327
328
329/** @name RTDVMMAPQTABLOC_F_XXX - Flags for RTDvmMapQueryTableLocations
330 * @{ */
331/** Make sure GPT includes the protective MBR. */
332#define RTDVMMAPQTABLOC_F_INCLUDE_LEGACY RT_BIT_32(0)
333/** Valid flags. */
334#define RTDVMMAPQTABLOC_F_VALID_MASK UINT32_C(1)
335/** @} */
336
337/**
338 * Query the partition table locations.
339 *
340 * @returns IPRT status code.
341 * @retval VERR_BUFFER_OVERFLOW if the table is too small, @a *pcActual will be
342 * set to the required size.
343 * @retval VERR_BUFFER_UNDERFLOW if the table is too big and @a pcActual is
344 * NULL.
345 * @param hVolMgr The volume manager handle.
346 * @param fFlags Flags, see RTDVMMAPQTABLOC_F_XXX.
347 * @param paLocations Where to return the info. This can be NULL if @a
348 * cLocations is zero and @a pcActual is given.
349 * @param cLocations The size of @a paLocations in items.
350 * @param pcActual Where to return the actual number of locations, or
351 * on VERR_BUFFER_OVERFLOW the necessary table size.
352 * Optional, when not specified the cLocations value
353 * must match exactly or it fails with
354 * VERR_BUFFER_UNDERFLOW.
355 */
356RTDECL(int) RTDvmMapQueryTableLocations(RTDVM hVolMgr, uint32_t fFlags,
357 PRTDVMTABLELOCATION paLocations, size_t cLocations, size_t *pcActual);
358
359/**
360 * Retains a valid volume handle.
361 *
362 * @returns New reference count on success, UINT32_MAX on failure.
363 * @param hVol The volume to retain.
364 */
365RTDECL(uint32_t) RTDvmVolumeRetain(RTDVMVOLUME hVol);
366
367/**
368 * Releases a valid volume handle.
369 *
370 * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
371 * @param hVol The volume to release.
372 */
373RTDECL(uint32_t) RTDvmVolumeRelease(RTDVMVOLUME hVol);
374
375/**
376 * Sets the callback to query the block allocation status for a volume.
377 * This overwrites any other callback set previously.
378 *
379 * @returns nothing.
380 * @param hVol The volume handle.
381 * @param pfnQueryBlockStatus The callback to set. Can be NULL to disable
382 * a previous callback.
383 * @param pvUser Opaque user data passed in the callback.
384 */
385RTDECL(void) RTDvmVolumeSetQueryBlockStatusCallback(RTDVMVOLUME hVol,
386 PFNDVMVOLUMEQUERYBLOCKSTATUS pfnQueryBlockStatus,
387 void *pvUser);
388
389/**
390 * Get the size of a volume in bytes.
391 *
392 * @returns Size of the volume in bytes or 0 on failure.
393 * @param hVol The volume handle.
394 */
395RTDECL(uint64_t) RTDvmVolumeGetSize(RTDVMVOLUME hVol);
396
397/**
398 * Gets the name of the volume if supported.
399 *
400 * @returns IPRT status code.
401 * @param hVol The volume handle.
402 * @param ppszVolName Where to store the name of the volume on success.
403 * The string must be freed with RTStrFree().
404 */
405RTDECL(int) RTDvmVolumeQueryName(RTDVMVOLUME hVol, char **ppszVolName);
406
407/**
408 * Get the volume type of the volume if supported.
409 *
410 * @returns The volume type on success, DVMVOLTYPE_INVALID if hVol is invalid.
411 * @param hVol The volume handle.
412 */
413RTDECL(RTDVMVOLTYPE) RTDvmVolumeGetType(RTDVMVOLUME hVol);
414
415/**
416 * Get the volume flags of the volume if supported.
417 *
418 * @returns The volume flags or UINT64_MAX on failure.
419 * @param hVol The volume handle.
420 */
421RTDECL(uint64_t) RTDvmVolumeGetFlags(RTDVMVOLUME hVol);
422
423/**
424 * Queries the range of the given volume on the underlying medium.
425 *
426 * @returns IPRT status code.
427 * @retval VERR_NOT_SUPPORTED if the DVMVOLUME_F_CONTIGUOUS flag is not returned by RTDvmVolumeGetFlags().
428 * @param hVol The volume handle.
429 * @param poffStart Where to store the start offset in bytes on the underlying medium.
430 * @param poffLast Where to store the last offset in bytes on the underlying medium (inclusive).
431 */
432RTDECL(int) RTDvmVolumeQueryRange(RTDVMVOLUME hVol, uint64_t *poffStart, uint64_t *poffLast);
433
434/**
435 * Returns the partition/whatever table location of the volume.
436 *
437 * For volume format with a single table, like GPT and BSD-labels, it will
438 * return the location of that table. Though for GPT, the fake MBR will not be
439 * included.
440 *
441 * For logical (extended) MBR-style volumes, this will return the location of
442 * the extended partition table. For primary volumes the MBR location is
443 * returned. The special MBR case is why this operation is done on the volume
444 * rather than the volume manager.
445 *
446 * Using RTDvmVolumeGetIndex with RTDVMVOLIDX_IN_PART_TABLE should get you
447 * the index in the table returned by this function.
448 *
449 * @returns IPRT status code.
450 * @param hVol The volume handle.
451 * @param poffTable Where to return the byte offset on the underlying
452 * media of the (partition/volume/whatever) table.
453 * @param pcbTable Where to return the table size in bytes. (This does
454 * not include any alignment padding or such, just
455 * padding up to sector/block size.)
456 */
457RTDECL(int) RTDvmVolumeQueryTableLocation(RTDVMVOLUME hVol, uint64_t *poffTable, uint64_t *pcbTable);
458
459/**
460 * RTDvmVolumeGetIndex indexes.
461 */
462typedef enum RTDVMVOLIDX
463{
464 /** Invalid zero value. */
465 RTDVMVOLIDX_INVALID = 0,
466 /** Index matching the host's volume numbering.
467 * This is a pseudo index, that gets translated to one of the others depending
468 * on which host we're running on. */
469 RTDVMVOLIDX_HOST,
470 /** Only consider user visible ones, i.e. don't count MBR extended partition
471 * entries and such like. */
472 RTDVMVOLIDX_USER_VISIBLE,
473 /** Index when all volumes, user visible, hidden, special, whatever ones are
474 * included.
475 *
476 * For MBR this is 1-based index where all primary entires are included whether
477 * in use or not. Only non-empty entries in extended tables are counted, though
478 * the forward link is included. */
479 RTDVMVOLIDX_ALL,
480 /** The raw index within the partition/volume/whatever table. This have a kind
481 * of special meaning to MBR, where there are multiple tables. */
482 RTDVMVOLIDX_IN_TABLE,
483 /** Follows the linux /dev/sdaX convention as closely as absolutely possible. */
484 RTDVMVOLIDX_LINUX,
485 /** End of valid indexes. */
486 RTDVMVOLIDX_END,
487 /** Make sure the type is 32-bit. */
488 RTDVMVOLIDX_32BIT_HACK = 0x7fffffff
489} RTDVMVOLIDX;
490
491/**
492 * Gets the tiven index for the specified volume.
493 *
494 * @returns The requested index, UINT32_MAX on failure.
495 * @param hVol The volume handle.
496 * @param enmIndex Which kind of index to get for the volume.
497 */
498RTDECL(uint32_t) RTDvmVolumeGetIndex(RTDVMVOLUME hVol, RTDVMVOLIDX enmIndex);
499
500/**
501 * Volume properties queriable via RTDvmVolumeQueryProp.
502 *
503 * @note Integer values can typically be queried in multiple sizes. This is
504 * handled by the frontend code. The format specific backends only
505 * have to handle the smallest allowed size.
506 */
507typedef enum RTDVMVOLPROP
508{
509 /** Customary invalid zero value. */
510 RTDVMVOLPROP_INVALID = 0,
511 /** unsigned[16,32,64]: MBR first cylinder (0-based, CHS). */
512 RTDVMVOLPROP_MBR_FIRST_CYLINDER,
513 /** unsigned[8,16,32,64]: MBR first head (0-based, CHS). */
514 RTDVMVOLPROP_MBR_FIRST_HEAD,
515 /** unsigned[8,16,32,64]: MBR first sector (1-based, CHS). */
516 RTDVMVOLPROP_MBR_FIRST_SECTOR,
517 /** unsigned[16,32,64]: MBR last cylinder (0-based, CHS). */
518 RTDVMVOLPROP_MBR_LAST_CYLINDER,
519 /** unsigned[8,16,32,64]: MBR last head (0-based, CHS). */
520 RTDVMVOLPROP_MBR_LAST_HEAD,
521 /** unsigned[8,16,32,64]: MBR last sector (1-based, CHS). */
522 RTDVMVOLPROP_MBR_LAST_SECTOR,
523 /** unsigned[8,16,32,64]: MBR partition type. */
524 RTDVMVOLPROP_MBR_TYPE,
525 /** RTUUID: GPT volume type. */
526 RTDVMVOLPROP_GPT_TYPE,
527 /** RTUUID: GPT volume UUID. */
528 RTDVMVOLPROP_GPT_UUID,
529 /** End of valid values. */
530 RTDVMVOLPROP_END,
531 /** Make sure the type is 32-bit. */
532 RTDVMVOLPROP_32BIT_HACK = 0x7fffffff
533} RTDVMVOLPROP;
534
535/**
536 * Query a generic volume property.
537 *
538 * This is an extensible interface for retrieving mostly format specific
539 * information, or information that's not commonly used. (It's modeled after
540 * RTLdrQueryPropEx.)
541 *
542 * @returns IPRT status code.
543 * @retval VERR_NOT_SUPPORTED if the property query isn't supported (either all
544 * or that specific property). The caller must handle this result.
545 * @retval VERR_NOT_FOUND is currently not returned, but intended for cases
546 * where it wasn't present in the tables.
547 * @retval VERR_INVALID_FUNCTION if the @a enmProperty value is wrong.
548 * @retval VERR_INVALID_PARAMETER if the fixed buffer size is wrong. Correct
549 * size in @a *pcbBuf.
550 * @retval VERR_BUFFER_OVERFLOW if the property doesn't have a fixed size
551 * buffer and the buffer isn't big enough. Correct size in @a *pcbBuf.
552 * @retval VERR_INVALID_HANDLE if the handle is invalid.
553 * @param hVol Handle to the volume.
554 * @param enmProperty The property to query.
555 * @param pvBuf Pointer to the input / output buffer. In most cases
556 * it's only used for returning data.
557 * @param cbBuf The size of the buffer.
558 * @param pcbBuf Where to return the amount of data returned. On
559 * buffer size errors, this is set to the correct size.
560 * Optional.
561 * @sa RTDvmVolumeGetPropU64
562 */
563RTDECL(int) RTDvmVolumeQueryProp(RTDVMVOLUME hVol, RTDVMVOLPROP enmProperty, void *pvBuf, size_t cbBuf, size_t *pcbBuf);
564
565/**
566 * Wrapper around RTDvmVolumeQueryProp for simplifying getting unimportant
567 * integer properties.
568 *
569 * @returns The property value if supported and found, the default value if not.
570 * Errors other than VERR_NOT_SUPPORTED and VERR_NOT_FOUND are
571 * asserted.
572 * @param hVol Handle to the volume.
573 * @param enmProperty The property to query.
574 * @param uDefault The value to return on error.
575 * @sa RTDvmVolumeQueryProp
576 */
577RTDECL(uint64_t) RTDvmVolumeGetPropU64(RTDVMVOLUME hVol, RTDVMVOLPROP enmProperty, uint64_t uDefault);
578
579/**
580 * Reads data from the given volume.
581 *
582 * @returns IPRT status code.
583 * @param hVol The volume handle.
584 * @param off Where to start reading from - 0 is the beginning of
585 * the volume.
586 * @param pvBuf Where to store the read data.
587 * @param cbRead How many bytes to read.
588 */
589RTDECL(int) RTDvmVolumeRead(RTDVMVOLUME hVol, uint64_t off, void *pvBuf, size_t cbRead);
590
591/**
592 * Writes data to the given volume.
593 *
594 * @returns IPRT status code.
595 * @param hVol The volume handle.
596 * @param off Where to start writing to - 0 is the beginning of
597 * the volume.
598 * @param pvBuf The data to write.
599 * @param cbWrite How many bytes to write.
600 */
601RTDECL(int) RTDvmVolumeWrite(RTDVMVOLUME hVol, uint64_t off, const void *pvBuf, size_t cbWrite);
602
603/**
604 * Returns the description of a given volume type.
605 *
606 * @returns The description of the type.
607 * @param enmVolType The volume type.
608 */
609RTDECL(const char *) RTDvmVolumeTypeGetDescr(RTDVMVOLTYPE enmVolType);
610
611/**
612 * Creates an VFS file from a volume handle.
613 *
614 * @returns IPRT status code.
615 * @param hVol The volume handle.
616 * @param fOpen RTFILE_O_XXX.
617 * @param phVfsFileOut Where to store the VFS file handle on success.
618 */
619RTDECL(int) RTDvmVolumeCreateVfsFile(RTDVMVOLUME hVol, uint64_t fOpen, PRTVFSFILE phVfsFileOut);
620
621RT_C_DECLS_END
622
623/** @} */
624
625#endif /* !IPRT_INCLUDED_dvm_h */
626
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