VirtualBox

Changeset 24527 in vbox


Ignore:
Timestamp:
Nov 9, 2009 8:39:29 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
54631
Message:

VHD: Fix incompatibility with Hyper-V. Contributed by Huihong Luo

File:
1 edited

Legend:

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

    r24150 r24527  
    17271727    /* Initialize BAT. */
    17281728    pImage->uBlockAllocationTableOffset = (uint64_t)sizeof(VHDFooter) + sizeof(VHDDynamicDiskHeader);
    1729     pImage->cBlockAllocationTableEntries = (uint32_t)(cbSize / pImage->cbDataBlock);
     1729    pImage->cBlockAllocationTableEntries = (uint32_t)((cbSize + pImage->cbDataBlock - 1) / pImage->cbDataBlock); /* Align table to the block size. */
    17301730    u32BlockAllocationTableSectors = (pImage->cBlockAllocationTableEntries * sizeof(uint32_t) + VHD_SECTOR_SIZE - 1) / VHD_SECTOR_SIZE;
    17311731    pImage->pBlockAllocationTable = (uint32_t *)RTMemAllocZ(pImage->cBlockAllocationTableEntries * sizeof(uint32_t));
     
    17371737        pImage->pBlockAllocationTable[i] = 0xFFFFFFFF; /* It is actually big endian. */
    17381738    }
     1739
    17391740    /* Round up to the sector size. */
    1740     pImage->uCurrentEndOfFile = vhdAllocateParentLocators(pImage, &DynamicDiskHeader,
    1741         pImage->uBlockAllocationTableOffset + u32BlockAllocationTableSectors * VHD_SECTOR_SIZE);
     1741    if (pImage->uImageFlags & VD_IMAGE_FLAGS_DIFF) /* fix hyper-v unreadable error */
     1742        pImage->uCurrentEndOfFile = vhdAllocateParentLocators(pImage, &DynamicDiskHeader,
     1743                                                              pImage->uBlockAllocationTableOffset + u32BlockAllocationTableSectors * VHD_SECTOR_SIZE);
     1744    else
     1745        pImage->uCurrentEndOfFile = pImage->uBlockAllocationTableOffset + u32BlockAllocationTableSectors * VHD_SECTOR_SIZE;
    17421746
    17431747    /* Set dynamic image size. */
Note: See TracChangeset for help on using the changeset viewer.

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