dvm.h revision c7814cf6e1240a519cbec0441e033d0e2470ed00
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync/** @file
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * IPRT Disk Volume Management API (DVM).
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/*
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Copyright (C) 2011-2012 Oracle Corporation
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * available from http://www.virtualbox.org. This file is free software;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * you can redistribute it and/or modify it under the terms of the GNU
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * General Public License (GPL) as published by the Free Software
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * The contents of this file may alternatively be used under the terms
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * of the Common Development and Distribution License Version 1.0
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * VirtualBox OSE distribution, in which case the provisions of the
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * CDDL are applicable instead of those of the GPL.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync *
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * You may elect to license modified versions of this file under the
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * terms and conditions of either the GPL or the CDDL or both.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#ifndef ___iprt_dvm_h
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#define ___iprt_dvm_h
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#include <iprt/types.h>
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncRT_C_DECLS_BEGIN
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/** @defgroup grp_dvm IPRT Disk Volume Management
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/**
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Volume type.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Comparable to the FS type in MBR partition maps
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * or the partition type GUIDs in GPT tables.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsynctypedef enum RTDVMVOLTYPE
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /** Invalid. */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTDVMVOLTYPE_INVALID = 0,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /** Unknown. */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTDVMVOLTYPE_UNKNOWN,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /** Volume hosts a NTFS filesystem. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync RTDVMVOLTYPE_NTFS,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /** Volume hosts a FAT16 filesystem. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync RTDVMVOLTYPE_FAT16,
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /** Volume hosts a FAT32 filesystem. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync RTDVMVOLTYPE_FAT32,
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /** Volume hosts a Linux swap. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync RTDVMVOLTYPE_LINUX_SWAP,
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /** Volume hosts a Linux filesystem. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync RTDVMVOLTYPE_LINUX_NATIVE,
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /** Volume hosts a Linux LVM. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync RTDVMVOLTYPE_LINUX_LVM,
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /** Volume hosts a Linux SoftRaid. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync RTDVMVOLTYPE_LINUX_SOFTRAID,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /** Volume hosts a FreeBSD disklabel. */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTDVMVOLTYPE_FREEBSD,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /** Volume hosts a NetBSD disklabel. */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTDVMVOLTYPE_NETBSD,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /** Volume hosts a OpenBSD disklabel. */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTDVMVOLTYPE_OPENBSD,
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /** Volume hosts a Mac OS X HFS or HFS+ filesystem. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync RTDVMVOLTYPE_MAC_OSX_HFS,
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /** Volume hosts a Solaris volume. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync RTDVMVOLTYPE_SOLARIS,
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /** End of the valid values. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync RTDVMVOLTYPE_END,
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /** Usual 32bit hack. */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTDVMVOLTYPE_32BIT_HACK = 0x7fffffff
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync} RTDVMVOLTYPE;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync/** @defgroup grp_dvm_flags Flags used by RTDvmCreate.
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync * @{ */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync/** DVM flags - Blocks are always marked as unused if the volume has
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync * no block status callback set.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * The default is to mark them as used. */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#define DVM_FLAGS_NO_STATUS_CALLBACK_MARK_AS_UNUSED RT_BIT_32(0)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/** DVM flags - Space which is unused in the map will be marked as used
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * when calling RTDvmMapQueryBlockStatus(). */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#define DVM_FLAGS_UNUSED_SPACE_MARK_AS_USED RT_BIT_32(1)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/** Mask of all valid flags. */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#define DVM_FLAGS_MASK (DVM_FLAGS_NO_STATUS_CALLBACK_MARK_AS_UNUSED | DVM_FLAGS_UNUSED_SPACE_MARK_AS_USED)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/** @} */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync/** @defgroup grp_dvm_vol_flags Volume flags used by DVMVolumeGetFlags.
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync * @{ */
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync/** Volume flags - Volume is bootable. */
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync#define DVMVOLUME_FLAGS_BOOTABLE RT_BIT_64(0)
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync/** Volume flags - Volume is active. */
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync#define DVMVOLUME_FLAGS_ACTIVE RT_BIT_64(1)
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync/** @} */
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync/** A handle to a volume manager. */
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsynctypedef struct RTDVMINTERNAL *RTDVM;
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync/** A pointer to a volume manager handle. */
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsynctypedef RTDVM *PRTDVM;
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync/** NIL volume manager handle. */
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync#define NIL_RTDVM ((RTDVM)~0)
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync/** A handle to a volume in a volume map. */
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsynctypedef struct RTDVMVOLUMEINTERNAL *RTDVMVOLUME;
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync/** A pointer to a volume handle. */
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsynctypedef RTDVMVOLUME *PRTDVMVOLUME;
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync/** NIL volume handle. */
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync#define NIL_RTDVMVOLUME ((RTDVMVOLUME)~0)
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync/**
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync * Callback to read data from the underlying medium.
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync *
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync * @returns IPRT status code.
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync * @param pvUser Opaque user data passed on creation.
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync * @param off Offset to start reading from.
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync * @param pvBuf Where to store the read data.
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync * @param cbRead How many bytes to read.
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync */
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsynctypedef DECLCALLBACK(int) FNDVMREAD(void *pvUser, uint64_t off, void *pvBuf, size_t cbRead);
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync/** Pointer to a read callback. */
07557d07616212d7ba6e7ab3059e85cb14633775vboxsynctypedef FNDVMREAD *PFNDVMREAD;
07557d07616212d7ba6e7ab3059e85cb14633775vboxsync
07557d07616212d7ba6e7ab3059e85cb14633775vboxsync/**
07557d07616212d7ba6e7ab3059e85cb14633775vboxsync * Callback to write data to the underlying medium.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync *
529e6bec97f5ef2e005c99c205c9624583ecb7f0vboxsync * @returns IPRT status code.
529e6bec97f5ef2e005c99c205c9624583ecb7f0vboxsync * @param pvUser Opaque user data passed on creation.
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync * @param off Offset to start writing to.
e94ff1af89bf631c68367d4e291ddbb491b5e5c0vboxsync * @param pvBuf The data to write.
529e6bec97f5ef2e005c99c205c9624583ecb7f0vboxsync * @param cbRead How many bytes to write.
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync */
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsynctypedef DECLCALLBACK(int) FNDVMWRITE(void *pvUser, uint64_t off, const void *pvBuf, size_t cbWrite);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/** Pointer to a read callback. */
529e6bec97f5ef2e005c99c205c9624583ecb7f0vboxsynctypedef FNDVMWRITE *PFNDVMWRITE;
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync/**
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync * Callback for querying the block allocation status of a volume.
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @returns IPRT status code.
529e6bec97f5ef2e005c99c205c9624583ecb7f0vboxsync * @param pvUser Opaque user data passed when setting the callback.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param off Offset relative to the start of the volume.
e94ff1af89bf631c68367d4e291ddbb491b5e5c0vboxsync * @param cb Range to check in bytes.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param pfAllocated Where to store the allocation status on success.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsynctypedef DECLCALLBACK(int) FNDVMVOLUMEQUERYBLOCKSTATUS(void *pvUser, uint64_t off,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync uint64_t cb, bool *pfAllocated);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/** Pointer to a query block allocation status callback. */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsynctypedef FNDVMVOLUMEQUERYBLOCKSTATUS *PFNDVMVOLUMEQUERYBLOCKSTATUS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/**
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Create a new volume manager.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @returns IPRT status.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param phVolMgr Where to store the handle to the volume manager on
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync * success.
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync * @param pfnRead Read callback for the underlying
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync * disk/container/whatever.
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync * @param pfnWrite Write callback for the underlying
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync * disk/container/whatever.
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync * @param cbDisk Size of the underlying disk in bytes.
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync * @param cbSector Size of one sector in bytes.
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync * @param fFlags Combination of RTDVM_FLAGS_*
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync * @param pvUser Opaque user data passed to the callbacks.
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync */
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsyncRTDECL(int) RTDvmCreate(PRTDVM phVolMgr, PFNDVMREAD pfnRead,
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync PFNDVMWRITE pfnWrite, uint64_t cbDisk,
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync uint64_t cbSector, uint32_t fFlags,
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync void *pvUser);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync/**
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Retain a given volume manager.
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync *
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync * @returns New reference count on success, UINT32_MAX on failure.
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync * @param hVolMgr The volume manager to retain.
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync */
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsyncRTDECL(uint32_t) RTDvmRetain(RTDVM hVolMgr);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsync/**
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsync * Releases a given volume manager.
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsync *
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsync * @param hVolMgr The volume manager to release.
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsync */
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsyncRTDECL(uint32_t) RTDvmRelease(RTDVM hVolMgr);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/**
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync * Probes the underyling disk for the best volume manager format handler
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * and opens it.
290f895ae2ac655ba90c8904a0e2687d8aa0837dvboxsync *
290f895ae2ac655ba90c8904a0e2687d8aa0837dvboxsync * @returns IPRT status code.
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync * @retval VERR_NOT_FOUND if no backend can handle the volume map on the disk.
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsync * @param hVolMgr The volume manager handle.
290f895ae2ac655ba90c8904a0e2687d8aa0837dvboxsync */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsyncRTDECL(int) RTDvmMapOpen(RTDVM hVolMgr);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/**
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsync * Initializes a new volume map using the given format handler.
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsync *
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsync * @returns IPRT status code.
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsync * @param hVolMgr The volume manager handle.
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsync * @param pszFmt The format to use for the new map.
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsync */
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsyncRTDECL(int) RTDvmMapInitialize(RTDVM hVolMgr, const char *pszFmt);
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync/**
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Gets the currently used format of the disk map.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync *
290f895ae2ac655ba90c8904a0e2687d8aa0837dvboxsync * @returns Name of the format.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param hVolMgr The volume manager handle.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsyncRTDECL(const char *) RTDvmMapGetFormat(RTDVM hVolMgr);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync/**
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * Gets the number of valid partitions in the map.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync *
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @returns The number of valid volumes in the map or UINT32_MAX on failure.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param hVolMgr The volume manager handle.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsyncRTDECL(uint32_t) RTDvmMapGetValidVolumes(RTDVM hVolMgr);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync/**
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * Gets the maximum number of partitions the map can hold.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync *
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @returns The maximum number of volumes in the map or UINT32_MAX on failure.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param hVolMgr The volume manager handle.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsyncRTDECL(uint32_t) RTDvmMapGetMaxVolumes(RTDVM hVolMgr);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync/**
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * Get the first valid volume from a map.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync *
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @returns IPRT status code.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param hVolMgr The volume manager handle.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param phVol Where to store the handle to the first volume on
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * success. Release with RTDvmVolumeRelease().
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsyncRTDECL(int) RTDvmMapQueryFirstVolume(RTDVM hVolMgr, PRTDVMVOLUME phVol);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync/**
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * Get the first valid volume from a map.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync *
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @returns IPRT status code.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param hVolMgr The volume manager handle.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param hVol Handle of the current volume.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param phVolNext Where to store the handle to the next volume on
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * success. Release with RTDvmVolumeRelease().
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsyncRTDECL(int) RTDvmMapQueryNextVolume(RTDVM hVolMgr, RTDVMVOLUME hVol, PRTDVMVOLUME phVolNext);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync/**
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * Returns whether the given block on the disk is in use.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync *
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @returns IPRT status code.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param hVolMgr The volume manager handler.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param off The start offset to check for.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param cb The range in bytes to check.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param pfAllocated Where to store the status on success.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync *
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @remark This method will return true even if a part of the range is not in use.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsyncRTDECL(int) RTDvmMapQueryBlockStatus(RTDVM hVolMgr, uint64_t off, uint64_t cb,
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync bool *pfAllocated);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync/**
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * Retains a valid volume handle.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync *
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @returns New reference count on success, UINT32_MAX on failure.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param hVol The volume to retain.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsyncRTDECL(uint32_t) RTDvmVolumeRetain(RTDVMVOLUME hVol);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync/**
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * Releases a valid volume handle.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync *
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param hVol The volume to release.
290f895ae2ac655ba90c8904a0e2687d8aa0837dvboxsync */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsyncRTDECL(uint32_t) RTDvmVolumeRelease(RTDVMVOLUME hVol);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync/**
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * Sets the callback to query the block allocation status for a volume.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * This overwrites any other callback set previously.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync *
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @returns nothing.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param hVol The volume handle.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param pfnQueryBlockStatus The callback to set. Can be NULL to disable
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * a previous callback.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param pvUser Opaque user data passed in the callback.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsyncRTDECL(void) RTDvmVolumeSetQueryBlockStatusCallback(RTDVMVOLUME hVol,
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync PFNDVMVOLUMEQUERYBLOCKSTATUS pfnQueryBlockStatus,
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync void *pvUser);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync/**
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * Get the size of a volume in bytes.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync *
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @returns Size of the volume in bytes or 0 on failure.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param hVol The volume handle.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsyncRTDECL(uint64_t) RTDvmVolumeGetSize(RTDVMVOLUME hVol);
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync/**
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * Gets the name of the volume if supported.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync *
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @returns IPRT status code.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param hVol The volume handle.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * @param ppszVolName Where to store the name of the volume on success.
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync * The string must be freed with RTStrFree().
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsyncRTDECL(int) RTDvmVolumeQueryName(RTDVMVOLUME hVol, char **ppszVolName);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync/**
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * Get the volume type of the volume if supported.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync *
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @returns The volume type on success, DVMVOLTYPE_INVALID if hVol is invalid.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @param hVol The volume handle.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync */
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsyncRTDECL(RTDVMVOLTYPE) RTDvmVolumeGetType(RTDVMVOLUME hVol);
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync/**
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * Get the volume flags of the volume if supported.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync *
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @returns The volume flags or UINT64_MAX on failure.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @param hVol The volume handle.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync */
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsyncRTDECL(uint64_t) RTDvmVolumeGetFlags(RTDVMVOLUME hVol);
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync/**
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * Reads data from the given volume.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync *
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @returns IPRT status code.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @param hVol The volume handle.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @param off Where to start reading from - 0 is the beginning of
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * the volume.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @param pvBuf Where to store the read data.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @param cbRead How many bytes to read.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync */
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsyncRTDECL(int) RTDvmVolumeRead(RTDVMVOLUME hVol, uint64_t off, void *pvBuf, size_t cbRead);
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync/**
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * Writes data to the given volume.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync *
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @returns IPRT status code.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @param hVol The volume handle.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @param off Where to start writing to - 0 is the beginning of
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * the volume.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @param pvBuf The data to write.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @param cbWrite How many bytes to write.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync */
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsyncRTDECL(int) RTDvmVolumeWrite(RTDVMVOLUME hVol, uint64_t off, const void *pvBuf, size_t cbWrite);
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync/**
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * Returns the description of a given volume type.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync *
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @returns The description of the type.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @param enmVolType The volume type.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync */
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsyncRTDECL(const char *) RTDvmVolumeTypeGetDescr(RTDVMVOLTYPE enmVolType);
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync/**
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * Creates an VFS file from a volume handle.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync *
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @returns IPRT status code.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @param hVol The volume handle.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * @param phVfsFileOut Where to store the VFS file handle on success.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync */
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsyncRTDECL(int) RTDvmVolumeCreateVfsFile(RTDVMVOLUME hVol, PRTVFSFILE phVfsFileOut);
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsyncRT_C_DECLS_END
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync/** @} */
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync#endif
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync