Changeset 46613 in vbox for trunk/src/VBox/Storage
- Timestamp:
- Jun 18, 2013 10:27:13 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 86497
- Location:
- trunk/src/VBox/Storage
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/DMG.cpp
r44529 r46613 741 741 dmgFlushImage(pThis); 742 742 743 vdIfIoIntFileClose(pThis->pIfIo, pThis->pStorage);743 rc = vdIfIoIntFileClose(pThis->pIfIo, pThis->pStorage); 744 744 pThis->pStorage = NULL; 745 745 } … … 1496 1496 pszFilename, pVDIfsDisk, pVDIfsImage, penmType)); 1497 1497 int rc; 1498 PVDIOSTORAGE pStorage ;1498 PVDIOSTORAGE pStorage = NULL; 1499 1499 uint64_t cbFile, offFtr = 0; 1500 1500 DMGUDIF Ftr; … … 1518 1518 } 1519 1519 else 1520 {1521 vdIfIoIntFileClose(pIfIo, pStorage);1522 1520 rc = VERR_VD_DMG_INVALID_HEADER; 1523 }1524 1521 1525 1522 if (RT_SUCCESS(rc)) … … 1548 1545 } 1549 1546 1550 vdIfIoIntFileClose(pIfIo, pStorage); 1547 if (pStorage) 1548 vdIfIoIntFileClose(pIfIo, pStorage); 1551 1549 1552 1550 LogFlowFunc(("returns %Rrc\n", rc)); -
trunk/src/VBox/Storage/Parallels.cpp
r46170 r46613 158 158 parallelsFlushImage(pImage); 159 159 160 vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage);160 rc = vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage); 161 161 pImage->pStorage = NULL; 162 162 } -
trunk/src/VBox/Storage/QCOW.cpp
r44940 r46613 996 996 qcowFlushImage(pImage); 997 997 998 vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage);998 rc = vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage); 999 999 pImage->pStorage = NULL; 1000 1000 } -
trunk/src/VBox/Storage/QED.cpp
r44940 r46613 1142 1142 qedFlushImage(pImage); 1143 1143 1144 vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage);1144 rc = vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage); 1145 1145 pImage->pStorage = NULL; 1146 1146 } -
trunk/src/VBox/Storage/RAW.cpp
r44528 r46613 160 160 } 161 161 162 vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage);162 rc = vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage); 163 163 pImage->pStorage = NULL; 164 164 } -
trunk/src/VBox/Storage/VD.cpp
r46112 r46613 2122 2122 /* Read the source data. */ 2123 2123 rc = pImageFrom->Backend->pfnRead(pImageFrom->pBackendData, 2124 2125 2124 uOffset, cbThisRead, &IoCtx, 2125 &cbThisRead); 2126 2126 2127 2127 if ( rc == VERR_VD_BLOCK_FREE … … 3944 3944 static int vdIOIntClose(void *pvUser, PVDIOSTORAGE pIoStorage) 3945 3945 { 3946 PVDIO pVDIo = (PVDIO)pvUser; 3947 3948 int rc = pVDIo->pInterfaceIo->pfnClose(pVDIo->pInterfaceIo->Core.pvUser, 3949 pIoStorage->pStorage); 3950 AssertRC(rc); 3951 3946 int rc = VINF_SUCCESS; 3947 PVDIO pVDIo = (PVDIO)pvUser; 3948 3949 /* We free everything here, even if closing the file failed for some reason. */ 3950 rc = pVDIo->pInterfaceIo->pfnClose(pVDIo->pInterfaceIo->Core.pvUser, pIoStorage->pStorage); 3952 3951 RTAvlrFileOffsetDestroy(pIoStorage->pTreeMetaXfers, vdIOIntTreeMetaXferDestroy, NULL); 3953 3952 RTMemFree(pIoStorage->pTreeMetaXfers); 3954 3953 RTMemFree(pIoStorage); 3955 return VINF_SUCCESS;3954 return rc; 3956 3955 } 3957 3956 … … 4690 4689 PVDINTERFACEIO pInterfaceIo = (PVDINTERFACEIO)pvUser; 4691 4690 int rc = pInterfaceIo->pfnClose(NULL, pIoStorage->pStorage); 4692 AssertRC(rc);4693 4691 4694 4692 RTMemFree(pIoStorage); 4695 return VINF_SUCCESS;4693 return rc; 4696 4694 } 4697 4695 … … 6763 6761 6764 6762 rc = pImageTo->Backend->pfnRead(pImageTo->pBackendData, 6765 6766 6763 uOffset, cbThisRead, 6764 &IoCtx, &cbThisRead); 6767 6765 if (rc == VERR_VD_BLOCK_FREE) 6768 6766 { … … 6776 6774 { 6777 6775 rc = pCurrImage->Backend->pfnRead(pCurrImage->pBackendData, 6778 6779 6776 uOffset, cbThisRead, 6777 &IoCtx, &cbThisRead); 6780 6778 } 6781 6779 -
trunk/src/VBox/Storage/VDI.cpp
r46612 r46613 225 225 vdiFlushImage(pImage); 226 226 227 vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage);227 rc = vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage); 228 228 pImage->pStorage = NULL; 229 229 } … … 1506 1506 1507 1507 /* Close the image. */ 1508 vdiFreeImage(pImage, false); 1509 1510 /* Rename the file. */ 1511 rc = vdIfIoIntFileMove(pImage->pIfIo, pImage->pszFilename, pszFilename, 0); 1512 if (RT_FAILURE(rc)) 1513 { 1514 /* The move failed, try to reopen the original image. */ 1515 int rc2 = vdiOpenImage(pImage, pImage->uOpenFlags); 1516 if (RT_FAILURE(rc2)) 1517 rc = rc2; 1518 1519 goto out; 1520 } 1521 1522 /* Update pImage with the new information. */ 1523 pImage->pszFilename = pszFilename; 1524 1525 /* Open the new image. */ 1526 rc = vdiOpenImage(pImage, pImage->uOpenFlags); 1527 if (RT_FAILURE(rc)) 1528 goto out; 1508 rc = vdiFreeImage(pImage, false); 1509 if (RT_SUCCESS(rc)) 1510 { 1511 /* Rename the file. */ 1512 rc = vdIfIoIntFileMove(pImage->pIfIo, pImage->pszFilename, pszFilename, 0); 1513 if (RT_FAILURE(rc)) 1514 { 1515 /* The move failed, try to reopen the original image. */ 1516 int rc2 = vdiOpenImage(pImage, pImage->uOpenFlags); 1517 if (RT_FAILURE(rc2)) 1518 rc = rc2; 1519 1520 goto out; 1521 } 1522 1523 /* Update pImage with the new information. */ 1524 pImage->pszFilename = pszFilename; 1525 1526 /* Open the new image. */ 1527 rc = vdiOpenImage(pImage, pImage->uOpenFlags); 1528 if (RT_FAILURE(rc)) 1529 goto out; 1530 } 1529 1531 1530 1532 out: … … 3165 3167 3166 3168 if (pStorage) 3167 vdIfIoIntFileClose(pIfIo, pStorage); 3169 { 3170 int rc2 = vdIfIoIntFileClose(pIfIo, pStorage); 3171 if (RT_SUCCESS(rc)) 3172 rc = rc2; /* Propagate error code only if repairing was successful. */ 3173 } 3168 3174 3169 3175 LogFlowFunc(("returns %Rrc\n", rc)); -
trunk/src/VBox/Storage/VHD.cpp
r44786 r46613 560 560 vhdFlushImage(pImage); 561 561 562 vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage);562 rc = vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage); 563 563 pImage->pStorage = NULL; 564 564 } … … 581 581 582 582 if (fDelete && pImage->pszFilename) 583 rc =vdIfIoIntFileDelete(pImage->pIfIo, pImage->pszFilename);583 vdIfIoIntFileDelete(pImage->pIfIo, pImage->pszFilename); 584 584 } 585 585 … … 3160 3160 3161 3161 if (pStorage) 3162 vdIfIoIntFileClose(pIfIo, pStorage); 3162 { 3163 int rc2 = vdIfIoIntFileClose(pIfIo, pStorage); 3164 if (RT_SUCCESS(rc)) 3165 rc = rc2; /* Propagate status code only when repairing the image was successful. */ 3166 } 3163 3167 3164 3168 LogFlowFunc(("returns %Rrc\n", rc)); -
trunk/src/VBox/Storage/VHDX.cpp
r46029 r46613 971 971 if (pImage->pStorage) 972 972 { 973 vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage);973 rc = vdIfIoIntFileClose(pImage->pIfIo, pImage->pStorage); 974 974 pImage->pStorage = NULL; 975 975 } -
trunk/src/VBox/Storage/VMDK.cpp
r44528 r46613 524 524 525 525 static void vmdkFreeStreamBuffers(PVMDKEXTENT pExtent); 526 static voidvmdkFreeExtentData(PVMDKIMAGE pImage, PVMDKEXTENT pExtent,527 526 static int vmdkFreeExtentData(PVMDKIMAGE pImage, PVMDKEXTENT pExtent, 527 bool fDelete); 528 528 529 529 static int vmdkCreateExtents(PVMDKIMAGE pImage, unsigned cExtents); … … 2862 2862 * Internal: free the memory used by the extent data structure, optionally 2863 2863 * deleting the referenced files. 2864 * 2865 * @returns VBox status code. 2866 * @param pImage Pointer to the image instance data. 2867 * @param pExtent The extent to free. 2868 * @param fDelete Flag whether to delete the backing storage. 2864 2869 */ 2865 static void vmdkFreeExtentData(PVMDKIMAGE pImage, PVMDKEXTENT pExtent, 2866 bool fDelete) 2867 { 2870 static int vmdkFreeExtentData(PVMDKIMAGE pImage, PVMDKEXTENT pExtent, 2871 bool fDelete) 2872 { 2873 int rc = VINF_SUCCESS; 2874 2868 2875 vmdkFreeGrainDirectory(pExtent); 2869 2876 if (pExtent->pDescData) … … 2875 2882 { 2876 2883 /* Do not delete raw extents, these have full and base names equal. */ 2877 vmdkFileClose(pImage, &pExtent->pFile,2878 fDelete2879 && pExtent->pszFullname2880 && strcmp(pExtent->pszFullname, pExtent->pszBasename));2884 rc =vmdkFileClose(pImage, &pExtent->pFile, 2885 fDelete 2886 && pExtent->pszFullname 2887 && strcmp(pExtent->pszFullname, pExtent->pszBasename)); 2881 2888 } 2882 2889 if (pExtent->pszBasename) … … 2891 2898 } 2892 2899 vmdkFreeStreamBuffers(pExtent); 2900 2901 return rc; 2893 2902 } 2894 2903 … … 4321 4330 { 4322 4331 for (unsigned i = 0 ; i < pImage->cExtents; i++) 4323 vmdkFreeExtentData(pImage, &pImage->pExtents[i], fDelete); 4332 { 4333 int rc2 = vmdkFreeExtentData(pImage, &pImage->pExtents[i], fDelete); 4334 if (RT_SUCCESS(rc)) 4335 rc = rc2; /* Propogate any error when closing the file. */ 4336 } 4324 4337 RTMemFree(pImage->pExtents); 4325 4338 pImage->pExtents = NULL; … … 4327 4340 pImage->cExtents = 0; 4328 4341 if (pImage->pFile != NULL) 4329 vmdkFileClose(pImage, &pImage->pFile, fDelete); 4330 vmdkFileCheckAllClose(pImage); 4342 { 4343 int rc2 = vmdkFileClose(pImage, &pImage->pFile, fDelete); 4344 if (RT_SUCCESS(rc)) 4345 rc = rc2; /* Propogate any error when closing the file. */ 4346 } 4347 int rc2 = vmdkFileCheckAllClose(pImage); 4348 if (RT_SUCCESS(rc)) 4349 rc = rc2; /* Propogate any error when closing the file. */ 4331 4350 4332 4351 if (pImage->pGTCache) … … 5517 5536 goto rollback; 5518 5537 /* Close the extent file. */ 5519 vmdkFileClose(pImage, &pExtent->pFile, false); 5538 rc = vmdkFileClose(pImage, &pExtent->pFile, false); 5539 if (RT_FAILURE(rc)) 5540 goto rollback; 5541 5520 5542 /* Rename the extent file. */ 5521 5543 rc = vdIfIoIntFileMove(pImage->pIfIo, pExtent->pszFullname, apszNewName[i], 0); … … 5526 5548 } 5527 5549 /* Release all old stuff. */ 5528 vmdkFreeImage(pImage, false); 5550 rc = vmdkFreeImage(pImage, false); 5551 if (RT_FAILURE(rc)) 5552 goto rollback; 5529 5553 5530 5554 fImageFreed = true;
Note:
See TracChangeset
for help on using the changeset viewer.