- Timestamp:
- Nov 24, 2009 3:21:07 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp
r24778 r24916 343 343 /** 344 344 * Maximum number of lines in a descriptor file. Not worth the effort of 345 * making it variable. Descriptor files are generally very short (~20 lines). 345 * making it variable. Descriptor files are generally very short (~20 lines), 346 * with the exception of sparse files split in 2G chunks, which need for the 347 * maximum size (almost 2T) exactly 1025 lines for the disk database. 346 348 */ 347 #define VMDK_DESCRIPTOR_LINES_MAX 1 00U349 #define VMDK_DESCRIPTOR_LINES_MAX 1100U 348 350 349 351 /** … … 2993 2995 else 2994 2996 { 2995 pImage->cbDescAlloc = VMDK_SECTOR2BYTE(20); 2997 /* Allocate at least 10K, and make sure that there is 5K free space 2998 * in case new entries need to be added to the descriptor. Never 2999 * alocate more than 128K, because that's no valid descriptor file 3000 * and will result in the correct "truncated read" error handling. */ 3001 uint64_t cbSize; 3002 rc = vmdkFileGetSize(pFile, &cbSize); 3003 if (RT_FAILURE(rc)) 3004 goto out; 3005 if (cbSize % VMDK_SECTOR2BYTE(10)) 3006 cbSize += VMDK_SECTOR2BYTE(20) - cbSize % VMDK_SECTOR2BYTE(10); 3007 else 3008 cbSize += VMDK_SECTOR2BYTE(10); 3009 cbSize = RT_MIN(cbSize, _128K); 3010 pImage->cbDescAlloc = RT_MAX(VMDK_SECTOR2BYTE(20), cbSize); 2996 3011 pImage->pDescData = (char *)RTMemAllocZ(pImage->cbDescAlloc); 2997 3012 if (!pImage->pDescData) … … 4549 4564 pImage->pDescData = NULL; 4550 4565 pImage->pVDIfsDisk = NULL; 4551 pImage->cbDescAlloc = VMDK_SECTOR2BYTE(20); 4566 /* Descriptors for split images can be pretty large, especially if the 4567 * filename is long. So prepare for the worst, and allocate quite some 4568 * memory for the descriptor in this case. */ 4569 if (uImageFlags & VD_VMDK_IMAGE_FLAGS_SPLIT_2G) 4570 pImage->cbDescAlloc = VMDK_SECTOR2BYTE(200); 4571 else 4572 pImage->cbDescAlloc = VMDK_SECTOR2BYTE(20); 4552 4573 pImage->pDescData = (char *)RTMemAllocZ(pImage->cbDescAlloc); 4553 4574 if (!pImage->pDescData)
Note:
See TracChangeset
for help on using the changeset viewer.