VirtualBox

Changeset 48743 in vbox for trunk/src


Ignore:
Timestamp:
Sep 27, 2013 6:19:03 PM (12 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)

Location:
trunk/src/VBox/Storage
Files:
11 edited

Legend:

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

    r46613 r48743  
    18041804}
    18051805
     1806/** @copydoc VBOXHDDBACKEND::pfnGetSectorSize */
     1807static uint32_t dmgGetSectorSize(void *pBackendData)
     1808{
     1809    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     1810    PDMGIMAGE pThis = (PDMGIMAGE)pBackendData;
     1811    uint32_t cb = 0;
     1812
     1813    AssertPtr(pThis);
     1814
     1815    if (pThis && pThis->pStorage)
     1816        cb = 2048;
     1817
     1818    LogFlowFunc(("returns %u\n", cb));
     1819    return cb;
     1820}
     1821
    18061822/** @copydoc VBOXHDDBACKEND::pfnGetSize */
    18071823static uint64_t dmgGetSize(void *pBackendData)
     
    22742290    /* pfnGetVersion */
    22752291    dmgGetVersion,
     2292    /* pfnGetSectorSize */
     2293    dmgGetSectorSize,
    22762294    /* pfnGetSize */
    22772295    dmgGetSize,
  • trunk/src/VBox/Storage/ISCSI.cpp

    r45486 r48743  
    42434243                    pImage->cbSector = RT_BE2H_U32(*(uint32_t *)&data12[8]);
    42444244                    pImage->cbSize = pImage->cVolume * pImage->cbSector;
    4245                     if (pImage->cVolume == 0 || pImage->cbSector != 512 || pImage->cbSize < pImage->cVolume)
     4245                    if (pImage->cVolume == 0 || pImage->cbSize < pImage->cVolume)
    42464246                    {
    42474247                        rc = vdIfError(pImage->pIfError, VERR_VD_ISCSI_INVALID_TYPE,
     
    43264326                        pImage->cbSector = (data8[4] << 24) | (data8[5] << 16) | (data8[6] << 8) | data8[7];
    43274327                        pImage->cbSize = pImage->cVolume * pImage->cbSector;
    4328                         if (pImage->cVolume == 0 || pImage->cbSector != 512)
     4328                        if (pImage->cVolume == 0)
    43294329                        {
    43304330                            rc = vdIfError(pImage->pIfError, VERR_VD_ISCSI_INVALID_TYPE,
    4331                                            RT_SRC_POS, N_("iSCSI: fallback capacity detectio for target address %s, target name %s, SCSI LUN %lld reports media sector count=%llu sector size=%u"),
     4331                                           RT_SRC_POS, N_("iSCSI: fallback capacity detection for target address %s, target name %s, SCSI LUN %lld reports media sector count=%llu sector size=%u"),
    43324332                                           pImage->pszTargetAddress, pImage->pszTargetName,
    43334333                                           pImage->LUN, pImage->cVolume, pImage->cbSector);
     
    49074907
    49084908    return 0;
     4909}
     4910
     4911/** @copydoc VBOXHDDBACKEND::pfnGetSectorSize */
     4912static uint32_t iscsiGetSectorSize(void *pBackendData)
     4913{
     4914    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     4915    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     4916
     4917    Assert(pImage);
     4918
     4919    if (pImage)
     4920        return pImage->cbSector;
     4921    else
     4922        return 0;
    49094923}
    49104924
     
    54115425    /* pfnGetVersion */
    54125426    iscsiGetVersion,
     5427    /* pfnGetSectorSize */
     5428    iscsiGetSectorSize,
    54135429    /* pfnGetSize */
    54145430    iscsiGetSize,
  • trunk/src/VBox/Storage/Parallels.cpp

    r46613 r48743  
    758758    else
    759759        return 0;
     760}
     761
     762/** @copydoc VBOXHDDBACKEND::pfnGetSectorSize */
     763static uint32_t parallelsGetSectorSize(void *pBackendData)
     764{
     765    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     766    PPARALLELSIMAGE pImage = (PPARALLELSIMAGE)pBackendData;
     767    uint32_t cb = 0;
     768
     769    AssertPtr(pImage);
     770
     771    if (pImage && pImage->pStorage)
     772        cb = 512;
     773
     774    LogFlowFunc(("returns %llu\n", cb));
     775    return cb;
    760776}
    761777
     
    12211237    /* pfnGetVersion */
    12221238    parallelsGetVersion,
     1239    /* pfnGetSectorSize */
     1240    parallelsGetSectorSize,
    12231241    /* pfnGetSize */
    12241242    parallelsGetSize,
  • trunk/src/VBox/Storage/QCOW.cpp

    r46613 r48743  
    19371937}
    19381938
     1939/** @copydoc VBOXHDDBACKEND::pfnGetSectorSize */
     1940static uint32_t qcowGetSectorSize(void *pBackendData)
     1941{
     1942    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     1943    PQCOWIMAGE pImage = (PQCOWIMAGE)pBackendData;
     1944    uint32_t cb = 0;
     1945
     1946    AssertPtr(pImage);
     1947
     1948    if (pImage && pImage->pStorage)
     1949        cb = 512;
     1950
     1951    LogFlowFunc(("returns %u\n", cb));
     1952    return cb;
     1953}
     1954
    19391955/** @copydoc VBOXHDDBACKEND::pfnGetSize */
    19401956static uint64_t qcowGetSize(void *pBackendData)
     
    24782494    /* pfnGetVersion */
    24792495    qcowGetVersion,
     2496    /* pfnGetSectorSize */
     2497    qcowGetSectorSize,
    24802498    /* pfnGetSize */
    24812499    qcowGetSize,
  • trunk/src/VBox/Storage/QED.cpp

    r46613 r48743  
    20252025}
    20262026
     2027/** @copydoc VBOXHDDBACKEND::pfnGetSectorSize */
     2028static uint32_t qedGetSectorSize(void *pBackendData)
     2029{
     2030    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     2031    PQEDIMAGE pImage = (PQEDIMAGE)pBackendData;
     2032    uint32_t cb = 0;
     2033
     2034    AssertPtr(pImage);
     2035
     2036    if (pImage && pImage->pStorage)
     2037        cb = 512;
     2038
     2039    LogFlowFunc(("returns %u\n", cb));
     2040    return cb;
     2041}
     2042
    20272043/** @copydoc VBOXHDDBACKEND::pfnGetSize */
    20282044static uint64_t qedGetSize(void *pBackendData)
     
    26162632    /* pfnGetVersion */
    26172633    qedGetVersion,
     2634    /* pfnGetSectorSize */
     2635    qedGetSectorSize,
    26182636    /* pfnGetSize */
    26192637    qedGetSize,
  • trunk/src/VBox/Storage/RAW.cpp

    r47297 r48743  
    6565    /** Logical geometry of this image. */
    6666    VDGEOMETRY          LCHSGeometry;
    67 
     67    /** Sector size of the image. */
     68    uint32_t            cbSector;
    6869} RAWIMAGE, *PRAWIMAGE;
    6970
     
    457458    rc = rawOpenImage(pImage, uOpenFlags);
    458459    if (RT_SUCCESS(rc))
     460    {
     461        if (enmType == VDTYPE_DVD)
     462            pImage->cbSector = 2048;
     463        else
     464            pImage->cbSector = 512;
    459465        *ppBackendData = pImage;
     466    }
    460467    else
    461468        RTMemFree(pImage);
     
    663670    else
    664671        return 0;
     672}
     673
     674/** @copydoc VBOXHDDBACKEND::pfnGetSize */
     675static uint32_t rawGetSectorSize(void *pBackendData)
     676{
     677    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     678    PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
     679    uint32_t cb = 0;
     680
     681    AssertPtr(pImage);
     682
     683    if (pImage && pImage->pStorage)
     684        cb = pImage->cbSector;
     685
     686    LogFlowFunc(("returns %u\n", cb));
     687    return cb;
    665688}
    666689
     
    11381161    /* pfnGetVersion */
    11391162    rawGetVersion,
     1163    /* pfnGetSectorSize */
     1164    rawGetSectorSize,
    11401165    /* pfnGetSize */
    11411166    rawGetSize,
  • 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 *
  • trunk/src/VBox/Storage/VDI.cpp

    r46613 r48743  
    17691769    LogFlowFunc(("returns %#x\n", uVersion));
    17701770    return uVersion;
     1771}
     1772
     1773/** @copydoc VBOXHDDBACKEND::pfnGetSectorSize */
     1774static uint32_t vdiGetSectorSize(void *pBackendData)
     1775{
     1776    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     1777    PVDIIMAGEDESC pImage = (PVDIIMAGEDESC)pBackendData;
     1778    uint64_t cbSector = 0;
     1779
     1780    AssertPtr(pImage);
     1781
     1782    if (pImage && pImage->pStorage)
     1783        cbSector = 512;
     1784
     1785    LogFlowFunc(("returns %zu\n", cbSector));
     1786    return cbSector;
    17711787}
    17721788
     
    32123228    /* pfnGetVersion */
    32133229    vdiGetVersion,
     3230    /* pfnGetSectorSize */
     3231    vdiGetSectorSize,
    32143232    /* pfnGetSize */
    32153233    vdiGetSize,
  • trunk/src/VBox/Storage/VHD.cpp

    r46613 r48743  
    18511851    LogFlowFunc(("returns %u\n", ver));
    18521852    return ver;
     1853}
     1854
     1855/** @copydoc VBOXHDDBACKEND::pfnGetSectorSize */
     1856static uint32_t vhdGetSectorSize(void *pBackendData)
     1857{
     1858    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     1859    PVHDIMAGE pImage = (PVHDIMAGE)pBackendData;
     1860    uint32_t cb = 0;
     1861
     1862    AssertPtr(pImage);
     1863
     1864    if (pImage)
     1865        cb = 512;
     1866
     1867    LogFlowFunc(("returns %zu\n", cb));
     1868    return cb;
    18531869}
    18541870
     
    32073223    /* pfnGetVersion */
    32083224    vhdGetVersion,
     3225    /* pfnGetSectorSize */
     3226    vhdGetSectorSize,
    32093227    /* pfnGetSize */
    32103228    vhdGetSize,
  • trunk/src/VBox/Storage/VHDX.cpp

    r46613 r48743  
    19911991}
    19921992
     1993/** @copydoc VBOXHDDBACKEND::pfnGetSectorSize */
     1994static uint32_t vhdxGetSectorSize(void *pBackendData)
     1995{
     1996    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     1997    PVHDXIMAGE pImage = (PVHDXIMAGE)pBackendData;
     1998    uint32_t cb = 0;
     1999
     2000    AssertPtr(pImage);
     2001
     2002    if (pImage && pImage->pStorage)
     2003        cb = pImage->cbLogicalSector;
     2004
     2005    LogFlowFunc(("returns %u\n", cb));
     2006    return cb;
     2007}
     2008
    19932009/** @copydoc VBOXHDDBACKEND::pfnGetSize */
    19942010static uint64_t vhdxGetSize(void *pBackendData)
     
    24452461    /* pfnGetVersion */
    24462462    vhdxGetVersion,
     2463    /* pfnGetSectorSize */
     2464    vhdxGetSectorSize,
    24472465    /* pfnGetSize */
    24482466    vhdxGetSize,
  • trunk/src/VBox/Storage/VMDK.cpp

    r47832 r48743  
    59745974}
    59755975
     5976/** @copydoc VBOXHDDBACKEND::pfnGetSectorSize */
     5977static uint32_t vmdkGetSectorSize(void *pBackendData)
     5978{
     5979    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     5980    PVMDKIMAGE pImage = (PVMDKIMAGE)pBackendData;
     5981
     5982    AssertPtr(pImage);
     5983
     5984    if (pImage)
     5985        return 512;
     5986    else
     5987        return 0;
     5988}
     5989
    59765990/** @copydoc VBOXHDDBACKEND::pfnGetSize */
    59775991static uint64_t vmdkGetSize(void *pBackendData)
     
    65726586    /* pfnGetVersion */
    65736587    vmdkGetVersion,
     6588    /* pfnGetSectorSize */
     6589    vmdkGetSectorSize,
    65746590    /* pfnGetSize */
    65756591    vmdkGetSize,
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