- Timestamp:
- Oct 3, 2013 8:06:54 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 89521
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Config.kmk
r48845 r48852 3751 3751 TEMPLATE_VBOXR3STATIC = VBox Static Ring 3 EXE 3752 3752 TEMPLATE_VBOXR3STATIC_EXTENDS = VBOXR3EXE 3753 TEMPLATE_VBOXR3STATIC_DEFS = IN_RT_STATIC $(TEMPLATE_VBOXR3EXE_DEFS)3753 TEMPLATE_VBOXR3STATIC_DEFS = IN_RT_STATIC IN_RT_R3 $(TEMPLATE_VBOXR3EXE_DEFS) 3754 3754 ifeq ($(KBUILD_TARGET),win) 3755 3755 TEMPLATE_VBOXR3STATIC_CFLAGS = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBOXR3EXE_CFLAGS)) -MT$(VBOX_VCC_CRT_TYPE) … … 3781 3781 # 3782 3782 # Temporary: Renaming the template and warnings will be errors (soon). 3783 # Unlike VBOXR3STATIC, this is strict wrt warnings and includes IPRT. 3783 3784 # 3784 3785 TEMPLATE_VBoxR3Static = New name for VBOXR3STATIC 3785 3786 TEMPLATE_VBoxR3Static_EXTENDS = VBOXR3STATIC 3786 3787 TEMPLATE_VBoxR3Static_EXTENDS_BY = appending 3788 TEMPLATE_VBoxR3Static_SDKS += VBOX_OPENSSL 3789 TEMPLATE_VBoxR3Static_SDKS.win += VBOX_NTDLL 3787 3790 ifeq ($(KBUILD_TARGET),win) 3788 3791 TEMPLATE_VBoxR3Static_CFLAGS += $(VBOX_VCC_WERR) … … 3793 3796 TEMPLATE_VBoxR3Static_CXXFLAGS += $(VBOX_GCC_WERR) 3794 3797 endif 3798 TEMPLATE_VBoxR3Static_LIBS += \ 3799 $(VBOX_LIB_RUNTIME_STATIC) 3800 ifndef SDK_VBOX_OPENSSL_LIBS 3801 TEMPLATE_VBoxR3Static_LIBS += \ 3802 $(PATH_STAGE_LIB)/VBox-libcrypto$(VBOX_SUFF_LIB) \ 3803 $(PATH_STAGE_LIB)/VBox-libssl$(VBOX_SUFF_LIB) 3804 endif 3805 if1of ($(KBUILD_TARGET),os2 win) 3806 TEMPLATE_VBoxR3Static_LIBS += \ 3807 $(PATH_STAGE_LIB)/VBox-liblzf-static$(VBOX_SUFF_LIB) \ 3808 $(PATH_STAGE_LIB)/VBox-zlib-static$(VBOX_SUFF_LIB) \ 3809 $(PATH_STAGE_LIB)/VBox-libxml2-static$(VBOX_SUFF_LIB) 3810 else 3811 TEMPLATE_VBoxR3Static_LIBS += \ 3812 $(PATH_STAGE_LIB)/VBox-liblzf$(VBOX_SUFF_LIB) \ 3813 $(SDK_VBOX_ZLIB_LIBS) 3814 ifeq ($(KBUILD_TARGET),linux) 3815 TEMPLATE_VBoxR3Static_LIBS += crypt 3816 else if1of ($(KBUILD_TARGET),darwin freebsd) 3817 TEMPLATE_VBoxR3Static_LIBS += iconv 3818 else ifeq ($(KBUILD_TARGET),solaris) 3819 TEMPLATE_VBoxR3Static_LIBS += kstat 3820 endif 3821 endif 3822 3795 3823 3796 3824 # -
trunk/include/VBox/err.h
r48267 r48852 1582 1582 /** Block read was marked as free in the image and returned as a zero block. */ 1583 1583 #define VINF_VD_NEW_ZEROED_BLOCK 3283 1584 /** Unable to parse the XML in DMG file. */ 1585 #define VERR_VD_DMG_XML_PARSE_ERROR (-3284) 1586 /** Unable to locate a usable DMG file within the XAR archive. */ 1587 #define VERR_VD_DMG_NOT_FOUND_INSIDE_XAR (-3285) 1584 1588 /** @} */ 1585 1589 -
trunk/src/VBox/Runtime/Makefile.kmk
r48845 r48852 232 232 # 233 233 RuntimeR3_TEMPLATE = VBoxR3Static 234 RuntimeR3_SDKS = VBOX_OPENSSL 234 RuntimeR3_SDKS = VBOX_OPENSSL VBOX_LIBXML2 235 235 RuntimeR3_SDKS.win = $(VBOX_WINPSDK) $(VBOX_WINDDK) 236 236 RuntimeR3_DEFS = IN_RT_R3 IN_SUP_R3 LDR_WITH_NATIVE LDR_WITH_ELF32 LDR_WITH_PE RT_WITH_VBOX RT_NO_GIP … … 515 515 r3/tcp.cpp \ 516 516 r3/udp.cpp \ 517 r3/generic/semspinmutex-r3-generic.cpp 517 r3/generic/semspinmutex-r3-generic.cpp \ 518 r3/xml.cpp \ 519 common/zip/xarvfs.cpp 520 518 521 519 522 #if1of ($(KBUILD_TARGET_ARCH),amd64 x86) … … 1069 1072 RuntimeBldProg_BLD_TRG_ARCH := $(KBUILD_HOST_ARCH) 1070 1073 RuntimeBldProg_BLD_TRG_CPU := $(KBUILD_HOST_CPU) 1074 RuntimeBldProg_SOURCES = $(filter-out \ 1075 r3/xml.cpp \ 1076 common/zip/xarvfs.cpp \ 1077 , $(RuntimeR3_SOURCES)) 1078 1071 1079 1072 1080 … … 1093 1101 common/checksum/sha% \ 1094 1102 generic/RTLogWriteUser-generic.cpp \ 1103 r3/xml.cpp \ 1104 common/zip/xarvfs.cpp \ 1095 1105 , $(RuntimeR3_SOURCES)) 1096 1106 RuntimeGuestR3_SOURCES += \ … … 1298 1308 VBoxRT_SOURCES := \ 1299 1309 VBox/VBoxRTDeps.cpp \ 1300 r3/xml.cpp \1301 1310 $(filter-out common/checksum/crc32.cpp, $(RuntimeR3_SOURCES)) \ 1302 1311 common/checksum/crc32-zlib.cpp \ 1303 common/misc/aiomgr.cpp \ 1304 common/zip/xarvfs.cpp 1312 common/misc/aiomgr.cpp 1305 1313 ifdef VBOX_WITH_LIBCURL 1306 1314 VBoxRT_SOURCES += common/misc/s3.cpp -
trunk/src/VBox/Storage/DMG.cpp
r48840 r48852 21 21 #define LOG_GROUP LOG_GROUP_VD_DMG 22 22 #include <VBox/vd-plugin.h> 23 #include <VBox/vd-ifs.h> 23 24 #include <VBox/log.h> 24 25 #include <VBox/err.h> 26 27 #include <iprt/asm.h> 28 #include <iprt/alloca.h> 25 29 #include <iprt/assert.h> 26 #include <iprt/asm.h> 30 #include <iprt/base64.h> 31 #include <iprt/ctype.h> 27 32 #include <iprt/mem.h> 28 #include <iprt/ctype.h>29 33 #include <iprt/string.h> 30 #include <iprt/base64.h>31 34 #include <iprt/zip.h> 35 #include <iprt/formats/xar.h> 36 32 37 33 38 /******************************************************************************* … … 311 316 /** Error interface. */ 312 317 PVDINTERFACEERROR pIfError; 313 /** I/O interface. */ 314 PVDINTERFACEIOINT pIfIo; 318 /** I/O interface - careful accessing this because of hDmgFileInXar. */ 319 PVDINTERFACEIOINT pIfIoXxx; 320 321 322 /** The VFS file handle for a DMG within a XAR archive. */ 323 RTVFSFILE hDmgFileInXar; 324 /** XAR file system stream handle. 325 * Sitting on this isn't really necessary, but insurance against the XAR code 326 * changes making back references from child objects to the stream itself. */ 327 RTVFSFSSTREAM hXarFss; 315 328 316 329 /** Flags the image was opened with. */ … … 393 406 } while (0) 394 407 395 /** VBoxDMG: Unable to parse the XML. */396 #define VERR_VD_DMG_XML_PARSE_ERROR (-3280)397 398 408 399 409 /******************************************************************************* … … 421 431 static bool dmgUdifCkSumIsValid(PCDMGUDIFCKSUM pCkSum, const char *pszPrefix); 422 432 433 434 435 /** 436 * vdIfIoIntFileReadSync / RTVfsFileReadAt wrapper. 437 */ 438 static int dmgWrapFileReadSync(PDMGIMAGE pThis, RTFOFF off, void *pvBuf, size_t cbToRead) 439 { 440 int rc; 441 if (pThis->hDmgFileInXar == NIL_RTVFSFILE) 442 rc = vdIfIoIntFileReadSync(pThis->pIfIoXxx, pThis->pStorage, off, pvBuf, cbToRead); 443 else 444 rc = RTVfsFileReadAt(pThis->hDmgFileInXar, off, pvBuf, cbToRead, NULL); 445 return rc; 446 } 447 448 /** 449 * vdIfIoIntFileReadUser / RTVfsFileReadAt wrapper. 450 */ 451 static int dmgWrapFileReadUser(PDMGIMAGE pThis, RTFOFF off, PVDIOCTX pIoCtx, size_t cbToRead) 452 { 453 int rc; 454 if (pThis->hDmgFileInXar == NIL_RTVFSFILE) 455 rc = vdIfIoIntFileReadUser(pThis->pIfIoXxx, pThis->pStorage, off, pIoCtx, cbToRead); 456 else 457 { 458 /* 459 * The I/O context stuff seems to complicated and undocument that I'm 460 * not going to bother trying implement this efficiently right now. 461 */ 462 void *pvFree = NULL; 463 void *pvBuf; 464 if (cbToRead < _32K) 465 pvBuf = alloca(cbToRead); 466 else 467 pvFree = pvBuf = RTMemTmpAlloc(cbToRead); 468 if (!pvBuf) 469 { 470 rc = RTVfsFileReadAt(pThis->hDmgFileInXar, off, pvBuf, cbToRead, NULL); 471 if (RT_SUCCESS(rc)) 472 vdIfIoIntIoCtxCopyTo(pThis->pIfIoXxx, pIoCtx, pvBuf, cbToRead); 473 if (pvFree) 474 RTMemTmpFree(pvFree); 475 } 476 else 477 rc = VERR_NO_TMP_MEMORY; 478 } 479 return rc; 480 } 481 482 /** 483 * vdIfIoIntFileGetSize / RTVfsFileGetSize wrapper. 484 */ 485 static int dmgWrapFileGetSize(PDMGIMAGE pThis, uint64_t *pcbFile) 486 { 487 int rc; 488 if (pThis->hDmgFileInXar == NIL_RTVFSFILE) 489 rc = vdIfIoIntFileGetSize(pThis->pIfIoXxx, pThis->pStorage, pcbFile); 490 else 491 rc = RTVfsFileGetSize(pThis->hDmgFileInXar, pcbFile); 492 return rc; 493 } 494 495 496 423 497 static DECLCALLBACK(int) dmgFileInflateHelper(void *pvUser, void *pvBuf, size_t cbBuf, size_t *pcbBuf) 424 498 { … … 435 509 } 436 510 cbBuf = RT_MIN(cbBuf, pInflateState->cbSize); 437 int rc = vdIfIoIntFileReadSync(pInflateState->pImage->pIfIo, 438 pInflateState->pImage->pStorage, 439 pInflateState->uFileOffset, 440 pvBuf, cbBuf); 511 int rc = dmgWrapFileReadSync(pInflateState->pImage, pInflateState->uFileOffset, pvBuf, cbBuf); 441 512 if (RT_FAILURE(rc)) 442 513 return rc; … … 737 808 if (pThis->pStorage) 738 809 { 810 RTVfsFileRelease(pThis->hDmgFileInXar); 811 pThis->hDmgFileInXar = NIL_RTVFSFILE; 812 RTVfsFsStrmRelease(pThis->hXarFss); 813 pThis->hXarFss = NIL_RTVFSFSSTREAM; 814 739 815 /* No point updating the file that is deleted anyway. */ 740 816 if (!fDelete) 741 817 dmgFlushImage(pThis); 742 818 743 rc = vdIfIoIntFileClose(pThis->pIfIo , pThis->pStorage);819 rc = vdIfIoIntFileClose(pThis->pIfIoXxx, pThis->pStorage); 744 820 pThis->pStorage = NULL; 745 821 } … … 766 842 767 843 if (fDelete && pThis->pszFilename) 768 vdIfIoIntFileDelete(pThis->pIfIo , pThis->pszFilename);844 vdIfIoIntFileDelete(pThis->pIfIoXxx, pThis->pszFilename); 769 845 770 846 if (pThis->pvDecompExtent) … … 774 850 pThis->cbDecompExtent = 0; 775 851 } 776 777 852 } 778 853 … … 1357 1432 } 1358 1433 1434 1435 /** 1436 * Worker for dmgOpenImage that tries to open a DMG inside a XAR file. 1437 * 1438 * We'll select the first .dmg inside the archive that we can get a file 1439 * interface to. 1440 * 1441 * @returns VBox status code. 1442 * @param fOpen Flags for defining the open type. 1443 * @param pVDIfsIo The storage I/O interface to use. 1444 * @param pvStorage The storage pointer that goes with @a pVDIfsIo. 1445 * @param pszFilename The input filename, optional. 1446 * @param phXarFss Where to return the XAR file system stream handle on 1447 * success 1448 * @param phDmgFileInXar Where to return the VFS handle to the DMG file 1449 * within the XAR image on success. 1450 * 1451 * @remarks Not using the PDMGIMAGE structure directly here because the function 1452 * is being in serveral places. 1453 */ 1454 static int dmgOpenImageWithinXar(uint32_t fOpen, PVDINTERFACEIO pVDIfsIo, void *pvStorage, const char *pszFilename, 1455 PRTVFSFSSTREAM phXarFss, PRTVFSFILE phDmgFileInXar) 1456 { 1457 /* 1458 * Open the XAR file stream. 1459 */ 1460 if (!pVDIfsIo) 1461 return VERR_INVALID_PARAMETER; 1462 1463 RTVFSFILE hVfsFile; 1464 int rc = VDIfCreateVfsFile(pVDIfsIo, pvStorage, fOpen, &hVfsFile); 1465 if (RT_FAILURE(rc)) 1466 return rc; 1467 1468 RTVFSIOSTREAM hVfsIos = RTVfsFileToIoStream(hVfsFile); 1469 RTVfsFileRelease(hVfsFile); 1470 1471 RTVFSFSSTREAM hXarFss; 1472 rc = RTZipXarFsStreamFromIoStream(hVfsIos, 0 /*fFlags*/, &hXarFss); 1473 RTVfsIoStrmRelease(hVfsIos); 1474 if (RT_FAILURE(rc)) 1475 return rc; 1476 1477 /* 1478 * Look for a DMG in the stream that we can use. 1479 */ 1480 for (;;) 1481 { 1482 char *pszName; 1483 RTVFSOBJTYPE enmType; 1484 RTVFSOBJ hVfsObj; 1485 rc = RTVfsFsStrmNext(hXarFss, &pszName, &enmType, &hVfsObj); 1486 if (RT_FAILURE(rc)) 1487 break; 1488 1489 /* It must be a file object so it can be seeked, this also implies that 1490 it's uncompressed. Then it must have the .dmg suffix. */ 1491 if (enmType == RTVFSOBJTYPE_FILE) 1492 { 1493 size_t cchName = strlen(pszName); 1494 const char *pszSuff = pszName + cchName - 4; 1495 if ( cchName >= 4 1496 && pszSuff[0] == '.' 1497 && (pszSuff[1] == 'd' || pszSuff[1] == 'D') 1498 && (pszSuff[2] == 'm' || pszSuff[2] == 'M') 1499 && (pszSuff[3] == 'g' || pszSuff[3] == 'G')) 1500 { 1501 RTVFSFILE hDmgFileInXar = RTVfsObjToFile(hVfsObj); 1502 AssertBreakStmt(hDmgFileInXar != NIL_RTVFSFILE, rc = VERR_INTERNAL_ERROR_3); 1503 1504 if (pszFilename) 1505 DMG_PRINTF(("DMG: Using '%s' within XAR file '%s'...\n", pszName, pszFilename)); 1506 *phXarFss = hXarFss; 1507 *phDmgFileInXar = hDmgFileInXar; 1508 1509 RTStrFree(pszName); 1510 RTVfsObjRelease(hVfsObj); 1511 1512 return VINF_SUCCESS; 1513 } 1514 } 1515 1516 /* Release the current return values. */ 1517 RTStrFree(pszName); 1518 RTVfsObjRelease(hVfsObj); 1519 } 1520 1521 /* Not found or some kind of error. */ 1522 RTVfsFsStrmRelease(hXarFss); 1523 if (rc == VERR_EOF) 1524 rc = VERR_VD_DMG_NOT_FOUND_INSIDE_XAR; 1525 AssertStmt(RT_FAILURE_NP(rc), rc = VERR_INTERNAL_ERROR_4); 1526 return rc; 1527 } 1528 1529 1359 1530 /** 1360 1531 * Worker for dmgOpen that reads in and validates all the necessary … … 1370 1541 1371 1542 pThis->pIfError = VDIfErrorGet(pThis->pVDIfsDisk); 1372 pThis->pIfIo = VDIfIoIntGet(pThis->pVDIfsImage); 1373 AssertPtrReturn(pThis->pIfIo, VERR_INVALID_PARAMETER); 1374 1375 int rc = vdIfIoIntFileOpen(pThis->pIfIo, pThis->pszFilename, 1376 VDOpenFlagsToFileOpenFlags(uOpenFlags, 1377 false /* fCreate */), 1543 pThis->pIfIoXxx = VDIfIoIntGet(pThis->pVDIfsImage); 1544 pThis->hDmgFileInXar = NIL_RTVFSFILE; 1545 pThis->hXarFss = NIL_RTVFSFSSTREAM; 1546 AssertPtrReturn(pThis->pIfIoXxx, VERR_INVALID_PARAMETER); 1547 1548 int rc = vdIfIoIntFileOpen(pThis->pIfIoXxx, pThis->pszFilename, 1549 VDOpenFlagsToFileOpenFlags(uOpenFlags, false /* fCreate */), 1378 1550 &pThis->pStorage); 1379 1551 if (RT_FAILURE(rc)) … … 1385 1557 1386 1558 /* 1559 * Check for XAR archive. 1560 */ 1561 uint32_t u32XarMagic; 1562 rc = dmgWrapFileReadSync(pThis, 0, &u32XarMagic, sizeof(u32XarMagic)); 1563 if (RT_FAILURE(rc)) 1564 return rc; 1565 if (u32XarMagic == XAR_HEADER_MAGIC) 1566 { 1567 rc = dmgOpenImageWithinXar(VDOpenFlagsToFileOpenFlags(uOpenFlags, false /* fCreate */), 1568 VDIfIoGet(pThis->pVDIfsImage), 1569 pThis->pStorage, 1570 pThis->pszFilename, 1571 &pThis->hXarFss, &pThis->hDmgFileInXar); 1572 if (RT_FAILURE(rc)) 1573 return rc; 1574 } 1575 1576 /* 1387 1577 * Read the footer. 1388 1578 */ 1389 rc = vdIfIoIntFileGetSize(pThis->pIfIo, pThis->pStorage, &pThis->cbFile);1579 rc = dmgWrapFileGetSize(pThis, &pThis->cbFile); 1390 1580 if (RT_FAILURE(rc)) 1391 1581 return rc; 1392 1582 if (pThis->cbFile < 1024) 1393 1583 return VERR_VD_DMG_INVALID_HEADER; 1394 rc = vdIfIoIntFileReadSync(pThis->pIfIo, pThis->pStorage, 1395 pThis->cbFile - sizeof(pThis->Ftr), 1396 &pThis->Ftr, sizeof(pThis->Ftr)); 1584 rc = dmgWrapFileReadSync(pThis, pThis->cbFile - sizeof(pThis->Ftr), &pThis->Ftr, sizeof(pThis->Ftr)); 1397 1585 if (RT_FAILURE(rc)) 1398 1586 return rc; … … 1424 1612 if (!pszXml) 1425 1613 return VERR_NO_MEMORY; 1426 rc = vdIfIoIntFileReadSync(pThis->pIfIo, pThis->pStorage, pThis->Ftr.offXml, 1427 pszXml, cchXml); 1614 rc = dmgWrapFileReadSync(pThis, pThis->Ftr.offXml, pszXml, cchXml); 1428 1615 if (RT_SUCCESS(rc)) 1429 1616 { … … 1495 1682 LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p penmType=%#p\n", 1496 1683 pszFilename, pVDIfsDisk, pVDIfsImage, penmType)); 1497 int rc;1498 PVDIOSTORAGE pStorage = NULL;1499 uint64_t cbFile, offFtr = 0;1500 DMGUDIF Ftr;1501 1684 1502 1685 PVDINTERFACEIOINT pIfIo = VDIfIoIntGet(pVDIfsImage); … … 1504 1687 1505 1688 /* 1506 * Open the file and read the footer.1689 * Open the file and check for XAR. 1507 1690 */ 1508 rc = vdIfIoIntFileOpen(pIfIo, pszFilename, 1509 VDOpenFlagsToFileOpenFlags(VD_OPEN_FLAGS_READONLY, 1510 false /* fCreate */), 1511 &pStorage); 1691 PVDIOSTORAGE pStorage = NULL; 1692 int rc = vdIfIoIntFileOpen(pIfIo, pszFilename, 1693 VDOpenFlagsToFileOpenFlags(VD_OPEN_FLAGS_READONLY, false /* fCreate */), 1694 &pStorage); 1695 if (RT_FAILURE(rc)) 1696 { 1697 LogFlowFunc(("returns %Rrc (error opening file)\n", rc)); 1698 return rc; 1699 } 1700 1701 /* 1702 * Check for XAR file. 1703 */ 1704 RTVFSFSSTREAM hXarFss = NIL_RTVFSFSSTREAM; 1705 RTVFSFILE hDmgFileInXar = NIL_RTVFSFILE; 1706 uint32_t u32XarMagic; 1707 rc = vdIfIoIntFileReadSync(pIfIo, pStorage, 0, &u32XarMagic, sizeof(u32XarMagic)); 1708 if ( RT_SUCCESS(rc) 1709 && u32XarMagic == XAR_HEADER_MAGIC) 1710 { 1711 rc = dmgOpenImageWithinXar(RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE, 1712 VDIfIoGet(pVDIfsImage), pStorage, NULL /* pszFilename */, 1713 &hXarFss, &hDmgFileInXar); 1714 if (RT_FAILURE(rc)) 1715 return rc; 1716 } 1717 1718 /* 1719 * Read the DMG footer. 1720 */ 1721 uint64_t cbFile; 1722 if (hDmgFileInXar == NIL_RTVFSFILE) 1723 rc = vdIfIoIntFileGetSize(pIfIo, pStorage, &cbFile); 1724 else 1725 rc = RTVfsFileGetSize(hDmgFileInXar, &cbFile); 1512 1726 if (RT_SUCCESS(rc)) 1513 rc = vdIfIoIntFileGetSize(pIfIo, pStorage, &cbFile); 1514 if (RT_SUCCESS(rc)) 1515 { 1516 offFtr = cbFile - sizeof(Ftr); 1517 rc = vdIfIoIntFileReadSync(pIfIo, pStorage, offFtr, &Ftr, sizeof(Ftr)); 1727 { 1728 DMGUDIF Ftr; 1729 uint64_t offFtr = cbFile - sizeof(Ftr); 1730 if (hDmgFileInXar == NIL_RTVFSFILE) 1731 rc = vdIfIoIntFileReadSync(pIfIo, pStorage, offFtr, &Ftr, sizeof(Ftr)); 1732 else 1733 rc = RTVfsFileReadAt(hDmgFileInXar, offFtr, &Ftr, sizeof(Ftr), NULL); 1734 if (RT_SUCCESS(rc)) 1735 { 1736 /* 1737 * Do we recognize this stuff? Does it look valid? 1738 */ 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))) 1742 { 1743 dmgUdifFtrFile2HostEndian(&Ftr); 1744 if (dmgUdifFtrIsValid(&Ftr, offFtr)) 1745 { 1746 rc = VINF_SUCCESS; 1747 *penmType = VDTYPE_DVD; 1748 } 1749 else 1750 { 1751 DMG_PRINTF(("Bad DMG: '%s' offFtr=%RTfoff\n", pszFilename, offFtr)); 1752 rc = VERR_VD_DMG_INVALID_HEADER; 1753 } 1754 } 1755 else 1756 rc = VERR_VD_DMG_INVALID_HEADER; 1757 } 1518 1758 } 1519 1759 else 1520 1760 rc = VERR_VD_DMG_INVALID_HEADER; 1521 1761 1522 if (RT_SUCCESS(rc)) 1523 { 1524 /* 1525 * Do we recognize this stuff? Does it look valid? 1526 */ 1527 if ( Ftr.u32Magic == RT_H2BE_U32(DMGUDIF_MAGIC) 1528 && Ftr.u32Version == RT_H2BE_U32(DMGUDIF_VER_CURRENT) 1529 && Ftr.cbFooter == RT_H2BE_U32(sizeof(Ftr))) 1530 { 1531 dmgUdifFtrFile2HostEndian(&Ftr); 1532 if (dmgUdifFtrIsValid(&Ftr, offFtr)) 1533 { 1534 rc = VINF_SUCCESS; 1535 *penmType = VDTYPE_DVD; 1536 } 1537 else 1538 { 1539 DMG_PRINTF(("Bad DMG: '%s' offFtr=%RTfoff\n", pszFilename, offFtr)); 1540 rc = VERR_VD_DMG_INVALID_HEADER; 1541 } 1542 } 1543 else 1544 rc = VERR_VD_DMG_INVALID_HEADER; 1545 } 1546 1547 if (pStorage) 1548 vdIfIoIntFileClose(pIfIo, pStorage); 1762 /* Clean up. */ 1763 RTVfsFileRelease(hDmgFileInXar); 1764 RTVfsFsStrmRelease(hXarFss); 1765 vdIfIoIntFileClose(pIfIo, pStorage); 1549 1766 1550 1767 LogFlowFunc(("returns %Rrc\n", rc)); … … 1558 1775 { 1559 1776 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); 1560 int rc = VINF_SUCCESS;1561 PDMGIMAGE pThis;1562 1777 1563 1778 /* Check open flags. All valid flags are (in principle) supported. */ 1564 if (uOpenFlags & ~VD_OPEN_FLAGS_MASK) 1565 { 1566 rc = VERR_INVALID_PARAMETER; 1567 goto out; 1568 } 1779 AssertReturn(!(uOpenFlags & ~VD_OPEN_FLAGS_MASK), VERR_INVALID_PARAMETER); 1569 1780 1570 1781 /* Check remaining arguments. */ 1571 if ( !VALID_PTR(pszFilename) 1572 || !*pszFilename) 1573 { 1574 rc = VERR_INVALID_PARAMETER; 1575 goto out; 1576 } 1782 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); 1783 AssertReturn(*pszFilename, VERR_INVALID_PARAMETER); 1577 1784 1578 1785 /* … … 1586 1793 || (uOpenFlags & VD_OPEN_FLAGS_ASYNC_IO)) 1587 1794 { 1588 rc = VERR_NOT_SUPPORTED;1589 goto out;1795 LogFlowFunc(("Unsupported flag(s): %#x\n", uOpenFlags)); 1796 return VERR_INVALID_PARAMETER; 1590 1797 } 1591 1798 … … 1594 1801 * then hand it over to a worker function that does all the rest. 1595 1802 */ 1596 pThis = (PDMGIMAGE)RTMemAllocZ(sizeof(*pThis)); 1597 if (!pThis) 1598 { 1599 rc = VERR_NO_MEMORY; 1600 goto out; 1601 } 1602 1603 pThis->pszFilename = pszFilename; 1604 pThis->pStorage = NULL; 1605 pThis->pVDIfsDisk = pVDIfsDisk; 1606 pThis->pVDIfsImage = pVDIfsImage; 1607 1608 rc = dmgOpenImage(pThis, uOpenFlags); 1609 if (RT_SUCCESS(rc)) 1610 *ppBackendData = pThis; 1611 else 1612 RTMemFree(pThis); 1613 1614 out: 1803 int rc = VERR_NO_MEMORY; 1804 PDMGIMAGE pThis = (PDMGIMAGE)RTMemAllocZ(sizeof(*pThis)); 1805 if (pThis) 1806 { 1807 pThis->pszFilename = pszFilename; 1808 pThis->pStorage = NULL; 1809 pThis->pVDIfsDisk = pVDIfsDisk; 1810 pThis->pVDIfsImage = pVDIfsImage; 1811 1812 rc = dmgOpenImage(pThis, uOpenFlags); 1813 if (RT_SUCCESS(rc)) 1814 *ppBackendData = pThis; 1815 else 1816 RTMemFree(pThis); 1817 } 1818 1615 1819 LogFlowFunc(("returns %Rrc (pBackendData=%#p)\n", rc, *ppBackendData)); 1616 1820 return rc; … … 1690 1894 case DMGEXTENTTYPE_RAW: 1691 1895 { 1692 rc = vdIfIoIntFileReadUser(pThis->pIfIo, pThis->pStorage, 1693 pExtent->offFileStart + DMG_BLOCK2BYTE(uExtentRel), 1694 pIoCtx, cbToRead); 1896 rc = dmgWrapFileReadUser(pThis, pExtent->offFileStart + DMG_BLOCK2BYTE(uExtentRel), pIoCtx, cbToRead); 1695 1897 break; 1696 1898 } 1697 1899 case DMGEXTENTTYPE_ZERO: 1698 1900 { 1699 vdIfIoIntIoCtxSet(pThis->pIfIo , pIoCtx, 0, cbToRead);1901 vdIfIoIntIoCtxSet(pThis->pIfIoXxx, pIoCtx, 0, cbToRead); 1700 1902 break; 1701 1903 } … … 1727 1929 1728 1930 if (RT_SUCCESS(rc)) 1729 vdIfIoIntIoCtxCopyTo(pThis->pIfIo , pIoCtx,1931 vdIfIoIntIoCtxCopyTo(pThis->pIfIoXxx, pIoCtx, 1730 1932 (uint8_t *)pThis->pvDecompExtent + DMG_BLOCK2BYTE(uExtentRel), 1731 1933 cbToRead); … … 1839 2041 AssertPtr(pThis); 1840 2042 1841 if (pThis )2043 if (pThis && pThis->pStorage) 1842 2044 { 1843 2045 uint64_t cbFile; 1844 if (pThis->pStorage) 1845 { 1846 int rc = vdIfIoIntFileGetSize(pThis->pIfIo, pThis->pStorage, &cbFile); 1847 if (RT_SUCCESS(rc)) 1848 cb = cbFile; 1849 } 2046 int rc = dmgWrapFileGetSize(pThis, &cbFile); 2047 if (RT_SUCCESS(rc)) 2048 cb = cbFile; 1850 2049 } 1851 2050 -
trunk/src/VBox/Storage/testcase/Makefile.kmk
r48846 r48852 84 84 # vbox-img - static because it migth be used as at standalone tool. 85 85 # 86 vbox-img_TEMPLATE = VB OXR3STATIC86 vbox-img_TEMPLATE = VBoxR3Static 87 87 vbox-img_DEFS += IN_VBOXDDU IN_VBOXDDU_STATIC VBOX_HDD_NO_DYNAMIC_BACKENDS 88 88 vbox-img_SOURCES = \ … … 100 100 ../QCOW.cpp \ 101 101 ../VHDX.cpp \ 102 ../VCICache.cpp 102 ../VCICache.cpp \ 103 ../VDIfVfs.cpp 103 104 vbox-img_LIBS = \ 104 105 $(VBOX_LIB_RUNTIME_STATIC)
Note:
See TracChangeset
for help on using the changeset viewer.