Changeset 11266 in vbox for trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp
- Timestamp:
- Aug 8, 2008 4:14:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp
r11176 r11266 368 368 /** Async I/O interface callbacks. */ 369 369 PVDINTERFACEASYNCIO pInterfaceAsyncIOCallbacks; 370 /** 370 /** 371 371 * Pointer to an array of task handles for task submission. 372 372 * This is an optimization because the task number to submit is not known … … 496 496 pVmdkFile->fAsyncIO = false; 497 497 } 498 if ( VBOX_SUCCESS(rc))498 if (RT_SUCCESS(rc)) 499 499 { 500 500 pVmdkFile->uReferences = 1; … … 554 554 rc = RTFileClose(pVmdkFile->File); 555 555 } 556 if ( VBOX_SUCCESS(rc) && pVmdkFile->fDelete)556 if (RT_SUCCESS(rc) && pVmdkFile->fDelete) 557 557 rc = RTFileDelete(pVmdkFile->pszFilename); 558 558 RTStrFree((char *)(void *)pVmdkFile->pszFilename); … … 567 567 * Internal: read from a file distinguishing between async and normal operation 568 568 */ 569 DECLINLINE(int) vmdkFileReadAt(PVMDKFILE pVmdkFile, 570 uint64_t uOffset, void *pvBuf, 569 DECLINLINE(int) vmdkFileReadAt(PVMDKFILE pVmdkFile, 570 uint64_t uOffset, void *pvBuf, 571 571 size_t cbToRead, size_t *pcbRead) 572 572 { … … 584 584 * Internal: write to a file distinguishing between async and normal operation 585 585 */ 586 DECLINLINE(int) vmdkFileWriteAt(PVMDKFILE pVmdkFile, 587 uint64_t uOffset, const void *pvBuf, 586 DECLINLINE(int) vmdkFileWriteAt(PVMDKFILE pVmdkFile, 587 uint64_t uOffset, const void *pvBuf, 588 588 size_t cbToWrite, size_t *pcbWritten) 589 589 { … … 663 663 rc2 = RTFileClose(pVmdkFile->File); 664 664 665 if ( VBOX_SUCCESS(rc) && pVmdkFile->fDelete)665 if (RT_SUCCESS(rc) && pVmdkFile->fDelete) 666 666 rc2 = RTFileDelete(pVmdkFile->pszFilename); 667 667 RTStrFree((char *)(void *)pVmdkFile->pszFilename); 668 668 RTMemFree(pVmdkFile); 669 if ( VBOX_SUCCESS(rc))669 if (RT_SUCCESS(rc)) 670 670 rc = rc2; 671 671 } … … 781 781 pGD, cbGD, NULL); 782 782 AssertRC(rc); 783 if ( VBOX_FAILURE(rc))783 if (RT_FAILURE(rc)) 784 784 { 785 785 rc = vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: could not read grain directory in '%s'"), pExtent->pszFullname); … … 801 801 pRGD, cbGD, NULL); 802 802 AssertRC(rc); 803 if ( VBOX_FAILURE(rc))803 if (RT_FAILURE(rc)) 804 804 { 805 805 rc = vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: could not read redundant grain directory in '%s'"), pExtent->pszFullname); … … 845 845 rc = vmdkFileReadAt(pExtent->pFile, VMDK_SECTOR2BYTE(*pGDTmp), 846 846 pTmpGT1, cbGT, NULL); 847 if ( VBOX_FAILURE(rc))847 if (RT_FAILURE(rc)) 848 848 { 849 849 rc = vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: error reading grain table in '%s'"), pExtent->pszFullname); … … 854 854 rc = vmdkFileReadAt(pExtent->pFile, VMDK_SECTOR2BYTE(*pRGDTmp), 855 855 pTmpGT2, cbGT, NULL); 856 if ( VBOX_FAILURE(rc))856 if (RT_FAILURE(rc)) 857 857 { 858 858 rc = vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: error reading backup grain table in '%s'"), pExtent->pszFullname); … … 874 874 875 875 out: 876 if ( VBOX_FAILURE(rc))876 if (RT_FAILURE(rc)) 877 877 vmdkFreeGrainDirectory(pExtent); 878 878 return rc; … … 912 912 cbOverhead = RT_ALIGN_64(VMDK_SECTOR2BYTE(uStartSector) + 2 * (cbGDRounded + cbGTRounded), VMDK_SECTOR2BYTE(pExtent->cSectorsPerGrain)); 913 913 rc = vmdkFileSetSize(pExtent->pFile, cbOverhead); 914 if ( VBOX_FAILURE(rc))914 if (RT_FAILURE(rc)) 915 915 goto out; 916 916 pExtent->uSectorRGD = uStartSector; … … 931 931 VMDK_SECTOR2BYTE(pExtent->uSectorRGD) + i * sizeof(uGTSectorLE), 932 932 &uGTSectorLE, sizeof(uGTSectorLE), NULL); 933 if ( VBOX_FAILURE(rc))933 if (RT_FAILURE(rc)) 934 934 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: cannot write new redundant grain directory entry in '%s'"), pExtent->pszFullname); 935 935 uOffsetSectors += VMDK_BYTE2SECTOR(pExtent->cGTEntries * sizeof(uint32_t)); … … 945 945 VMDK_SECTOR2BYTE(pExtent->uSectorGD) + i * sizeof(uGTSectorLE), 946 946 &uGTSectorLE, sizeof(uGTSectorLE), NULL); 947 if ( VBOX_FAILURE(rc))947 if (RT_FAILURE(rc)) 948 948 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: cannot write new grain directory entry in '%s'"), pExtent->pszFullname); 949 949 uOffsetSectors += VMDK_BYTE2SECTOR(pExtent->cGTEntries * sizeof(uint32_t)); … … 953 953 954 954 out: 955 if ( VBOX_FAILURE(rc))955 if (RT_FAILURE(rc)) 956 956 vmdkFreeGrainDirectory(pExtent); 957 957 return rc; … … 1176 1176 return VERR_VDI_VALUE_NOT_FOUND; 1177 1177 int rc = vmdkStringUnquote(pImage, pszValue, &pszValueUnquoted, NULL); 1178 if ( VBOX_FAILURE(rc))1178 if (RT_FAILURE(rc)) 1179 1179 return rc; 1180 1180 *ppszValue = pszValueUnquoted; … … 1188 1188 1189 1189 int rc = RTStrAPrintf(&pszValueQuoted, "\"%s\"", pszValue); 1190 if ( VBOX_FAILURE(rc))1190 if (RT_FAILURE(rc)) 1191 1191 return rc; 1192 1192 rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDesc, pszKey, … … 1305 1305 return VERR_VDI_VALUE_NOT_FOUND; 1306 1306 int rc = vmdkStringUnquote(pImage, pszValue, &pszValueUnquoted, NULL); 1307 if ( VBOX_FAILURE(rc))1307 if (RT_FAILURE(rc)) 1308 1308 return rc; 1309 1309 *ppszValue = pszValueUnquoted; … … 1321 1321 return VERR_VDI_VALUE_NOT_FOUND; 1322 1322 int rc = vmdkStringUnquote(pImage, pszValue, &pszValueUnquoted, NULL); 1323 if ( VBOX_FAILURE(rc))1323 if (RT_FAILURE(rc)) 1324 1324 return rc; 1325 1325 rc = RTStrToUInt32Ex(pszValueUnquoted, NULL, 10, puValue); … … 1338 1338 return VERR_VDI_VALUE_NOT_FOUND; 1339 1339 int rc = vmdkStringUnquote(pImage, pszValue, &pszValueUnquoted, NULL); 1340 if ( VBOX_FAILURE(rc))1340 if (RT_FAILURE(rc)) 1341 1341 return rc; 1342 1342 rc = RTUuidFromStr(pUuid, pszValueUnquoted); … … 1354 1354 { 1355 1355 rc = RTStrAPrintf(&pszValQuoted, "\"%s\"", pszVal); 1356 if ( VBOX_FAILURE(rc))1356 if (RT_FAILURE(rc)) 1357 1357 return rc; 1358 1358 } … … 1372 1372 1373 1373 int rc = RTStrAPrintf(&pszUuid, "\"%Vuuid\"", pUuid); 1374 if ( VBOX_FAILURE(rc))1374 if (RT_FAILURE(rc)) 1375 1375 return rc; 1376 1376 rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDDB, pszKey, … … 1386 1386 1387 1387 int rc = RTStrAPrintf(&pszValue, "\"%d\"", uValue); 1388 if ( VBOX_FAILURE(rc))1388 if (RT_FAILURE(rc)) 1389 1389 return rc; 1390 1390 rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDDB, pszKey, … … 1517 1517 VMDK_DDB_GEO_PCHS_CYLINDERS, 1518 1518 pPCHSGeometry->cCylinders); 1519 if ( VBOX_FAILURE(rc))1519 if (RT_FAILURE(rc)) 1520 1520 return rc; 1521 1521 rc = vmdkDescDDBSetU32(pImage, &pImage->Descriptor, 1522 1522 VMDK_DDB_GEO_PCHS_HEADS, 1523 1523 pPCHSGeometry->cHeads); 1524 if ( VBOX_FAILURE(rc))1524 if (RT_FAILURE(rc)) 1525 1525 return rc; 1526 1526 rc = vmdkDescDDBSetU32(pImage, &pImage->Descriptor, … … 1536 1536 VMDK_DDB_GEO_LCHS_CYLINDERS, 1537 1537 pLCHSGeometry->cCylinders); 1538 if ( VBOX_FAILURE(rc))1538 if (RT_FAILURE(rc)) 1539 1539 return rc; 1540 1540 rc = vmdkDescDDBSetU32(pImage, &pImage->Descriptor, 1541 1541 VMDK_DDB_GEO_LCHS_HEADS, 1542 1542 pLCHSGeometry->cHeads); 1543 if ( VBOX_FAILURE(rc))1543 if (RT_FAILURE(rc)) 1544 1544 return rc; 1545 1545 rc = vmdkDescDDBSetU32(pImage, &pImage->Descriptor, … … 1564 1564 1565 1565 rc = vmdkDescInitStr(pImage, pDescriptor, "# Disk DescriptorFile"); 1566 if ( VBOX_FAILURE(rc))1566 if (RT_FAILURE(rc)) 1567 1567 goto out; 1568 1568 rc = vmdkDescInitStr(pImage, pDescriptor, "version=1"); 1569 if ( VBOX_FAILURE(rc))1569 if (RT_FAILURE(rc)) 1570 1570 goto out; 1571 1571 pDescriptor->uFirstDesc = pDescriptor->cLines - 1; 1572 1572 rc = vmdkDescInitStr(pImage, pDescriptor, ""); 1573 if ( VBOX_FAILURE(rc))1573 if (RT_FAILURE(rc)) 1574 1574 goto out; 1575 1575 rc = vmdkDescInitStr(pImage, pDescriptor, "# Extent description"); 1576 if ( VBOX_FAILURE(rc))1576 if (RT_FAILURE(rc)) 1577 1577 goto out; 1578 1578 rc = vmdkDescInitStr(pImage, pDescriptor, "NOACCESS 0 ZERO "); 1579 if ( VBOX_FAILURE(rc))1579 if (RT_FAILURE(rc)) 1580 1580 goto out; 1581 1581 pDescriptor->uFirstExtent = pDescriptor->cLines - 1; 1582 1582 rc = vmdkDescInitStr(pImage, pDescriptor, ""); 1583 if ( VBOX_FAILURE(rc))1583 if (RT_FAILURE(rc)) 1584 1584 goto out; 1585 1585 /* The trailing space is created by VMware, too. */ 1586 1586 rc = vmdkDescInitStr(pImage, pDescriptor, "# The disk Data Base "); 1587 if ( VBOX_FAILURE(rc))1587 if (RT_FAILURE(rc)) 1588 1588 goto out; 1589 1589 rc = vmdkDescInitStr(pImage, pDescriptor, "#DDB"); 1590 if ( VBOX_FAILURE(rc))1590 if (RT_FAILURE(rc)) 1591 1591 goto out; 1592 1592 rc = vmdkDescInitStr(pImage, pDescriptor, ""); 1593 if ( VBOX_FAILURE(rc))1593 if (RT_FAILURE(rc)) 1594 1594 goto out; 1595 1595 rc = vmdkDescInitStr(pImage, pDescriptor, "ddb.virtualHWVersion = \"4\""); 1596 if ( VBOX_FAILURE(rc))1596 if (RT_FAILURE(rc)) 1597 1597 goto out; 1598 1598 pDescriptor->uFirstDDB = pDescriptor->cLines - 1; … … 1604 1604 rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDesc, 1605 1605 "CID", szBuf); 1606 if ( VBOX_FAILURE(rc))1606 if (RT_FAILURE(rc)) 1607 1607 goto out; 1608 1608 rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDesc, 1609 1609 "parentCID", "ffffffff"); 1610 if ( VBOX_FAILURE(rc))1610 if (RT_FAILURE(rc)) 1611 1611 goto out; 1612 1612 1613 1613 rc = vmdkDescDDBSetStr(pImage, pDescriptor, "ddb.adapterType", "ide"); 1614 if ( VBOX_FAILURE(rc))1614 if (RT_FAILURE(rc)) 1615 1615 goto out; 1616 1616 … … 1628 1628 rc = vmdkPreprocessDescriptor(pImage, pDescData, cbDescData, 1629 1629 &pImage->Descriptor); 1630 if ( VBOX_FAILURE(rc))1630 if (RT_FAILURE(rc)) 1631 1631 return rc; 1632 1632 … … 1634 1634 uint32_t uVersion; 1635 1635 rc = vmdkDescBaseGetU32(&pImage->Descriptor, "version", &uVersion); 1636 if ( VBOX_FAILURE(rc))1636 if (RT_FAILURE(rc)) 1637 1637 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error finding key 'version' in descriptor in '%s'"), pImage->pszFilename); 1638 1638 if (uVersion != 1) … … 1643 1643 rc = vmdkDescBaseGetStr(pImage, &pImage->Descriptor, "createType", 1644 1644 &pszCreateType); 1645 if ( VBOX_FAILURE(rc))1645 if (RT_FAILURE(rc)) 1646 1646 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: cannot get image type from descriptor in '%s'"), pImage->pszFilename); 1647 1647 if ( !strcmp(pszCreateType, "twoGbMaxExtentSparse") … … 1671 1671 /* Non-monolithic image, extents need to be allocated. */ 1672 1672 rc = vmdkCreateExtents(pImage, cExtents); 1673 if ( VBOX_FAILURE(rc))1673 if (RT_FAILURE(rc)) 1674 1674 return rc; 1675 1675 } … … 1704 1704 rc = RTStrToUInt64Ex(pszLine, &pszLine, 10, 1705 1705 &pImage->pExtents[i].cNominalSectors); 1706 if ( VBOX_FAILURE(rc))1706 if (RT_FAILURE(rc)) 1707 1707 return vmdkError(pImage, VERR_VDI_INVALID_HEADER, RT_SRC_POS, N_("VMDK: parse error in extent description in '%s'"), pImage->pszFilename); 1708 1708 if (*pszLine++ != ' ') … … 1750 1750 char *pszBasename; 1751 1751 rc = vmdkStringUnquote(pImage, pszLine, &pszBasename, &pszLine); 1752 if ( VBOX_FAILURE(rc))1752 if (RT_FAILURE(rc)) 1753 1753 return rc; 1754 1754 pImage->pExtents[i].pszBasename = pszBasename; … … 1761 1761 rc = RTStrToUInt64Ex(pszLine, &pszLine, 10, 1762 1762 &pImage->pExtents[i].uSectorOffset); 1763 if ( VBOX_FAILURE(rc))1763 if (RT_FAILURE(rc)) 1764 1764 return vmdkError(pImage, VERR_VDI_INVALID_HEADER, RT_SRC_POS, N_("VMDK: parse error in extent description in '%s'"), pImage->pszFilename); 1765 1765 } … … 1777 1777 if (rc == VERR_VDI_VALUE_NOT_FOUND) 1778 1778 pImage->PCHSGeometry.cCylinders = 0; 1779 else if ( VBOX_FAILURE(rc))1779 else if (RT_FAILURE(rc)) 1780 1780 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error getting PCHS geometry from extent description in '%s'"), pImage->pszFilename); 1781 1781 rc = vmdkDescDDBGetU32(pImage, &pImage->Descriptor, … … 1784 1784 if (rc == VERR_VDI_VALUE_NOT_FOUND) 1785 1785 pImage->PCHSGeometry.cHeads = 0; 1786 else if ( VBOX_FAILURE(rc))1786 else if (RT_FAILURE(rc)) 1787 1787 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error getting PCHS geometry from extent description in '%s'"), pImage->pszFilename); 1788 1788 rc = vmdkDescDDBGetU32(pImage, &pImage->Descriptor, … … 1791 1791 if (rc == VERR_VDI_VALUE_NOT_FOUND) 1792 1792 pImage->PCHSGeometry.cSectors = 0; 1793 else if ( VBOX_FAILURE(rc))1793 else if (RT_FAILURE(rc)) 1794 1794 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error getting PCHS geometry from extent description in '%s'"), pImage->pszFilename); 1795 1795 if ( pImage->PCHSGeometry.cCylinders == 0 … … 1812 1812 if (rc == VERR_VDI_VALUE_NOT_FOUND) 1813 1813 pImage->LCHSGeometry.cCylinders = 0; 1814 else if ( VBOX_FAILURE(rc))1814 else if (RT_FAILURE(rc)) 1815 1815 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error getting LCHS geometry from extent description in '%s'"), pImage->pszFilename); 1816 1816 rc = vmdkDescDDBGetU32(pImage, &pImage->Descriptor, … … 1819 1819 if (rc == VERR_VDI_VALUE_NOT_FOUND) 1820 1820 pImage->LCHSGeometry.cHeads = 0; 1821 else if ( VBOX_FAILURE(rc))1821 else if (RT_FAILURE(rc)) 1822 1822 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error getting LCHS geometry from extent description in '%s'"), pImage->pszFilename); 1823 1823 rc = vmdkDescDDBGetU32(pImage, &pImage->Descriptor, … … 1826 1826 if (rc == VERR_VDI_VALUE_NOT_FOUND) 1827 1827 pImage->LCHSGeometry.cSectors = 0; 1828 else if ( VBOX_FAILURE(rc))1828 else if (RT_FAILURE(rc)) 1829 1829 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error getting LCHS geometry from extent description in '%s'"), pImage->pszFilename); 1830 1830 if ( pImage->LCHSGeometry.cCylinders == 0 … … 1850 1850 { 1851 1851 rc = RTUuidCreate(&pImage->ImageUuid); 1852 if ( VBOX_FAILURE(rc))1852 if (RT_FAILURE(rc)) 1853 1853 return rc; 1854 1854 rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor, 1855 1855 VMDK_DDB_IMAGE_UUID, &pImage->ImageUuid); 1856 if ( VBOX_FAILURE(rc))1856 if (RT_FAILURE(rc)) 1857 1857 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing image UUID in descriptor in '%s'"), pImage->pszFilename); 1858 1858 } 1859 1859 } 1860 else if ( VBOX_FAILURE(rc))1860 else if (RT_FAILURE(rc)) 1861 1861 return rc; 1862 1862 … … 1875 1875 { 1876 1876 rc = RTUuidCreate(&pImage->ModificationUuid); 1877 if ( VBOX_FAILURE(rc))1877 if (RT_FAILURE(rc)) 1878 1878 return rc; 1879 1879 rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor, 1880 1880 VMDK_DDB_MODIFICATION_UUID, 1881 1881 &pImage->ModificationUuid); 1882 if ( VBOX_FAILURE(rc))1882 if (RT_FAILURE(rc)) 1883 1883 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing image modification UUID in descriptor in '%s'"), pImage->pszFilename); 1884 1884 } 1885 1885 } 1886 else if ( VBOX_FAILURE(rc))1886 else if (RT_FAILURE(rc)) 1887 1887 return rc; 1888 1888 … … 1900 1900 { 1901 1901 rc = RTUuidClear(&pImage->ParentUuid); 1902 if ( VBOX_FAILURE(rc))1902 if (RT_FAILURE(rc)) 1903 1903 return rc; 1904 1904 rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor, 1905 1905 VMDK_DDB_PARENT_UUID, &pImage->ParentUuid); 1906 if ( VBOX_FAILURE(rc))1906 if (RT_FAILURE(rc)) 1907 1907 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing parent UUID in descriptor in '%s'"), pImage->pszFilename); 1908 1908 } 1909 1909 } 1910 else if ( VBOX_FAILURE(rc))1910 else if (RT_FAILURE(rc)) 1911 1911 return rc; 1912 1912 … … 1925 1925 { 1926 1926 rc = RTUuidCreate(&pImage->ParentModificationUuid); 1927 if ( VBOX_FAILURE(rc))1927 if (RT_FAILURE(rc)) 1928 1928 return rc; 1929 1929 rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor, 1930 1930 VMDK_DDB_PARENT_MODIFICATION_UUID, 1931 1931 &pImage->ParentModificationUuid); 1932 if ( VBOX_FAILURE(rc))1932 if (RT_FAILURE(rc)) 1933 1933 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing parent modification UUID in descriptor in '%s'"), pImage->pszFilename); 1934 1934 } 1935 1935 } 1936 else if ( VBOX_FAILURE(rc))1936 else if (RT_FAILURE(rc)) 1937 1937 return rc; 1938 1938 … … 1973 1973 return vmdkError(pImage, VERR_BUFFER_OVERFLOW, RT_SRC_POS, N_("VMDK: descriptor too long in '%s'"), pImage->pszFilename); 1974 1974 rc = vmdkFileWriteAt(pDescFile, uOffset, psz, cb, NULL); 1975 if ( VBOX_FAILURE(rc))1975 if (RT_FAILURE(rc)) 1976 1976 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error writing descriptor in '%s'"), pImage->pszFilename); 1977 1977 uOffset += cb; 1978 1978 rc = vmdkFileWriteAt(pDescFile, uOffset, "\n", 1, NULL); 1979 if ( VBOX_FAILURE(rc))1979 if (RT_FAILURE(rc)) 1980 1980 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error writing descriptor in '%s'"), pImage->pszFilename); 1981 1981 uOffset++; … … 1987 1987 { 1988 1988 rc = vmdkFileWriteAt(pDescFile, uOffset, "", 1, NULL); 1989 if ( VBOX_FAILURE(rc))1989 if (RT_FAILURE(rc)) 1990 1990 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error writing descriptor in '%s'"), pImage->pszFilename); 1991 1991 uOffset++; … … 1995 1995 { 1996 1996 rc = vmdkFileSetSize(pDescFile, uOffset); 1997 if ( VBOX_FAILURE(rc))1997 if (RT_FAILURE(rc)) 1998 1998 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error truncating descriptor in '%s'"), pImage->pszFilename); 1999 1999 } … … 2012 2012 int rc = vmdkFileReadAt(pExtent->pFile, 0, &Header, sizeof(Header), NULL); 2013 2013 AssertRC(rc); 2014 if ( VBOX_FAILURE(rc))2014 if (RT_FAILURE(rc)) 2015 2015 { 2016 2016 rc = vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: error reading extent header in '%s'"), pExtent->pszFullname); … … 2026 2026 * image is at least truncated, or even seriously garbled. */ 2027 2027 rc = vmdkFileGetSize(pExtent->pFile, &cbExtentSize); 2028 if ( VBOX_FAILURE(rc))2028 if (RT_FAILURE(rc)) 2029 2029 { 2030 2030 rc = vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: error getting size in '%s'"), pExtent->pszFullname); … … 2093 2093 2094 2094 out: 2095 if ( VBOX_FAILURE(rc))2095 if (RT_FAILURE(rc)) 2096 2096 vmdkFreeExtentData(pImage, pExtent, false); 2097 2097 … … 2136 2136 int rc = vmdkFileWriteAt(pExtent->pFile, 0, &Header, sizeof(Header), NULL); 2137 2137 AssertRC(rc); 2138 if ( VBOX_FAILURE(rc))2138 if (RT_FAILURE(rc)) 2139 2139 rc = vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: error writing extent header in '%s'"), pExtent->pszFullname); 2140 2140 return rc; … … 2154 2154 int rc = vmdkFileReadAt(pExtent->pFile, 0, &Header, sizeof(Header), NULL); 2155 2155 AssertRC(rc); 2156 if ( VBOX_FAILURE(rc))2156 if (RT_FAILURE(rc)) 2157 2157 goto out; 2158 2158 if ( RT_LE2H_U32(Header.magicNumber) != VMDK_ESX_SPARSE_MAGICNUMBER … … 2202 2202 2203 2203 out: 2204 if ( VBOX_FAILURE(rc))2204 if (RT_FAILURE(rc)) 2205 2205 vmdkFreeExtentData(pImage, pExtent, false); 2206 2206 … … 2318 2318 /* 2319 2319 * Open the image. 2320 * We don't have to check for asynchronous access because 2320 * We don't have to check for asynchronous access because 2321 2321 * we only support raw access and the opened file is a description 2322 2322 * file were no data is stored. … … 2326 2326 ? RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE 2327 2327 : RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, false); 2328 if ( VBOX_FAILURE(rc))2328 if (RT_FAILURE(rc)) 2329 2329 { 2330 2330 /* Do NOT signal an appropriate error here, as the VD layer has the … … 2336 2336 /* Read magic (if present). */ 2337 2337 rc = vmdkFileReadAt(pFile, 0, &u32Magic, sizeof(u32Magic), NULL); 2338 if ( VBOX_FAILURE(rc))2338 if (RT_FAILURE(rc)) 2339 2339 { 2340 2340 rc = vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error reading the magic number in '%s'"), pImage->pszFilename); … … 2347 2347 /* It's a hosted sparse single-extent image. */ 2348 2348 rc = vmdkCreateExtents(pImage, 1); 2349 if ( VBOX_FAILURE(rc))2349 if (RT_FAILURE(rc)) 2350 2350 goto out; 2351 2351 /* The opened file is passed to the extent. No separate descriptor … … 2361 2361 } 2362 2362 rc = vmdkReadMetaSparseExtent(pImage, pExtent); 2363 if ( VBOX_FAILURE(rc))2363 if (RT_FAILURE(rc)) 2364 2364 goto out; 2365 2365 /* As we're dealing with a monolithic sparse image here, there must … … 2382 2382 VMDK_SECTOR2BYTE(pExtent->cDescriptorSectors), NULL); 2383 2383 AssertRC(rc); 2384 if ( VBOX_FAILURE(rc))2384 if (RT_FAILURE(rc)) 2385 2385 { 2386 2386 rc = vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: read error for descriptor in '%s'"), pExtent->pszFullname); … … 2390 2390 rc = vmdkParseDescriptor(pImage, pExtent->pDescData, 2391 2391 VMDK_SECTOR2BYTE(pExtent->cDescriptorSectors)); 2392 if ( VBOX_FAILURE(rc))2392 if (RT_FAILURE(rc)) 2393 2393 goto out; 2394 2394 … … 2413 2413 rc = vmdkFileReadAt(pImage->pFile, 0, pImage->pDescData, 2414 2414 pImage->cbDescAlloc, &cbRead); 2415 if ( VBOX_FAILURE(rc))2415 if (RT_FAILURE(rc)) 2416 2416 { 2417 2417 rc = vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: read error for descriptor in '%s'"), pImage->pszFilename); … … 2428 2428 rc = vmdkParseDescriptor(pImage, pImage->pDescData, 2429 2429 pImage->cbDescAlloc); 2430 if ( VBOX_FAILURE(rc))2430 if (RT_FAILURE(rc)) 2431 2431 goto out; 2432 2432 2433 /* 2433 /* 2434 2434 * We have to check for the asynchronous open flag. The 2435 2435 * extents are parsed and the type of all are known now. … … 2445 2445 && (pExtent->enmType != VMDKETYPE_ZERO)) 2446 2446 { 2447 /* 2447 /* 2448 2448 * Opened image contains at least one none flat or zero extent. 2449 2449 * Return error but don't set error message as the caller … … 2490 2490 RTPATH_SLASH, pExtent->pszBasename); 2491 2491 RTStrFree(pszDirname); 2492 if ( VBOX_FAILURE(rc))2492 if (RT_FAILURE(rc)) 2493 2493 goto out; 2494 2494 } … … 2505 2505 ? RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE 2506 2506 : RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, false); 2507 if ( VBOX_FAILURE(rc))2507 if (RT_FAILURE(rc)) 2508 2508 { 2509 2509 /* Do NOT signal an appropriate error here, as the VD … … 2513 2513 } 2514 2514 rc = vmdkReadMetaSparseExtent(pImage, pExtent); 2515 if ( VBOX_FAILURE(rc))2515 if (RT_FAILURE(rc)) 2516 2516 goto out; 2517 2517 … … 2528 2528 ? RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE 2529 2529 : RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, true); 2530 if ( VBOX_FAILURE(rc))2530 if (RT_FAILURE(rc)) 2531 2531 { 2532 2532 /* Do NOT signal an appropriate error here, as the VD … … 2564 2564 /* Update the image metadata now in case has changed. */ 2565 2565 rc = vmdkFlushImage(pImage); 2566 if ( VBOX_FAILURE(rc))2566 if (RT_FAILURE(rc)) 2567 2567 goto out; 2568 2568 … … 2599 2599 2600 2600 rc = vmdkAllocateGrainTableCache(pImage); 2601 if ( VBOX_FAILURE(rc))2601 if (RT_FAILURE(rc)) 2602 2602 goto out; 2603 2603 2604 2604 out: 2605 if ( VBOX_FAILURE(rc))2605 if (RT_FAILURE(rc)) 2606 2606 vmdkFreeImage(pImage, false); 2607 2607 return rc; … … 2622 2622 * file and open the (flat) raw disk. */ 2623 2623 rc = vmdkCreateExtents(pImage, 1); 2624 if ( VBOX_FAILURE(rc))2624 if (RT_FAILURE(rc)) 2625 2625 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new extent list in '%s'"), pImage->pszFilename); 2626 2626 pExtent = &pImage->pExtents[0]; … … 2629 2629 RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED, 2630 2630 false); 2631 if ( VBOX_FAILURE(rc))2631 if (RT_FAILURE(rc)) 2632 2632 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new file '%s'"), pImage->pszFilename); 2633 2633 … … 2652 2652 rc = vmdkFileOpen(pImage, &pExtent->pFile, pExtent->pszFullname, 2653 2653 RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, false); 2654 if ( VBOX_FAILURE(rc))2654 if (RT_FAILURE(rc)) 2655 2655 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not open raw disk file '%s'"), pExtent->pszFullname); 2656 2656 } … … 2695 2695 2696 2696 rc = vmdkCreateExtents(pImage, cExtents); 2697 if ( VBOX_FAILURE(rc))2697 if (RT_FAILURE(rc)) 2698 2698 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new extent list in '%s'"), pImage->pszFilename); 2699 2699 … … 2702 2702 RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED, 2703 2703 false); 2704 if ( VBOX_FAILURE(rc))2704 if (RT_FAILURE(rc)) 2705 2705 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new file '%s'"), pImage->pszFilename); 2706 2706 … … 2761 2761 RTPATH_SLASH, pExtent->pszBasename); 2762 2762 RTStrFree(pszDirname); 2763 if ( VBOX_FAILURE(rc))2763 if (RT_FAILURE(rc)) 2764 2764 return rc; 2765 2765 pExtent->pszFullname = pszFullname; … … 2774 2774 RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED, 2775 2775 false); 2776 if ( VBOX_FAILURE(rc))2776 if (RT_FAILURE(rc)) 2777 2777 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new partition data file '%s'"), pExtent->pszFullname); 2778 2778 rc = vmdkFileWriteAt(pExtent->pFile, … … 2780 2780 pPart->pvPartitionData, 2781 2781 pPart->cbPartitionData, NULL); 2782 if ( VBOX_FAILURE(rc))2782 if (RT_FAILURE(rc)) 2783 2783 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not write partition data to '%s'"), pExtent->pszFullname); 2784 2784 uPartOffset += VMDK_BYTE2SECTOR(pPart->cbPartitionData); … … 2822 2822 RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, 2823 2823 false); 2824 if ( VBOX_FAILURE(rc))2824 if (RT_FAILURE(rc)) 2825 2825 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not open raw partition file '%s'"), pExtent->pszFullname); 2826 2826 } … … 2854 2854 pRaw->fRawDisk ? 2855 2855 "fullDevice" : "partitionedDevice"); 2856 if ( VBOX_FAILURE(rc))2856 if (RT_FAILURE(rc)) 2857 2857 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not set the image type in '%s'"), pImage->pszFilename); 2858 2858 return rc; … … 2881 2881 } 2882 2882 rc = vmdkCreateExtents(pImage, cExtents); 2883 if ( VBOX_FAILURE(rc))2883 if (RT_FAILURE(rc)) 2884 2884 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new extent list in '%s'"), pImage->pszFilename); 2885 2885 … … 2895 2895 RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED, 2896 2896 false); 2897 if ( VBOX_FAILURE(rc))2897 if (RT_FAILURE(rc)) 2898 2898 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new sparse descriptor file '%s'"), pImage->pszFilename); 2899 2899 pImage->pszFilename = RTStrDup(pImage->pszFilename); … … 2940 2940 pszBasenameExt); 2941 2941 RTStrFree(pszBasenameBase); 2942 if ( VBOX_FAILURE(rc))2942 if (RT_FAILURE(rc)) 2943 2943 return rc; 2944 2944 cbTmp = strlen(pszTmp) + 1; … … 2958 2958 RTPATH_SLASH, pExtent->pszBasename); 2959 2959 RTStrFree(pszBasedirectory); 2960 if ( VBOX_FAILURE(rc))2960 if (RT_FAILURE(rc)) 2961 2961 return rc; 2962 2962 pExtent->pszFullname = pszFullname; … … 2966 2966 RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED, 2967 2967 false); 2968 if ( VBOX_FAILURE(rc))2968 if (RT_FAILURE(rc)) 2969 2969 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new file '%s'"), pExtent->pszFullname); 2970 2970 if (enmType == VD_IMAGE_TYPE_FIXED) 2971 2971 { 2972 2972 rc = vmdkFileSetSize(pExtent->pFile, cbExtent); 2973 if ( VBOX_FAILURE(rc))2973 if (RT_FAILURE(rc)) 2974 2974 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not set size of new file '%s'"), pExtent->pszFullname); 2975 2975 … … 2994 2994 2995 2995 rc = vmdkFileWriteAt(pExtent->pFile, uOff, pvBuf, cbChunk, NULL); 2996 if ( VBOX_FAILURE(rc))2996 if (RT_FAILURE(rc)) 2997 2997 { 2998 2998 RTMemFree(pvBuf); … … 3007 3007 uPercentStart + uOff * uPercentSpan / cbExtent, 3008 3008 pvUser); 3009 if ( VBOX_FAILURE(rc))3009 if (RT_FAILURE(rc)) 3010 3010 { 3011 3011 RTMemFree(pvBuf); … … 3055 3055 1), 3056 3056 true); 3057 if ( VBOX_FAILURE(rc))3057 if (RT_FAILURE(rc)) 3058 3058 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new grain directory in '%s'"), pExtent->pszFullname); 3059 3059 } 3060 3060 3061 if ( VBOX_SUCCESS(rc) && pfnProgress)3061 if (RT_SUCCESS(rc) && pfnProgress) 3062 3062 pfnProgress(NULL /* WARNING! pVM=NULL */, 3063 3063 uPercentStart + i * uPercentSpan / cExtents, … … 3083 3083 rc = vmdkDescBaseSetStr(pImage, &pImage->Descriptor, "createType", 3084 3084 pszDescType); 3085 if ( VBOX_FAILURE(rc))3085 if (RT_FAILURE(rc)) 3086 3086 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not set the image type in '%s'"), pImage->pszFilename); 3087 3087 return rc; … … 3105 3105 rc = vmdkCreateDescriptor(pImage, pImage->pDescData, pImage->cbDescAlloc, 3106 3106 &pImage->Descriptor); 3107 if ( VBOX_FAILURE(rc))3107 if (RT_FAILURE(rc)) 3108 3108 { 3109 3109 rc = vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new descriptor in '%s'"), pImage->pszFilename); … … 3135 3135 } 3136 3136 3137 if ( VBOX_FAILURE(rc))3138 goto out; 3139 3140 if ( VBOX_SUCCESS(rc) && pfnProgress)3137 if (RT_FAILURE(rc)) 3138 goto out; 3139 3140 if (RT_SUCCESS(rc) && pfnProgress) 3141 3141 pfnProgress(NULL /* WARNING! pVM=NULL */, 3142 3142 uPercentStart + uPercentSpan * 98 / 100, pvUser); … … 3152 3152 pExtent->cNominalSectors, pExtent->enmType, 3153 3153 pExtent->pszBasename, pExtent->uSectorOffset); 3154 if ( VBOX_FAILURE(rc))3154 if (RT_FAILURE(rc)) 3155 3155 { 3156 3156 rc = vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not insert the extent list into descriptor in '%s'"), pImage->pszFilename); … … 3165 3165 { 3166 3166 rc = vmdkDescSetPCHSGeometry(pImage, pPCHSGeometry); 3167 if ( VBOX_FAILURE(rc))3167 if (RT_FAILURE(rc)) 3168 3168 goto out; 3169 3169 } … … 3173 3173 { 3174 3174 rc = vmdkDescSetLCHSGeometry(pImage, pLCHSGeometry); 3175 if ( VBOX_FAILURE(rc))3175 if (RT_FAILURE(rc)) 3176 3176 goto out; 3177 3177 } … … 3181 3181 3182 3182 rc = RTUuidCreate(&pImage->ImageUuid); 3183 if ( VBOX_FAILURE(rc))3183 if (RT_FAILURE(rc)) 3184 3184 goto out; 3185 3185 rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor, 3186 3186 VMDK_DDB_IMAGE_UUID, &pImage->ImageUuid); 3187 if ( VBOX_FAILURE(rc))3187 if (RT_FAILURE(rc)) 3188 3188 { 3189 3189 rc = vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing image UUID in new descriptor in '%s'"), pImage->pszFilename); … … 3193 3193 rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor, 3194 3194 VMDK_DDB_PARENT_UUID, &pImage->ParentUuid); 3195 if ( VBOX_FAILURE(rc))3195 if (RT_FAILURE(rc)) 3196 3196 { 3197 3197 rc = vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing parent image UUID in new descriptor in '%s'"), pImage->pszFilename); … … 3202 3202 VMDK_DDB_MODIFICATION_UUID, 3203 3203 &pImage->ModificationUuid); 3204 if ( VBOX_FAILURE(rc))3204 if (RT_FAILURE(rc)) 3205 3205 { 3206 3206 rc = vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing modification UUID in new descriptor in '%s'"), pImage->pszFilename); … … 3211 3211 VMDK_DDB_PARENT_MODIFICATION_UUID, 3212 3212 &pImage->ParentModificationUuid); 3213 if ( VBOX_FAILURE(rc))3213 if (RT_FAILURE(rc)) 3214 3214 { 3215 3215 rc = vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing parent modification UUID in new descriptor in '%s'"), pImage->pszFilename); … … 3218 3218 3219 3219 rc = vmdkAllocateGrainTableCache(pImage); 3220 if ( VBOX_FAILURE(rc))3220 if (RT_FAILURE(rc)) 3221 3221 goto out; 3222 3222 3223 3223 rc = vmdkSetImageComment(pImage, pszComment); 3224 if ( VBOX_FAILURE(rc))3224 if (RT_FAILURE(rc)) 3225 3225 { 3226 3226 rc = vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: cannot set image comment in '%s'"), pImage->pszFilename); … … 3228 3228 } 3229 3229 3230 if ( VBOX_SUCCESS(rc) && pfnProgress)3230 if (RT_SUCCESS(rc) && pfnProgress) 3231 3231 pfnProgress(NULL /* WARNING! pVM=NULL */, 3232 3232 uPercentStart + uPercentSpan * 99 / 100, pvUser); … … 3235 3235 3236 3236 out: 3237 if ( VBOX_SUCCESS(rc) && pfnProgress)3237 if (RT_SUCCESS(rc) && pfnProgress) 3238 3238 pfnProgress(NULL /* WARNING! pVM=NULL */, 3239 3239 uPercentStart + uPercentSpan, pvUser); 3240 3240 3241 if ( VBOX_FAILURE(rc))3241 if (RT_FAILURE(rc)) 3242 3242 vmdkFreeImage(pImage, rc != VERR_ALREADY_EXISTS); 3243 3243 return rc; … … 3262 3262 if (pszComment) 3263 3263 RTStrFree(pszCommentEncoded); 3264 if ( VBOX_FAILURE(rc))3264 if (RT_FAILURE(rc)) 3265 3265 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing image comment in descriptor in '%s'"), pImage->pszFilename); 3266 3266 return VINF_SUCCESS; … … 3320 3320 { 3321 3321 rc = vmdkWriteDescriptor(pImage); 3322 if ( VBOX_FAILURE(rc))3322 if (RT_FAILURE(rc)) 3323 3323 goto out; 3324 3324 } … … 3333 3333 case VMDKETYPE_HOSTED_SPARSE: 3334 3334 rc = vmdkWriteMetaSparseExtent(pExtent); 3335 if ( VBOX_FAILURE(rc))3335 if (RT_FAILURE(rc)) 3336 3336 goto out; 3337 3337 break; … … 3451 3451 VMDK_SECTOR2BYTE(uGTSector) + (uGTBlock % (pExtent->cGTEntries / VMDK_GT_CACHELINE_SIZE)) * sizeof(aGTDataTmp), 3452 3452 aGTDataTmp, sizeof(aGTDataTmp), NULL); 3453 if ( VBOX_FAILURE(rc))3453 if (RT_FAILURE(rc)) 3454 3454 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: cannot read grain table entry in '%s'"), pExtent->pszFullname); 3455 3455 pGTCacheEntry->uExtent = pExtent->uExtent; … … 3498 3498 * a new grain table and put the reference to it in the GDs. */ 3499 3499 rc = vmdkFileGetSize(pExtent->pFile, &cbExtentSize); 3500 if ( VBOX_FAILURE(rc))3500 if (RT_FAILURE(rc)) 3501 3501 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: error getting size in '%s'"), pExtent->pszFullname); 3502 3502 Assert(!(cbExtentSize % 512)); … … 3519 3519 VMDK_SECTOR2BYTE(uGTSector) + i * sizeof(aGTDataTmp), 3520 3520 aGTDataTmp, sizeof(aGTDataTmp), NULL); 3521 if ( VBOX_FAILURE(rc))3521 if (RT_FAILURE(rc)) 3522 3522 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: cannot write grain table allocation in '%s'"), pExtent->pszFullname); 3523 3523 } … … 3526 3526 AssertReturn(!uRGTSector, VERR_VDI_INVALID_HEADER); 3527 3527 rc = vmdkFileGetSize(pExtent->pFile, &cbExtentSize); 3528 if ( VBOX_FAILURE(rc))3528 if (RT_FAILURE(rc)) 3529 3529 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: error getting size in '%s'"), pExtent->pszFullname); 3530 3530 Assert(!(cbExtentSize % 512)); … … 3546 3546 VMDK_SECTOR2BYTE(uRGTSector) + i * sizeof(aGTDataTmp), 3547 3547 aGTDataTmp, sizeof(aGTDataTmp), NULL); 3548 if ( VBOX_FAILURE(rc))3548 if (RT_FAILURE(rc)) 3549 3549 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: cannot write backup grain table allocation in '%s'"), pExtent->pszFullname); 3550 3550 } … … 3559 3559 VMDK_SECTOR2BYTE(pExtent->uSectorGD) + uGDIndex * sizeof(uGTSectorLE), 3560 3560 &uGTSectorLE, sizeof(uGTSectorLE), NULL); 3561 if ( VBOX_FAILURE(rc))3561 if (RT_FAILURE(rc)) 3562 3562 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: cannot write grain directory entry in '%s'"), pExtent->pszFullname); 3563 3563 if (pExtent->pRGD) … … 3567 3567 VMDK_SECTOR2BYTE(pExtent->uSectorRGD) + uGDIndex * sizeof(uRGTSectorLE), 3568 3568 &uRGTSectorLE, sizeof(uRGTSectorLE), NULL); 3569 if ( VBOX_FAILURE(rc))3569 if (RT_FAILURE(rc)) 3570 3570 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: cannot write backup grain directory entry in '%s'"), pExtent->pszFullname); 3571 3571 } … … 3578 3578 3579 3579 rc = vmdkFileGetSize(pExtent->pFile, &cbExtentSize); 3580 if ( VBOX_FAILURE(rc))3580 if (RT_FAILURE(rc)) 3581 3581 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: error getting size in '%s'"), pExtent->pszFullname); 3582 3582 Assert(!(cbExtentSize % 512)); … … 3584 3584 /* Write the data. */ 3585 3585 rc = vmdkFileWriteAt(pExtent->pFile, cbExtentSize, pvBuf, cbWrite, NULL); 3586 if ( VBOX_FAILURE(rc))3586 if (RT_FAILURE(rc)) 3587 3587 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: cannot write allocated data block in '%s'"), pExtent->pszFullname); 3588 3588 … … 3598 3598 VMDK_SECTOR2BYTE(uGTSector) + (uGTBlock % (pExtent->cGTEntries / VMDK_GT_CACHELINE_SIZE)) * sizeof(aGTDataTmp), 3599 3599 aGTDataTmp, sizeof(aGTDataTmp), NULL); 3600 if ( VBOX_FAILURE(rc))3600 if (RT_FAILURE(rc)) 3601 3601 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: cannot read allocated grain table entry in '%s'"), pExtent->pszFullname); 3602 3602 pGTCacheEntry->uExtent = pExtent->uExtent; … … 3619 3619 VMDK_SECTOR2BYTE(uGTSector) + (uGTBlock % (pExtent->cGTEntries / VMDK_GT_CACHELINE_SIZE)) * sizeof(aGTDataTmp), 3620 3620 aGTDataTmp, sizeof(aGTDataTmp), NULL); 3621 if ( VBOX_FAILURE(rc))3621 if (RT_FAILURE(rc)) 3622 3622 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: cannot write updated grain table in '%s'"), pExtent->pszFullname); 3623 3623 if (pExtent->pRGD) … … 3627 3627 VMDK_SECTOR2BYTE(uRGTSector) + (uGTBlock % (pExtent->cGTEntries / VMDK_GT_CACHELINE_SIZE)) * sizeof(aGTDataTmp), 3628 3628 aGTDataTmp, sizeof(aGTDataTmp), NULL); 3629 if ( VBOX_FAILURE(rc))3629 if (RT_FAILURE(rc)) 3630 3630 return vmdkError(pExtent->pImage, rc, RT_SRC_POS, N_("VMDK: cannot write updated backup grain table in '%s'"), pExtent->pszFullname); 3631 3631 } 3632 3632 #ifdef VBOX_WITH_VMDK_ESX 3633 if ( VBOX_SUCCESS(rc) && pExtent->enmType == VMDKETYPE_ESX_SPARSE)3633 if (RT_SUCCESS(rc) && pExtent->enmType == VMDKETYPE_ESX_SPARSE) 3634 3634 { 3635 3635 pExtent->uFreeSector = uGTSector + VMDK_BYTE2SECTOR(cbWrite); … … 3733 3733 3734 3734 rc = vmdkOpenImage(pImage, uOpenFlags); 3735 if ( VBOX_SUCCESS(rc))3735 if (RT_SUCCESS(rc)) 3736 3736 *ppBackendData = pImage; 3737 3737 … … 3809 3809 pPCHSGeometry, pLCHSGeometry, 3810 3810 pfnProgress, pvUser, uPercentStart, uPercentSpan); 3811 if ( VBOX_SUCCESS(rc))3811 if (RT_SUCCESS(rc)) 3812 3812 { 3813 3813 /* So far the image is opened in read/write mode. Make sure the … … 3817 3817 vmdkFreeImage(pImage, false); 3818 3818 rc = vmdkOpenImage(pImage, uOpenFlags); 3819 if ( VBOX_FAILURE(rc))3819 if (RT_FAILURE(rc)) 3820 3820 goto out; 3821 3821 } … … 3895 3895 * with zeros. We actually save stuff when and if we change it. 3896 3896 */ 3897 apszOldName = (char **)RTMemTmpAllocZ((cExtents + 1) * sizeof(char*)); 3898 apszNewName = (char **)RTMemTmpAllocZ((cExtents + 1) * sizeof(char*)); 3899 apszNewLines = (char **)RTMemTmpAllocZ((cExtents) * sizeof(char*)); 3897 apszOldName = (char **)RTMemTmpAllocZ((cExtents + 1) * sizeof(char*)); 3898 apszNewName = (char **)RTMemTmpAllocZ((cExtents + 1) * sizeof(char*)); 3899 apszNewLines = (char **)RTMemTmpAllocZ((cExtents) * sizeof(char*)); 3900 3900 if (!apszOldName || !apszNewName || !apszNewLines) 3901 3901 { … … 3954 3954 pImage->Descriptor.aLines[line] = apszNewLines[i]; 3955 3955 /* Compose new name for the extent. */ 3956 apszNewName[i] = vmdkStrReplace(pExtent->pszFullname, 3956 apszNewName[i] = vmdkStrReplace(pExtent->pszFullname, 3957 3957 pszOldBasename, pszNewBasename); 3958 3958 if (!apszNewName[i]) … … 3962 3962 /* Rename the extent file. */ 3963 3963 rc = RTFileMove(pExtent->pszFullname, apszNewName[i], 0); 3964 if ( VBOX_FAILURE(rc))3964 if (RT_FAILURE(rc)) 3965 3965 goto rollback; 3966 3966 /* Remember the old name. */ … … 3979 3979 */ 3980 3980 apszNewName[cExtents] = RTPathFilename(pszFilename); 3981 /* Rename the descriptor file if it's separate. */ 3981 /* Rename the descriptor file if it's separate. */ 3982 3982 if (!fEmbeddedDesc) 3983 3983 { 3984 3984 rc = RTFileMove(pImage->pszFilename, apszNewName[cExtents], 0); 3985 if ( VBOX_FAILURE(rc))3985 if (RT_FAILURE(rc)) 3986 3986 goto rollback; 3987 3987 /* Save old name only if we may need to change it back. */ … … 3994 3994 /* Open the new image. */ 3995 3995 rc = vmdkOpenImage(pImage, pImage->uOpenFlags); 3996 if ( VBOX_SUCCESS(rc))3996 if (RT_SUCCESS(rc)) 3997 3997 goto out; 3998 3998 3999 3999 rollback: 4000 4000 /* Roll back all changes in case of failure. */ 4001 if ( VBOX_FAILURE(rc))4001 if (RT_FAILURE(rc)) 4002 4002 { 4003 4003 int rrc; … … 4005 4005 { 4006 4006 /* 4007 * Some extents may have been closed, close the rest. We will 4008 * re-open the whole thing later. 4007 * Some extents may have been closed, close the rest. We will 4008 * re-open the whole thing later. 4009 4009 */ 4010 4010 vmdkFreeImage(pImage, false); … … 4099 4099 rc = vmdkFindExtent(pImage, VMDK_BYTE2SECTOR(uOffset), 4100 4100 &pExtent, &uSectorExtentRel); 4101 if ( VBOX_FAILURE(rc))4101 if (RT_FAILURE(rc)) 4102 4102 goto out; 4103 4103 … … 4121 4121 rc = vmdkGetSector(pImage->pGTCache, pExtent, uSectorExtentRel, 4122 4122 &uSectorExtentAbs); 4123 if ( VBOX_FAILURE(rc))4123 if (RT_FAILURE(rc)) 4124 4124 goto out; 4125 4125 /* Clip read range to at most the rest of the grain. */ … … 4186 4186 rc = vmdkFindExtent(pImage, VMDK_BYTE2SECTOR(uOffset), 4187 4187 &pExtent, &uSectorExtentRel); 4188 if ( VBOX_FAILURE(rc))4188 if (RT_FAILURE(rc)) 4189 4189 goto out; 4190 4190 … … 4205 4205 rc = vmdkGetSector(pImage->pGTCache, pExtent, uSectorExtentRel, 4206 4206 &uSectorExtentAbs); 4207 if ( VBOX_FAILURE(rc))4207 if (RT_FAILURE(rc)) 4208 4208 goto out; 4209 4209 /* Clip write range to at most the rest of the grain. */ … … 4266 4266 PVMDKIMAGE pImage = (PVMDKIMAGE)pBackendData; 4267 4267 int rc; 4268 4268 4269 4269 Assert(pImage); 4270 4270 … … 4336 4336 { 4337 4337 int rc = vmdkFileGetSize(pImage->pFile, &cbFile); 4338 if ( VBOX_SUCCESS(rc))4338 if (RT_SUCCESS(rc)) 4339 4339 cb += cbFile; 4340 4340 for (unsigned i = 0; i <= pImage->cExtents; i++) 4341 4341 { 4342 4342 rc = vmdkFileGetSize(pImage->pFile, &cbFile); 4343 if ( VBOX_SUCCESS(rc))4343 if (RT_SUCCESS(rc)) 4344 4344 cb += cbFile; 4345 4345 } … … 4396 4396 } 4397 4397 rc = vmdkDescSetPCHSGeometry(pImage, pPCHSGeometry); 4398 if ( VBOX_FAILURE(rc))4398 if (RT_FAILURE(rc)) 4399 4399 goto out; 4400 4400 … … 4455 4455 } 4456 4456 rc = vmdkDescSetLCHSGeometry(pImage, pLCHSGeometry); 4457 if ( VBOX_FAILURE(rc))4457 if (RT_FAILURE(rc)) 4458 4458 goto out; 4459 4459 … … 4546 4546 if (rc == VERR_VDI_VALUE_NOT_FOUND) 4547 4547 pszCommentEncoded = NULL; 4548 else if ( VBOX_FAILURE(rc))4548 else if (RT_FAILURE(rc)) 4549 4549 goto out; 4550 4550 … … 4627 4627 rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor, 4628 4628 VMDK_DDB_IMAGE_UUID, pUuid); 4629 if ( VBOX_FAILURE(rc))4629 if (RT_FAILURE(rc)) 4630 4630 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing image UUID in descriptor in '%s'"), pImage->pszFilename); 4631 4631 rc = VINF_SUCCESS; … … 4678 4678 rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor, 4679 4679 VMDK_DDB_MODIFICATION_UUID, pUuid); 4680 if ( VBOX_FAILURE(rc))4680 if (RT_FAILURE(rc)) 4681 4681 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing modification UUID in descriptor in '%s'"), pImage->pszFilename); 4682 4682 rc = VINF_SUCCESS; … … 4729 4729 rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor, 4730 4730 VMDK_DDB_PARENT_UUID, pUuid); 4731 if ( VBOX_FAILURE(rc))4731 if (RT_FAILURE(rc)) 4732 4732 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing parent image UUID in descriptor in '%s'"), pImage->pszFilename); 4733 4733 rc = VINF_SUCCESS; … … 4780 4780 rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor, 4781 4781 VMDK_DDB_PARENT_MODIFICATION_UUID, pUuid); 4782 if ( VBOX_FAILURE(rc))4782 if (RT_FAILURE(rc)) 4783 4783 return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing parent image UUID in descriptor in '%s'"), pImage->pszFilename); 4784 4784 rc = VINF_SUCCESS; … … 4901 4901 rc = vmdkFindExtent(pImage, VMDK_BYTE2SECTOR(uOffset), 4902 4902 &pExtent, &uSectorExtentRel); 4903 if ( VBOX_FAILURE(rc))4903 if (RT_FAILURE(rc)) 4904 4904 goto out; 4905 4905 … … 4923 4923 void *pTask; 4924 4924 rc = pImage->pInterfaceAsyncIOCallbacks->pfnPrepareRead(pImage->pInterfaceAsyncIO->pvUser, pExtent->pFile->pStorage, 4925 VMDK_SECTOR2BYTE(uSectorExtentRel), 4925 VMDK_SECTOR2BYTE(uSectorExtentRel), 4926 4926 (uint8_t *)paSegCurrent->pvSeg + uOffsetInCurrentSegment, 4927 4927 cbToRead, &pTask); 4928 if ( VBOX_FAILURE(rc))4928 if (RT_FAILURE(rc)) 4929 4929 { 4930 4930 AssertMsgFailed(("Preparing read failed rc=%Vrc\n", rc)); … … 4966 4966 } 4967 4967 case VMDKETYPE_ZERO: 4968 memset((uint8_t *)paSegCurrent->pvSeg + uOffsetInCurrentSegment, 0, cbToRead); 4968 memset((uint8_t *)paSegCurrent->pvSeg + uOffsetInCurrentSegment, 0, cbToRead); 4969 4969 break; 4970 4970 default: … … 5000 5000 NULL, pvUser, 5001 5001 NULL /* Nothing required after read. */); 5002 AssertMsg( VBOX_SUCCESS(rc), ("Failed to enqueue tasks rc=%Vrc\n", rc));5002 AssertMsg(RT_SUCCESS(rc), ("Failed to enqueue tasks rc=%Vrc\n", rc)); 5003 5003 } 5004 5004 … … 5037 5037 rc = vmdkFindExtent(pImage, VMDK_BYTE2SECTOR(uOffset), 5038 5038 &pExtent, &uSectorExtentRel); 5039 if ( VBOX_FAILURE(rc))5039 if (RT_FAILURE(rc)) 5040 5040 goto out; 5041 5041 … … 5059 5059 void *pTask; 5060 5060 rc = pImage->pInterfaceAsyncIOCallbacks->pfnPrepareWrite(pImage->pInterfaceAsyncIO->pvUser, pExtent->pFile->pStorage, 5061 VMDK_SECTOR2BYTE(uSectorExtentRel), 5061 VMDK_SECTOR2BYTE(uSectorExtentRel), 5062 5062 (uint8_t *)paSegCurrent->pvSeg + uOffsetInCurrentSegment, 5063 5063 cbToWrite, &pTask); 5064 if ( VBOX_FAILURE(rc))5064 if (RT_FAILURE(rc)) 5065 5065 { 5066 5066 AssertMsgFailed(("Preparing read failed rc=%Vrc\n", rc)); … … 5134 5134 rc = pImage->pInterfaceAsyncIOCallbacks->pfnTasksSubmit(pImage->pInterfaceAsyncIO->pvUser, 5135 5135 pImage->apTask, cTasksToSubmit, 5136 NULL, pvUser, 5136 NULL, pvUser, 5137 5137 NULL /* Nothing required after read. */); 5138 AssertMsg( VBOX_SUCCESS(rc), ("Failed to enqueue tasks rc=%Vrc\n", rc));5138 AssertMsg(RT_SUCCESS(rc), ("Failed to enqueue tasks rc=%Vrc\n", rc)); 5139 5139 } 5140 5140
Note:
See TracChangeset
for help on using the changeset viewer.