VirtualBox

Changeset 31919 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 24, 2010 12:53:24 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
65129
Message:

VBoxHDD/Resize: Calculate the CHS geometry if the caller doesn't provide one and image has a valid geometry set

File:
1 edited

Legend:

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

    r31803 r31919  
    49754975        fLockWrite = true;
    49764976
    4977         rc = pImage->Backend->pfnResize(pImage->pvBackendData,
    4978                                         cbSize * _1M,
    4979                                         pPCHSGeometry,
    4980                                         pLCHSGeometry,
    4981                                         0, 99,
    4982                                         pDisk->pVDIfsDisk,
    4983                                         pImage->pVDIfsImage,
    4984                                         pVDIfsOperation);
     4977        PDMMEDIAGEOMETRY PCHSGeometryOld;
     4978        PDMMEDIAGEOMETRY LCHSGeometryOld;
     4979        PCPDMMEDIAGEOMETRY pPCHSGeometryNew;
     4980        PCPDMMEDIAGEOMETRY pLCHSGeometryNew;
     4981
     4982        if (pPCHSGeometry->cCylinders == 0)
     4983        {
     4984            /* Auto-detect marker, calculate new value ourself. */
     4985            rc = pImage->Backend->pfnGetPCHSGeometry(pImage->pvBackendData, &PCHSGeometryOld);
     4986            if (RT_SUCCESS(rc) && (PCHSGeometryOld.cCylinders != 0))
     4987                PCHSGeometryOld.cCylinders = RT_MIN(cbSize / 512 / PCHSGeometryOld.cHeads / PCHSGeometryOld.cSectors, 16383);
     4988            else if (rc == VERR_VD_GEOMETRY_NOT_SET)
     4989                rc = VINF_SUCCESS;
     4990
     4991            pPCHSGeometryNew = &PCHSGeometryOld;
     4992        }
     4993        else
     4994            pPCHSGeometryNew = pPCHSGeometry;
     4995
     4996        if (pLCHSGeometry->cCylinders == 0)
     4997        {
     4998            /* Auto-detect marker, calculate new value ourself. */
     4999            rc = pImage->Backend->pfnGetLCHSGeometry(pImage->pvBackendData, &LCHSGeometryOld);
     5000            if (RT_SUCCESS(rc) && (LCHSGeometryOld.cCylinders != 0))
     5001                LCHSGeometryOld.cCylinders = cbSize / 512 / LCHSGeometryOld.cHeads / LCHSGeometryOld.cSectors;
     5002            else if (rc == VERR_VD_GEOMETRY_NOT_SET)
     5003                rc = VINF_SUCCESS;
     5004
     5005            pLCHSGeometryNew = &LCHSGeometryOld;
     5006        }
     5007        else
     5008            pLCHSGeometryNew = pLCHSGeometry;
     5009
     5010        if (RT_SUCCESS(rc))
     5011            rc = pImage->Backend->pfnResize(pImage->pvBackendData,
     5012                                            cbSize * _1M,
     5013                                            pPCHSGeometryNew,
     5014                                            pLCHSGeometryNew,
     5015                                            0, 99,
     5016                                            pDisk->pVDIfsDisk,
     5017                                            pImage->pVDIfsImage,
     5018                                            pVDIfsOperation);
    49855019    } while (0);
    49865020
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