Changeset 32610 in vbox
- Timestamp:
- Sep 17, 2010 2:58:23 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp
r32598 r32610 1419 1419 } 1420 1420 pExtent->pGD = pGD; 1421 pRGD = (uint32_t *)RTMemAllocZ(cbGD); 1422 if (!pRGD) 1423 { 1424 rc = VERR_NO_MEMORY; 1425 goto out; 1426 } 1427 pExtent->pRGD = pRGD; 1421 if (!(pImage->uImageFlags & VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED)) 1422 { 1423 pRGD = (uint32_t *)RTMemAllocZ(cbGD); 1424 if (!pRGD) 1425 { 1426 rc = VERR_NO_MEMORY; 1427 goto out; 1428 } 1429 pExtent->pRGD = pRGD; 1430 } 1431 else 1432 pExtent->pRGD = NULL; 1428 1433 1429 1434 if (uStartSector != VMDK_GD_AT_END) 1430 1435 { 1431 cbOverhead = RT_ALIGN_64(VMDK_SECTOR2BYTE(uStartSector) + 2 * (cbGDRounded + cbGTRounded), VMDK_SECTOR2BYTE(pExtent->cSectorsPerGrain)); 1432 /* For streamOptimized extents put the end-of-stream marker at the end. */ 1436 cbOverhead = VMDK_SECTOR2BYTE(uStartSector) + cbGDRounded + cbGTRounded; 1437 /* For streamOptimized extents there is only one grain directory, 1438 * and for all others take redundant grain directory into account. */ 1433 1439 if (pImage->uImageFlags & VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED) 1434 rc = vmdkFileSetSize(pImage, pExtent->pFile, cbOverhead + 512); 1440 { 1441 cbOverhead = RT_ALIGN_64(cbOverhead, 1442 VMDK_SECTOR2BYTE(pExtent->cSectorsPerGrain)); 1443 if (pExtent->fFooter) 1444 rc = vmdkFileSetSize(pImage, pExtent->pFile, cbOverhead); 1445 else 1446 rc = vmdkFileSetSize(pImage, pExtent->pFile, cbOverhead + 512); 1447 } 1435 1448 else 1449 { 1450 cbOverhead += cbGDRounded + cbGTRounded; 1451 cbOverhead = RT_ALIGN_64(cbOverhead, 1452 VMDK_SECTOR2BYTE(pExtent->cSectorsPerGrain)); 1436 1453 rc = vmdkFileSetSize(pImage, pExtent->pFile, cbOverhead); 1454 } 1437 1455 if (RT_FAILURE(rc)) 1438 1456 goto out; … … 1442 1460 else 1443 1461 { 1444 cbOverhead = VMDK_SECTOR2BYTE(uStartSector); 1445 pExtent->uSectorRGD = uStartSector; 1462 cbOverhead = 512 + pImage->cbDescAlloc; 1446 1463 pExtent->uSectorGD = uStartSector; 1447 1464 } … … 4072 4089 rc = vmdkFileGetSize(pImage, pExtent->pFile, &uFileOffset); 4073 4090 AssertRC(rc); 4091 /* Align to sector, as the previous write could have been any size. */ 4074 4092 uFileOffset = RT_ALIGN_64(uFileOffset, 512); 4075 4093 … … 4331 4349 4332 4350 pExtent->enmAccess = VMDKACCESS_READONLY; 4333 pExtent->fUncleanShutdown = true;4351 pExtent->fUncleanShutdown = false; 4334 4352 pExtent->cNominalSectors = VMDK_BYTE2SECTOR(cbSize); 4335 4353 pExtent->uSectorOffset = 0; … … 4445 4463 pfnProgress(pvUser, uPercentStart + uPercentSpan * 50 / 100); 4446 4464 4465 /* Now that all descriptor entries are complete, shrink it to the minimum 4466 * size. It will never be changed afterwards anyway. */ 4467 pExtent->cDescriptorSectors = VMDK_BYTE2SECTOR(RT_ALIGN_64( pImage->Descriptor.aLines[pImage->Descriptor.cLines] 4468 - pImage->Descriptor.aLines[0], 512)); 4447 4469 rc = vmdkWriteMetaSparseExtent(pImage, &pImage->pExtents[0], 0); 4448 4470 if (RT_FAILURE(rc)) … … 5637 5659 /* Always return failure, to avoid opening other VMDK files via this 5638 5660 * special VMDK streamOptimized format backend. */ 5639 rc = VERR_ VD_VMDK_INVALID_HEADER;5661 rc = VERR_NOT_SUPPORTED; 5640 5662 5641 5663 out: … … 5873 5895 if (RT_FAILURE(rc)) 5874 5896 goto out; 5875 if (uFileOffset % 512) 5876 { 5877 rc = VERR_INTERNAL_ERROR; 5878 goto out; 5879 } 5897 /* Align to sector, as the previous write could have been any size. */ 5898 uFileOffset = RT_ALIGN_64(uFileOffset, 512); 5880 5899 5881 5900 /* Paranoia check: extent type, grain table buffer presence and
Note:
See TracChangeset
for help on using the changeset viewer.