VirtualBox

Changeset 48743 in vbox for trunk/src/VBox/Storage/VD.cpp


Ignore:
Timestamp:
Sep 27, 2013 6:19:03 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
89380
Message:

Storage/VD: Add support for different sector sizes (only opening and reading and writing images, not creating them with a sector size other than 512 bytes)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/VD.cpp

    r48574 r48743  
    82238223
    82248224/**
     8225 * Get sector size of an image in HDD container.
     8226 *
     8227 * @return  Virtual disk sector size in bytes.
     8228 * @return  0 if image with specified number was not opened.
     8229 * @param   pDisk           Pointer to HDD container.
     8230 * @param   nImage          Image number, counts from 0. 0 is always base image of container.
     8231 */
     8232VBOXDDU_DECL(uint32_t) VDGetSectorSize(PVBOXHDD pDisk, unsigned nImage)
     8233{
     8234    uint64_t cbSector;
     8235    int rc2;
     8236    bool fLockRead = false;
     8237
     8238    LogFlowFunc(("pDisk=%#p nImage=%u\n", pDisk, nImage));
     8239    do
     8240    {
     8241        /* sanity check */
     8242        AssertPtrBreakStmt(pDisk, cbSector = 0);
     8243        AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     8244
     8245        rc2 = vdThreadStartRead(pDisk);
     8246        AssertRC(rc2);
     8247        fLockRead = true;
     8248
     8249        PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
     8250        AssertPtrBreakStmt(pImage, cbSector = 0);
     8251        cbSector = pImage->Backend->pfnGetSectorSize(pImage->pBackendData);
     8252    } while (0);
     8253
     8254    if (RT_UNLIKELY(fLockRead))
     8255    {
     8256        rc2 = vdThreadFinishRead(pDisk);
     8257        AssertRC(rc2);
     8258    }
     8259
     8260    LogFlowFunc(("returns %u\n", cbSector));
     8261    return cbSector;
     8262}
     8263
     8264/**
    82258265 * Get total capacity of an image in HDD container.
    82268266 *
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