VirtualBox

vbox的更動 33773 路徑 trunk/src/VBox/Storage/RAW.cpp


忽略:
時間撮記:
2010-11-4 下午03:00:05 (14 年 以前)
作者:
vboxsync
訊息:

Storage: Do not assume CD image has to include ISO9660 filesystem.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Storage/RAW.cpp

    r33757 r33773  
    3131*   Constants And Macros, Structures and Typedefs                              *
    3232*******************************************************************************/
    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);
    5833
    5934/**
     
    10176/** Size of write operations when filling an image with zeroes. */
    10277#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)
    10381
    10482/*******************************************************************************
     
    515493    uint64_t cbFile;
    516494    int rc = VINF_SUCCESS;
    517     ISOVOLDESC IsoVolDesc;
    518495    char *pszExtension = NULL;
    519496
     
    550527        if (!RTStrICmp(pszExtension, ".iso")) /* DVD images. */
    551528        {
    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))
    553534            {
    554                 rc = pInterfaceIOCallbacks->pfnReadSync(pInterfaceIO->pvUser, pStorage,
    555                                                         32768, &IsoVolDesc, sizeof(IsoVolDesc), NULL);
     535                *penmType = VDTYPE_DVD;
     536                rc = VINF_SUCCESS;
    556537            }
    557538            else
    558539                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             }
    579540        }
    580541        else if (!RTStrICmp(pszExtension, ".img") || !RTStrICmp(pszExtension, ".ima")) /* Floppy images */
    581542        {
    582             if (!(cbFile % 512))
     543            if (!(cbFile % 512) && cbFile <= RAW_MAX_FLOPPY_IMG_SIZE)
    583544            {
    584545                *penmType = VDTYPE_FLOPPY;
     
    11461107        rc = VERR_VD_NOT_OPENED;
    11471108
    1148 out:
    11491109    LogFlowFunc(("returns %Rrc\n", rc));
    11501110    return rc;
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette