VirtualBox

Changeset 9565 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Jun 10, 2008 11:39:40 AM (17 years ago)
Author:
vboxsync
Message:

Fix incorrect check verifying disk type. Also make the API for getting the disk type return an error if the cached value is invalid.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VBoxHDD-new.cpp

    r9560 r9565  
    11081108         * diff images. Some image formats don't distinguish between normal
    11091109         * and diff images, so this must be corrected here. */
     1110        if (VBOX_FAILURE(rc))
     1111            enmImageType = VD_IMAGE_TYPE_INVALID;
    11101112        if (    VBOX_SUCCESS(rc)
    11111113            &&  !(uOpenFlags & VD_OPEN_FLAGS_INFO))
    11121114        {
    1113             rc = VERR_VDI_INVALID_TYPE;
    1114             break;
    1115         }
    1116         if (    pDisk->cImages == 0
    1117             &&  (   enmImageType != VD_IMAGE_TYPE_FIXED
    1118                  || enmImageType != VD_IMAGE_TYPE_NORMAL))
    1119         {
    1120             rc = VERR_VDI_INVALID_TYPE;
    1121             break;
    1122         }
    1123         else if (pDisk->cImages != 0)
    1124         {
    1125             if (    enmImageType != VD_IMAGE_TYPE_NORMAL
    1126                 ||  enmImageType != VD_IMAGE_TYPE_DIFF)
     1115            if (    pDisk->cImages == 0
     1116                &&  (   enmImageType != VD_IMAGE_TYPE_FIXED
     1117                     || enmImageType != VD_IMAGE_TYPE_NORMAL))
    11271118            {
    11281119                rc = VERR_VDI_INVALID_TYPE;
    11291120                break;
    11301121            }
    1131             else
    1132                 enmImageType = VD_IMAGE_TYPE_DIFF;
     1122            else if (pDisk->cImages != 0)
     1123            {
     1124                if (    enmImageType != VD_IMAGE_TYPE_NORMAL
     1125                    ||  enmImageType != VD_IMAGE_TYPE_DIFF)
     1126                {
     1127                    rc = VERR_VDI_INVALID_TYPE;
     1128                    break;
     1129                }
     1130                else
     1131                    enmImageType = VD_IMAGE_TYPE_DIFF;
     1132            }
    11331133        }
    11341134        pImage->enmImageType = enmImageType;
     
    27772777        AssertPtrBreakStmt(pImage, rc = VERR_VDI_IMAGE_NOT_FOUND);
    27782778
    2779         *penmType = pImage->enmImageType;
     2779        if (    pImage->enmImageType >= VD_IMAGE_TYPE_FIRST
     2780            &&  pImage->enmImageType <= VD_IMAGE_TYPE_DIFF)
     2781        {
     2782            *penmType = pImage->enmImageType;
     2783            rc = VINF_SUCCESS;
     2784        }
     2785        else
     2786            rc = VERR_VDI_INVALID_TYPE;
    27802787    } while (0);
    27812788
Note: See TracChangeset for help on using the changeset viewer.

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