VirtualBox

Ignore:
Timestamp:
Oct 13, 2008 3:43:50 PM (16 years ago)
Author:
vboxsync
Message:

Device/Storage: Fix incorrect translation between image type enums. Mishandled fixed VDIs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp

    r12143 r13223  
    127127
    128128/**
     129 * Internal: translate VD image type enum to VDI image type enum.
     130 */
     131static VDIIMAGETYPE vdiTranslateTypeVD2VDI(VDIMAGETYPE enmType)
     132{
     133    switch (enmType)
     134    {
     135        case VD_IMAGE_TYPE_NORMAL:
     136            return VDI_IMAGE_TYPE_NORMAL;
     137        case VD_IMAGE_TYPE_FIXED:
     138            return VDI_IMAGE_TYPE_FIXED;
     139        case VD_IMAGE_TYPE_UNDO:
     140            return VDI_IMAGE_TYPE_UNDO;
     141        case VD_IMAGE_TYPE_DIFF:
     142            return VDI_IMAGE_TYPE_DIFF;
     143        default:
     144            AssertMsgFailed(("invalid VDIMAGETYPE enmType=%d\n", (int)enmType));
     145            return VDI_IMAGE_TYPE_NORMAL;
     146    }
     147}
     148
     149/**
     150 * Internal: translate VDI image type enum to VD image type enum.
     151 */
     152static VDIMAGETYPE vdiTranslateTypeVDI2VD(VDIIMAGETYPE enmType)
     153{
     154    switch (enmType)
     155    {
     156        case VDI_IMAGE_TYPE_NORMAL:
     157            return VD_IMAGE_TYPE_NORMAL;
     158        case VDI_IMAGE_TYPE_FIXED:
     159            return VD_IMAGE_TYPE_FIXED;
     160        case VDI_IMAGE_TYPE_UNDO:
     161            return VD_IMAGE_TYPE_UNDO;
     162        case VDI_IMAGE_TYPE_DIFF:
     163            return VD_IMAGE_TYPE_DIFF;
     164        default:
     165            AssertMsgFailed(("invalid VDIIMAGETYPE enmType=%d\n", (int)enmType));
     166            return VD_IMAGE_TYPE_INVALID;
     167    }
     168}
     169
     170/**
    129171 * Internal: Init VDI header. Always use latest header version.
    130172 * @param   pHeader     Assumes it was initially initialized to all zeros.
     
    137179    pHeader->uVersion = VDI_IMAGE_VERSION;
    138180    pHeader->u.v1.cbHeader = sizeof(VDIHEADER1);
    139     pHeader->u.v1.u32Type = (uint32_t)(  enmType == VD_IMAGE_TYPE_NORMAL
    140                                        ? VDI_IMAGE_TYPE_NORMAL
    141                                        : VDI_IMAGE_TYPE_DIFF);
     181    pHeader->u.v1.u32Type = (uint32_t)vdiTranslateTypeVD2VDI(enmType);
    142182    pHeader->u.v1.fFlags = (uImageFlags & VD_VDI_IMAGE_FLAGS_ZERO_EXPAND) ? 1 : 0;
    143183#ifdef VBOX_STRICT
     
    11531193
    11541194    if (pImage)
    1155         *penmImageType =   getImageType(&pImage->Header) == VDI_IMAGE_TYPE_NORMAL
    1156                          ? VD_IMAGE_TYPE_NORMAL
    1157                          : VD_IMAGE_TYPE_DIFF;
     1195        *penmImageType = vdiTranslateTypeVDI2VD(getImageType(&pImage->Header));
    11581196    else
    11591197        rc = VERR_VDI_NOT_OPENED;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette