VirtualBox

Changeset 33081 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Oct 12, 2010 5:54:54 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
66608
Message:

Storage/VDI: fix a sneaky bug which led to temporary amnesia what the LCHS geometry is set for a newly created image

File:
1 edited

Legend:

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

    r33030 r33081  
    349349{
    350350    pHeader->uVersion = VDI_IMAGE_VERSION;
    351     pHeader->u.v1.cbHeader = sizeof(VDIHEADER1);
    352     pHeader->u.v1.u32Type = (uint32_t)vdiTranslateImageFlags2VDI(uImageFlags);
    353     pHeader->u.v1.fFlags = (uImageFlags & VD_VDI_IMAGE_FLAGS_ZERO_EXPAND) ? 1 : 0;
     351    pHeader->u.v1plus.cbHeader = sizeof(VDIHEADER1PLUS);
     352    pHeader->u.v1plus.u32Type = (uint32_t)vdiTranslateImageFlags2VDI(uImageFlags);
     353    pHeader->u.v1plus.fFlags = (uImageFlags & VD_VDI_IMAGE_FLAGS_ZERO_EXPAND) ? 1 : 0;
    354354#ifdef VBOX_STRICT
    355355    char achZero[VDI_IMAGE_COMMENT_SIZE] = {0};
    356     Assert(!memcmp(pHeader->u.v1.szComment, achZero, VDI_IMAGE_COMMENT_SIZE));
     356    Assert(!memcmp(pHeader->u.v1plus.szComment, achZero, VDI_IMAGE_COMMENT_SIZE));
    357357#endif
    358     pHeader->u.v1.szComment[0] = '\0';
     358    pHeader->u.v1plus.szComment[0] = '\0';
    359359    if (pszComment)
    360360    {
    361         AssertMsg(strlen(pszComment) < sizeof(pHeader->u.v1.szComment),
     361        AssertMsg(strlen(pszComment) < sizeof(pHeader->u.v1plus.szComment),
    362362                  ("HDD Comment is too long, cb=%d\n", strlen(pszComment)));
    363         strncat(pHeader->u.v1.szComment, pszComment, sizeof(pHeader->u.v1.szComment)-1);
     363        strncat(pHeader->u.v1plus.szComment, pszComment, sizeof(pHeader->u.v1plus.szComment)-1);
    364364    }
    365365
    366366    /* Mark the legacy geometry not-calculated. */
    367     pHeader->u.v1.LegacyGeometry.cCylinders = 0;
    368     pHeader->u.v1.LegacyGeometry.cHeads = 0;
    369     pHeader->u.v1.LegacyGeometry.cSectors = 0;
    370     pHeader->u.v1.LegacyGeometry.cbSector = VDI_GEOMETRY_SECTOR_SIZE;
    371     pHeader->u.v1.u32Dummy = 0; /* used to be the translation value */
    372 
    373     pHeader->u.v1.cbDisk = cbDisk;
    374     pHeader->u.v1.cbBlock = cbBlock;
    375     pHeader->u.v1.cBlocks = (uint32_t)(cbDisk / cbBlock);
     367    pHeader->u.v1plus.LegacyGeometry.cCylinders = 0;
     368    pHeader->u.v1plus.LegacyGeometry.cHeads = 0;
     369    pHeader->u.v1plus.LegacyGeometry.cSectors = 0;
     370    pHeader->u.v1plus.LegacyGeometry.cbSector = VDI_GEOMETRY_SECTOR_SIZE;
     371    pHeader->u.v1plus.u32Dummy = 0; /* used to be the translation value */
     372
     373    pHeader->u.v1plus.cbDisk = cbDisk;
     374    pHeader->u.v1plus.cbBlock = cbBlock;
     375    pHeader->u.v1plus.cBlocks = (uint32_t)(cbDisk / cbBlock);
    376376    if (cbDisk % cbBlock)
    377         pHeader->u.v1.cBlocks++;
    378     pHeader->u.v1.cbBlockExtra = cbBlockExtra;
    379     pHeader->u.v1.cBlocksAllocated = 0;
     377        pHeader->u.v1plus.cBlocks++;
     378    pHeader->u.v1plus.cbBlockExtra = cbBlockExtra;
     379    pHeader->u.v1plus.cBlocksAllocated = 0;
    380380
    381381    /* Init offsets. */
    382     pHeader->u.v1.offBlocks = RT_ALIGN_32(sizeof(VDIPREHEADER) + sizeof(VDIHEADER1), VDI_DATA_ALIGN);
    383     pHeader->u.v1.offData = RT_ALIGN_32(pHeader->u.v1.offBlocks + (pHeader->u.v1.cBlocks * sizeof(VDIIMAGEBLOCKPOINTER)), VDI_DATA_ALIGN);
     382    pHeader->u.v1plus.offBlocks = RT_ALIGN_32(sizeof(VDIPREHEADER) + sizeof(VDIHEADER1PLUS), VDI_DATA_ALIGN);
     383    pHeader->u.v1plus.offData = RT_ALIGN_32(pHeader->u.v1plus.offBlocks + (pHeader->u.v1plus.cBlocks * sizeof(VDIIMAGEBLOCKPOINTER)), VDI_DATA_ALIGN);
    384384
    385385    /* Init uuids. */
    386     RTUuidCreate(&pHeader->u.v1.uuidCreate);
    387     RTUuidClear(&pHeader->u.v1.uuidModify);
    388     RTUuidClear(&pHeader->u.v1.uuidLinkage);
    389     RTUuidClear(&pHeader->u.v1.uuidParentModify);
     386    RTUuidCreate(&pHeader->u.v1plus.uuidCreate);
     387    RTUuidClear(&pHeader->u.v1plus.uuidModify);
     388    RTUuidClear(&pHeader->u.v1plus.uuidLinkage);
     389    RTUuidClear(&pHeader->u.v1plus.uuidParentModify);
    390390
    391391    /* Mark LCHS geometry not-calculated. */
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