Changeset 7780 in vbox
- Timestamp:
- Apr 7, 2008 4:36:56 PM (17 years ago)
- Location:
- trunk/src/VBox/Devices/Storage
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/RawHDDCore.cpp
r7654 r7780 466 466 static int rawWrite(void *pBackendData, uint64_t uOffset, const void *pvBuf, 467 467 size_t cbToWrite, size_t *pcbWriteProcess, 468 size_t *pcbPreRead, size_t *pcbPostRead )468 size_t *pcbPreRead, size_t *pcbPostRead, unsigned fWrite) 469 469 { 470 470 LogFlowFunc(("pBackendData=%#p uOffset=%llu pvBuf=%#p cbToWrite=%zu pcbWriteProcess=%#p pcbPreRead=%#p pcbPostRead=%#p\n", pBackendData, uOffset, pvBuf, cbToWrite, pcbWriteProcess, pcbPreRead, pcbPostRead)); … … 990 990 /* cbSize */ 991 991 sizeof(VBOXHDDBACKEND), 992 /* uBackendCaps */ 993 VD_CAP_CREATE_FIXED, 992 994 /* pfnCheckIfValid */ 993 995 rawCheckIfValid, -
trunk/src/VBox/Devices/Storage/VBoxHDD-new.cpp
r7690 r7780 109 109 110 110 111 extern VBOXHDDBACKEND g_RawBackend; 111 112 extern VBOXHDDBACKEND g_VmdkBackend; 112 113 extern VBOXHDDBACKEND g_VDIBackend; … … 117 118 static PCVBOXHDDBACKEND aBackends[] = 118 119 { 120 &g_RawBackend, 119 121 &g_VmdkBackend, 120 122 &g_VDIBackend, … … 441 443 uOffset - cbPreRead, pvTmp, 442 444 cbPreRead + cbThisWrite + cbPostRead, 443 NULL, 444 &cbPreRead, &cbPostRead); 445 NULL, &cbPreRead, &cbPostRead, 0); 445 446 Assert(rc != VERR_VDI_BLOCK_FREE); 446 447 Assert(cbPreRead == 0); … … 521 522 uOffset - cbPreRead, pvTmp, 522 523 cbPreRead + cbThisWrite + cbPostRead, 523 NULL, 524 &cbPreRead, &cbPostRead); 524 NULL, &cbPreRead, &cbPostRead, 0); 525 525 Assert(rc != VERR_VDI_BLOCK_FREE); 526 526 Assert(cbPreRead == 0); … … 551 551 rc = pImage->Backend->pfnWrite(pImage->pvBackendData, uOffset, pvBuf, 552 552 cbThisWrite, &cbThisWrite, &cbPreRead, 553 &cbPostRead );553 &cbPostRead, 0); 554 554 if (rc == VERR_VDI_BLOCK_FREE) 555 555 { … … 585 585 } while (cbWrite != 0 && VBOX_SUCCESS(rc)); 586 586 587 return rc; 588 } 589 590 591 /** 592 * Lists all HDD backends and their capabilities in a caller-provided buffer. 593 * 594 * @returns VBox status code. 595 * VERR_BUFFER_OVERFLOW if not enough space is passed. 596 * @param cEntriesAlloc Number of list entries available. 597 * @param pEntries Pointer to array for the entries. 598 * @param pcEntriesUsed Number of entries returned. 599 */ 600 VBOXDDU_DECL(int) VDBackendInfo(unsigned cEntriesAlloc, PVDBACKENDINFO pEntries, 601 unsigned *pcEntriesUsed) 602 { 603 int rc = VINF_SUCCESS; 604 PRTDIR pPluginDir = NULL; 605 unsigned cEntries = 0; 606 607 LogFlowFunc(("cEntriesAlloc=%u pEntries=%#p pcEntriesUsed=%#p\n", cEntriesAlloc, pEntries, pcEntriesUsed)); 608 do 609 { 610 /* Check arguments. */ 611 AssertMsgBreak(cEntriesAlloc, 612 ("cEntriesAlloc=%u\n", cEntriesAlloc), 613 rc = VERR_INVALID_PARAMETER); 614 AssertMsgBreak(VALID_PTR(pEntries), 615 ("pEntries=%#p\n", pEntries), 616 rc = VERR_INVALID_PARAMETER); 617 AssertMsgBreak(VALID_PTR(pcEntriesUsed), 618 ("pcEntriesUsed=%#p\n", pcEntriesUsed), 619 rc = VERR_INVALID_PARAMETER); 620 621 /* First enumerate static backends. */ 622 for (unsigned i = 0; aBackends[i] != NULL; i++) 623 { 624 char *pszName = RTStrDup(aBackends[i]->pszBackendName); 625 if (!pszName) 626 { 627 rc = VERR_NO_MEMORY; 628 break; 629 } 630 pEntries[cEntries].pszBackend = pszName; 631 pEntries[cEntries].uBackendCaps = aBackends[i]->uBackendCaps; 632 cEntries++; 633 if (cEntries >= cEntriesAlloc) 634 { 635 rc = VERR_BUFFER_OVERFLOW; 636 break; 637 } 638 } 639 if (VBOX_FAILURE(rc)) 640 break; 641 642 /* Then enumerate plugin backends. */ 643 char szPath[RTPATH_MAX]; 644 rc = RTPathSharedLibs(szPath, sizeof(szPath)); 645 if (VBOX_FAILURE(rc)) 646 break; 647 648 /* To get all entries with VBoxHDD as prefix. */ 649 char *pszPluginFilter; 650 rc = RTStrAPrintf(&pszPluginFilter, "%s/%s*", szPath, 651 VBOX_HDDFORMAT_PLUGIN_PREFIX); 652 if (VBOX_FAILURE(rc)) 653 { 654 rc = VERR_NO_MEMORY; 655 break; 656 } 657 658 /* The plugins are in the same directory as the other shared libs. */ 659 rc = RTDirOpenFiltered(&pPluginDir, pszPluginFilter, RTDIRFILTER_WINNT); 660 if (VBOX_FAILURE(rc)) 661 break; 662 663 PRTDIRENTRY pPluginDirEntry = NULL; 664 unsigned cbPluginDirEntry = sizeof(RTDIRENTRY); 665 pPluginDirEntry = (PRTDIRENTRY)RTMemAllocZ(sizeof(RTDIRENTRY)); 666 if (!pPluginDirEntry) 667 { 668 rc = VERR_NO_MEMORY; 669 break; 670 } 671 672 while ((rc = RTDirRead(pPluginDir, pPluginDirEntry, &cbPluginDirEntry)) != VERR_NO_MORE_FILES) 673 { 674 RTLDRMOD hPlugin = NIL_RTLDRMOD; 675 PFNVBOXHDDFORMATLOAD pfnHDDFormatLoad = NULL; 676 PVBOXHDDBACKEND pBackend = NULL; 677 678 if (rc == VERR_BUFFER_OVERFLOW) 679 { 680 /* allocate new buffer. */ 681 RTMemFree(pPluginDirEntry); 682 pPluginDirEntry = (PRTDIRENTRY)RTMemAllocZ(cbPluginDirEntry); 683 /* Retry. */ 684 rc = RTDirRead(pPluginDir, pPluginDirEntry, &cbPluginDirEntry); 685 if (VBOX_FAILURE(rc)) 686 break; 687 } 688 else if (VBOX_FAILURE(rc)) 689 break; 690 691 /* We got the new entry. */ 692 if (pPluginDirEntry->enmType != RTDIRENTRYTYPE_FILE) 693 continue; 694 695 rc = RTLdrLoad(pPluginDirEntry->szName, &hPlugin); 696 if (VBOX_SUCCESS(rc)) 697 { 698 rc = RTLdrGetSymbol(hPlugin, VBOX_HDDFORMAT_LOAD_NAME, (void**)&pfnHDDFormatLoad); 699 if (VBOX_FAILURE(rc) || !pfnHDDFormatLoad) 700 { 701 LogFunc(("error resolving the entry point %s in plugin %s, rc=%Vrc, pfnHDDFormat=%#p\n", VBOX_HDDFORMAT_LOAD_NAME, pPluginDirEntry->szName, rc, pfnHDDFormatLoad)); 702 if (VBOX_SUCCESS(rc)) 703 rc = VERR_SYMBOL_NOT_FOUND; 704 } 705 706 if (VBOX_SUCCESS(rc)) 707 { 708 /* Get the function table. */ 709 rc = pfnHDDFormatLoad(&pBackend); 710 if (VBOX_SUCCESS(rc) && pBackend->cbSize == sizeof(VBOXHDDBACKEND)) 711 { 712 char *pszName = RTStrDup(pBackend->pszBackendName); 713 if (!pszName) 714 { 715 rc = VERR_NO_MEMORY; 716 break; 717 } 718 pEntries[cEntries].pszBackend = pszName; 719 pEntries[cEntries].uBackendCaps = pBackend->uBackendCaps; 720 cEntries++; 721 if (cEntries >= cEntriesAlloc) 722 { 723 rc = VERR_BUFFER_OVERFLOW; 724 break; 725 } 726 } 727 } 728 else 729 pBackend = NULL; 730 731 RTLdrClose(hPlugin); 732 } 733 } 734 RTStrFree(pszPluginFilter); 735 if (pPluginDirEntry) 736 RTMemFree(pPluginDirEntry); 737 if (pPluginDir) 738 RTDirClose(pPluginDir); 739 } while (0); 740 741 LogFlowFunc(("returns %Vrc *pcEntriesUsed=%u\n", rc, cEntries)); 742 *pcEntriesUsed = cEntries; 587 743 return rc; 588 744 } … … 3029 3185 { 3030 3186 RTLogPrintf("Dumping VD image \"%s\" (Backend=%s)\n", 3031 3187 pImage->Backend->pszBackendName, pImage->pszFilename); 3032 3188 pImage->Backend->pfnDump(pImage->pvBackendData); 3033 3189 } -
trunk/src/VBox/Devices/Storage/VBoxHDD-newInternal.h
r7155 r7780 21 21 #include <VBox/VBoxHDD-new.h> 22 22 23 24 /** @name VBox HDD backend write flags 25 * @{ 26 */ 27 /** Do not allocate a new block on this write. */ 28 #define VD_WRITE_NO_ALLOC RT_BIT(1) 29 /** @}*/ 30 31 23 32 /** 24 33 * Image format backend interface used by VBox HDD Container implementation. … … 35 44 */ 36 45 uint32_t cbSize; 46 47 /** 48 * The capabilities of the backend. 49 */ 50 uint64_t uBackendCaps; 37 51 38 52 /** … … 144 158 * @param pcbPostRead Pointer to the returned amount of data that must 145 159 * be postfixed to perform a full block write. 146 */ 147 DECLR3CALLBACKMEMBER(int, pfnWrite, (void *pvBackendData, uint64_t off, const void *pvBuf, size_t cbWrite, size_t *pcbWriteProcess, size_t *pcbPreRead, size_t *pcbPostRead)); 160 * @param fWrite Flags which affect write behavior. Combination 161 * of the VD_WRITE_* flags. 162 */ 163 DECLR3CALLBACKMEMBER(int, pfnWrite, (void *pvBackendData, uint64_t off, const void *pvBuf, size_t cbWrite, size_t *pcbWriteProcess, size_t *pcbPreRead, size_t *pcbPostRead, unsigned fWrite)); 148 164 149 165 /** -
trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp
r7689 r7780 962 962 static int vdiWrite(void *pBackendData, uint64_t uOffset, const void *pvBuf, 963 963 size_t cbToWrite, size_t *pcbWriteProcess, 964 size_t *pcbPreRead, size_t *pcbPostRead )964 size_t *pcbPreRead, size_t *pcbPostRead, unsigned fWrite) 965 965 { 966 966 LogFlowFunc(("pBackendData=%#p uOffset=%llu pvBuf=%#p cbToWrite=%zu pcbWriteProcess=%#p pcbPreRead=%#p pcbPostRead=%#p\n", pBackendData, uOffset, pvBuf, cbToWrite, pcbWriteProcess, pcbPreRead, pcbPostRead)); … … 1710 1710 /* cbSize */ 1711 1711 sizeof(VBOXHDDBACKEND), 1712 /* uBackendCaps */ 1713 VD_CAP_UUID | VD_CAP_CREATE_FIXED | VD_CAP_CREATE_DYNAMIC 1714 | VD_CAP_CREATE_SPLIT_2G | VD_CAP_DIFF, 1712 1715 /* pfnCheckIfValid */ 1713 1716 vdiCheckIfValid, -
trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp
r7653 r7780 3683 3683 static int vmdkWrite(void *pBackendData, uint64_t uOffset, const void *pvBuf, 3684 3684 size_t cbToWrite, size_t *pcbWriteProcess, 3685 size_t *pcbPreRead, size_t *pcbPostRead )3685 size_t *pcbPreRead, size_t *pcbPostRead, unsigned fWrite) 3686 3686 { 3687 3687 LogFlowFunc(("pBackendData=%#p uOffset=%llu pvBuf=%#p cbToWrite=%zu pcbWriteProcess=%#p pcbPreRead=%#p pcbPostRead=%#p\n", pBackendData, uOffset, pvBuf, cbToWrite, pcbWriteProcess, pcbPreRead, pcbPostRead)); … … 4350 4350 /* cbSize */ 4351 4351 sizeof(VBOXHDDBACKEND), 4352 /* uBackendCaps */ 4353 VD_CAP_UUID | VD_CAP_CREATE_FIXED | VD_CAP_CREATE_DYNAMIC 4354 | VD_CAP_CREATE_SPLIT_2G | VD_CAP_DIFF, 4352 4355 /* pfnCheckIfValid */ 4353 4356 vmdkCheckIfValid,
Note:
See TracChangeset
for help on using the changeset viewer.