- Timestamp:
- Nov 1, 2010 1:53:01 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67266
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImplExport.cpp
r33540 r33651 1613 1613 HRESULT rc = S_OK; 1614 1614 1615 PVDINTERFACEIO p Sha1Callbacks = 0;1615 PVDINTERFACEIO pRTSha1Callbacks = 0; 1616 1616 PVDINTERFACEIO pRTFileCallbacks = 0; 1617 1617 do 1618 1618 { 1619 p Sha1Callbacks =Sha1CreateInterface();1620 if (!p Sha1Callbacks)1619 pRTSha1Callbacks = RTSha1CreateInterface(); 1620 if (!pRTSha1Callbacks) 1621 1621 { 1622 1622 rc = E_OUTOFMEMORY; … … 1630 1630 } 1631 1631 1632 SHA1STORAGE storage;1632 RTSHA1STORAGE storage; 1633 1633 RT_ZERO(storage); 1634 1634 storage.fCreateDigest = m->fManifest; … … 1642 1642 break; 1643 1643 } 1644 rc = writeFSImpl(pTask, writeLock, p Sha1Callbacks, &storage);1644 rc = writeFSImpl(pTask, writeLock, pRTSha1Callbacks, &storage); 1645 1645 }while(0); 1646 1646 1647 1647 /* Cleanup */ 1648 if (p Sha1Callbacks)1649 RTMemFree(p Sha1Callbacks);1648 if (pRTSha1Callbacks) 1649 RTMemFree(pRTSha1Callbacks); 1650 1650 if (pRTFileCallbacks) 1651 1651 RTMemFree(pRTFileCallbacks); … … 1668 1668 HRESULT rc = S_OK; 1669 1669 1670 PVDINTERFACEIO p Sha1Callbacks = 0;1670 PVDINTERFACEIO pRTSha1Callbacks = 0; 1671 1671 PVDINTERFACEIO pRTTarCallbacks = 0; 1672 1672 do 1673 1673 { 1674 p Sha1Callbacks =Sha1CreateInterface();1675 if (!p Sha1Callbacks)1674 pRTSha1Callbacks = RTSha1CreateInterface(); 1675 if (!pRTSha1Callbacks) 1676 1676 { 1677 1677 rc = E_OUTOFMEMORY; … … 1685 1685 } 1686 1686 VDINTERFACE VDInterfaceIO; 1687 SHA1STORAGE storage;1687 RTSHA1STORAGE storage; 1688 1688 RT_ZERO(storage); 1689 1689 storage.fCreateDigest = m->fManifest; … … 1696 1696 break; 1697 1697 } 1698 rc = writeFSImpl(pTask, writeLock, p Sha1Callbacks, &storage);1698 rc = writeFSImpl(pTask, writeLock, pRTSha1Callbacks, &storage); 1699 1699 }while(0); 1700 1700 … … 1702 1702 1703 1703 /* Cleanup */ 1704 if (p Sha1Callbacks)1705 RTMemFree(p Sha1Callbacks);1704 if (pRTSha1Callbacks) 1705 RTMemFree(pRTSha1Callbacks); 1706 1706 if (pRTTarCallbacks) 1707 1707 RTMemFree(pRTTarCallbacks); … … 1715 1715 } 1716 1716 1717 HRESULT Appliance::writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pCallbacks, P SHA1STORAGE pStorage)1717 HRESULT Appliance::writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pCallbacks, PRTSHA1STORAGE pStorage) 1718 1718 { 1719 1719 LogFlowFuncEnter(); … … 1747 1747 strOvfFile.c_str()); 1748 1748 /* Write the ovf file to disk. */ 1749 vrc = Sha1WriteBuf(strOvfFile.c_str(), pvBuf, cbSize, pCallbacks, pStorage);1749 vrc = RTSha1WriteBuf(strOvfFile.c_str(), pvBuf, cbSize, pCallbacks, pStorage); 1750 1750 RTMemFree(pvBuf); 1751 1751 if (RT_FAILURE(vrc)) … … 1865 1865 pStorage->fCreateDigest = false; 1866 1866 /* Write the manifest file to disk. */ 1867 vrc = Sha1WriteBuf(strMfFilePath.c_str(), pvBuf, cbSize, pCallbacks, pStorage);1867 vrc = RTSha1WriteBuf(strMfFilePath.c_str(), pvBuf, cbSize, pCallbacks, pStorage); 1868 1868 RTMemFree(pvBuf); 1869 1869 if (RT_FAILURE(vrc)) -
trunk/src/VBox/Main/ApplianceImplIO.cpp
r33643 r33651 53 53 } RTTARSTORAGEINTERNAL, *PRTTARSTORAGEINTERNAL; 54 54 55 typedef struct SHA1STORAGEINTERNAL55 typedef struct RTSHA1STORAGEINTERNAL 56 56 { 57 57 /** Completion callback. */ … … 62 62 uint32_t fOpenMode; 63 63 /** Our own storage handle. */ 64 P SHA1STORAGE pSha1Storage;64 PRTSHA1STORAGE pSha1Storage; 65 65 /** Circular buffer used for transferring data from/to the worker thread. */ 66 66 PRTCIRCBUF pCircBuf; … … 77 77 /** Event for signaling a finished task of the worker thread. */ 78 78 RTSEMEVENT workFinishedEvent; 79 /** SHA1 calculation context. */79 /** rtSha1 calculation context. */ 80 80 RTSHA1CONTEXT ctx; 81 81 /** Write mode only: Memory buffer for writing zeros. */ … … 87 87 // uint64_t calls; 88 88 // uint64_t waits; 89 } SHA1STORAGEINTERNAL, *PSHA1STORAGEINTERNAL;89 } RTSHA1STORAGEINTERNAL, *PRTSHA1STORAGEINTERNAL; 90 90 91 91 /****************************************************************************** … … 456 456 457 457 /****************************************************************************** 458 * Internal: Sha1 interface458 * Internal: RTSha1 interface 459 459 ******************************************************************************/ 460 460 461 DECLCALLBACK(int) sha1CalcWorkerThread(RTTHREAD /* aThread */, void *pvUser)462 { 463 /* Validate input. */ 464 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 465 466 P SHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvUser;461 DECLCALLBACK(int) rtSha1CalcWorkerThread(RTTHREAD /* aThread */, void *pvUser) 462 { 463 /* Validate input. */ 464 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 465 466 PRTSHA1STORAGEINTERNAL pInt = (PRTSHA1STORAGEINTERNAL)pvUser; 467 467 468 468 PVDINTERFACE pIO = VDInterfaceGet(pInt->pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); … … 624 624 } 625 625 626 DECLINLINE(int) sha1SignalManifestThread(PSHA1STORAGEINTERNAL pInt, uint32_t uStatus)626 DECLINLINE(int) rtSha1SignalManifestThread(PRTSHA1STORAGEINTERNAL pInt, uint32_t uStatus) 627 627 { 628 628 ASMAtomicWriteU32(&pInt->u32Status, uStatus); … … 630 630 } 631 631 632 DECLINLINE(int) sha1WaitForManifestThreadFinished(PSHA1STORAGEINTERNAL pInt)632 DECLINLINE(int) rtSha1WaitForManifestThreadFinished(PRTSHA1STORAGEINTERNAL pInt) 633 633 { 634 634 // RTPrintf("start\n"); … … 647 647 } 648 648 649 DECLINLINE(int) sha1FlushCurBuf(PSHA1STORAGEINTERNAL pInt)649 DECLINLINE(int) rtSha1FlushCurBuf(PRTSHA1STORAGEINTERNAL pInt) 650 650 { 651 651 int rc = VINF_SUCCESS; … … 653 653 { 654 654 /* Let the write worker thread start immediately. */ 655 rc = sha1SignalManifestThread(pInt, STATUS_WRITE);655 rc = rtSha1SignalManifestThread(pInt, STATUS_WRITE); 656 656 if (RT_FAILURE(rc)) 657 657 return rc; 658 658 659 659 /* Wait until the write worker thread has finished. */ 660 rc = sha1WaitForManifestThreadFinished(pInt);660 rc = rtSha1WaitForManifestThreadFinished(pInt); 661 661 } 662 662 … … 664 664 } 665 665 666 static int sha1OpenCallback(void *pvUser, const char *pszLocation, uint32_t fOpen,667 PFNVDCOMPLETED pfnCompleted, void **ppInt)666 static int rtSha1OpenCallback(void *pvUser, const char *pszLocation, uint32_t fOpen, 667 PFNVDCOMPLETED pfnCompleted, void **ppInt) 668 668 { 669 669 /* Validate input. */ … … 674 674 AssertReturn((fOpen & RTFILE_O_READWRITE) != RTFILE_O_READWRITE, VERR_INVALID_PARAMETER); /* No read/write allowed */ 675 675 676 P SHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser;676 PRTSHA1STORAGE pSha1Storage = (PRTSHA1STORAGE)pvUser; 677 677 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 678 678 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); … … 682 682 DEBUG_PRINT_FLOW(); 683 683 684 P SHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)RTMemAllocZ(sizeof(SHA1STORAGEINTERNAL));684 PRTSHA1STORAGEINTERNAL pInt = (PRTSHA1STORAGEINTERNAL)RTMemAllocZ(sizeof(RTSHA1STORAGEINTERNAL)); 685 685 if (!pInt) 686 686 return VERR_NO_MEMORY; … … 724 724 break; 725 725 /* Create the worker thread. */ 726 rc = RTThreadCreate(&pInt->pWorkerThread, sha1CalcWorkerThread, pInt, 0, RTTHREADTYPE_MAIN_HEAVY_WORKER, RTTHREADFLAGS_WAITABLE, "SHA1-Worker");726 rc = RTThreadCreate(&pInt->pWorkerThread, rtSha1CalcWorkerThread, pInt, 0, RTTHREADTYPE_MAIN_HEAVY_WORKER, RTTHREADFLAGS_WAITABLE, "SHA1-Worker"); 727 727 if (RT_FAILURE(rc)) 728 728 break; 729 729 730 730 if (pSha1Storage->fCreateDigest) 731 /* Create a sha1 context the worker thread will work with. */731 /* Create a SHA1 context the worker thread will work with. */ 732 732 RTSha1Init(&pInt->ctx); 733 733 … … 742 742 { 743 743 /* Immediately let the worker thread start the reading. */ 744 rc = sha1SignalManifestThread(pInt, STATUS_READ);744 rc = rtSha1SignalManifestThread(pInt, STATUS_READ); 745 745 } 746 746 } … … 751 751 if (pInt->pWorkerThread) 752 752 { 753 sha1SignalManifestThread(pInt, STATUS_END);753 rtSha1SignalManifestThread(pInt, STATUS_END); 754 754 RTThreadWait(pInt->pWorkerThread, RT_INDEFINITE_WAIT, 0); 755 755 } … … 770 770 } 771 771 772 static int sha1CloseCallback(void *pvUser, void *pvStorage)773 { 774 /* Validate input. */ 775 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 776 AssertPtrReturn(pvStorage, VERR_INVALID_POINTER); 777 778 P SHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser;772 static int rtSha1CloseCallback(void *pvUser, void *pvStorage) 773 { 774 /* Validate input. */ 775 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 776 AssertPtrReturn(pvStorage, VERR_INVALID_POINTER); 777 778 PRTSHA1STORAGE pSha1Storage = (PRTSHA1STORAGE)pvUser; 779 779 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 780 780 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); … … 782 782 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 783 783 784 P SHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage;784 PRTSHA1STORAGEINTERNAL pInt = (PRTSHA1STORAGEINTERNAL)pvStorage; 785 785 786 786 DEBUG_PRINT_FLOW(); … … 789 789 790 790 /* Make sure all pending writes are flushed */ 791 rc = sha1FlushCurBuf(pInt);791 rc = rtSha1FlushCurBuf(pInt); 792 792 793 793 if (pInt->pWorkerThread) 794 794 { 795 795 /* Signal the worker thread to end himself */ 796 rc = sha1SignalManifestThread(pInt, STATUS_END);796 rc = rtSha1SignalManifestThread(pInt, STATUS_END); 797 797 /* Worker thread stopped? */ 798 798 rc = RTThreadWait(pInt->pWorkerThread, RT_INDEFINITE_WAIT, 0); … … 835 835 } 836 836 837 static int sha1DeleteCallback(void *pvUser, const char *pcszFilename)838 { 839 /* Validate input. */ 840 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 841 842 P SHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser;837 static int rtSha1DeleteCallback(void *pvUser, const char *pcszFilename) 838 { 839 /* Validate input. */ 840 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 841 842 PRTSHA1STORAGE pSha1Storage = (PRTSHA1STORAGE)pvUser; 843 843 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 844 844 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); … … 851 851 } 852 852 853 static int sha1MoveCallback(void *pvUser, const char *pcszSrc, const char *pcszDst, unsigned fMove)854 { 855 /* Validate input. */ 856 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 857 858 P SHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser;853 static int rtSha1MoveCallback(void *pvUser, const char *pcszSrc, const char *pcszDst, unsigned fMove) 854 { 855 /* Validate input. */ 856 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 857 858 PRTSHA1STORAGE pSha1Storage = (PRTSHA1STORAGE)pvUser; 859 859 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 860 860 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); … … 867 867 } 868 868 869 static int sha1GetFreeSpaceCallback(void *pvUser, const char *pcszFilename, int64_t *pcbFreeSpace)870 { 871 /* Validate input. */ 872 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 873 874 P SHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser;869 static int rtSha1GetFreeSpaceCallback(void *pvUser, const char *pcszFilename, int64_t *pcbFreeSpace) 870 { 871 /* Validate input. */ 872 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 873 874 PRTSHA1STORAGE pSha1Storage = (PRTSHA1STORAGE)pvUser; 875 875 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 876 876 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); … … 883 883 } 884 884 885 static int sha1GetModificationTimeCallback(void *pvUser, const char *pcszFilename, PRTTIMESPEC pModificationTime)886 { 887 /* Validate input. */ 888 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 889 890 P SHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser;885 static int rtSha1GetModificationTimeCallback(void *pvUser, const char *pcszFilename, PRTTIMESPEC pModificationTime) 886 { 887 /* Validate input. */ 888 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 889 890 PRTSHA1STORAGE pSha1Storage = (PRTSHA1STORAGE)pvUser; 891 891 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 892 892 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); … … 900 900 901 901 902 static int sha1GetSizeCallback(void *pvUser, void *pvStorage, uint64_t *pcbSize)903 { 904 /* Validate input. */ 905 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 906 AssertPtrReturn(pvStorage, VERR_INVALID_POINTER); 907 908 P SHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser;902 static int rtSha1GetSizeCallback(void *pvUser, void *pvStorage, uint64_t *pcbSize) 903 { 904 /* Validate input. */ 905 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 906 AssertPtrReturn(pvStorage, VERR_INVALID_POINTER); 907 908 PRTSHA1STORAGE pSha1Storage = (PRTSHA1STORAGE)pvUser; 909 909 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 910 910 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); … … 912 912 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 913 913 914 P SHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage;914 PRTSHA1STORAGEINTERNAL pInt = (PRTSHA1STORAGEINTERNAL)pvStorage; 915 915 916 916 DEBUG_PRINT_FLOW(); … … 926 926 } 927 927 928 static int sha1SetSizeCallback(void *pvUser, void *pvStorage, uint64_t cbSize)929 { 930 /* Validate input. */ 931 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 932 AssertPtrReturn(pvStorage, VERR_INVALID_POINTER); 933 934 P SHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser;928 static int rtSha1SetSizeCallback(void *pvUser, void *pvStorage, uint64_t cbSize) 929 { 930 /* Validate input. */ 931 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 932 AssertPtrReturn(pvStorage, VERR_INVALID_POINTER); 933 934 PRTSHA1STORAGE pSha1Storage = (PRTSHA1STORAGE)pvUser; 935 935 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 936 936 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); … … 938 938 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 939 939 940 P SHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage;940 PRTSHA1STORAGEINTERNAL pInt = (PRTSHA1STORAGEINTERNAL)pvStorage; 941 941 942 942 DEBUG_PRINT_FLOW(); … … 945 945 } 946 946 947 static int sha1WriteSyncCallback(void *pvUser, void *pvStorage, uint64_t uOffset,947 static int rtSha1WriteSyncCallback(void *pvUser, void *pvStorage, uint64_t uOffset, 948 948 const void *pvBuf, size_t cbWrite, size_t *pcbWritten) 949 949 { … … 952 952 AssertPtrReturn(pvStorage, VERR_INVALID_POINTER); 953 953 954 P SHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser;954 PRTSHA1STORAGE pSha1Storage = (PRTSHA1STORAGE)pvUser; 955 955 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 956 956 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); … … 958 958 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 959 959 960 P SHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage;960 PRTSHA1STORAGEINTERNAL pInt = (PRTSHA1STORAGEINTERNAL)pvStorage; 961 961 962 962 DEBUG_PRINT_FLOW(); … … 980 980 size_t cbToWrite = RT_MIN(pInt->cbZeroBuf, cbSize - cbAllWritten); 981 981 size_t cbWritten = 0; 982 rc = sha1WriteSyncCallback(pvUser, pvStorage, pInt->cbCurAll,983 pInt->pvZeroBuf, cbToWrite, &cbWritten);982 rc = rtSha1WriteSyncCallback(pvUser, pvStorage, pInt->cbCurAll, 983 pInt->pvZeroBuf, cbToWrite, &cbWritten); 984 984 if (RT_FAILURE(rc)) 985 985 break; … … 1005 1005 if ((cbWrite - cbAllWritten) > cbAvail) 1006 1006 { 1007 rc = sha1SignalManifestThread(pInt, STATUS_WRITE);1007 rc = rtSha1SignalManifestThread(pInt, STATUS_WRITE); 1008 1008 if(RT_FAILURE(rc)) 1009 1009 break; … … 1011 1011 if (cbAvail == 0) 1012 1012 { 1013 rc = sha1WaitForManifestThreadFinished(pInt);1013 rc = rtSha1WaitForManifestThreadFinished(pInt); 1014 1014 if (RT_FAILURE(rc)) 1015 1015 break; … … 1037 1037 if ( RT_SUCCESS(rc) 1038 1038 && RTCircBufUsed(pInt->pCircBuf) >= (RTCircBufSize(pInt->pCircBuf) / 2)) 1039 rc = sha1SignalManifestThread(pInt, STATUS_WRITE);1039 rc = rtSha1SignalManifestThread(pInt, STATUS_WRITE); 1040 1040 1041 1041 return rc; 1042 1042 } 1043 1043 1044 static int sha1ReadSyncCallback(void *pvUser, void *pvStorage, uint64_t uOffset,1045 void *pvBuf, size_t cbRead, size_t *pcbRead)1046 { 1047 /* Validate input. */ 1048 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 1049 AssertPtrReturn(pvStorage, VERR_INVALID_POINTER); 1050 1051 P SHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser;1044 static int rtSha1ReadSyncCallback(void *pvUser, void *pvStorage, uint64_t uOffset, 1045 void *pvBuf, size_t cbRead, size_t *pcbRead) 1046 { 1047 /* Validate input. */ 1048 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 1049 AssertPtrReturn(pvStorage, VERR_INVALID_POINTER); 1050 1051 PRTSHA1STORAGE pSha1Storage = (PRTSHA1STORAGE)pvUser; 1052 1052 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 1053 1053 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); … … 1057 1057 // DEBUG_PRINT_FLOW(); 1058 1058 1059 P SHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage;1059 PRTSHA1STORAGEINTERNAL pInt = (PRTSHA1STORAGEINTERNAL)pvStorage; 1060 1060 1061 1061 int rc = VINF_SUCCESS; … … 1068 1068 if (pInt->cbCurAll < uOffset) 1069 1069 { 1070 rc = sha1ReadSyncCallback(pvUser, pvStorage, pInt->cbCurAll, 0, uOffset - pInt->cbCurAll, 0);1070 rc = rtSha1ReadSyncCallback(pvUser, pvStorage, pInt->cbCurAll, 0, uOffset - pInt->cbCurAll, 0); 1071 1071 if (RT_FAILURE(rc)) 1072 1072 return rc; … … 1089 1089 if ((cbRead - cbAllRead) > cbAvail) 1090 1090 { 1091 rc = sha1SignalManifestThread(pInt, STATUS_READ);1091 rc = rtSha1SignalManifestThread(pInt, STATUS_READ); 1092 1092 if(RT_FAILURE(rc)) 1093 1093 break; … … 1095 1095 if (cbAvail == 0) 1096 1096 { 1097 rc = sha1WaitForManifestThreadFinished(pInt);1097 rc = rtSha1WaitForManifestThreadFinished(pInt); 1098 1098 if (RT_FAILURE(rc)) 1099 1099 break; … … 1126 1126 if ( RT_SUCCESS(rc) 1127 1127 && RTCircBufFree(pInt->pCircBuf) >= (RTCircBufSize(pInt->pCircBuf) / 2)) 1128 rc = sha1SignalManifestThread(pInt, STATUS_READ);1128 rc = rtSha1SignalManifestThread(pInt, STATUS_READ); 1129 1129 1130 1130 return rc; 1131 1131 } 1132 1132 1133 static int sha1FlushSyncCallback(void *pvUser, void *pvStorage)1134 { 1135 /* Validate input. */ 1136 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 1137 AssertPtrReturn(pvStorage, VERR_INVALID_POINTER); 1138 1139 P SHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser;1133 static int rtSha1FlushSyncCallback(void *pvUser, void *pvStorage) 1134 { 1135 /* Validate input. */ 1136 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 1137 AssertPtrReturn(pvStorage, VERR_INVALID_POINTER); 1138 1139 PRTSHA1STORAGE pSha1Storage = (PRTSHA1STORAGE)pvUser; 1140 1140 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 1141 1141 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); … … 1145 1145 DEBUG_PRINT_FLOW(); 1146 1146 1147 P SHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage;1147 PRTSHA1STORAGEINTERNAL pInt = (PRTSHA1STORAGEINTERNAL)pvStorage; 1148 1148 1149 1149 /* Check if there is still something in the buffer. If yes, flush it. */ 1150 int rc = sha1FlushCurBuf(pInt);1150 int rc = rtSha1FlushCurBuf(pInt); 1151 1151 if (RT_FAILURE(rc)) 1152 1152 return rc; … … 1159 1159 ******************************************************************************/ 1160 1160 1161 PVDINTERFACEIO Sha1CreateInterface()1161 PVDINTERFACEIO RTSha1CreateInterface() 1162 1162 { 1163 1163 PVDINTERFACEIO pCallbacks = (PVDINTERFACEIO)RTMemAllocZ(sizeof(VDINTERFACEIO)); … … 1167 1167 pCallbacks->cbSize = sizeof(VDINTERFACEIO); 1168 1168 pCallbacks->enmInterface = VDINTERFACETYPE_IO; 1169 pCallbacks->pfnOpen = sha1OpenCallback;1170 pCallbacks->pfnClose = sha1CloseCallback;1171 pCallbacks->pfnDelete = sha1DeleteCallback;1172 pCallbacks->pfnMove = sha1MoveCallback;1173 pCallbacks->pfnGetFreeSpace = sha1GetFreeSpaceCallback;1174 pCallbacks->pfnGetModificationTime = sha1GetModificationTimeCallback;1175 pCallbacks->pfnGetSize = sha1GetSizeCallback;1176 pCallbacks->pfnSetSize = sha1SetSizeCallback;1177 pCallbacks->pfnReadSync = sha1ReadSyncCallback;1178 pCallbacks->pfnWriteSync = sha1WriteSyncCallback;1179 pCallbacks->pfnFlushSync = sha1FlushSyncCallback;1169 pCallbacks->pfnOpen = rtSha1OpenCallback; 1170 pCallbacks->pfnClose = rtSha1CloseCallback; 1171 pCallbacks->pfnDelete = rtSha1DeleteCallback; 1172 pCallbacks->pfnMove = rtSha1MoveCallback; 1173 pCallbacks->pfnGetFreeSpace = rtSha1GetFreeSpaceCallback; 1174 pCallbacks->pfnGetModificationTime = rtSha1GetModificationTimeCallback; 1175 pCallbacks->pfnGetSize = rtSha1GetSizeCallback; 1176 pCallbacks->pfnSetSize = rtSha1SetSizeCallback; 1177 pCallbacks->pfnReadSync = rtSha1ReadSyncCallback; 1178 pCallbacks->pfnWriteSync = rtSha1WriteSyncCallback; 1179 pCallbacks->pfnFlushSync = rtSha1FlushSyncCallback; 1180 1180 1181 1181 return pCallbacks; … … 1228 1228 } 1229 1229 1230 int Sha1ReadBuf(const char *pcszFilename, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, void *pvUser)1230 int RTSha1ReadBuf(const char *pcszFilename, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, void *pvUser) 1231 1231 { 1232 1232 /* Validate input. */ … … 1294 1294 } 1295 1295 1296 int Sha1WriteBuf(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO pCallbacks, void *pvUser)1296 int RTSha1WriteBuf(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO pCallbacks, void *pvUser) 1297 1297 { 1298 1298 /* Validate input. */ -
trunk/src/VBox/Main/ApplianceImplImport.cpp
r33567 r33651 707 707 HRESULT rc = S_OK; 708 708 709 PVDINTERFACEIO p Sha1Callbacks = 0;709 PVDINTERFACEIO pRTSha1Callbacks = 0; 710 710 PVDINTERFACEIO pRTFileCallbacks = 0; 711 711 do 712 712 { 713 p Sha1Callbacks =Sha1CreateInterface();714 if (!p Sha1Callbacks)713 pRTSha1Callbacks = RTSha1CreateInterface(); 714 if (!pRTSha1Callbacks) 715 715 { 716 716 rc = E_OUTOFMEMORY; … … 724 724 } 725 725 VDINTERFACE VDInterfaceIO; 726 SHA1STORAGE storage;726 RTSHA1STORAGE storage; 727 727 RT_ZERO(storage); 728 728 int vrc = VDInterfaceAdd(&VDInterfaceIO, "Appliance::IORTFile", … … 734 734 break; 735 735 } 736 rc = readFSImpl(pTask, p Sha1Callbacks, &storage);736 rc = readFSImpl(pTask, pRTSha1Callbacks, &storage); 737 737 }while(0); 738 738 739 739 /* Cleanup */ 740 if (p Sha1Callbacks)741 RTMemFree(p Sha1Callbacks);740 if (pRTSha1Callbacks) 741 RTMemFree(pRTSha1Callbacks); 742 742 if (pRTFileCallbacks) 743 743 RTMemFree(pRTFileCallbacks); … … 762 762 HRESULT rc = S_OK; 763 763 764 PVDINTERFACEIO p Sha1Callbacks = 0;764 PVDINTERFACEIO pRTSha1Callbacks = 0; 765 765 PVDINTERFACEIO pRTTarCallbacks = 0; 766 766 do 767 767 { 768 p Sha1Callbacks =Sha1CreateInterface();769 if (!p Sha1Callbacks)768 pRTSha1Callbacks = RTSha1CreateInterface(); 769 if (!pRTSha1Callbacks) 770 770 { 771 771 rc = E_OUTOFMEMORY; … … 779 779 } 780 780 VDINTERFACE VDInterfaceIO; 781 SHA1STORAGE storage;781 RTSHA1STORAGE storage; 782 782 RT_ZERO(storage); 783 783 vrc = VDInterfaceAdd(&VDInterfaceIO, "Appliance::IORTTar", … … 789 789 break; 790 790 } 791 rc = readFSImpl(pTask, p Sha1Callbacks, &storage);791 rc = readFSImpl(pTask, pRTSha1Callbacks, &storage); 792 792 }while(0); 793 793 … … 795 795 796 796 /* Cleanup */ 797 if (p Sha1Callbacks)798 RTMemFree(p Sha1Callbacks);797 if (pRTSha1Callbacks) 798 RTMemFree(pRTSha1Callbacks); 799 799 if (pRTTarCallbacks) 800 800 RTMemFree(pRTTarCallbacks); … … 806 806 } 807 807 808 HRESULT Appliance::readFSImpl(TaskOVF *pTask, PVDINTERFACEIO pCallbacks, P SHA1STORAGE pStorage)808 HRESULT Appliance::readFSImpl(TaskOVF *pTask, PVDINTERFACEIO pCallbacks, PRTSHA1STORAGE pStorage) 809 809 { 810 810 LogFlowFuncEnter(); … … 820 820 /* Read the OVF into a memory buffer */ 821 821 size_t cbSize = 0; 822 int vrc = Sha1ReadBuf(strOvfFile.c_str(), &pvTmpBuf, &cbSize, pCallbacks, pStorage);822 int vrc = RTSha1ReadBuf(strOvfFile.c_str(), &pvTmpBuf, &cbSize, pCallbacks, pStorage); 823 823 if (RT_FAILURE(vrc)) 824 824 throw setError(VBOX_E_FILE_ERROR, … … 1112 1112 HRESULT rc = S_OK; 1113 1113 1114 PVDINTERFACEIO p Sha1Callbacks = 0;1114 PVDINTERFACEIO pRTSha1Callbacks = 0; 1115 1115 PVDINTERFACEIO pRTFileCallbacks = 0; 1116 1116 void *pvMfBuf = 0; … … 1119 1119 { 1120 1120 /* Create the necessary file access interfaces. */ 1121 p Sha1Callbacks =Sha1CreateInterface();1122 if (!p Sha1Callbacks)1121 pRTSha1Callbacks = RTSha1CreateInterface(); 1122 if (!pRTSha1Callbacks) 1123 1123 throw E_OUTOFMEMORY; 1124 1124 pRTFileCallbacks = RTFileCreateInterface(); … … 1127 1127 1128 1128 VDINTERFACE VDInterfaceIO; 1129 SHA1STORAGE storage;1129 RTSHA1STORAGE storage; 1130 1130 RT_ZERO(storage); 1131 1131 storage.fCreateDigest = true; … … 1143 1143 storage.fCreateDigest = RTFileExists(strMfFile.c_str()); 1144 1144 /* Now import the appliance. */ 1145 importMachines(stack, p Sha1Callbacks, &storage);1145 importMachines(stack, pRTSha1Callbacks, &storage); 1146 1146 /* Read & verify the manifest file, if there is one. */ 1147 1147 if (storage.fCreateDigest) … … 1149 1149 /* Add the ovf file to the digest list. */ 1150 1150 stack.llSrcDisksDigest.push_front(STRPAIR(pTask->locInfo.strPath, m->strOVFSHA1Digest)); 1151 rc = readManifestFile(strMfFile, &pvMfBuf, &cbMfSize, p Sha1Callbacks, &storage);1151 rc = readManifestFile(strMfFile, &pvMfBuf, &cbMfSize, pRTSha1Callbacks, &storage); 1152 1152 if (FAILED(rc)) throw rc; 1153 1153 rc = verifyManifestFile(strMfFile, stack, pvMfBuf, cbMfSize); … … 1164 1164 if (pvMfBuf) 1165 1165 RTMemFree(pvMfBuf); 1166 if (p Sha1Callbacks)1167 RTMemFree(p Sha1Callbacks);1166 if (pRTSha1Callbacks) 1167 RTMemFree(pRTSha1Callbacks); 1168 1168 if (pRTFileCallbacks) 1169 1169 RTMemFree(pRTFileCallbacks); … … 1188 1188 HRESULT rc = S_OK; 1189 1189 1190 PVDINTERFACEIO p Sha1Callbacks = 0;1190 PVDINTERFACEIO pRTSha1Callbacks = 0; 1191 1191 PVDINTERFACEIO pRTTarCallbacks = 0; 1192 1192 void *pvMfBuf = 0; … … 1195 1195 { 1196 1196 /* Create the necessary file access interfaces. */ 1197 p Sha1Callbacks =Sha1CreateInterface();1198 if (!p Sha1Callbacks)1197 pRTSha1Callbacks = RTSha1CreateInterface(); 1198 if (!pRTSha1Callbacks) 1199 1199 throw E_OUTOFMEMORY; 1200 1200 pRTTarCallbacks = RTTarCreateInterface(); … … 1203 1203 1204 1204 VDINTERFACE VDInterfaceIO; 1205 SHA1STORAGE storage;1205 RTSHA1STORAGE storage; 1206 1206 RT_ZERO(storage); 1207 1207 vrc = VDInterfaceAdd(&VDInterfaceIO, "Appliance::IORTTar", … … 1217 1217 throw E_FAIL; 1218 1218 1219 PVDINTERFACEIO pCallbacks = p Sha1Callbacks;1220 P SHA1STORAGE pStorage = &storage;1219 PVDINTERFACEIO pCallbacks = pRTSha1Callbacks; 1220 PRTSHA1STORAGE pStorage = &storage; 1221 1221 1222 1222 /* We always need to create the digest, cause we didn't know if there … … 1270 1270 if (pvMfBuf) 1271 1271 RTMemFree(pvMfBuf); 1272 if (p Sha1Callbacks)1273 RTMemFree(p Sha1Callbacks);1272 if (pRTSha1Callbacks) 1273 RTMemFree(pRTSha1Callbacks); 1274 1274 if (pRTTarCallbacks) 1275 1275 RTMemFree(pRTTarCallbacks); … … 1472 1472 } 1473 1473 1474 HRESULT Appliance::readManifestFile(const Utf8Str &strFile, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, P SHA1STORAGE pStorage)1474 HRESULT Appliance::readManifestFile(const Utf8Str &strFile, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, PRTSHA1STORAGE pStorage) 1475 1475 { 1476 1476 HRESULT rc = S_OK; … … 1478 1478 bool fOldDigest = pStorage->fCreateDigest; 1479 1479 pStorage->fCreateDigest = false; /* No digest for the manifest file */ 1480 int vrc = Sha1ReadBuf(strFile.c_str(), ppvBuf, pcbSize, pCallbacks, pStorage);1480 int vrc = RTSha1ReadBuf(strFile.c_str(), ppvBuf, pcbSize, pCallbacks, pStorage); 1481 1481 if ( RT_FAILURE(vrc) 1482 1482 && vrc != VERR_FILE_NOT_FOUND) … … 1489 1489 } 1490 1490 1491 HRESULT Appliance::readTarManifestFile(RTTAR tar, const Utf8Str &strFile, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, P SHA1STORAGE pStorage)1491 HRESULT Appliance::readTarManifestFile(RTTAR tar, const Utf8Str &strFile, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, PRTSHA1STORAGE pStorage) 1492 1492 { 1493 1493 HRESULT rc = S_OK; … … 1663 1663 ImportStack &stack, 1664 1664 PVDINTERFACEIO pCallbacks, 1665 P SHA1STORAGE pStorage)1665 PRTSHA1STORAGE pStorage) 1666 1666 { 1667 1667 ComObjPtr<Progress> pProgress; … … 1803 1803 ImportStack &stack, 1804 1804 PVDINTERFACEIO pCallbacks, 1805 P SHA1STORAGE pStorage)1805 PRTSHA1STORAGE pStorage) 1806 1806 { 1807 1807 HRESULT rc; … … 2355 2355 ImportStack &stack, 2356 2356 PVDINTERFACEIO pCallbacks, 2357 P SHA1STORAGE pStorage)2357 PRTSHA1STORAGE pStorage) 2358 2358 { 2359 2359 Assert(vsdescThis->m->pConfig); … … 2544 2544 void Appliance::importMachines(ImportStack &stack, 2545 2545 PVDINTERFACEIO pCallbacks, 2546 P SHA1STORAGE pStorage)2546 PRTSHA1STORAGE pStorage) 2547 2547 { 2548 2548 HRESULT rc = S_OK; -
trunk/src/VBox/Main/include/ApplianceImpl.h
r33417 r33651 35 35 typedef struct VDINTERFACE *PVDINTERFACE; 36 36 typedef struct VDINTERFACEIO *PVDINTERFACEIO; 37 typedef struct SHA1STORAGE *PSHA1STORAGE;37 typedef struct RTSHA1STORAGE *PRTSHA1STORAGE; 38 38 39 39 namespace ovf … … 152 152 HRESULT readFSOVF(TaskOVF *pTask); 153 153 HRESULT readFSOVA(TaskOVF *pTask); 154 HRESULT readFSImpl(TaskOVF *pTask, PVDINTERFACEIO pCallbacks, P SHA1STORAGE pStorage);154 HRESULT readFSImpl(TaskOVF *pTask, PVDINTERFACEIO pCallbacks, PRTSHA1STORAGE pStorage); 155 155 HRESULT readS3(TaskOVF *pTask); 156 156 … … 166 166 HRESULT importS3(TaskOVF *pTask); 167 167 168 HRESULT readManifestFile(const Utf8Str &strFile, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, P SHA1STORAGE pStorage);169 HRESULT readTarManifestFile(RTTAR tar, const Utf8Str &strFile, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, P SHA1STORAGE pStorage);168 HRESULT readManifestFile(const Utf8Str &strFile, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, PRTSHA1STORAGE pStorage); 169 HRESULT readTarManifestFile(RTTAR tar, const Utf8Str &strFile, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, PRTSHA1STORAGE pStorage); 170 170 HRESULT verifyManifestFile(const Utf8Str &strFile, ImportStack &stack, void *pvBuf, size_t cbSize); 171 171 … … 181 181 ImportStack &stack, 182 182 PVDINTERFACEIO pCallbacks, 183 P SHA1STORAGE pStorage);183 PRTSHA1STORAGE pStorage); 184 184 void importMachineGeneric(const ovf::VirtualSystem &vsysThis, 185 185 ComObjPtr<VirtualSystemDescription> &vsdescThis, … … 187 187 ImportStack &stack, 188 188 PVDINTERFACEIO pCallbacks, 189 P SHA1STORAGE pStorage);189 PRTSHA1STORAGE pStorage); 190 190 void importVBoxMachine(ComObjPtr<VirtualSystemDescription> &vsdescThis, 191 191 ComPtr<IMachine> &pNewMachine, 192 192 ImportStack &stack, 193 193 PVDINTERFACEIO pCallbacks, 194 P SHA1STORAGE pStorage);194 PRTSHA1STORAGE pStorage); 195 195 void importMachines(ImportStack &stack, 196 196 PVDINTERFACEIO pCallbacks, 197 P SHA1STORAGE pStorage);197 PRTSHA1STORAGE pStorage); 198 198 199 199 /******************************************************************************* … … 206 206 HRESULT writeFSOVF(TaskOVF *pTask, AutoWriteLockBase& writeLock); 207 207 HRESULT writeFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock); 208 HRESULT writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pCallbacks, P SHA1STORAGE pStorage);208 HRESULT writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pCallbacks, PRTSHA1STORAGE pStorage); 209 209 HRESULT writeS3(TaskOVF *pTask); 210 210 -
trunk/src/VBox/Main/include/ApplianceImplPrivate.h
r33417 r33651 221 221 ovf::CIMOSType_T convertVBoxOSType2CIMOSType(const char *pcszVbox); 222 222 223 typedef struct SHA1STORAGE223 typedef struct RTSHA1STORAGE 224 224 { 225 225 PVDINTERFACE pVDImageIfaces; 226 226 bool fCreateDigest; 227 227 Utf8Str strDigest; 228 } SHA1STORAGE, *PSHA1STORAGE;229 230 PVDINTERFACEIO Sha1CreateInterface();228 } RTSHA1STORAGE, *PRTSHA1STORAGE; 229 230 PVDINTERFACEIO RTSha1CreateInterface(); 231 231 PVDINTERFACEIO RTFileCreateInterface(); 232 232 PVDINTERFACEIO RTTarCreateInterface(); 233 int Sha1ReadBuf(const char *pcszFilename, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, void *pvUser);234 int Sha1WriteBuf(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO pCallbacks, void *pvUser);233 int RTSha1ReadBuf(const char *pcszFilename, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, void *pvUser); 234 int RTSha1WriteBuf(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO pCallbacks, void *pvUser); 235 235 236 236 #endif // ____H_APPLIANCEIMPLPRIVATE
Note:
See TracChangeset
for help on using the changeset viewer.