儲存庫 vbox 的更動 50200
- 時間撮記:
- 2014-1-23 下午09:13:23 (11 年 以前)
- 位置:
- trunk/src/VBox/Main
- 檔案:
-
- 修改 5 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Main/Makefile.kmk
r50124 r50200 60 60 endif 61 61 VBOX_MAIN_DEFS += \ 62 USE_RTTAR_FOR_READING \ 62 63 $(if $(VBOX_WITH_RAW_MODE),VBOX_WITH_RAW_MODE,) \ 63 64 $(if $(VBOX_WITH_RAW_RING1),VBOX_WITH_RAW_RING1,) \ -
trunk/src/VBox/Main/include/ApplianceImpl.h
r50198 r50200 173 173 PVDINTERFACEIO pCallbacks, 174 174 PSHASTORAGE pStorage); 175 HRESULT i_readTarFileToBuf(RTTAR tar, 176 const Utf8Str &strFile, 177 void **ppvBuf, 178 size_t *pcbSize, 179 bool fCreateDigest, 180 PVDINTERFACEIO pCallbacks, 181 PSHASTORAGE pStorage); 175 HRESULT i_readTarFileToBuf( 176 #ifdef USE_RTTAR_FOR_READING 177 RTTAR tar, 178 #else 179 struct FSSRDONLYINTERFACEIO *pTarIo, 180 #endif 181 const Utf8Str &strFile, 182 void **ppvBuf, 183 size_t *pcbSize, 184 bool fCreateDigest, 185 PVDINTERFACEIO pCallbacks, 186 PSHASTORAGE pStorage); 182 187 HRESULT i_verifyManifestFile(const Utf8Str &strFile, ImportStack &stack, void *pvBuf, size_t cbSize); 183 188 -
trunk/src/VBox/Main/include/ApplianceImplPrivate.h
r50199 r50200 21 21 #include "ovfreader.h" 22 22 #include <map> 23 #include <iprt/vfs.h> 23 24 24 25 //////////////////////////////////////////////////////////////////////////////// … … 249 250 PVDINTERFACEIO FileCreateInterface(); 250 251 PVDINTERFACEIO TarCreateInterface(); 252 253 /** Pointer to the instance data for the fssRdOnly_ methods. */ 254 typedef struct FSSRDONLYINTERFACEIO *PFSSRDONLYINTERFACEIO; 255 256 int fssRdOnlyCreateInterfaceForTarFile(const char *pszFilename, PFSSRDONLYINTERFACEIO *pTarIo); 257 void fssRdOnlyDestroyInterface(PFSSRDONLYINTERFACEIO pFssIo); 258 int fssRdOnlyGetCurrentName(PFSSRDONLYINTERFACEIO pFssIo, const char **ppszName); 259 int fssRdOnlySkipCurrent(PFSSRDONLYINTERFACEIO pFssIo); 260 bool fssRdOnlyIsCurrentDirectory(PFSSRDONLYINTERFACEIO pFssIo); 261 251 262 int readFileIntoBuffer(const char *pcszFilename, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pIfIo, void *pvUser); 252 263 int writeBufferToFile(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO pIfIo, void *pvUser); -
trunk/src/VBox/Main/src-server/ApplianceImplIO.cpp
r50199 r50200 37 37 #include <VBox/vd.h> 38 38 39 #include "Logging.h" 40 41 39 42 /****************************************************************************** 40 43 * Structures and Typedefs * … … 55 58 PFNVDCOMPLETED pfnCompleted; 56 59 } TARSTORAGEINTERNAL, *PTARSTORAGEINTERNAL; 60 57 61 58 62 typedef struct SHASTORAGEINTERNAL … … 119 123 120 124 125 /** @name VDINTERFACEIO stubs returning not-implemented. 126 * @{ 127 */ 128 129 /** @interface_method_impl{VDINTERFACEIO,pfnDelete} */ 130 static DECLCALLBACK(int) notImpl_Delete(void *pvUser, const char *pcszFilename) 131 { 132 NOREF(pvUser); NOREF(pcszFilename); 133 Log(("%s\n", __FUNCTION__)); DEBUG_PRINT_FLOW(); 134 return VERR_NOT_IMPLEMENTED; 135 } 136 137 /** @interface_method_impl{VDINTERFACEIO,pfnMove} */ 138 static DECLCALLBACK(int) notImpl_Move(void *pvUser, const char *pcszSrc, const char *pcszDst, unsigned fMove) 139 { 140 NOREF(pvUser); NOREF(pcszSrc); NOREF(pcszDst); NOREF(fMove); 141 Log(("%s\n", __FUNCTION__)); DEBUG_PRINT_FLOW(); 142 return VERR_NOT_IMPLEMENTED; 143 } 144 145 /** @interface_method_impl{VDINTERFACEIO,pfnGetFreeSpace} */ 146 static DECLCALLBACK(int) notImpl_GetFreeSpace(void *pvUser, const char *pcszFilename, int64_t *pcbFreeSpace) 147 { 148 NOREF(pvUser); NOREF(pcszFilename); NOREF(pcbFreeSpace); 149 Log(("%s\n", __FUNCTION__)); DEBUG_PRINT_FLOW(); 150 return VERR_NOT_IMPLEMENTED; 151 } 152 153 /** @interface_method_impl{VDINTERFACEIO,pfnGetModificationTime} */ 154 static DECLCALLBACK(int) notImpl_GetModificationTime(void *pvUser, const char *pcszFilename, PRTTIMESPEC pModificationTime) 155 { 156 NOREF(pvUser); NOREF(pcszFilename); NOREF(pModificationTime); 157 Log(("%s\n", __FUNCTION__)); DEBUG_PRINT_FLOW(); 158 return VERR_NOT_IMPLEMENTED; 159 } 160 161 /** @interface_method_impl{VDINTERFACEIO,pfnSetSize} */ 162 static DECLCALLBACK(int) notImpl_SetSize(void *pvUser, void *pvStorage, uint64_t cb) 163 { 164 NOREF(pvUser); NOREF(pvStorage); NOREF(cb); 165 Log(("%s\n", __FUNCTION__)); DEBUG_PRINT_FLOW(); 166 return VERR_NOT_IMPLEMENTED; 167 } 168 169 /** @interface_method_impl{VDINTERFACEIO,pfnWriteSync} */ 170 static DECLCALLBACK(int) notImpl_WriteSync(void *pvUser, void *pvStorage, uint64_t off, const void *pvBuf, size_t cbWrite, size_t *pcbWritten) 171 { 172 NOREF(pvUser); NOREF(pvStorage); NOREF(off); NOREF(pvBuf); NOREF(cbWrite); NOREF(pcbWritten); 173 Log(("%s\n", __FUNCTION__)); DEBUG_PRINT_FLOW(); 174 return VERR_NOT_IMPLEMENTED; 175 } 176 177 /** @interface_method_impl{VDINTERFACEIO,pfnFlushSync} */ 178 static DECLCALLBACK(int) notImpl_FlushSync(void *pvUser, void *pvStorage) 179 { 180 NOREF(pvUser); NOREF(pvStorage); 181 Log(("%s\n", __FUNCTION__)); DEBUG_PRINT_FLOW(); 182 return VERR_NOT_IMPLEMENTED; 183 } 184 185 /** @} */ 186 187 121 188 /****************************************************************************** 122 189 * Internal: RTFile interface … … 470 537 return VERR_NOT_IMPLEMENTED; 471 538 } 539 540 541 /** @name VDINTERFACEIO implementation on top of an IPRT file system stream. 542 * @{ */ 543 544 545 /** 546 * Internal data for read only I/O stream (related to FSSRDONLYINTERFACEIO). 547 */ 548 typedef struct IOSRDONLYINTERNAL 549 { 550 /** The I/O stream. */ 551 RTVFSIOSTREAM hVfsIos; 552 /** Completion callback. */ 553 PFNVDCOMPLETED pfnCompleted; 554 } IOSRDONLYINTERNAL, *PIOSRDONLYINTERNAL; 555 556 /** 557 * Extended VD I/O interface structure that fssRdOnly uses. 558 * 559 * It's passed as pvUser to each call. 560 */ 561 typedef struct FSSRDONLYINTERFACEIO 562 { 563 VDINTERFACEIO CoreIo; 564 565 /** The file system stream object. */ 566 RTVFSFSSTREAM hVfsFss; 567 /** Set if we've seen VERR_EOF on the file system stream already. */ 568 bool fEndOfFss; 569 570 /** The current object in the stream. */ 571 RTVFSOBJ hVfsCurObj; 572 /** The name of the current object. */ 573 char *pszCurName; 574 /** The type of the current object. */ 575 RTVFSOBJTYPE enmCurType; 576 577 } FSSRDONLYINTERFACEIO; 578 579 580 /** @interface_method_impl{VDINTERFACEIO,pfnOpen} */ 581 static DECLCALLBACK(int) fssRdOnly_Open(void *pvUser, const char *pszLocation, uint32_t fOpen, PFNVDCOMPLETED pfnCompleted, void **ppInt) 582 { 583 PFSSRDONLYINTERFACEIO pThis = (PFSSRDONLYINTERFACEIO)pvUser; 584 585 /* 586 * Validate input. 587 */ 588 AssertPtrReturn(ppInt, VERR_INVALID_POINTER); 589 AssertPtrNullReturn(pfnCompleted, VERR_INVALID_PARAMETER); 590 AssertReturn((fOpen & RTFILE_O_ACCESS_MASK) == RTFILE_O_READ, VERR_INVALID_PARAMETER); 591 592 DEBUG_PRINT_FLOW(); 593 594 /* 595 * Scan the stream until a matching file is found. 596 */ 597 for (;;) 598 { 599 if (pThis->hVfsCurObj != NIL_RTVFSOBJ) 600 { 601 if (RTStrICmp(pThis->pszCurName, pszLocation) == 0) 602 { 603 switch (pThis->enmCurType) 604 { 605 case RTVFSOBJTYPE_IO_STREAM: 606 case RTVFSOBJTYPE_FILE: 607 { 608 PIOSRDONLYINTERNAL pFile = (PIOSRDONLYINTERNAL)RTMemAlloc(sizeof(*pFile)); 609 if (!pFile) 610 return VERR_NO_MEMORY; 611 pFile->hVfsIos = RTVfsObjToIoStream(pThis->hVfsCurObj); 612 pFile->pfnCompleted = pfnCompleted; 613 *ppInt = pFile; 614 615 /* Force stream to be advanced on next open call. */ 616 RTVfsObjRelease(pThis->hVfsCurObj); 617 pThis->hVfsCurObj = NIL_RTVFSOBJ; 618 RTStrFree(pThis->pszCurName); 619 pThis->pszCurName = NULL; 620 621 return VINF_SUCCESS; 622 } 623 624 case RTVFSOBJTYPE_DIR: 625 return VERR_IS_A_DIRECTORY; 626 default: 627 return VERR_UNEXPECTED_FS_OBJ_TYPE; 628 } 629 } 630 631 /* 632 * Drop the current stream object. 633 */ 634 RTVfsObjRelease(pThis->hVfsCurObj); 635 pThis->hVfsCurObj = NIL_RTVFSOBJ; 636 RTStrFree(pThis->pszCurName); 637 pThis->pszCurName = NULL; 638 } 639 640 /* 641 * Fetch the next object in the stream. 642 */ 643 if (pThis->fEndOfFss) 644 return VERR_FILE_NOT_FOUND; 645 int rc = RTVfsFsStrmNext(pThis->hVfsFss, &pThis->pszCurName, &pThis->enmCurType, &pThis->hVfsCurObj); 646 if (RT_FAILURE(rc)) 647 { 648 pThis->fEndOfFss = rc == VERR_EOF; 649 return rc == VERR_EOF ? VERR_FILE_NOT_FOUND : rc; 650 } 651 } 652 } 653 654 /** @interface_method_impl{VDINTERFACEIO,pfnClose} */ 655 static int fssRdOnly_Close(void *pvUser, void *pvStorage) 656 { 657 PIOSRDONLYINTERNAL pFile = (PIOSRDONLYINTERNAL)pvStorage; 658 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 659 AssertPtrReturn(pFile, VERR_INVALID_POINTER); 660 DEBUG_PRINT_FLOW(); 661 662 uint32_t cRefs = RTVfsIoStrmRelease(pFile->hVfsIos); 663 pFile->hVfsIos = NIL_RTVFSIOSTREAM; 664 RTMemFree(pFile); 665 666 return cRefs != UINT32_MAX ? VINF_SUCCESS : VERR_INTERNAL_ERROR_3; 667 } 668 669 670 /** @interface_method_impl{VDINTERFACEIO,pfnGetSize} */ 671 static DECLCALLBACK(int) fssRdOnly_GetSize(void *pvUser, void *pvStorage, uint64_t *pcb) 672 { 673 PIOSRDONLYINTERNAL pFile = (PIOSRDONLYINTERNAL)pvStorage; 674 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 675 AssertPtrReturn(pFile, VERR_INVALID_POINTER); 676 AssertPtrReturn(pcb, VERR_INVALID_POINTER); 677 DEBUG_PRINT_FLOW(); 678 679 RTFSOBJINFO ObjInfo; 680 int rc = RTVfsIoStrmQueryInfo(pFile->hVfsIos, &ObjInfo, RTFSOBJATTRADD_NOTHING); 681 if (RT_SUCCESS(rc)) 682 *pcb = ObjInfo.cbObject; 683 return rc; 684 } 685 686 /** @interface_method_impl{VDINTERFACEIO,pfnRead} */ 687 static DECLCALLBACK(int) fssRdOnly_ReadSync(void *pvUser, void *pvStorage, uint64_t off, void *pvBuf, size_t cbToRead, size_t *pcbRead) 688 { 689 PIOSRDONLYINTERNAL pFile = (PIOSRDONLYINTERNAL)pvStorage; 690 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 691 AssertPtrReturn(pFile, VERR_INVALID_POINTER); 692 AssertPtrNullReturn(pcbRead, VERR_INVALID_POINTER); 693 DEBUG_PRINT_FLOW(); 694 695 return RTVfsIoStrmReadAt(pFile->hVfsIos, off, pvBuf, cbToRead, true /*fBlocking*/, pcbRead); 696 } 697 698 699 /** 700 * Opens the specified tar file for stream-like reading, returning a VD I/O 701 * interface to it. 702 * 703 * @returns VBox status code. 704 * @param pszFilename The path to the TAR file. 705 * @param ppTarIo Where to return the VD I/O interface. This 706 * shall be passed as pvUser when using the 707 * interface. 708 * 709 * Pass to fssRdOnlyDestroyInterface for cleaning 710 * up! 711 */ 712 int fssRdOnlyCreateInterfaceForTarFile(const char *pszFilename, PFSSRDONLYINTERFACEIO *ppTarIo) 713 { 714 /* 715 * Open the tar file first. 716 */ 717 RTVFSFILE hVfsFile; 718 int rc = RTVfsFileOpenNormal(pszFilename, RTFILE_O_READ | RTFILE_O_DENY_NONE | RTFILE_O_OPEN, &hVfsFile); 719 if (RT_SUCCESS(rc)) 720 { 721 RTVFSIOSTREAM hVfsIos = RTVfsFileToIoStream(hVfsFile); 722 RTVFSFSSTREAM hVfsFss; 723 rc = RTZipTarFsStreamFromIoStream(hVfsIos, 0 /*fFlags*/, &hVfsFss); 724 if (RT_SUCCESS(rc)) 725 { 726 /* 727 * Allocate and init a callback + instance data structure. 728 */ 729 PFSSRDONLYINTERFACEIO pThis = (PFSSRDONLYINTERFACEIO)RTMemAllocZ(sizeof(*pThis)); 730 if (pThis) 731 { 732 pThis->CoreIo.pfnOpen = fssRdOnly_Open; 733 pThis->CoreIo.pfnClose = fssRdOnly_Close; 734 pThis->CoreIo.pfnDelete = notImpl_Delete; 735 pThis->CoreIo.pfnMove = notImpl_Move; 736 pThis->CoreIo.pfnGetFreeSpace = notImpl_GetFreeSpace; 737 pThis->CoreIo.pfnGetModificationTime = notImpl_GetModificationTime; 738 pThis->CoreIo.pfnGetSize = fssRdOnly_GetSize; 739 pThis->CoreIo.pfnSetSize = notImpl_SetSize; 740 pThis->CoreIo.pfnReadSync = fssRdOnly_ReadSync; 741 pThis->CoreIo.pfnWriteSync = notImpl_WriteSync; 742 pThis->CoreIo.pfnFlushSync = notImpl_FlushSync; 743 744 pThis->hVfsFss = hVfsFss; 745 pThis->fEndOfFss = false; 746 pThis->hVfsCurObj = NIL_RTVFSOBJ; 747 pThis->pszCurName = NULL; 748 pThis->enmCurType = RTVFSOBJTYPE_INVALID; 749 750 *ppTarIo = pThis; 751 return VINF_SUCCESS; 752 } 753 754 RTVfsFsStrmRelease(hVfsFss); 755 } 756 RTVfsIoStrmRelease(hVfsIos); 757 RTVfsFileRelease(hVfsFile); 758 } 759 760 *ppTarIo = NULL; 761 return rc; 762 } 763 764 /** 765 * Destroys a read-only FSS interface. 766 * 767 * @param pFssIo What TarFssCreateReadOnlyInterfaceForFile 768 * returned. 769 */ 770 void fssRdOnlyDestroyInterface(PFSSRDONLYINTERFACEIO pFssIo) 771 { 772 AssertPtr(pFssIo); AssertPtr(pFssIo->hVfsFss); 773 774 RTVfsFsStrmRelease(pFssIo->hVfsFss); 775 pFssIo->hVfsFss = NIL_RTVFSFSSTREAM; 776 777 RTVfsObjRelease(pFssIo->hVfsCurObj); 778 pFssIo->hVfsCurObj = NIL_RTVFSOBJ; 779 780 RTStrFree(pFssIo->pszCurName); 781 pFssIo->pszCurName = NULL; 782 783 RTMemFree(pFssIo); 784 } 785 786 787 /** 788 * Returns the read-only name of the current stream object. 789 * 790 * @returns VBox status code. 791 * @param pFssIo What TarFssCreateReadOnlyInterfaceForFile 792 * returned. 793 * @param ppszName Where to return the filename. DO NOT FREE! 794 */ 795 int fssRdOnlyGetCurrentName(PFSSRDONLYINTERFACEIO pFssIo, const char **ppszName) 796 { 797 AssertPtr(pFssIo); AssertPtr(pFssIo->hVfsFss); 798 799 if (pFssIo->hVfsCurObj == NIL_RTVFSOBJ) 800 { 801 if (pFssIo->fEndOfFss) 802 return VERR_EOF; 803 int rc = RTVfsFsStrmNext(pFssIo->hVfsFss, &pFssIo->pszCurName, &pFssIo->enmCurType, &pFssIo->hVfsCurObj); 804 if (RT_FAILURE(rc)) 805 { 806 pFssIo->fEndOfFss = rc == VERR_EOF; 807 *ppszName = NULL; 808 return rc; 809 } 810 } 811 812 *ppszName = pFssIo->pszCurName; 813 return VINF_SUCCESS; 814 } 815 816 817 /** 818 * Skips the current object. 819 * 820 * @returns VBox status code. 821 * @param pFssIo What TarFssCreateReadOnlyInterfaceForFile 822 * returned. 823 */ 824 int fssRdOnlySkipCurrent(PFSSRDONLYINTERFACEIO pFssIo) 825 { 826 AssertPtr(pFssIo); AssertPtr(pFssIo->hVfsFss); 827 828 if (pFssIo->hVfsCurObj == NIL_RTVFSOBJ) 829 { 830 if (pFssIo->fEndOfFss) 831 return VERR_EOF; 832 int rc = RTVfsFsStrmNext(pFssIo->hVfsFss, &pFssIo->pszCurName, &pFssIo->enmCurType, &pFssIo->hVfsCurObj); 833 if (RT_FAILURE(rc)) 834 { 835 pFssIo->fEndOfFss = rc == VERR_EOF; 836 return rc; 837 } 838 } 839 840 /* Force a RTVfsFsStrmNext call the next time around. */ 841 RTVfsObjRelease(pFssIo->hVfsCurObj); 842 pFssIo->hVfsCurObj = NIL_RTVFSOBJ; 843 844 RTStrFree(pFssIo->pszCurName); 845 pFssIo->pszCurName = NULL; 846 847 return VINF_SUCCESS; 848 } 849 850 851 /** 852 * Checks if the current file is a directory. 853 * 854 * @returns true if directory, false if not (or error). 855 * @param pFssIo What TarFssCreateReadOnlyInterfaceForFile 856 * returned. 857 */ 858 bool fssRdOnlyIsCurrentDirectory(PFSSRDONLYINTERFACEIO pFssIo) 859 { 860 AssertPtr(pFssIo); AssertPtr(pFssIo->hVfsFss); 861 862 if (pFssIo->hVfsCurObj == NIL_RTVFSOBJ) 863 { 864 if (pFssIo->fEndOfFss) 865 return false; 866 int rc = RTVfsFsStrmNext(pFssIo->hVfsFss, &pFssIo->pszCurName, &pFssIo->enmCurType, &pFssIo->hVfsCurObj); 867 if (RT_FAILURE(rc)) 868 { 869 pFssIo->fEndOfFss = rc == VERR_EOF; 870 return false; 871 } 872 } 873 874 return pFssIo->enmCurType == RTVFSOBJTYPE_DIR; 875 } 876 877 878 879 /** @} */ 880 472 881 473 882 /****************************************************************************** -
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r50199 r50200 786 786 RTCString &availableImage) 787 787 { 788 HRESULT rc = S_OK; 788 #ifdef USE_RTTAR_FOR_READING 789 789 RTTAR tar = (RTTAR)pSHAStorage->pVDImageIfaces->pvUser; 790 790 char *pszFilename = 0; … … 804 804 805 805 availableImage = pszFilename; 806 807 return rc; 806 return S_OK; 807 808 #else 809 PFSSRDONLYINTERFACEIO pTarIo = (PFSSRDONLYINTERFACEIO)pSHAStorage->pVDImageIfaces->pvUser; 810 const char *pszFilename; 811 int vrc = fssRdOnlyGetCurrentName(pTarIo, &pszFilename); 812 if (RT_SUCCESS(vrc)) 813 { 814 if (!fssRdOnlyIsCurrentDirectory(pTarIo)) 815 { 816 availableImage = pszFilename; 817 return S_OK; 818 } 819 820 throw setError(VBOX_E_FILE_ERROR, tr("Empty directory folder (%s) isn't allowed in the OVA package (%Rrc)"), 821 pszFilename, VERR_IS_A_DIRECTORY); 822 } 823 824 throw setError(VBOX_E_FILE_ERROR, tr("Could not open the current file in the OVA package (%Rrc)"), vrc); 825 #endif 808 826 } 809 827 … … 1046 1064 LogFlowFuncEnter(); 1047 1065 1066 #ifdef USE_RTTAR_FOR_READING 1048 1067 RTTAR tar; 1049 1068 HRESULT rc = S_OK; … … 1119 1138 } 1120 1139 1121 1122 1123 1140 /* Cleanup */ 1124 1141 if (pszFilename) … … 1133 1150 1134 1151 return rc; 1152 1153 #else 1154 /* 1155 * Open the tar file and get a VD I/O interface for it. 1156 */ 1157 HRESULT hrc; 1158 PFSSRDONLYINTERFACEIO pTarIo; 1159 int vrc = fssRdOnlyCreateInterfaceForTarFile(pTask->locInfo.strPath.c_str(), &pTarIo); 1160 if (RT_SUCCESS(vrc)) 1161 { 1162 /* 1163 * Check that the first file is has an .ovf suffix. 1164 */ 1165 const char *pszName; 1166 vrc = fssRdOnlyGetCurrentName(pTarIo, &pszName); 1167 if (RT_SUCCESS(vrc)) 1168 { 1169 size_t cchName = strlen(pszName); 1170 if ( cchName >= sizeof(".ovf") 1171 && RTStrICmp(&pszName[cchName - sizeof(".ovf") + 1], ".ovf") == 0) 1172 { 1173 /* 1174 * Stack the rest of the expected VD I/O stuff. 1175 */ 1176 PVDINTERFACEIO pShaIo = ShaCreateInterface(); 1177 if (pShaIo) 1178 { 1179 Utf8Str IoName = i_applianceIOName(applianceIOTar); 1180 SHASTORAGE ShaStorage; 1181 RT_ZERO(ShaStorage); 1182 vrc = VDInterfaceAdd((PVDINTERFACE)pTarIo, IoName.c_str(), 1183 VDINTERFACETYPE_IO, pTarIo, sizeof(VDINTERFACEIO), 1184 &ShaStorage.pVDImageIfaces); 1185 if (RT_SUCCESS(vrc)) 1186 /* 1187 * Read and parse the OVF. 1188 */ 1189 hrc = i_readFSImpl(pTask, pszName, pShaIo, &ShaStorage); 1190 else 1191 hrc = setError(VBOX_E_IPRT_ERROR, "Creation of the VD interface failed (%Rrc)", vrc); 1192 RTMemFree(pShaIo); 1193 } 1194 else 1195 hrc = E_OUTOFMEMORY; 1196 } 1197 else 1198 hrc = setError(VBOX_E_FILE_ERROR, 1199 tr("First file in the OVA package must have the extension 'ovf'. But the file '%s' has a different extension."), 1200 pszName); 1201 } 1202 else 1203 hrc = setError(VBOX_E_FILE_ERROR, tr("Error reading OVA file '%s' (%Rrc)"), pTask->locInfo.strPath.c_str(), vrc); 1204 fssRdOnlyDestroyInterface(pTarIo); 1205 } 1206 else 1207 hrc = setError(VBOX_E_FILE_ERROR, tr("Could not open the OVA file '%s' (%Rrc)"), pTask->locInfo.strPath.c_str(), vrc); 1208 1209 LogFlowFunc(("rc=%Rhrc\n", hrc)); 1210 LogFlowFuncLeave(); 1211 return hrc; 1212 #endif 1135 1213 } 1136 1214 … … 1604 1682 { 1605 1683 LogFlowFuncEnter(); 1606 1684 HRESULT rc = S_OK; 1685 1686 /* 1687 * Open the OVA (TAR) file. 1688 */ 1689 #ifdef USE_RTTAR_FOR_READING 1690 PVDINTERFACEIO pTarIo = 0; 1607 1691 RTTAR tar; 1608 1692 int vrc = RTTarOpen(&tar, 1609 1693 pTask->locInfo.strPath.c_str(), 1610 1694 RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE, true); 1695 #else 1696 PFSSRDONLYINTERFACEIO pTarIo; 1697 int vrc = fssRdOnlyCreateInterfaceForTarFile(pTask->locInfo.strPath.c_str(), &pTarIo); 1698 PFSSRDONLYINTERFACEIO tar = pTarIo; /* temporary hack */ 1699 #endif 1611 1700 if (RT_FAILURE(vrc)) 1612 1701 return setError(VBOX_E_FILE_ERROR, … … 1614 1703 pTask->locInfo.strPath.c_str(), vrc); 1615 1704 1616 HRESULT rc = S_OK;1617 1705 1618 1706 PVDINTERFACEIO pShaIo = 0; 1619 PVDINTERFACEIO pTarIo = 0; 1707 #ifdef USE_RTTAR_FOR_READING 1620 1708 char *pszFilename = 0; 1709 #endif 1621 1710 void *pvMfBuf = 0; 1622 1711 void *pvCertBuf = 0; … … 1634 1723 if (!pShaIo) 1635 1724 throw setError(E_OUTOFMEMORY); 1725 #ifdef USE_RTTAR_FOR_READING 1636 1726 pTarIo = TarCreateInterface(); 1637 1727 if (!pTarIo) 1638 1728 throw setError(E_OUTOFMEMORY); 1729 #endif 1639 1730 1640 1731 SHASTORAGE storage; … … 1643 1734 Utf8Str nameTar = i_applianceIOName(applianceIOTar); 1644 1735 1736 #ifdef USE_RTTAR_FOR_READING 1645 1737 vrc = VDInterfaceAdd(&pTarIo->Core, nameTar.c_str(), 1646 1738 VDINTERFACETYPE_IO, tar, sizeof(VDINTERFACEIO), 1647 1739 &storage.pVDImageIfaces); 1740 #else 1741 vrc = VDInterfaceAdd((PVDINTERFACE)pTarIo, nameTar.c_str(), 1742 VDINTERFACETYPE_IO, pTarIo, sizeof(VDINTERFACEIO), 1743 &storage.pVDImageIfaces); 1744 #endif 1648 1745 if (RT_FAILURE(vrc)) 1649 1746 throw setError(VBOX_E_IPRT_ERROR, … … 1665 1762 * are named. 1666 1763 */ 1764 #ifdef USE_RTTAR_FOR_READING 1667 1765 vrc = RTTarCurrentFile(tar, &pszFilename); 1766 #else 1767 const char *pszFilename; 1768 vrc = fssRdOnlyGetCurrentName(pTarIo, &pszFilename); 1769 #endif 1668 1770 if (RT_FAILURE(vrc)) 1669 1771 throw setError(VBOX_E_IPRT_ERROR, … … 1682 1784 1683 1785 /* Skip the OVF file, cause this was read in IAppliance::Read already. */ 1786 #ifdef USE_RTTAR_FOR_READING 1684 1787 vrc = RTTarSeekNextFile(tar); 1685 1788 if ( RT_FAILURE(vrc) … … 1694 1797 tr("Empty directory folder (%s) isn't allowed in the OVA package (%Rrc)"), 1695 1798 pszFilename, vrc); 1799 #else 1800 vrc = fssRdOnlySkipCurrent(pTarIo); 1801 if (RT_SUCCESS(vrc)) 1802 vrc = fssRdOnlyGetCurrentName(pTarIo, &pszFilename); 1803 if ( RT_FAILURE(vrc) 1804 && vrc != VERR_EOF) 1805 throw setError(VBOX_E_IPRT_ERROR, tr("Seeking within the archive failed (%Rrc)"), vrc); 1806 #endif 1696 1807 1697 1808 PVDINTERFACEIO pCallbacks = pShaIo; … … 1725 1836 * there is a manifest file. 1726 1837 */ 1838 #ifdef USE_RTTAR_FOR_READING 1727 1839 vrc = RTTarCurrentFile(tar, &pszFilename); 1840 #else 1841 vrc = fssRdOnlyGetCurrentName(pTarIo, &pszFilename); 1842 #endif 1728 1843 if (RT_SUCCESS(vrc)) 1729 1844 { … … 1772 1887 * (Requires mainfest, as mention before.) 1773 1888 */ 1889 #ifdef USE_RTTAR_FOR_READING 1774 1890 RTStrFree(pszFilename); 1775 1891 pszFilename = NULL; 1776 1892 vrc = RTTarCurrentFile(tar, &pszFilename); 1893 #else 1894 vrc = fssRdOnlyGetCurrentName(pTarIo, &pszFilename); 1895 #endif 1777 1896 if (RT_SUCCESS(vrc)) 1778 1897 { … … 1819 1938 writeLock.acquire(); 1820 1939 1940 #ifdef USE_RTTAR_FOR_READING 1821 1941 RTTarClose(tar); 1942 #else 1943 fssRdOnlyDestroyInterface(pTarIo); 1944 #endif 1822 1945 1823 1946 /* Cleanup */ 1947 #ifdef USE_RTTAR_FOR_READING 1824 1948 if (pszFilename) 1825 1949 RTStrFree(pszFilename); 1950 #endif 1826 1951 if (pvMfBuf) 1827 1952 RTMemFree(pvMfBuf); 1828 1953 if (pShaIo) 1829 1954 RTMemFree(pShaIo); 1955 #ifdef USE_RTTAR_FOR_READING 1830 1956 if (pTarIo) 1831 1957 RTMemFree(pTarIo); 1958 #endif 1832 1959 if (pvCertBuf) 1833 1960 RTMemFree(pvCertBuf); … … 2057 2184 } 2058 2185 2059 HRESULT Appliance::i_readTarFileToBuf(RTTAR tar, 2186 HRESULT Appliance::i_readTarFileToBuf( 2187 #ifdef USE_RTTAR_FOR_READING 2188 RTTAR tar, 2189 #else 2190 PFSSRDONLYINTERFACEIO pTarIo, 2191 #endif 2060 2192 const Utf8Str &strFile, 2061 2193 void **ppvBuf, … … 2067 2199 HRESULT rc = S_OK; 2068 2200 2201 #ifdef USE_RTTAR_FOR_READING 2069 2202 char *pszCurFile; 2070 2203 int vrc = RTTarCurrentFile(tar, &pszCurFile); 2204 #else 2205 const char *pszCurFile; 2206 int vrc = fssRdOnlyGetCurrentName(pTarIo, &pszCurFile); 2207 #endif 2071 2208 if (RT_SUCCESS(vrc)) 2072 2209 { … … 2080 2217 tr("Empty directory folder (%s) isn't allowed in the OVA package (%Rrc)"), 2081 2218 pszCurFile, vrc); 2219 #ifdef USE_RTTAR_FOR_READING 2082 2220 RTStrFree(pszCurFile); 2083 } 2221 #endif 2222 } 2223 #ifdef USE_RTTAR_FOR_READING 2084 2224 else if (vrc != VERR_TAR_END_OF_FILE) 2225 #else 2226 else if (vrc != VERR_EOF) 2227 #endif 2085 2228 rc = setError(VBOX_E_IPRT_ERROR, "Seeking within the archive failed (%Rrc)", vrc); 2086 2229
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器