dvm.cpp revision 68fb2428898c55a7172e6a75a0a8d7ce259919bd
/* $Id$ */
/** @file
* IPRT Disk Volume Management API (DVM) - generic code.
*/
/*
* Copyright (C) 2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* The internal volume manager structure.
*/
typedef struct RTDVMINTERNAL
{
/** The DVM magic (RTDVM_MAGIC). */
/** The disk descriptor. */
/** Pointer to the backend operations table after a successful probe. */
/** The format specific volume manager data. */
/** Reference counter. */
/** Pointer to an internal volume manager. */
typedef RTDVMINTERNAL *PRTDVMINTERNAL;
/**
* The internal volume structure.
*/
typedef struct RTDVMVOLUMEINTERNAL
{
/** The DVM volume magic (RTDVMVOLUME_MAGIC). */
/** Pointer to the owning volume manager. */
/** Format specific volume data. */
/** Reference counter. */
/** Pointer to an internal volume. */
typedef RTDVMVOLUMEINTERNAL *PRTDVMVOLUMEINTERNAL;
/*******************************************************************************
* Global variables *
*******************************************************************************/
extern RTDVMFMTOPS g_rtDvmFmtMbr;
extern RTDVMFMTOPS g_rtDvmFmtGpt;
/**
* Supported volume formats.
*/
static PCRTDVMFMTOPS g_aDvmFmts[] =
{
};
/**
* Descriptions of the volume types.
*
* This is indexed by RTDVMVOLTYPE.
*/
static const char * g_apcszDvmVolTypes[] =
{
"Invalid",
"Unknown",
"NTFS",
"FAT16",
"FAT32",
"Linux swap",
"Linux native",
"Linux LVM",
"Linux SoftRaid",
"FreeBSD",
"NetBSD",
"OpenBSD",
"Mac OS X HFS or HFS+",
"Solaris"
};
{
int rc = VINF_SUCCESS;
{
}
else
rc = VERR_NO_MEMORY;
return rc;
}
{
return cRefs;
}
/**
* Destroys a volume manager handle.
*
* @param pThis The volume manager to destroy.
*/
{
{
/* Let the backend do it's own cleanup first. */
}
}
{
return 0;
if (cRefs == 0)
return cRefs;
}
{
int rc = VINF_SUCCESS;
for (unsigned i = 0; i < RT_ELEMENTS(g_aDvmFmts); i++)
{
if ( RT_SUCCESS(rc)
{
}
else if (RT_FAILURE(rc))
break;
}
if (RT_SUCCESS(rc))
{
{
/* Open the format. */
if (RT_SUCCESS(rc))
}
else
rc = VERR_NOT_FOUND;
}
return rc;
}
{
int rc = VINF_SUCCESS;
for (unsigned i = 0; i < RT_ELEMENTS(g_aDvmFmts); i++)
{
{
if (RT_SUCCESS(rc))
break;
}
}
return rc;
}
{
}
{
}
{
}
{
int rc = VINF_SUCCESS;
{
/* Reference the volume manager. */
}
else
rc = VERR_NO_MEMORY;
return rc;
}
{
int rc = VINF_SUCCESS;
if (RT_SUCCESS(rc))
{
if (RT_FAILURE(rc))
}
return rc;
}
{
int rc = VINF_SUCCESS;
if (RT_SUCCESS(rc))
{
if (RT_FAILURE(rc))
}
return rc;
}
{
return cRefs;
}
/**
* Destroys a volume handle.
*
* @param pThis The volume to destroy.
*/
{
/* Close the volume. */
/* Release the reference of the volume manager. */
}
{
if (pThis == NIL_RTDVMVOLUME)
return 0;
if (cRefs == 0)
return cRefs;
}
{
AssertPtrReturn(pThis, 0);
}
{
}
{
}
{
}
{
}
{
}
{
return g_apcszDvmVolTypes[enmVolType];
}