Changeset 33524 in vbox for trunk/src/VBox/Devices/Storage
- Timestamp:
- Oct 27, 2010 4:44:37 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67121
- Location:
- trunk/src/VBox/Devices/Storage
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DMGHDDCore.cpp
r33479 r33524 407 407 408 408 /** NULL-terminated array of supported file extensions. */ 409 static const char *const s_apszDmgFileExtensions[] =410 { 411 "dmg",412 NULL409 static const VDFILEEXTENSION s_aDmgFileExtensions[] = 410 { 411 {"dmg", VDTYPE_DVD}, 412 {NULL, VDTYPE_INVALID} 413 413 }; 414 414 … … 1592 1592 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 1593 1593 static int dmgCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 1594 PVDINTERFACE pVDIfsImage) 1595 { 1596 LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage)); 1594 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 1595 { 1596 LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p penmType=%#p\n", 1597 pszFilename, pVDIfsDisk, pVDIfsImage, penmType)); 1597 1598 int rc; 1598 1599 PVDIOSTORAGE pStorage; … … 1639 1640 { 1640 1641 if (dmgUdifFtrIsValid(&Ftr, offFtr)) 1642 { 1641 1643 rc = VINF_SUCCESS; 1644 *penmType = VDTYPE_DVD; 1645 } 1642 1646 else 1643 1647 { … … 1659 1663 static int dmgOpen(const char *pszFilename, unsigned uOpenFlags, 1660 1664 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 1661 void **ppBackendData)1665 VDTYPE enmType, void **ppBackendData) 1662 1666 { 1663 1667 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); … … 2136 2140 { 2137 2141 LogFlowFunc(("pBackendData=%#p pszComment=\"%s\"\n", pBackendData, pszComment)); 2138 PDMGIMAGE p This= (PDMGIMAGE)pBackendData;2142 PDMGIMAGE pImage = (PDMGIMAGE)pBackendData; 2139 2143 int rc; 2140 2144 2141 AssertPtr(pThis); 2142 2143 if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2144 { 2145 rc = VERR_VD_IMAGE_READ_ONLY; 2146 goto out; 2147 } 2148 2149 if (pThis) 2150 rc = VERR_NOT_SUPPORTED; 2145 AssertPtr(pImage); 2146 2147 if (pImage) 2148 { 2149 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2150 rc = VERR_VD_IMAGE_READ_ONLY; 2151 else 2152 rc = VERR_NOT_SUPPORTED; 2153 } 2151 2154 else 2152 2155 rc = VERR_VD_NOT_OPENED; … … 2346 2349 /* uBackendCaps */ 2347 2350 VD_CAP_FILE | VD_CAP_VFS, 2348 /* pa pszFileExtensions */2349 s_a pszDmgFileExtensions,2351 /* paFileExtensions */ 2352 s_aDmgFileExtensions, 2350 2353 /* paConfigInfo */ 2351 2354 NULL, -
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r33218 r33524 2004 2004 unsigned iLevel = 0; 2005 2005 PCFGMNODE pCurNode = pCfg; 2006 VDTYPE enmType = VDTYPE_HDD; 2006 2007 2007 2008 for (;;) … … 2017 2018 "ReadOnly\0MaybeReadOnly\0TempReadOnly\0Shareable\0HonorZeroWrites\0" 2018 2019 "HostIPStack\0UseNewIo\0BootAcceleration\0BootAccelerationBuffer\0" 2019 "SetupMerge\0MergeSource\0MergeTarget\0BwGroup\0 ");2020 "SetupMerge\0MergeSource\0MergeTarget\0BwGroup\0Type\0"); 2020 2021 } 2021 2022 else … … 2132 2133 else 2133 2134 rc = VINF_SUCCESS; 2135 2136 char *psz; 2137 rc = CFGMR3QueryStringAlloc(pCfg, "Type", &psz); 2138 if (RT_FAILURE(rc)) 2139 { 2140 rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_BLOCK_NO_TYPE, N_("Failed to obtain the type")); 2141 break; 2142 } 2143 else if (!strcmp(psz, "HardDisk")) 2144 enmType = VDTYPE_HDD; 2145 else if (!strcmp(psz, "DVD")) 2146 enmType = VDTYPE_DVD; 2147 else if (!strcmp(psz, "Floppy")) 2148 enmType = VDTYPE_FLOPPY; 2149 else 2150 { 2151 rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_BLOCK_UNKNOWN_TYPE, RT_SRC_POS, 2152 N_("Unknown type \"%s\""), psz); 2153 MMR3HeapFree(psz); 2154 break; 2155 } 2156 MMR3HeapFree(psz); psz = NULL; 2134 2157 } 2135 2158 … … 2270 2293 if (RT_SUCCESS(rc)) 2271 2294 { 2272 rc = VDCreate(pThis->pVDIfsDisk, &pThis->pDisk);2295 rc = VDCreate(pThis->pVDIfsDisk, enmType, &pThis->pDisk); 2273 2296 /* Error message is already set correctly. */ 2274 2297 } -
trunk/src/VBox/Devices/Storage/ISCSIHDDCore.cpp
r33182 r33524 4369 4369 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 4370 4370 static int iscsiCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 4371 PVDINTERFACE pVDIfsImage )4371 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 4372 4372 { 4373 4373 LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename)); … … 4384 4384 static int iscsiOpen(const char *pszFilename, unsigned uOpenFlags, 4385 4385 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 4386 void **ppBackendData)4386 VDTYPE enmType, void **ppBackendData) 4387 4387 { 4388 4388 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); -
trunk/src/VBox/Devices/Storage/ParallelsHDDCore.cpp
r33258 r33524 105 105 106 106 /** NULL-terminated array of supported file extensions. */ 107 static const char *const s_apszParallelsFileExtensions[] =108 { 109 "hdd",110 NULL107 static const VDFILEEXTENSION s_aParallelsFileExtensions[] = 108 { 109 {"hdd", VDTYPE_HDD}, 110 {NULL, VDTYPE_INVALID} 111 111 }; 112 112 … … 415 415 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 416 416 static int parallelsCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 417 PVDINTERFACE pVDIfsImage )417 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 418 418 { 419 419 int rc; … … 471 471 } 472 472 473 if (RT_SUCCESS(rc)) 474 *penmType = VDTYPE_HDD; 475 473 476 pInterfaceIOCallbacks->pfnClose(pInterfaceIO->pvUser, pStorage); 474 477 return rc; … … 478 481 static int parallelsOpen(const char *pszFilename, unsigned uOpenFlags, 479 482 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 480 void **ppBackendData)483 VDTYPE enmType, void **ppBackendData) 481 484 { 482 485 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); … … 1001 1004 AssertPtr(pImage); 1002 1005 1003 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 1004 { 1005 rc = VERR_VD_IMAGE_READ_ONLY; 1006 goto out; 1007 } 1008 1009 if (pImage) 1010 rc = VERR_NOT_SUPPORTED; 1006 if (pImage) 1007 { 1008 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 1009 rc = VERR_VD_IMAGE_READ_ONLY; 1010 else 1011 rc = VERR_NOT_SUPPORTED; 1012 } 1011 1013 else 1012 1014 rc = VERR_VD_NOT_OPENED; … … 1357 1359 /* uBackendCaps */ 1358 1360 VD_CAP_FILE | VD_CAP_ASYNC | VD_CAP_VFS, 1359 /* pa pszFileExtensions */1360 s_a pszParallelsFileExtensions,1361 /* paFileExtensions */ 1362 s_aParallelsFileExtensions, 1361 1363 /* paConfigInfo */ 1362 1364 NULL, -
trunk/src/VBox/Devices/Storage/RawHDDCore.cpp
r33234 r33524 26 26 #include <iprt/assert.h> 27 27 #include <iprt/alloc.h> 28 28 #include <iprt/path.h> 29 29 30 30 /******************************************************************************* 31 31 * Constants And Macros, Structures and Typedefs * 32 32 *******************************************************************************/ 33 /** 34 * ISO volume descriptor. 35 */ 36 #pragma pack(1) 37 typedef struct ISOVOLDESC 38 { 39 union 40 { 41 /** Byte view. */ 42 uint8_t au8[2048]; 43 /** Field view. */ 44 struct 45 { 46 /** Descriptor type. */ 47 uint8_t u8Type; 48 /** Standard identifier */ 49 uint8_t au8Id[5]; 50 /** Descriptor version. */ 51 uint8_t u8Version; 52 /** Rest depends on the descriptor type. */ 53 } fields; 54 }; 55 } ISOVOLDESC, *PISOVOLDESC; 56 #pragma pack() 57 AssertCompileSize(ISOVOLDESC, 2048); 33 58 34 59 /** … … 82 107 83 108 /** NULL-terminated array of supported file extensions. */ 84 static const char *const s_apszRawFileExtensions[] =85 { 86 /** @todo At the moment this backend doesn't claim any extensions, but it might87 * be useful to add a few later. However this needs careful testing, as the88 * CheckIfValid function never returns success. */89 NULL109 static const VDFILEEXTENSION s_aRawFileExtensions[] = 110 { 111 {"iso", VDTYPE_DVD}, 112 {"img", VDTYPE_FLOPPY}, 113 {"ima", VDTYPE_FLOPPY}, 114 {NULL, VDTYPE_INVALID} 90 115 }; 91 116 … … 484 509 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 485 510 static int rawCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 486 PVDINTERFACE pVDIfsImage) 487 { 488 LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename)); 511 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 512 { 513 LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage)); 514 PVDIOSTORAGE pStorage = NULL; 515 uint64_t cbFile; 489 516 int rc = VINF_SUCCESS; 517 ISOVOLDESC IsoVolDesc; 518 char *pszExtension = NULL; 519 520 /* Get I/O interface. */ 521 PVDINTERFACE pInterfaceIO = VDInterfaceGet(pVDIfsImage, VDINTERFACETYPE_IOINT); 522 AssertPtrReturn(pInterfaceIO, VERR_INVALID_PARAMETER); 523 PVDINTERFACEIOINT pInterfaceIOCallbacks = VDGetInterfaceIOInt(pInterfaceIO); 524 AssertPtrReturn(pInterfaceIOCallbacks, VERR_INVALID_PARAMETER); 490 525 491 526 if ( !VALID_PTR(pszFilename) … … 496 531 } 497 532 498 /* Always return failure, to avoid opening everything as a raw image. */ 499 rc = VERR_VD_RAW_INVALID_HEADER; 533 pszExtension = RTPathExt(pszFilename); 534 535 /* 536 * Open the file and read the footer. 537 */ 538 rc = pInterfaceIOCallbacks->pfnOpen(pInterfaceIO->pvUser, pszFilename, 539 VDOpenFlagsToFileOpenFlags(VD_OPEN_FLAGS_READONLY, 540 false /* fCreate */), 541 &pStorage); 542 if (RT_SUCCESS(rc)) 543 rc = pInterfaceIOCallbacks->pfnGetSize(pInterfaceIO->pvUser, pStorage, 544 &cbFile); 545 546 /* Try to guess the image type based on the extension. */ 547 if ( RT_SUCCESS(rc) 548 && pszExtension) 549 { 550 if (!strcmp(pszExtension, ".iso")) /* DVD images. */ 551 { 552 if (cbFile >= (32768 + sizeof(ISOVOLDESC))) 553 { 554 rc = pInterfaceIOCallbacks->pfnReadSync(pInterfaceIO->pvUser, pStorage, 555 32768, &IsoVolDesc, sizeof(IsoVolDesc), NULL); 556 } 557 else 558 rc = VERR_VD_RAW_INVALID_HEADER; 559 560 if (RT_SUCCESS(rc)) 561 { 562 /* 563 * Do we recognize this stuff? 564 */ 565 if ( !memcmp(IsoVolDesc.fields.au8Id, "BEA01", 5) 566 || !memcmp(IsoVolDesc.fields.au8Id, "BOOT2", 5) 567 || !memcmp(IsoVolDesc.fields.au8Id, "CD001", 5) 568 || !memcmp(IsoVolDesc.fields.au8Id, "CDW02", 5) 569 || !memcmp(IsoVolDesc.fields.au8Id, "NSR02", 5) 570 || !memcmp(IsoVolDesc.fields.au8Id, "NSR03", 5) 571 || !memcmp(IsoVolDesc.fields.au8Id, "TEA01", 5)) 572 { 573 *penmType = VDTYPE_DVD; 574 rc = VINF_SUCCESS; 575 } 576 else 577 rc = VERR_VD_RAW_INVALID_HEADER; 578 } 579 } 580 else if (!strcmp(pszExtension, ".img") || !strcmp(pszExtension, ".ima")) /* Floppy images */ 581 { 582 if (!(cbFile % 512)) 583 { 584 *penmType = VDTYPE_FLOPPY; 585 rc = VINF_SUCCESS; 586 } 587 else 588 rc = VERR_VD_RAW_INVALID_HEADER; 589 } 590 } 591 else 592 rc = VERR_VD_RAW_INVALID_HEADER; 593 594 if (pStorage) 595 pInterfaceIOCallbacks->pfnClose(pInterfaceIO->pvUser, pStorage); 500 596 501 597 out: … … 507 603 static int rawOpen(const char *pszFilename, unsigned uOpenFlags, 508 604 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 509 void **ppBackendData)605 VDTYPE enmType, void **ppBackendData) 510 606 { 511 607 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); … … 1040 1136 AssertPtr(pImage); 1041 1137 1042 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 1043 { 1044 rc = VERR_VD_IMAGE_READ_ONLY; 1045 goto out; 1046 } 1047 1048 if (pImage) 1049 rc = VERR_NOT_SUPPORTED; 1138 if (pImage) 1139 { 1140 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 1141 rc = VERR_VD_IMAGE_READ_ONLY; 1142 else 1143 rc = VERR_NOT_SUPPORTED; 1144 } 1050 1145 else 1051 1146 rc = VERR_VD_NOT_OPENED; … … 1292 1387 { 1293 1388 /* pszBackendName */ 1294 " raw",1389 "RAW", 1295 1390 /* cbSize */ 1296 1391 sizeof(VBOXHDDBACKEND), 1297 1392 /* uBackendCaps */ 1298 1393 VD_CAP_CREATE_FIXED | VD_CAP_FILE | VD_CAP_ASYNC | VD_CAP_VFS, 1299 /* pa pszFileExtensions */1300 s_a pszRawFileExtensions,1394 /* paFileExtensions */ 1395 s_aRawFileExtensions, 1301 1396 /* paConfigInfo */ 1302 1397 NULL, -
trunk/src/VBox/Devices/Storage/VBoxHDD.cpp
r33495 r33524 156 156 /** Structure signature (VBOXHDDDISK_SIGNATURE). */ 157 157 uint32_t u32Signature; 158 159 /** Image type. */ 160 VDTYPE enmType; 158 161 159 162 /** Number of opened images. */ … … 440 443 extern VBOXHDDBACKEND g_VhdBackend; 441 444 extern VBOXHDDBACKEND g_ParallelsBackend; 442 #ifdef VBOX_WITH_DMG443 445 extern VBOXHDDBACKEND g_DmgBackend; 444 #endif445 446 #ifdef VBOX_WITH_ISCSI 446 447 extern VBOXHDDBACKEND g_ISCSIBackend; … … 451 452 static PVBOXHDDBACKEND aStaticBackends[] = 452 453 { 453 &g_RawBackend,454 454 &g_VmdkBackend, 455 455 &g_VDIBackend, 456 456 &g_VhdBackend, 457 &g_ParallelsBackend 458 #ifdef VBOX_WITH_DMG 459 ,&g_DmgBackend 460 #endif 457 &g_ParallelsBackend, 458 &g_DmgBackend, 459 &g_RawBackend 461 460 #ifdef VBOX_WITH_ISCSI 462 461 ,&g_ISCSIBackend … … 3584 3583 pEntries[i].pszBackend = g_apBackends[i]->pszBackendName; 3585 3584 pEntries[i].uBackendCaps = g_apBackends[i]->uBackendCaps; 3586 pEntries[i].pa pszFileExtensions = g_apBackends[i]->papszFileExtensions;3585 pEntries[i].paFileExtensions = g_apBackends[i]->paFileExtensions; 3587 3586 pEntries[i].paConfigInfo = g_apBackends[i]->paConfigInfo; 3588 3587 pEntries[i].pfnComposeLocation = g_apBackends[i]->pfnComposeLocation; … … 3622 3621 pEntry->pszBackend = g_apBackends[i]->pszBackendName; 3623 3622 pEntry->uBackendCaps = g_apBackends[i]->uBackendCaps; 3624 pEntry->pa pszFileExtensions = g_apBackends[i]->papszFileExtensions;3623 pEntry->paFileExtensions = g_apBackends[i]->paFileExtensions; 3625 3624 pEntry->paConfigInfo = g_apBackends[i]->paConfigInfo; 3626 3625 return VINF_SUCCESS; … … 3637 3636 * @returns VBox status code. 3638 3637 * @param pVDIfsDisk Pointer to the per-disk VD interface list. 3638 * @param enmType Type of the image container. 3639 3639 * @param ppDisk Where to store the reference to HDD container. 3640 3640 */ 3641 VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfsDisk, PVBOXHDD *ppDisk)3641 VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfsDisk, VDTYPE enmType, PVBOXHDD *ppDisk) 3642 3642 { 3643 3643 int rc = VINF_SUCCESS; … … 3656 3656 { 3657 3657 pDisk->u32Signature = VBOXHDDDISK_SIGNATURE; 3658 pDisk->enmType = enmType; 3658 3659 pDisk->cImages = 0; 3659 3660 pDisk->pBase = NULL; … … 3809 3810 */ 3810 3811 VBOXDDU_DECL(int) VDGetFormat(PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 3811 const char *pszFilename, char **ppszFormat )3812 const char *pszFilename, char **ppszFormat, VDTYPE *penmType) 3812 3813 { 3813 3814 int rc = VERR_NOT_SUPPORTED; … … 3825 3826 AssertMsgReturn(VALID_PTR(ppszFormat), 3826 3827 ("ppszFormat=%#p\n", ppszFormat), 3828 VERR_INVALID_PARAMETER); 3829 AssertMsgReturn(VALID_PTR(ppszFormat), 3830 ("penmType=%#p\n", penmType), 3827 3831 VERR_INVALID_PARAMETER); 3828 3832 … … 3886 3890 { 3887 3891 rc = g_apBackends[i]->pfnCheckIfValid(pszFilename, pVDIfsDisk, 3888 pVDIfsImage );3892 pVDIfsImage, penmType); 3889 3893 if ( RT_SUCCESS(rc) 3890 3894 /* The correct backend has been found, but there is a small … … 4048 4052 pDisk->pVDIfsDisk, 4049 4053 pImage->pVDIfsImage, 4054 pDisk->enmType, 4050 4055 &pImage->pBackendData); 4051 4056 /* If the open in read-write mode failed, retry in read-only mode. */ … … 4063 4068 pDisk->pVDIfsDisk, 4064 4069 pImage->pVDIfsImage, 4070 pDisk->enmType, 4065 4071 &pImage->pBackendData); 4066 4072 if (RT_FAILURE(rc)) … … 7186 7192 pBackendInfo->pszBackend = pImage->Backend->pszBackendName; 7187 7193 pBackendInfo->uBackendCaps = pImage->Backend->uBackendCaps; 7188 pBackendInfo->pa pszFileExtensions = pImage->Backend->papszFileExtensions;7194 pBackendInfo->paFileExtensions = pImage->Backend->paFileExtensions; 7189 7195 pBackendInfo->paConfigInfo = pImage->Backend->paConfigInfo; 7190 7196 } while (0); -
trunk/src/VBox/Devices/Storage/VCICacheCore.cpp
r33522 r33524 1901 1901 AssertPtr(pCache); 1902 1902 1903 if (pCache->uOpenFlags & VD_OPEN_FLAGS_READONLY)1904 {1905 rc = VERR_VD_IMAGE_READ_ONLY;1906 goto out;1907 }1908 1909 1903 if (pCache) 1910 rc = VERR_NOT_SUPPORTED; 1904 { 1905 if (pCache->uOpenFlags & VD_OPEN_FLAGS_READONLY) 1906 rc = VERR_VD_IMAGE_READ_ONLY; 1907 else 1908 rc = VERR_NOT_SUPPORTED; 1909 } 1911 1910 else 1912 1911 rc = VERR_VD_NOT_OPENED; -
trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp
r33478 r33524 38 38 39 39 /** NULL-terminated array of supported file extensions. */ 40 static const char *const s_apszVdiFileExtensions[] =41 { 42 "vdi",43 NULL40 static const VDFILEEXTENSION s_aVdiFileExtensions[] = 41 { 42 {"vdi", VDTYPE_HDD}, 43 {NULL, VDTYPE_INVALID} 44 44 }; 45 45 … … 999 999 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 1000 1000 static int vdiCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 1001 PVDINTERFACE pVDIfsImage )1001 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 1002 1002 { 1003 1003 LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename)); … … 1028 1028 RTMemFree(pImage); 1029 1029 1030 if (RT_SUCCESS(rc)) 1031 *penmType = VDTYPE_HDD; 1032 1030 1033 out: 1031 1034 LogFlowFunc(("returns %Rrc\n", rc)); … … 1036 1039 static int vdiOpen(const char *pszFilename, unsigned uOpenFlags, 1037 1040 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 1038 void **ppBackendData)1041 VDTYPE enmType, void **ppBackendData) 1039 1042 { 1040 1043 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); … … 1701 1704 AssertPtr(pImage); 1702 1705 1703 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)1704 {1705 rc = VERR_VD_IMAGE_READ_ONLY;1706 goto out;1707 }1708 1709 1706 if (pImage) 1710 1707 { 1711 size_t cchComment = pszComment ? strlen(pszComment) : 0; 1712 if (cchComment >= VDI_IMAGE_COMMENT_SIZE) 1713 { 1714 LogFunc(("pszComment is too long, %d bytes!\n", cchComment)); 1715 rc = VERR_VD_VDI_COMMENT_TOO_LONG; 1716 goto out; 1717 } 1718 1719 /* we don't support old style images */ 1720 if (GET_MAJOR_HEADER_VERSION(&pImage->Header) == 1) 1721 { 1722 /* 1723 * Update the comment field, making sure to zero out all of the previous comment. 1724 */ 1725 memset(pImage->Header.u.v1.szComment, '\0', VDI_IMAGE_COMMENT_SIZE); 1726 memcpy(pImage->Header.u.v1.szComment, pszComment, cchComment); 1727 1728 /* write out new the header */ 1729 rc = vdiUpdateHeader(pImage); 1730 } 1708 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 1709 rc = VERR_VD_IMAGE_READ_ONLY; 1731 1710 else 1732 rc = VERR_VD_VDI_UNSUPPORTED_VERSION; 1711 { 1712 size_t cchComment = pszComment ? strlen(pszComment) : 0; 1713 if (cchComment >= VDI_IMAGE_COMMENT_SIZE) 1714 { 1715 LogFunc(("pszComment is too long, %d bytes!\n", cchComment)); 1716 rc = VERR_VD_VDI_COMMENT_TOO_LONG; 1717 goto out; 1718 } 1719 1720 /* we don't support old style images */ 1721 if (GET_MAJOR_HEADER_VERSION(&pImage->Header) == 1) 1722 { 1723 /* 1724 * Update the comment field, making sure to zero out all of the previous comment. 1725 */ 1726 memset(pImage->Header.u.v1.szComment, '\0', VDI_IMAGE_COMMENT_SIZE); 1727 memcpy(pImage->Header.u.v1.szComment, pszComment, cchComment); 1728 1729 /* write out new the header */ 1730 rc = vdiUpdateHeader(pImage); 1731 } 1732 else 1733 rc = VERR_VD_VDI_UNSUPPORTED_VERSION; 1734 } 1733 1735 } 1734 1736 else … … 2657 2659 VD_CAP_UUID | VD_CAP_CREATE_FIXED | VD_CAP_CREATE_DYNAMIC 2658 2660 | VD_CAP_DIFF | VD_CAP_FILE | VD_CAP_ASYNC | VD_CAP_VFS, 2659 /* pa pszFileExtensions */2660 s_a pszVdiFileExtensions,2661 /* paFileExtensions */ 2662 s_aVdiFileExtensions, 2661 2663 /* paConfigInfo */ 2662 2664 NULL, -
trunk/src/VBox/Devices/Storage/VHDHDDCore.cpp
r33495 r33524 241 241 242 242 /** NULL-terminated array of supported file extensions. */ 243 static const char *const s_apszVhdFileExtensions[] =244 { 245 "vhd",246 NULL243 static const VDFILEEXTENSION s_aVhdFileExtensions[] = 244 { 245 {"vhd", VDTYPE_HDD}, 246 {NULL, VDTYPE_INVALID} 247 247 }; 248 248 … … 1380 1380 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 1381 1381 static int vhdCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 1382 PVDINTERFACE pVDIfsImage )1382 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 1383 1383 { 1384 1384 LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage)); … … 1416 1416 rc = VERR_VD_VHD_INVALID_HEADER; 1417 1417 else 1418 { 1419 *penmType = VDTYPE_HDD; 1418 1420 rc = VINF_SUCCESS; 1421 } 1419 1422 1420 1423 pInterfaceIOCallbacks->pfnClose(pInterfaceIO->pvUser, pStorage); … … 1428 1431 static int vhdOpen(const char *pszFilename, unsigned uOpenFlags, 1429 1432 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 1430 void **ppBackendData)1433 VDTYPE enmType, void **ppBackendData) 1431 1434 { 1432 1435 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); … … 2137 2140 AssertPtr(pImage); 2138 2141 2139 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)2140 {2141 rc = VERR_VD_IMAGE_READ_ONLY;2142 goto out;2143 }2144 2145 2142 if (pImage) 2146 rc = VERR_NOT_SUPPORTED; 2143 { 2144 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2145 rc = VERR_VD_IMAGE_READ_ONLY; 2146 else 2147 rc = VERR_NOT_SUPPORTED; 2148 } 2147 2149 else 2148 2150 rc = VERR_VD_NOT_OPENED; … … 3020 3022 VD_CAP_CREATE_FIXED | VD_CAP_CREATE_DYNAMIC | 3021 3023 VD_CAP_ASYNC | VD_CAP_VFS, 3022 /* pa pszFileExtensions */3023 s_a pszVhdFileExtensions,3024 /* paFileExtensions */ 3025 s_aVhdFileExtensions, 3024 3026 /* paConfigInfo */ 3025 3027 NULL, -
trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp
r33493 r33524 514 514 515 515 /** NULL-terminated array of supported file extensions. */ 516 static const char *const s_apszVmdkFileExtensions[] =517 { 518 "vmdk",519 NULL516 static const VDFILEEXTENSION s_aVmdkFileExtensions[] = 517 { 518 {"vmdk", VDTYPE_HDD}, 519 {NULL, VDTYPE_INVALID} 520 520 }; 521 521 … … 5704 5704 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 5705 5705 static int vmdkCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 5706 PVDINTERFACE pVDIfsImage) 5707 { 5708 LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename)); 5706 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 5707 { 5708 LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p penmType=%#p\n", 5709 pszFilename, pVDIfsDisk, pVDIfsImage, penmType)); 5709 5710 int rc = VINF_SUCCESS; 5710 5711 PVMDKIMAGE pImage; … … 5738 5739 RTMemFree(pImage); 5739 5740 5741 if (RT_SUCCESS(rc)) 5742 *penmType = VDTYPE_HDD; 5743 5740 5744 out: 5741 5745 LogFlowFunc(("returns %Rrc\n", rc)); … … 5746 5750 static int vmdkOpen(const char *pszFilename, unsigned uOpenFlags, 5747 5751 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 5748 void **ppBackendData)5752 VDTYPE enmType, void **ppBackendData) 5749 5753 { 5750 5754 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); … … 7322 7326 | VD_CAP_CREATE_SPLIT_2G | VD_CAP_DIFF | VD_CAP_FILE | VD_CAP_ASYNC 7323 7327 | VD_CAP_VFS, 7324 /* pa pszFileExtensions */7325 s_a pszVmdkFileExtensions,7328 /* paFileExtensions */ 7329 s_aVmdkFileExtensions, 7326 7330 /* paConfigInfo */ 7327 7331 NULL, -
trunk/src/VBox/Devices/Storage/testcase/tstVD-2.cpp
r28800 r33524 86 86 }; 87 87 88 static const char *tstVDDeviceType(VDTYPE enmType) 89 { 90 switch (enmType) 91 { 92 case VDTYPE_HDD: 93 return "HardDisk"; 94 case VDTYPE_DVD: 95 return "DVD"; 96 case VDTYPE_FLOPPY: 97 return "Floppy"; 98 default: 99 return "Unknown"; 100 } 101 } 102 88 103 static int tstVDBackendInfo(void) 89 104 { … … 108 123 RTPrintf("Backend %u: name=%s capabilities=%#06x extensions=", 109 124 i, aVDInfo[i].pszBackend, aVDInfo[i].uBackendCaps); 110 if (aVDInfo[i].pa pszFileExtensions)111 { 112 const char *const *papsz = aVDInfo[i].papszFileExtensions;113 while ( *papsz!= NULL)114 { 115 if (pa psz != aVDInfo[i].papszFileExtensions)125 if (aVDInfo[i].paFileExtensions) 126 { 127 PCVDFILEEXTENSION pa = aVDInfo[i].paFileExtensions; 128 while (pa->pszExtension != NULL) 129 { 130 if (pa != aVDInfo[i].paFileExtensions) 116 131 RTPrintf(","); 117 RTPrintf("%s ", *papsz);118 pa psz++;119 } 120 if (pa psz == aVDInfo[i].papszFileExtensions)132 RTPrintf("%s (%s)", pa->pszExtension, tstVDDeviceType(pa->enmType)); 133 pa++; 134 } 135 if (pa == aVDInfo[i].paFileExtensions) 121 136 RTPrintf("<EMPTY>"); 122 137 } -
trunk/src/VBox/Devices/Storage/testcase/tstVD.cpp
r33083 r33524 92 92 AssertRC(rc); 93 93 94 rc = VDCreate(&VDIError, &pVD);94 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 95 95 CHECK("VDCreate()"); 96 96 … … 150 150 AssertRC(rc); 151 151 152 rc = VDCreate(&VDIError, &pVD);152 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 153 153 CHECK("VDCreate()"); 154 154 … … 505 505 PVBOXHDD pVD = NULL; 506 506 char *pszFormat; 507 VDTYPE enmType = VDTYPE_INVALID; 507 508 VDGEOMETRY PCHS = { 0, 0, 0 }; 508 509 VDGEOMETRY LCHS = { 0, 0, 0 }; … … 539 540 540 541 541 rc = VDCreate(&VDIError, &pVD);542 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 542 543 CHECK("VDCreate()"); 543 544 … … 548 549 RTFileClose(File); 549 550 rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 550 pszBaseFilename, &pszFormat );551 pszBaseFilename, &pszFormat, &enmType); 551 552 RTPrintf("VDGetFormat() pszFormat=%s rc=%Rrc\n", pszFormat, rc); 552 553 if (RT_SUCCESS(rc) && strcmp(pszFormat, pszBackend)) … … 664 665 665 666 666 rc = VDCreate(&VDIError, &pVD);667 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 667 668 CHECK("VDCreate()"); 668 669 … … 738 739 AssertRC(rc); 739 740 740 rc = VDCreate(&VDIError, &pVD);741 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 741 742 CHECK("VDCreate()"); 742 743 … … 789 790 AssertRC(rc); 790 791 791 rc = VDCreate(&VDIError, &pVD);792 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 792 793 CHECK("VDCreate()"); 793 794 -
trunk/src/VBox/Devices/Storage/testcase/tstVDCopy.cpp
r32536 r33524 70 70 char *pbBuf1 = NULL; 71 71 char *pbBuf2 = NULL; 72 VDTYPE enmTypeVD1 = VDTYPE_INVALID; 73 VDTYPE enmTypeVD2 = VDTYPE_INVALID; 72 74 73 75 #define CHECK(str) \ … … 98 100 99 101 rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 100 argv[1], &pszVD1 );102 argv[1], &pszVD1, &enmTypeVD1); 101 103 CHECK("VDGetFormat() hdd1"); 102 104 103 105 rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 104 argv[2], &pszVD2 );106 argv[2], &pszVD2, &enmTypeVD2); 105 107 CHECK("VDGetFormat() hdd2"); 106 108 107 rc = VDCreate(&VDIError, &pVD1);109 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD1); 108 110 CHECK("VDCreate() hdd1"); 109 111 110 rc = VDCreate(&VDIError, &pVD2);112 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD2); 111 113 CHECK("VDCreate() hdd1"); 112 114 -
trunk/src/VBox/Devices/Storage/testcase/tstVDShareable.cpp
r32536 r33524 92 92 AssertRC(rc); 93 93 94 rc = VDCreate(&VDIError, &pVD);94 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 95 95 CHECK("VDCreate()"); 96 rc = VDCreate(&VDIError, &pVD2);96 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD2); 97 97 CHECK("VDCreate() #2"); 98 98 -
trunk/src/VBox/Devices/Storage/testcase/tstVDSnap.cpp
r32536 r33524 276 276 277 277 278 rc = VDCreate(pVDIfs, &pVD);278 rc = VDCreate(pVDIfs, VDTYPE_HDD, &pVD); 279 279 CHECK("VDCreate()"); 280 280 -
trunk/src/VBox/Devices/Storage/testcase/vbox-img.cpp
r33288 r33524 124 124 const char *pszFilename = NULL; 125 125 char *pszFormat = NULL; 126 VDTYPE enmType = VDTYPE_INVALID; 126 127 RTUUID imageUuid; 127 128 RTUUID parentUuid; … … 188 189 /* Don't pass error interface, as that would triggers error messages 189 190 * because some backends fail to open the image. */ 190 rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat );191 rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType); 191 192 if (RT_FAILURE(rc)) 192 193 return errorRuntime("Format autodetect failed: %Rrc\n", rc); … … 194 195 195 196 PVBOXHDD pVD = NULL; 196 rc = VDCreate(pVDIfs, &pVD);197 rc = VDCreate(pVDIfs, enmType, &pVD); 197 198 if (RT_FAILURE(rc)) 198 199 return errorRuntime("Cannot create the virtual disk container: %Rrc\n", rc); … … 625 626 bool fStdOut = false; 626 627 const char *pszSrcFormat = NULL; 628 VDTYPE enmSrcType = VDTYPE_HDD; 627 629 const char *pszDstFormat = NULL; 628 630 const char *pszVariant = NULL; … … 788 790 if (!pszSrcFormat) 789 791 { 790 char *pszFormat; 791 rc = VDGetFormat(NULL, NULL, pszSrcFilename, &pszFormat); 792 char *pszFormat = NULL; 793 VDTYPE enmType = VDTYPE_INVALID; 794 rc = VDGetFormat(NULL, NULL, pszSrcFilename, &pszFormat, &enmType); 792 795 if (RT_FAILURE(rc)) 793 796 { … … 796 799 } 797 800 pszSrcFormat = pszFormat; 798 } 799 800 rc = VDCreate(pVDIfs, &pSrcDisk); 801 enmSrcType = enmType; 802 } 803 804 rc = VDCreate(pVDIfs, enmSrcType, &pSrcDisk); 801 805 if (RT_FAILURE(rc)) 802 806 { … … 814 818 } 815 819 816 rc = VDCreate(pVDIfs, &pDstDisk);820 rc = VDCreate(pVDIfs, VDTYPE_HDD, &pDstDisk); 817 821 if (RT_FAILURE(rc)) 818 822 { … … 883 887 /* just try it */ 884 888 char *pszFormat = NULL; 885 rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat); 889 VDTYPE enmType = VDTYPE_INVALID; 890 rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType); 886 891 if (RT_FAILURE(rc)) 887 892 return errorSyntax("Format autodetect failed: %Rrc\n", rc); 888 893 889 rc = VDCreate(pVDIfs, &pDisk);894 rc = VDCreate(pVDIfs, enmType, &pDisk); 890 895 if (RT_FAILURE(rc)) 891 896 return errorRuntime("Error while creating the virtual disk container: %Rrc\n", rc); … … 940 945 /* just try it */ 941 946 char *pszFormat = NULL; 942 rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat); 947 VDTYPE enmType = VDTYPE_INVALID; 948 rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType); 943 949 if (RT_FAILURE(rc)) 944 950 return errorSyntax("Format autodetect failed: %Rrc\n", rc); 945 951 946 rc = VDCreate(pVDIfs, &pDisk);952 rc = VDCreate(pVDIfs, enmType, &pDisk); 947 953 if (RT_FAILURE(rc)) 948 954 return errorRuntime("Error while creating the virtual disk container: %Rrc\n", rc); -
trunk/src/VBox/Devices/Storage/testcase/vditool.cpp
r32536 r33524 104 104 105 105 PVBOXHDD hdd; 106 rc = VDCreate(NULL, &hdd);106 rc = VDCreate(NULL, VDTYPE_HDD, &hdd); 107 107 if (RT_FAILURE(rc)) 108 108 return PrintDone(rc);
Note:
See TracChangeset
for help on using the changeset viewer.