- Timestamp:
- Nov 4, 2010 3:00:05 PM (14 years ago)
- Location:
- trunk/src/VBox/Storage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/DMG.cpp
r33567 r33773 751 751 752 752 default: 753 AssertMsgFailed(("%x\n", u32Kind));753 // AssertMsgFailed(("%x\n", u32Kind)); 754 754 break; 755 755 } -
trunk/src/VBox/Storage/RAW.cpp
r33757 r33773 31 31 * Constants And Macros, Structures and Typedefs * 32 32 *******************************************************************************/ 33 /**34 * ISO volume descriptor.35 */36 #pragma pack(1)37 typedef struct ISOVOLDESC38 {39 union40 {41 /** Byte view. */42 uint8_t au8[2048];43 /** Field view. */44 struct45 {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);58 33 59 34 /** … … 101 76 /** Size of write operations when filling an image with zeroes. */ 102 77 #define RAW_FILL_SIZE (128 * _1K) 78 79 /** The maximum reasonable size of a floppy image. */ 80 #define RAW_MAX_FLOPPY_IMG_SIZE (512 * 82 * 24 * 2) 103 81 104 82 /******************************************************************************* … … 515 493 uint64_t cbFile; 516 494 int rc = VINF_SUCCESS; 517 ISOVOLDESC IsoVolDesc;518 495 char *pszExtension = NULL; 519 496 … … 550 527 if (!RTStrICmp(pszExtension, ".iso")) /* DVD images. */ 551 528 { 552 if (cbFile >= (32768 + sizeof(ISOVOLDESC))) 529 /* Note that there are ISO images smaller than 1 MB; it is impossible to distinguish 530 * between raw floppy and CD images based on their size (and cannot be reliably done 531 * based on contents, either). 532 */ 533 if (cbFile > 32768 && !(cbFile % 2048)) 553 534 { 554 rc = pInterfaceIOCallbacks->pfnReadSync(pInterfaceIO->pvUser, pStorage,555 32768, &IsoVolDesc, sizeof(IsoVolDesc), NULL);535 *penmType = VDTYPE_DVD; 536 rc = VINF_SUCCESS; 556 537 } 557 538 else 558 539 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 else577 rc = VERR_VD_RAW_INVALID_HEADER;578 }579 540 } 580 541 else if (!RTStrICmp(pszExtension, ".img") || !RTStrICmp(pszExtension, ".ima")) /* Floppy images */ 581 542 { 582 if (!(cbFile % 512) )543 if (!(cbFile % 512) && cbFile <= RAW_MAX_FLOPPY_IMG_SIZE) 583 544 { 584 545 *penmType = VDTYPE_FLOPPY; … … 1146 1107 rc = VERR_VD_NOT_OPENED; 1147 1108 1148 out:1149 1109 LogFlowFunc(("returns %Rrc\n", rc)); 1150 1110 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.