VirtualBox

Changeset 48871 in vbox for trunk/src/VBox/Storage/DMG.cpp


Ignore:
Timestamp:
Oct 4, 2013 2:50:59 AM (11 years ago)
Author:
vboxsync
Message:

DMG: Fixes.

File:
1 edited

Legend:

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

    r48854 r48871  
    3939*   Structures and Typedefs                                                    *
    4040*******************************************************************************/
     41#if 0
     42/** @def VBOX_WITH_DIRECT_XAR_ACCESS
     43 * When defined, we will use RTVfs to access the XAR file instead of going
     44 * the slightly longer way thru the VFS -> VD wrapper. */
     45# define VBOX_WITH_DIRECT_XAR_ACCESS
     46#endif
    4147
    4248/** Sector size, multiply with all sector counts to get number of bytes. */
     
    787793    int rc = VINF_SUCCESS;
    788794
    789     if (   pThis->pStorage
     795    if (   pThis
     796        && (pThis->pStorage || pThis->hDmgFileInXar != NIL_RTVFSFILE)
    790797        && !(pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY))
    791798    {
    792         /* @todo handle writable files, update checksums etc. */
     799        /** @todo handle writable files, update checksums etc. */
    793800    }
    794801
     
    809816    if (pThis)
    810817    {
     818        RTVfsFileRelease(pThis->hDmgFileInXar);
     819        pThis->hDmgFileInXar = NIL_RTVFSFILE;
     820
     821        RTVfsFsStrmRelease(pThis->hXarFss);
     822        pThis->hXarFss = NIL_RTVFSFSSTREAM;
     823
    811824        if (pThis->pStorage)
    812825        {
    813             RTVfsFileRelease(pThis->hDmgFileInXar);
    814             pThis->hDmgFileInXar = NIL_RTVFSFILE;
    815             RTVfsFsStrmRelease(pThis->hXarFss);
    816             pThis->hXarFss = NIL_RTVFSFSSTREAM;
    817 
    818826            /* No point updating the file that is deleted anyway. */
    819827            if (!fDelete)
     
    14441452 * @returns VBox status code.
    14451453 * @param   fOpen           Flags for defining the open type.
    1446  * @param   pVDIfs          List of VD I/O interfaces that we can use.
     1454 * @param   pVDIfIoInt      The internal VD I/O interface to use.
    14471455 * @param   pvStorage       The storage pointer that goes with @a pVDIfsIo.
    14481456 * @param   pszFilename     The input filename, optional.
     
    14551463 *          is being in serveral places.
    14561464 */
    1457 static int dmgOpenImageWithinXar(uint32_t fOpen, PVDINTERFACE pVDIfs, void *pvStorage, const char *pszFilename,
     1465static int dmgOpenImageWithinXar(uint32_t fOpen, PVDINTERFACEIOINT pVDIfIoInt, void *pvStorage, const char *pszFilename,
    14581466                                 PRTVFSFSSTREAM phXarFss, PRTVFSFILE phDmgFileInXar)
    14591467{
     
    14621470     */
    14631471    RTVFSFILE hVfsFile;
    1464     int rc = VDIfCreateVfsFile(pVDIfs, pvStorage, fOpen, &hVfsFile);
     1472#ifdef VBOX_WITH_DIRECT_XAR_ACCESS
     1473    int rc = RTVfsFileOpenNormal(pszFilename, fOpen, &hVfsFile);
     1474#else
     1475    int rc = VDIfCreateVfsFile(NULL, pVDIfIoInt, pvStorage, fOpen, &hVfsFile);
     1476#endif
    14651477    if (RT_FAILURE(rc))
    14661478        return rc;
     
    15661578    {
    15671579        rc = dmgOpenImageWithinXar(VDOpenFlagsToFileOpenFlags(uOpenFlags, false /* fCreate */),
    1568                                    pThis->pVDIfsImage,
     1580                                   pThis->pIfIoXxx,
    15691581                                   pThis->pStorage,
    15701582                                   pThis->pszFilename,
     
    15721584        if (RT_FAILURE(rc))
    15731585            return rc;
    1574     }
     1586#ifdef VBOX_WITH_DIRECT_XAR_ACCESS
     1587        vdIfIoIntFileClose(pThis->pIfIoXxx, pThis->pStorage);
     1588        pThis->pStorage = NULL;
     1589#endif
     1590    }
     1591#if 0 /* This is for testing whether the VFS wrappers actually works. */
     1592    else
     1593    {
     1594        rc = RTVfsFileOpenNormal(pThis->pszFilename, VDOpenFlagsToFileOpenFlags(uOpenFlags, false /* fCreate */),
     1595                                 &pThis->hDmgFileInXar);
     1596        if (RT_FAILURE(rc))
     1597            return rc;
     1598        vdIfIoIntFileClose(pThis->pIfIoXxx, pThis->pStorage);
     1599        pThis->pStorage = NULL;
     1600    }
     1601#endif
    15751602
    15761603    /*
     
    17101737    {
    17111738        rc = dmgOpenImageWithinXar(RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE,
    1712                                    pVDIfsImage, pStorage, NULL /* pszFilename */,
     1739                                   pIfIo, pStorage, pszFilename,
    17131740                                   &hXarFss, &hDmgFileInXar);
    17141741        if (RT_FAILURE(rc))
     
    17371764             * Do we recognize this stuff? Does it look valid?
    17381765             */
    1739             if (   Ftr.u32Magic    == RT_H2BE_U32(DMGUDIF_MAGIC)
    1740                 && Ftr.u32Version  == RT_H2BE_U32(DMGUDIF_VER_CURRENT)
    1741                 && Ftr.cbFooter    == RT_H2BE_U32(sizeof(Ftr)))
     1766            if (   Ftr.u32Magic    == RT_H2BE_U32_C(DMGUDIF_MAGIC)
     1767                && Ftr.u32Version  == RT_H2BE_U32_C(DMGUDIF_VER_CURRENT)
     1768                && Ftr.cbFooter    == RT_H2BE_U32_C(sizeof(Ftr)))
    17421769            {
    17431770                dmgUdifFtrFile2HostEndian(&Ftr);
     
    20092036    AssertPtr(pThis);
    20102037
    2011     if (pThis && pThis->pStorage)
     2038    if (pThis && (pThis->pStorage || pThis->hDmgFileInXar != NIL_RTVFSFILE))
    20122039        cb = 2048;
    20132040
     
    20252052    AssertPtr(pThis);
    20262053
    2027     if (pThis && pThis->pStorage)
     2054    if (pThis && (pThis->pStorage || pThis->hDmgFileInXar != NIL_RTVFSFILE))
    20282055        cb = pThis->cbSize;
    20292056
     
    20412068    AssertPtr(pThis);
    20422069
    2043     if (pThis && pThis->pStorage)
     2070    if (pThis && (pThis->pStorage || pThis->hDmgFileInXar != NIL_RTVFSFILE))
    20442071    {
    20452072        uint64_t cbFile;
     
    24362463    if (pThis)
    24372464    {
    2438         vdIfErrorMessage(pThis->pIfError, "Header: Geometry PCHS=%u/%u/%u LCHS=%u/%u/%u cbSector=%llu\n",
     2465        vdIfErrorMessage(pThis->pIfError, "Header: Geometry PCHS=%u/%u/%u LCHS=%u/%u/%u cSectors=%llu\n",
    24392466                         pThis->PCHSGeometry.cCylinders, pThis->PCHSGeometry.cHeads, pThis->PCHSGeometry.cSectors,
    24402467                         pThis->LCHSGeometry.cCylinders, pThis->LCHSGeometry.cHeads, pThis->LCHSGeometry.cSectors,
    2441                          pThis->cbSize / 512);
     2468                         pThis->cbSize / DMG_SECTOR_SIZE);
    24422469    }
    24432470}
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