VirtualBox

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

Last change on this file since 92348 was 86780, checked in by vboxsync, 4 years ago

IPRT/dvm: Added OS/2 partition type GUID.

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