- Timestamp:
- Aug 23, 2021 7:23:15 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/VD.cpp
r90802 r90806 5792 5792 pDisk, pszBackend, pszFilename, uOpenFlags, pVDIfsCache)); 5793 5793 5794 /* sanity check */ 5795 AssertPtrReturn(pDisk, VERR_INVALID_PARAMETER); 5796 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 5797 5798 /* Check arguments. */ 5799 AssertPtrReturn(pszBackend, VERR_INVALID_POINTER); 5800 AssertReturn(*pszBackend != '\0', VERR_INVALID_PARAMETER); 5801 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); 5802 AssertReturn(*pszFilename != '\0', VERR_INVALID_PARAMETER); 5803 AssertMsgReturn((uOpenFlags & ~VD_OPEN_FLAGS_MASK) == 0, ("uOpenFlags=%#x\n", uOpenFlags), 5804 VERR_INVALID_PARAMETER); 5805 5794 5806 do 5795 5807 { 5796 /* sanity check */5797 AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);5798 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));5799 5800 /* Check arguments. */5801 AssertMsgBreakStmt(VALID_PTR(pszBackend) && *pszBackend,5802 ("pszBackend=%#p \"%s\"\n", pszBackend, pszBackend),5803 rc = VERR_INVALID_PARAMETER);5804 AssertMsgBreakStmt(VALID_PTR(pszFilename) && *pszFilename,5805 ("pszFilename=%#p \"%s\"\n", pszFilename, pszFilename),5806 rc = VERR_INVALID_PARAMETER);5807 AssertMsgBreakStmt((uOpenFlags & ~VD_OPEN_FLAGS_MASK) == 0,5808 ("uOpenFlags=%#x\n", uOpenFlags),5809 rc = VERR_INVALID_PARAMETER);5810 5811 5808 /* Set up image descriptor. */ 5812 5809 pCache = (PVDCACHE)RTMemAllocZ(sizeof(VDCACHE)); … … 5964 5961 pDisk, pszFilter, pVDIfsFilter)); 5965 5962 5963 /* sanity check */ 5964 AssertPtrReturn(pDisk, VERR_INVALID_PARAMETER); 5965 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 5966 5967 /* Check arguments. */ 5968 AssertPtrReturn(pszFilter, VERR_INVALID_POINTER); 5969 AssertReturn(*pszFilter != '\0', VERR_INVALID_PARAMETER); 5970 AssertMsgReturn(!(fFlags & ~VD_FILTER_FLAGS_MASK), ("Invalid flags set (fFlags=%#x)\n", fFlags), 5971 VERR_INVALID_PARAMETER); 5972 5966 5973 do 5967 5974 { 5968 /* sanity check */5969 AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);5970 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));5971 5972 /* Check arguments. */5973 AssertMsgBreakStmt(VALID_PTR(pszFilter) && *pszFilter,5974 ("pszFilter=%#p \"%s\"\n", pszFilter, pszFilter),5975 rc = VERR_INVALID_PARAMETER);5976 5977 AssertMsgBreakStmt(!(fFlags & ~VD_FILTER_FLAGS_MASK),5978 ("Invalid flags set (fFlags=%#x)\n", fFlags),5979 rc = VERR_INVALID_PARAMETER);5980 5981 5975 /* Set up image descriptor. */ 5982 5976 pFilter = (PVDFILTER)RTMemAllocZ(sizeof(VDFILTER)); … … 6070 6064 uOpenFlags, pVDIfsImage, pVDIfsOperation)); 6071 6065 6066 /* sanity check */ 6067 AssertPtrReturn(pDisk, VERR_INVALID_POINTER); 6068 AssertMsgReturn(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature), 6069 VERR_INVALID_MAGIC); 6070 6071 /* Check arguments. */ 6072 AssertPtrReturn(pszBackend, VERR_INVALID_POINTER); 6073 AssertReturn(*pszBackend != '\0', VERR_INVALID_PARAMETER); 6074 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); 6075 AssertReturn(*pszFilename != '\0', VERR_INVALID_PARAMETER); 6076 AssertMsgReturn(cbSize || (uImageFlags & VD_VMDK_IMAGE_FLAGS_RAWDISK), ("cbSize=%llu\n", cbSize), 6077 VERR_INVALID_PARAMETER); 6078 if (cbSize % 512 && !(uImageFlags & VD_VMDK_IMAGE_FLAGS_RAWDISK)) 6079 { 6080 rc = vdError(pDisk, VERR_VD_INVALID_SIZE, RT_SRC_POS, 6081 N_("VD: The given disk size %llu is not aligned on a sector boundary (512 bytes)"), cbSize); 6082 LogFlowFunc(("returns %Rrc\n", rc)); 6083 return rc; 6084 } 6085 AssertMsgReturn( ((uImageFlags & ~VD_IMAGE_FLAGS_MASK) == 0) 6086 || ((uImageFlags & (VD_IMAGE_FLAGS_FIXED | VD_IMAGE_FLAGS_DIFF)) != VD_IMAGE_FLAGS_FIXED), 6087 ("uImageFlags=%#x\n", uImageFlags), 6088 VERR_INVALID_PARAMETER); 6089 AssertMsgReturn( !(uImageFlags & VD_VMDK_IMAGE_FLAGS_RAWDISK) 6090 || !(uImageFlags & ~(VD_VMDK_IMAGE_FLAGS_RAWDISK | VD_IMAGE_FLAGS_FIXED)), 6091 ("uImageFlags=%#x\n", uImageFlags), 6092 VERR_INVALID_PARAMETER); 6093 /* The PCHS geometry fields may be 0 to leave it for later. */ 6094 AssertPtrReturn(pPCHSGeometry, VERR_INVALID_PARAMETER); 6095 AssertMsgReturn( pPCHSGeometry->cHeads <= 16 6096 && pPCHSGeometry->cSectors <= 63, 6097 ("PCHS=%u/%u/%u\n", pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors), 6098 VERR_INVALID_PARAMETER); 6099 /* The LCHS geometry fields may be 0 to leave it to later autodetection. */ 6100 AssertPtrReturn(pLCHSGeometry, VERR_INVALID_POINTER); 6101 AssertMsgReturn( pLCHSGeometry->cHeads <= 255 6102 && pLCHSGeometry->cSectors <= 63, 6103 ("LCHS=%u/%u/%u\n", pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors), 6104 VERR_INVALID_PARAMETER); 6105 /* The UUID may be NULL. */ 6106 AssertPtrNullReturn(pUuid, VERR_INVALID_POINTER); 6107 AssertMsgReturn((uOpenFlags & ~VD_OPEN_FLAGS_MASK) == 0, ("uOpenFlags=%#x\n", uOpenFlags), 6108 VERR_INVALID_PARAMETER); 6109 6072 6110 AssertPtrNullReturn(pVDIfsOperation, VERR_INVALID_PARAMETER); 6073 6111 PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation); … … 6075 6113 do 6076 6114 { 6077 /** @todo r=bird: there is no particular reason why this validation has to be6078 * done inside the do-break-while-goto-is-false loop. (pIfProgress is6079 * only called on success.) Could just AssertMsgReturn, rather than6080 * complicated AssertMsgBreakStmt. */6081 /* sanity check */6082 AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);6083 AssertMsgBreakStmt(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature),6084 rc = VERR_INVALID_MAGIC);6085 6086 /* Check arguments. */6087 AssertMsgBreakStmt(VALID_PTR(pszBackend) && *pszBackend,6088 ("pszBackend=%#p \"%s\"\n", pszBackend, pszBackend),6089 rc = VERR_INVALID_PARAMETER);6090 AssertMsgBreakStmt(VALID_PTR(pszFilename) && *pszFilename,6091 ("pszFilename=%#p \"%s\"\n", pszFilename, pszFilename),6092 rc = VERR_INVALID_PARAMETER);6093 AssertMsgBreakStmt(cbSize || (uImageFlags & VD_VMDK_IMAGE_FLAGS_RAWDISK),6094 ("cbSize=%llu\n", cbSize),6095 rc = VERR_INVALID_PARAMETER);6096 if (cbSize % 512 && !(uImageFlags & VD_VMDK_IMAGE_FLAGS_RAWDISK))6097 {6098 rc = vdError(pDisk, VERR_VD_INVALID_SIZE, RT_SRC_POS,6099 N_("VD: The given disk size %llu is not aligned on a sector boundary (512 bytes)"), cbSize);6100 break;6101 }6102 AssertMsgBreakStmt( ((uImageFlags & ~VD_IMAGE_FLAGS_MASK) == 0)6103 || ((uImageFlags & (VD_IMAGE_FLAGS_FIXED | VD_IMAGE_FLAGS_DIFF)) != VD_IMAGE_FLAGS_FIXED),6104 ("uImageFlags=%#x\n", uImageFlags),6105 rc = VERR_INVALID_PARAMETER);6106 AssertMsgBreakStmt( !(uImageFlags & VD_VMDK_IMAGE_FLAGS_RAWDISK)6107 || !(uImageFlags & ~(VD_VMDK_IMAGE_FLAGS_RAWDISK | VD_IMAGE_FLAGS_FIXED)),6108 ("uImageFlags=%#x\n", uImageFlags),6109 rc = VERR_INVALID_PARAMETER);6110 /* The PCHS geometry fields may be 0 to leave it for later. */6111 AssertPtrBreakStmt(pPCHSGeometry, rc = VERR_INVALID_PARAMETER);6112 AssertMsgBreakStmt( pPCHSGeometry->cHeads <= 166113 && pPCHSGeometry->cSectors <= 63,6114 ("PCHS=%u/%u/%u\n", pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors),6115 rc = VERR_INVALID_PARAMETER);6116 /* The LCHS geometry fields may be 0 to leave it to later autodetection. */6117 AssertPtrBreakStmt(pLCHSGeometry, rc = VERR_INVALID_PARAMETER);6118 AssertMsgBreakStmt( pLCHSGeometry->cHeads <= 2556119 && pLCHSGeometry->cSectors <= 63,6120 ("LCHS=%u/%u/%u\n", pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors),6121 rc = VERR_INVALID_PARAMETER);6122 /* The UUID may be NULL. */6123 AssertMsgBreakStmt(pUuid == NULL || VALID_PTR(pUuid),6124 ("pUuid=%#p UUID=%RTuuid\n", pUuid, pUuid),6125 rc = VERR_INVALID_PARAMETER);6126 AssertMsgBreakStmt((uOpenFlags & ~VD_OPEN_FLAGS_MASK) == 0,6127 ("uOpenFlags=%#x\n", uOpenFlags),6128 rc = VERR_INVALID_PARAMETER);6129 6130 6115 /* Check state. Needs a temporary read lock. Holding the write lock 6131 6116 * all the time would be blocking other activities for too long. */ … … 6354 6339 pDisk, pszBackend, pszFilename, uImageFlags, pszComment, pUuid, uOpenFlags, pVDIfsImage, pVDIfsOperation)); 6355 6340 6341 /* sanity check */ 6342 AssertPtrReturn(pDisk, VERR_INVALID_PARAMETER); 6343 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 6344 6345 /* Check arguments. */ 6346 AssertPtrReturn(pszBackend, VERR_INVALID_POINTER); 6347 AssertReturn(*pszBackend != '\0', VERR_INVALID_PARAMETER); 6348 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); 6349 AssertReturn(*pszFilename != '\0', VERR_INVALID_PARAMETER); 6350 AssertMsgReturn((uImageFlags & ~VD_IMAGE_FLAGS_MASK) == 0, ("uImageFlags=%#x\n", uImageFlags), 6351 VERR_INVALID_PARAMETER); 6352 /* The UUID may be NULL. */ 6353 AssertPtrNullReturn(pUuid, VERR_INVALID_POINTER); 6354 /* The parent UUID may be NULL. */ 6355 AssertPtrNullReturn(pParentUuid, VERR_INVALID_POINTER); 6356 AssertMsgReturn((uOpenFlags & ~VD_OPEN_FLAGS_MASK) == 0, ("uOpenFlags=%#x\n", uOpenFlags), 6357 VERR_INVALID_PARAMETER); 6358 6356 6359 PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation); 6357 6358 6360 do 6359 6361 { 6360 /* sanity check */6361 AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);6362 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));6363 6364 /* Check arguments. */6365 AssertMsgBreakStmt(VALID_PTR(pszBackend) && *pszBackend,6366 ("pszBackend=%#p \"%s\"\n", pszBackend, pszBackend),6367 rc = VERR_INVALID_PARAMETER);6368 AssertMsgBreakStmt(VALID_PTR(pszFilename) && *pszFilename,6369 ("pszFilename=%#p \"%s\"\n", pszFilename, pszFilename),6370 rc = VERR_INVALID_PARAMETER);6371 AssertMsgBreakStmt((uImageFlags & ~VD_IMAGE_FLAGS_MASK) == 0,6372 ("uImageFlags=%#x\n", uImageFlags),6373 rc = VERR_INVALID_PARAMETER);6374 /* The UUID may be NULL. */6375 AssertMsgBreakStmt(pUuid == NULL || VALID_PTR(pUuid),6376 ("pUuid=%#p UUID=%RTuuid\n", pUuid, pUuid),6377 rc = VERR_INVALID_PARAMETER);6378 /* The parent UUID may be NULL. */6379 AssertMsgBreakStmt(pParentUuid == NULL || VALID_PTR(pParentUuid),6380 ("pParentUuid=%#p ParentUUID=%RTuuid\n", pParentUuid, pParentUuid),6381 rc = VERR_INVALID_PARAMETER);6382 AssertMsgBreakStmt((uOpenFlags & ~VD_OPEN_FLAGS_MASK) == 0,6383 ("uOpenFlags=%#x\n", uOpenFlags),6384 rc = VERR_INVALID_PARAMETER);6385 6386 6362 /* Check state. Needs a temporary read lock. Holding the write lock 6387 6363 * all the time would be blocking other activities for too long. */ … … 6615 6591 pDisk, pszBackend, pszFilename, cbSize, uImageFlags, pszComment, pUuid, uOpenFlags, pVDIfsCache, pVDIfsOperation)); 6616 6592 6593 /* sanity check */ 6594 AssertPtrReturn(pDisk, VERR_INVALID_POINTER); 6595 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 6596 6597 /* Check arguments. */ 6598 AssertPtrReturn(pszBackend, VERR_INVALID_POINTER); 6599 AssertReturn(*pszBackend, VERR_INVALID_PARAMETER); 6600 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); 6601 AssertReturn(*pszFilename != '\0', VERR_INVALID_PARAMETER); 6602 AssertReturn(cbSize > 0, VERR_INVALID_PARAMETER); 6603 AssertMsgReturn((uImageFlags & ~VD_IMAGE_FLAGS_MASK) == 0, ("uImageFlags=%#x\n", uImageFlags), 6604 VERR_INVALID_PARAMETER); 6605 /* The UUID may be NULL. */ 6606 AssertPtrNullReturn(pUuid, VERR_INVALID_POINTER); 6607 AssertMsgReturn((uOpenFlags & ~VD_OPEN_FLAGS_MASK) == 0, ("uOpenFlags=%#x\n", uOpenFlags), 6608 VERR_INVALID_PARAMETER); 6609 6617 6610 PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation); 6618 6611 6619 6612 do 6620 6613 { 6621 /* sanity check */6622 AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);6623 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));6624 6625 /* Check arguments. */6626 AssertMsgBreakStmt(VALID_PTR(pszBackend) && *pszBackend,6627 ("pszBackend=%#p \"%s\"\n", pszBackend, pszBackend),6628 rc = VERR_INVALID_PARAMETER);6629 AssertMsgBreakStmt(VALID_PTR(pszFilename) && *pszFilename,6630 ("pszFilename=%#p \"%s\"\n", pszFilename, pszFilename),6631 rc = VERR_INVALID_PARAMETER);6632 AssertMsgBreakStmt(cbSize,6633 ("cbSize=%llu\n", cbSize),6634 rc = VERR_INVALID_PARAMETER);6635 AssertMsgBreakStmt((uImageFlags & ~VD_IMAGE_FLAGS_MASK) == 0,6636 ("uImageFlags=%#x\n", uImageFlags),6637 rc = VERR_INVALID_PARAMETER);6638 /* The UUID may be NULL. */6639 AssertMsgBreakStmt(pUuid == NULL || VALID_PTR(pUuid),6640 ("pUuid=%#p UUID=%RTuuid\n", pUuid, pUuid),6641 rc = VERR_INVALID_PARAMETER);6642 AssertMsgBreakStmt((uOpenFlags & ~VD_OPEN_FLAGS_MASK) == 0,6643 ("uOpenFlags=%#x\n", uOpenFlags),6644 rc = VERR_INVALID_PARAMETER);6645 6646 6614 /* Check state. Needs a temporary read lock. Holding the write lock 6647 6615 * all the time would be blocking other activities for too long. */
Note:
See TracChangeset
for help on using the changeset viewer.