Changeset 14321 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Nov 18, 2008 5:20:18 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/VHDHDDCore.cpp
r13840 r14321 468 468 469 469 pImage->u64DataOffset = RT_BE2H_U64(vhdFooter.DataOffset); 470 LogFlow (("%s: DataOffset=%llu\n", __FUNCTION__, pImage->u64DataOffset));470 LogFlowFunc(("DataOffset=%llu\n", pImage->u64DataOffset)); 471 471 472 472 if (pImage->enmImageType == VD_IMAGE_TYPE_NORMAL || pImage->enmImageType == VD_IMAGE_TYPE_DIFF) … … 524 524 525 525 pImage->cbDataBlock = RT_BE2H_U32(vhdDynamicDiskHeader.BlockSize); 526 LogFlow (("%s: BlockSize=%u\n", __FUNCTION__, pImage->cbDataBlock));526 LogFlowFunc(("BlockSize=%u\n", pImage->cbDataBlock)); 527 527 pImage->cBlockAllocationTableEntries = RT_BE2H_U32(vhdDynamicDiskHeader.MaxTableEntries); 528 LogFlow (("%s: MaxTableEntries=%lu\n", __FUNCTION__, pImage->cBlockAllocationTableEntries));528 LogFlowFunc(("MaxTableEntries=%lu\n", pImage->cBlockAllocationTableEntries)); 529 529 AssertMsg(!(pImage->cbDataBlock % 512), ("%s: Data block size is not a multiple of 512!!\n", __FUNCTION__)); 530 530 531 531 pImage->cSectorsPerDataBlock = pImage->cbDataBlock / 512; 532 LogFlow (("%s: SectorsPerDataBlock=%u\n", __FUNCTION__, pImage->cSectorsPerDataBlock));532 LogFlowFunc(("SectorsPerDataBlock=%u\n", pImage->cSectorsPerDataBlock)); 533 533 534 534 /* … … 538 538 pImage->cbDataBlockBitmap = pImage->cSectorsPerDataBlock / 8; 539 539 pImage->cDataBlockBitmapSectors = pImage->cbDataBlockBitmap / 512; 540 LogFlow (("%s: cbDataBlockBitmap=%u\n", __FUNCTION__, pImage->cbDataBlockBitmap));540 LogFlowFunc(("cbDataBlockBitmap=%u\n", pImage->cbDataBlockBitmap)); 541 541 542 542 pImage->pu8Bitmap = (uint8_t *)RTMemAllocZ(pImage->cbDataBlockBitmap); … … 552 552 */ 553 553 uBlockAllocationTableOffset = RT_BE2H_U64(vhdDynamicDiskHeader.TableOffset); 554 LogFlow (("%s: uBlockAllocationTableOffset=%llu\n", __FUNCTION__, uBlockAllocationTableOffset));554 LogFlowFunc(("uBlockAllocationTableOffset=%llu\n", uBlockAllocationTableOffset)); 555 555 pImage->uBlockAllocationTableOffset = uBlockAllocationTableOffset; 556 556 rc = RTFileReadAt(pImage->File, uBlockAllocationTableOffset, pBlockAllocationTable, pImage->cBlockAllocationTableEntries * sizeof(uint32_t), NULL); 557 557 pImage->uDataBlockStart = uBlockAllocationTableOffset + pImage->cBlockAllocationTableEntries * sizeof(uint32_t); 558 LogFlow (("%s: uDataBlockStart=%llu\n", __FUNCTION__, pImage->uDataBlockStart));558 LogFlowFunc(("uDataBlockStart=%llu\n", pImage->uDataBlockStart)); 559 559 560 560 /* … … 612 612 PVHDIMAGE pImage = (PVHDIMAGE)pBackendData; 613 613 614 Assert (pImage);614 AssertPtr(pImage); 615 615 616 616 if (pImage) … … 625 625 int rc = VINF_SUCCESS; 626 626 627 Assert (pImage);628 Assert (penmImageType);627 AssertPtr(pImage); 628 AssertPtr(penmImageType); 629 629 630 630 if (pImage) … … 641 641 int rc; 642 642 643 Assert (pImage);643 AssertPtr(pImage); 644 644 645 645 if (pImage) … … 656 656 rc = VERR_VDI_NOT_OPENED; 657 657 658 LogFlow(("%s: returned %Rrc (CHS=%u/%u/%u)\n", __FUNCTION__, rc, 659 pImage->PCHSGeometry.cCylinders, pImage->PCHSGeometry.cHeads, pImage->PCHSGeometry.cSectors)); 658 LogFlowFunc(("returned %Rrc (CHS=%u/%u/%u)\n", rc, pImage->PCHSGeometry.cCylinders, pImage->PCHSGeometry.cHeads, pImage->PCHSGeometry.cSectors)); 660 659 return rc; 661 660 } … … 666 665 int rc; 667 666 668 Assert (pImage);667 AssertPtr(pImage); 669 668 670 669 if (pImage) … … 683 682 684 683 out: 685 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));684 LogFlowFunc(("returned %Rrc\n", rc)); 686 685 return rc; 687 686 } … … 692 691 int rc; 693 692 694 Assert (pImage);693 AssertPtr(pImage); 695 694 696 695 if (pImage) … … 707 706 rc = VERR_VDI_NOT_OPENED; 708 707 709 LogFlow(("%s: returned %Rrc (CHS=%u/%u/%u)\n", __FUNCTION__, rc, 710 pImage->LCHSGeometry.cCylinders, pImage->LCHSGeometry.cHeads, pImage->LCHSGeometry.cSectors)); 708 LogFlowFunc(("returned %Rrc (CHS=%u/%u/%u)\n", rc, pImage->LCHSGeometry.cCylinders, pImage->LCHSGeometry.cHeads, pImage->LCHSGeometry.cSectors)); 711 709 return rc; 712 710 } … … 717 715 int rc; 718 716 719 Assert (pImage);717 AssertPtr(pImage); 720 718 721 719 if (pImage) … … 734 732 735 733 out: 736 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));734 LogFlowFunc(("returned %Rrc\n", rc)); 737 735 return rc; 738 736 } … … 743 741 unsigned uImageFlags; 744 742 745 Assert (pImage);743 AssertPtr(pImage); 746 744 747 745 if (pImage) … … 750 748 uImageFlags = 0; 751 749 752 LogFlow (("%s: returned %#x\n", __FUNCTION__, uImageFlags));750 LogFlowFunc(("returned %#x\n", uImageFlags)); 753 751 return uImageFlags; 754 752 } … … 759 757 unsigned uOpenFlags; 760 758 761 Assert (pImage);759 AssertPtr(pImage); 762 760 763 761 if (pImage) … … 766 764 uOpenFlags = 0; 767 765 768 LogFlow (("%s: returned %d\n", __FUNCTION__, uOpenFlags));766 LogFlowFunc(("returned %d\n", uOpenFlags)); 769 767 return uOpenFlags; 770 768 } … … 793 791 794 792 out: 795 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));793 LogFlowFunc(("returned %Rrc\n", rc)); 796 794 return rc; 797 795 } … … 834 832 } 835 833 836 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));834 LogFlowFunc(("returned %Rrc\n", rc)); 837 835 return rc; 838 836 } … … 857 855 } 858 856 859 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));857 LogFlowFunc(("returned %Rrc\n", rc)); 860 858 return rc; 861 859 } … … 866 864 int rc = VINF_SUCCESS; 867 865 868 LogFlow (("%s: pBackendData=%p uOffset=%#llx pvBuf=%p cbRead=%u pcbActuallyRead=%p\n", __FUNCTION__, pBackendData, uOffset, pvBuf, cbRead, pcbActuallyRead));866 LogFlowFunc(("pBackendData=%p uOffset=%#llx pvBuf=%p cbRead=%u pcbActuallyRead=%p\n", pBackendData, uOffset, pvBuf, cbRead, pcbActuallyRead)); 869 867 870 868 if (uOffset + cbRead > pImage->cbSize) … … 883 881 uint64_t uVhdOffset; 884 882 885 LogFlow (("%s: cBlockAllocationTableEntry=%u cBatEntryIndex=%u\n", __FUNCTION__, cBlockAllocationTableEntry, cBATEntryIndex));886 LogFlow (("%s: BlockAllocationEntry=%u\n", __FUNCTION__, pImage->pBlockAllocationTable[cBlockAllocationTableEntry]));883 LogFlowFunc(("cBlockAllocationTableEntry=%u cBatEntryIndex=%u\n", cBlockAllocationTableEntry, cBATEntryIndex)); 884 LogFlowFunc(("BlockAllocationEntry=%u\n", pImage->pBlockAllocationTable[cBlockAllocationTableEntry])); 887 885 888 886 /* … … 897 895 898 896 uVhdOffset = ((uint64_t)pImage->pBlockAllocationTable[cBlockAllocationTableEntry] + pImage->cDataBlockBitmapSectors + cBATEntryIndex) * 512; 899 Log(("%s: uVhdOffset=%llu cbRead=%u\n", __FUNCTION__,uVhdOffset, cbRead));897 Log(("%s: uVhdOffset=%llu cbRead=%u\n", uVhdOffset, cbRead)); 900 898 901 899 /* … … 948 946 cbRead = cSectors * VHD_SECTOR_SIZE; 949 947 950 Log(("%s: uVhdOffset=%llu cbRead=%u\n", __FUNCTION__,uVhdOffset, cbRead));948 Log(("%s: uVhdOffset=%llu cbRead=%u\n", uVhdOffset, cbRead)); 951 949 rc = RTFileReadAt(pImage->File, uVhdOffset, pvBuf, cbRead, NULL); 952 950 } … … 977 975 978 976 cbRead = cSectors * VHD_SECTOR_SIZE; 979 Log(("%s: Sectors free: uVhdOffset=%llu cbRead=%u\n", __FUNCTION__,uVhdOffset, cbRead));977 Log(("%s: Sectors free: uVhdOffset=%llu cbRead=%u\n", uVhdOffset, cbRead)); 980 978 rc = VERR_VDI_BLOCK_FREE; 981 979 } … … 999 997 } 1000 998 1001 static int vhdWrite(void *pBackendData, uint64_t uOffset, const void *pvBuf, size_t cb Write, size_t *pcbWriteProcess, size_t *pcbPreRead, size_t *pcbPostRead, unsigned fWrite)999 static int vhdWrite(void *pBackendData, uint64_t uOffset, const void *pvBuf, size_t cbToWrite, size_t *pcbWriteProcess, size_t *pcbPreRead, size_t *pcbPostRead, unsigned fWrite) 1002 1000 { 1003 1001 PVHDIMAGE pImage = (PVHDIMAGE)pBackendData; 1004 1002 int rc = VINF_SUCCESS; 1005 1003 1006 LogFlow(("%s: pBackendData=%p uOffset=%llu pvBuf=%p cbWrite=%u pcbWriteProcess=%p pcbPreRead=%p pcbPostRead=%p fWrite=%u\n", 1007 __FUNCTION__, pBackendData, uOffset, pvBuf, cbWrite, pcbPreRead, pcbPostRead, fWrite)); 1008 1004 LogFlowFunc(("pBackendData=%p uOffset=%llu pvBuf=%p cbToWrite=%u pcbWriteProcess=%p pcbPreRead=%p pcbPostRead=%p fWrite=%u\n", 1005 pBackendData, uOffset, pvBuf, cbToWrite, pcbPreRead, pcbPostRead, fWrite)); 1006 1007 AssertPtr(pImage); 1009 1008 Assert(uOffset % 512 == 0); 1010 Assert(cb Write % 512 == 0);1009 Assert(cbToWrite % 512 == 0); 1011 1010 1012 1011 if (pImage->pBlockAllocationTable) … … 1024 1023 * and we need to allocate a new block. 1025 1024 */ 1025 /** @todo Integrate this properly into the unallocated block logic. 1026 * The current code wouldn't be able to handle diff images at all. */ 1026 1027 if (pImage->pBlockAllocationTable[cBlockAllocationTableEntry] == ~0U) 1027 1028 { … … 1053 1054 * Clip write range. 1054 1055 */ 1055 cb Write = RT_MIN(cbWrite, (pImage->cbDataBlock - (cBATEntryIndex * 512)));1056 RTFileWriteAt(pImage->File, uVhdOffset, pvBuf, cb Write, NULL);1056 cbToWrite = RT_MIN(cbToWrite, (pImage->cbDataBlock - (cBATEntryIndex * 512))); 1057 RTFileWriteAt(pImage->File, uVhdOffset, pvBuf, cbToWrite, NULL); 1057 1058 1058 1059 /* Read in the block's bitmap. */ … … 1063 1064 { 1064 1065 /* Set the bits for all sectors having been written. */ 1065 for (uint32_t iSector = 0; iSector < (cb Write / VHD_SECTOR_SIZE); iSector++)1066 for (uint32_t iSector = 0; iSector < (cbToWrite / VHD_SECTOR_SIZE); iSector++) 1066 1067 { 1067 1068 uint32_t iBitmap = cBATEntryIndex / 8; /* Byte in the block bitmap. */ … … 1081 1082 else 1082 1083 { 1083 rc = RTFileWriteAt(pImage->File, uOffset, pvBuf, cb Write, NULL);1084 rc = RTFileWriteAt(pImage->File, uOffset, pvBuf, cbToWrite, NULL); 1084 1085 } 1085 1086 1086 1087 if (pcbWriteProcess) 1087 *pcbWriteProcess = cb Write;1088 *pcbWriteProcess = cbToWrite; 1088 1089 1089 1090 return rc; … … 1136 1137 PVHDIMAGE pImage = (PVHDIMAGE)pBackendData; 1137 1138 1138 Assert (pImage);1139 1140 if (pImage) 1141 { 1142 Log(("%s: cbSize=%llu\n", __FUNCTION__,pImage->cbSize));1139 AssertPtr(pImage); 1140 1141 if (pImage) 1142 { 1143 Log(("%s: cbSize=%llu\n", pImage->cbSize)); 1143 1144 return pImage->cbSize; 1144 1145 } … … 1151 1152 PVHDIMAGE pImage = (PVHDIMAGE)pBackendData; 1152 1153 1153 Assert (pImage);1154 AssertPtr(pImage); 1154 1155 1155 1156 if (pImage) … … 1171 1172 int rc; 1172 1173 1173 Assert (pImage);1174 AssertPtr(pImage); 1174 1175 1175 1176 if (pImage) … … 1180 1181 else 1181 1182 rc = VERR_VDI_NOT_OPENED; 1182 LogFlow (("%s: returned %Rrc (%RTuuid)\n", __FUNCTION__, rc, pUuid));1183 LogFlowFunc(("returned %Rrc (%RTuuid)\n", rc, pUuid)); 1183 1184 return rc; 1184 1185 } … … 1189 1190 int rc; 1190 1191 1191 LogFlowFunc((" 1192 Assert (pImage);1192 LogFlowFunc(("Uuid=%RTuuid\n", pUuid)); 1193 AssertPtr(pImage); 1193 1194 1194 1195 if (pImage) … … 1200 1201 else 1201 1202 rc = VERR_VDI_NOT_OPENED; 1202 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));1203 LogFlowFunc(("returned %Rrc\n", rc)); 1203 1204 return rc; 1204 1205 } … … 1209 1210 int rc; 1210 1211 1211 Assert (pImage);1212 AssertPtr(pImage); 1212 1213 1213 1214 if (pImage) … … 1218 1219 rc = VERR_VDI_NOT_OPENED; 1219 1220 1220 LogFlow (("%s: returned %Rrc comment='%s'\n", __FUNCTION__, rc, pszComment));1221 LogFlowFunc(("returned %Rrc comment='%s'\n", rc, pszComment)); 1221 1222 return rc; 1222 1223 } … … 1227 1228 int rc; 1228 1229 1229 LogFlowFunc((" comment'%s'\n", pszComment));1230 Assert (pImage);1230 LogFlowFunc(("pszComment='%s'\n", pszComment)); 1231 AssertPtr(pImage); 1231 1232 1232 1233 if (pImage) … … 1238 1239 rc = VERR_VDI_NOT_OPENED; 1239 1240 1240 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));1241 LogFlowFunc(("returned %Rrc\n", rc)); 1241 1242 return rc; 1242 1243 } … … 1247 1248 int rc; 1248 1249 1249 Assert (pImage);1250 AssertPtr(pImage); 1250 1251 1251 1252 if (pImage) … … 1255 1256 else 1256 1257 rc = VERR_VDI_NOT_OPENED; 1257 LogFlow (("%s: returned %Rrc (%RTuuid)\n", __FUNCTION__, rc, pUuid));1258 LogFlowFunc(("returned %Rrc (%RTuuid)\n", rc, pUuid)); 1258 1259 return rc; 1259 1260 } … … 1264 1265 int rc; 1265 1266 1266 LogFlowFunc((" 1267 Assert (pImage);1267 LogFlowFunc(("Uuid=%RTuuid\n", pUuid)); 1268 AssertPtr(pImage); 1268 1269 1269 1270 if (pImage) … … 1273 1274 else 1274 1275 rc = VERR_VDI_NOT_OPENED; 1275 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));1276 LogFlowFunc(("returned %Rrc\n", rc)); 1276 1277 return rc; 1277 1278 } … … 1282 1283 int rc; 1283 1284 1284 Assert (pImage);1285 AssertPtr(pImage); 1285 1286 1286 1287 if (pImage) … … 1291 1292 else 1292 1293 rc = VERR_VDI_NOT_OPENED; 1293 LogFlow (("%s: returned %Rrc (%RTuuid)\n", __FUNCTION__, rc, pUuid));1294 LogFlowFunc(("returned %Rrc (%RTuuid)\n", rc, pUuid)); 1294 1295 return rc; 1295 1296 } … … 1301 1302 1302 1303 LogFlowFunc((" %RTuuid\n", pUuid)); 1303 Assert (pImage);1304 AssertPtr(pImage); 1304 1305 1305 1306 if (pImage && pImage->File != NIL_RTFILE) … … 1315 1316 else 1316 1317 rc = VERR_VDI_NOT_OPENED; 1317 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));1318 LogFlowFunc(("returned %Rrc\n", rc)); 1318 1319 return rc; 1319 1320 } … … 1324 1325 int rc; 1325 1326 1326 Assert (pImage);1327 AssertPtr(pImage); 1327 1328 1328 1329 if (pImage) … … 1332 1333 else 1333 1334 rc = VERR_VDI_NOT_OPENED; 1334 LogFlow (("%s: returned %Rrc (%RTuuid)\n", __FUNCTION__, rc, pUuid));1335 LogFlowFunc(("returned %Rrc (%RTuuid)\n", rc, pUuid)); 1335 1336 return rc; 1336 1337 } … … 1341 1342 int rc; 1342 1343 1343 LogFlow (("%s:%RTuuid\n", pUuid));1344 Assert (pImage);1344 LogFlowFunc(("%RTuuid\n", pUuid)); 1345 AssertPtr(pImage); 1345 1346 1346 1347 if (pImage) … … 1350 1351 else 1351 1352 rc = VERR_VDI_NOT_OPENED; 1352 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));1353 LogFlowFunc(("returned %Rrc\n", rc)); 1353 1354 return rc; 1354 1355 } … … 1721 1722 } 1722 1723 out: 1723 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));1724 LogFlowFunc(("returned %Rrc\n", rc)); 1724 1725 return rc; 1725 1726 } … … 1729 1730 PVHDIMAGE pImage = (PVHDIMAGE)pBackendData; 1730 1731 1731 Assert (pImage);1732 AssertPtr(pImage); 1732 1733 if (pImage) 1733 1734 { … … 1742 1743 PVHDIMAGE pImage = (PVHDIMAGE)pvBackendData; 1743 1744 1744 Assert (pImage);1745 AssertPtr(pImage); 1745 1746 if (pImage) 1746 1747 { … … 1752 1753 else 1753 1754 rc = VERR_VDI_NOT_OPENED; 1754 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));1755 LogFlowFunc(("returned %Rrc\n", rc)); 1755 1756 return rc; 1756 1757 } … … 1761 1762 PVHDIMAGE pImage = (PVHDIMAGE)pvBackendData; 1762 1763 1763 Assert (pImage);1764 AssertPtr(pImage); 1764 1765 if (pImage) 1765 1766 vhdTime2RtTime(pTimeStamp, pImage->u32ParentTimeStamp); 1766 1767 else 1767 1768 rc = VERR_VDI_NOT_OPENED; 1768 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));1769 LogFlowFunc(("returned %Rrc\n", rc)); 1769 1770 return rc; 1770 1771 } … … 1775 1776 PVHDIMAGE pImage = (PVHDIMAGE)pvBackendData; 1776 1777 1777 Assert (pImage);1778 AssertPtr(pImage); 1778 1779 if (pImage) 1779 1780 { … … 1788 1789 else 1789 1790 rc = VERR_VDI_NOT_OPENED; 1790 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));1791 LogFlowFunc(("returned %Rrc\n", rc)); 1791 1792 return rc; 1792 1793 } … … 1797 1798 PVHDIMAGE pImage = (PVHDIMAGE)pvBackendData; 1798 1799 1799 Assert (pImage);1800 AssertPtr(pImage); 1800 1801 if (pImage) 1801 1802 *ppszParentFilename = RTStrDup(pImage->pszParentFilename); 1802 1803 else 1803 1804 rc = VERR_VDI_NOT_OPENED; 1804 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));1805 LogFlowFunc(("returned %Rrc\n", rc)); 1805 1806 return rc; 1806 1807 } … … 1811 1812 PVHDIMAGE pImage = (PVHDIMAGE)pvBackendData; 1812 1813 1813 Assert (pImage);1814 AssertPtr(pImage); 1814 1815 if (pImage) 1815 1816 { … … 1829 1830 else 1830 1831 rc = VERR_VDI_NOT_OPENED; 1831 LogFlow (("%s: returned %Rrc\n", __FUNCTION__, rc));1832 LogFlowFunc(("returned %Rrc\n", rc)); 1832 1833 return rc; 1833 1834 } … … 1846 1847 } 1847 1848 1848 static int vhdAsyncWrite(void *pvBackendData, uint64_t uOffset, size_t cb Write,1849 static int vhdAsyncWrite(void *pvBackendData, uint64_t uOffset, size_t cbToWrite, 1849 1850 PPDMDATASEG paSeg, unsigned cSeg, void *pvUser) 1850 1851 {
Note:
See TracChangeset
for help on using the changeset viewer.