- Timestamp:
- Jan 18, 2007 4:56:28 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/src/VBox/Devices/Storage/VBoxHDD.cpp (modified) (33 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/VBoxHDD.cpp
r139 r150 35 35 #include <iprt/uuid.h> 36 36 #include <iprt/file.h> 37 38 #include <string.h> 37 #include <iprt/string.h> 39 38 40 39 #include "Builtins.h" … … 743 742 /* Check common header parameters. */ 744 743 745 bool f ailure= false;744 bool fFailed = false; 746 745 747 746 if ( getImageType(pHeader) < VDI_IMAGE_TYPE_FIRST … … 749 748 { 750 749 LogRel(("VDI: bad image type %d\n", getImageType(pHeader))); 751 f ailure= true;750 fFailed = true; 752 751 } 753 752 … … 755 754 { 756 755 LogRel(("VDI: bad image flags %08x\n", getImageFlags(pHeader))); 757 f ailure= true;756 fFailed = true; 758 757 } 759 758 … … 762 761 LogRel(("VDI: wrong sector size (%d != %d)\n", 763 762 (getImageGeometry(pHeader))->cbSector, VDI_GEOMETRY_SECTOR_SIZE)); 764 f ailure= true;763 fFailed = true; 765 764 } 766 765 … … 773 772 getImageDiskSize(pHeader), getImageBlockSize(pHeader), 774 773 getImageBlocks(pHeader), getPowerOfTwo(getImageBlockSize(pHeader)))); 775 f ailure= true;774 fFailed = true; 776 775 } 777 776 … … 782 781 getImageBlocksAllocated(pHeader), getImageBlocks(pHeader), 783 782 getImageBlockSize(pHeader), getImageDiskSize(pHeader))); 784 f ailure= true;783 fFailed = true; 785 784 } 786 785 … … 790 789 LogRel(("VDI: wrong extra size (%d, %d)\n", 791 790 getImageExtraBlockSize(pHeader), getPowerOfTwo(getImageExtraBlockSize(pHeader)))); 792 f ailure= true;791 fFailed = true; 793 792 } 794 793 … … 797 796 LogRel(("VDI: wrong disk size (%d, %d, %lld)\n", 798 797 getImageBlockSize(pHeader), getImageBlocks(pHeader), getImageDiskSize(pHeader))); 799 f ailure= true;798 fFailed = true; 800 799 } 801 800 … … 803 802 { 804 803 LogRel(("VDI: uuid of creator is 0\n")); 805 f ailure= true;804 fFailed = true; 806 805 } 807 806 … … 809 808 { 810 809 LogRel(("VDI: uuid of modificator is 0\n")); 811 f ailure= true;812 } 813 814 return f ailure? VERR_VDI_INVALID_HEADER : VINF_SUCCESS;810 fFailed = true; 811 } 812 813 return fFailed ? VERR_VDI_INVALID_HEADER : VINF_SUCCESS; 815 814 } 816 815 … … 1928 1927 1929 1928 /** 1930 * @note Only used by tstVDI.1931 *1932 1929 * internal: commit last image(s) to selected previous image. 1933 1930 * note: all images accessed across this call must be opened in R/W mode. 1931 * @remark Only used by tstVDI. 1934 1932 */ 1935 1933 static int vdiCommitToImage(PVDIDISK pDisk, PVDIIMAGEDESC pDstImage, … … 2480 2478 /** 2481 2479 * Shrinks growing image file by removing zeroed data blocks. 2482 * @note Only used by vditool2483 2480 * 2484 2481 * @returns VBox status code. … … 2486 2483 * @param pfnProgress Progress callback. Optional. 2487 2484 * @param pvUser User argument for the progress callback. 2485 * @remark Only used by vditool 2488 2486 */ 2489 2487 IDER3DECL(int) VDIShrinkImage(const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser) … … 2533 2531 unsigned cBlocksAllocated2 = (unsigned)(cbData >> pImage->uShiftIndex2Offset); 2534 2532 if (cbData != (uint64_t)cBlocksAllocated << pImage->uShiftIndex2Offset) 2535 Log(("VDIShrinkImage: invalid image file length, cbBlock=%u cBlocks=%u " 2536 "cBlocksAllocated=%u cBlocksAllocated2=%u cbData=%llu\n", 2533 Log(("VDIShrinkImage: invalid image file length, cbBlock=%u cBlocks=%u cBlocksAllocated=%u cBlocksAllocated2=%u cbData=%llu\n", 2537 2534 cbBlock, cBlocks, cBlocksAllocated, cBlocksAllocated2, cbData)); 2538 2535 … … 2542 2539 if (!paBlocks2) 2543 2540 { 2544 Log(("VDIShrinkImage: failed to allocate paBlocks2 buffer (%u bytes)\n", 2545 sizeof(VDIIMAGEBLOCKPOINTER) * cBlocks)); 2541 Log(("VDIShrinkImage: failed to allocate paBlocks2 buffer (%u bytes)\n", sizeof(VDIIMAGEBLOCKPOINTER) * cBlocks)); 2546 2542 vdiCloseImage(pImage); 2547 2543 return VERR_NO_MEMORY; … … 2571 2567 else 2572 2568 { 2573 Log(("VDIShrinkImage: block n=%u -> uBlock=%u is out of blocks range! (cbBlock=%u " 2574 "cBlocks=%u cBlocksAllocated=%u cBlocksAllocated2=%u cbData=%llu)\n", 2569 Log(("VDIShrinkImage: block n=%u -> uBlock=%u is out of blocks range! (cbBlock=%u cBlocks=%u cBlocksAllocated=%u cBlocksAllocated2=%u cbData=%llu)\n", 2575 2570 n, uBlock, cbBlock, cBlocks, cBlocksAllocated, cBlocksAllocated2, cbData)); 2576 2571 /* free link to invalid block. */ … … 2596 2591 if (VBOX_FAILURE(rc)) 2597 2592 { 2598 Log(("VDIShrinkImage: seek rc=%Vrc filename=\"%s\" uBlock=%u cBlocks=%u " 2599 "cBlocksAllocated=%u cBlocksAllocated2=%u cbData=%llu\n", 2600 rc, pImage->szFilename, uBlock, cBlocks, cBlocksAllocated, 2601 cBlocksAllocated2, cbData)); 2593 Log(("VDIShrinkImage: seek rc=%Vrc filename=\"%s\" uBlock=%u cBlocks=%u cBlocksAllocated=%u cBlocksAllocated2=%u cbData=%llu\n", 2594 rc, pImage->szFilename, uBlock, cBlocks, cBlocksAllocated, cBlocksAllocated2, cbData)); 2602 2595 break; 2603 2596 } … … 2605 2598 if (VBOX_FAILURE(rc)) 2606 2599 { 2607 Log(("VDIShrinkImage: read rc=%Vrc filename=\"%s\" cbBlock=%u uBlock=%u " 2608 "cBlocks=%u cBlocksAllocated=%u cBlocksAllocated2=%u cbData=%llu\n", 2609 rc, pImage->szFilename, cbBlock, uBlock, cBlocks, cBlocksAllocated, 2610 cBlocksAllocated2, cbData)); 2600 Log(("VDIShrinkImage: read rc=%Vrc filename=\"%s\" cbBlock=%u uBlock=%u cBlocks=%u cBlocksAllocated=%u cBlocksAllocated2=%u cbData=%llu\n", 2601 rc, pImage->szFilename, cbBlock, uBlock, cBlocks, cBlocksAllocated, cBlocksAllocated2, cbData)); 2611 2602 break; 2612 2603 } … … 2633 2624 if (VBOX_FAILURE(rc)) 2634 2625 { 2635 Log(("VDIShrinkImage: seek(2) rc=%Vrc filename=\"%s\" uBlockWrite=%u " 2636 "cBlocks=%u cBlocksAllocated=%u cBlocksAllocated2=%u cbData=%llu\n", 2637 rc, pImage->szFilename, uBlockWrite, cBlocks, cBlocksAllocated, 2638 cBlocksAllocated2, cbData)); 2626 Log(("VDIShrinkImage: seek(2) rc=%Vrc filename=\"%s\" uBlockWrite=%u cBlocks=%u cBlocksAllocated=%u cBlocksAllocated2=%u cbData=%llu\n", 2627 rc, pImage->szFilename, uBlockWrite, cBlocks, cBlocksAllocated, cBlocksAllocated2, cbData)); 2639 2628 break; 2640 2629 } … … 2642 2631 if (VBOX_FAILURE(rc)) 2643 2632 { 2644 Log(("VDIShrinkImage: write rc=%Vrc filename=\"%s\" cbBlock=%u " 2645 "uBlockWrite=%u cBlocks=%u cBlocksAllocated=%u " 2646 "cBlocksAllocated2=%u cbData=%llu\n", 2647 rc, pImage->szFilename, cbBlock, uBlockWrite, cBlocks, 2648 cBlocksAllocated, cBlocksAllocated2, cbData)); 2633 Log(("VDIShrinkImage: write rc=%Vrc filename=\"%s\" cbBlock=%u uBlockWrite=%u cBlocks=%u cBlocksAllocated=%u cBlocksAllocated2=%u cbData=%llu\n", 2634 rc, pImage->szFilename, cbBlock, uBlockWrite, cBlocks, cBlocksAllocated, cBlocksAllocated2, cbData)); 2649 2635 break; 2650 2636 } … … 2718 2704 /** 2719 2705 * Converts image file from older VDI formats to current one. 2720 * @note Only used by vditool2721 2706 * 2722 2707 * @returns VBox status code. … … 2724 2709 * @param pfnProgress Progress callback. Optional. 2725 2710 * @param pvUser User argument for the progress callback. 2711 * @remark Only used by vditool 2726 2712 */ 2727 2713 IDER3DECL(int) VDIConvertImage(const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser) … … 4003 3989 * Note that in case of unrecoverable error all images of HDD container will be closed. 4004 3990 * 4005 * @note Only used by tstVDI.4006 *4007 3991 * @returns VBox status code. 4008 3992 * @param pDisk Pointer to VDI HDD container. 4009 3993 * @param pfnProgress Progress callback. Optional. 4010 3994 * @param pvUser User argument for the progress callback. 3995 * @remark Only used by tstVDI. 4011 3996 */ 4012 3997 IDER3DECL(int) VDIDiskCommitLastDiff(PVDIDISK pDisk, PFNVMPROGRESS pfnProgress, void *pvUser) … … 4067 4052 4068 4053 /** 4069 * @note Only used by tstVDI.4070 *4071 4054 * Creates and opens a new differencing image file in HDD container. 4072 4055 * See comments for VDIDiskOpenImage function about differencing images. … … 4078 4061 * @param pfnProgress Progress callback. Optional. 4079 4062 * @param pvUser User argument for the progress callback. 4063 * @remark Only used by tstVDI. 4080 4064 */ 4081 4065 IDER3DECL(int) VDIDiskCreateOpenDifferenceImage(PVDIDISK pDisk, const char *pszFilename, … … 4116 4100 4117 4101 /** 4118 * @note Only used by tstVDI.4119 *4120 4102 * internal: debug image dump. 4103 * 4104 * @remark Only used by tstVDI. 4121 4105 */ 4122 4106 static void vdiDumpImage(PVDIIMAGEDESC pImage) … … 4181 4165 /** 4182 4166 * Debug helper - dumps all opened images of HDD container into the log file. 4183 * @note Only used by tstVDI and vditool4184 4167 * 4185 4168 * @param pDisk Pointer to VDI HDD container. 4169 * @remark Only used by tstVDI and vditool 4186 4170 */ 4187 4171 IDER3DECL(void) VDIDiskDumpImages(PVDIDISK pDisk) … … 4269 4253 if (VBOX_FAILURE(rc)) 4270 4254 return PDMDRV_SET_ERROR(pDrvIns, rc, 4271 N_("VHDD: Configuration error: Querying \"Path\" as " 4272 "string failed")); 4255 N_("VHDD: Configuration error: Querying \"Path\" as string failed")); 4273 4256 4274 4257 bool fReadOnly; … … 4280 4263 MMR3HeapFree(pszName); 4281 4264 return PDMDRV_SET_ERROR(pDrvIns, rc, 4282 N_("VHDD: Configuration error: Querying \"ReadOnly\" as " 4283 "boolean failed")); 4265 N_("VHDD: Configuration error: Querying \"ReadOnly\" as boolean failed")); 4284 4266 } 4285 4267 … … 4311 4293 if (VBOX_FAILURE(rc)) 4312 4294 return PDMDRV_SET_ERROR(pDrvIns, rc, 4313 N_("VHDD: Configuration error: Querying \"Path\" as " 4314 "string failed")); 4295 N_("VHDD: Configuration error: Querying \"Path\" as string failed")); 4315 4296 4316 4297 /** True if the media is readonly. */ … … 4323 4304 MMR3HeapFree(pszName); 4324 4305 return PDMDRV_SET_ERROR(pDrvIns, rc, 4325 N_("VHDD: Configuration error: Querying \"ReadOnly\" as " 4326 "boolean failed")); 4327 return rc; 4306 N_("VHDD: Configuration error: Querying \"ReadOnly\" as boolean failed")); 4328 4307 } 4329 4308 … … 4334 4313 : VDI_OPEN_FLAGS_NORMAL); 4335 4314 if (VBOX_SUCCESS(rc)) 4336 Log(("vdiConstruct: Opened '%s' in %s mode\n", 4337 pszName, VDIDiskIsReadOnly(pData) ? "read-only" : "read-write")); 4315 Log(("vdiConstruct: Opened '%s' in %s mode\n", pszName, VDIDiskIsReadOnly(pData) ? "read-only" : "read-write")); 4338 4316 else 4339 4317 AssertMsgFailed(("Failed to open image '%s' rc=%Vrc\n", pszName, rc));
Note:
See TracChangeset
for help on using the changeset viewer.

