Changeset 2590 in vbox for trunk/src/VBox
- Timestamp:
- May 11, 2007 12:18:06 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/VBoxHDD-new.cpp
r2564 r2590 44 44 * VBox HDD Container image descriptor. 45 45 */ 46 typedef struct V BOXHDDIMAGEDESC46 typedef struct VDIMAGE 47 47 { 48 48 /** Link to parent image descriptor, if any. */ 49 struct V BOXHDDIMAGEDESC*pPrev;49 struct VDIMAGE *pPrev; 50 50 /** Link to child image descriptor, if any. */ 51 struct V BOXHDDIMAGEDESC*pNext;51 struct VDIMAGE *pNext; 52 52 /** Container base filename. (UTF-8) */ 53 char 53 char *pszFilename; 54 54 /** Data managed by the backend which keeps the actual info. */ 55 void *pvBackendData; 56 } VBOXHDDIMAGEDESC, *PVBOXHDDIMAGEDESC; 55 void *pvBackendData; 56 /** Image open flags (only those handled generically in this code and which 57 * the backends will never ever see). */ 58 unsigned uOpenFlags; 59 } VDIMAGE, *PVDIMAGE; 57 60 58 61 /** … … 76 79 77 80 /** Base image. */ 78 PV BOXHDDIMAGEDESCpBase;81 PVDIMAGE pBase; 79 82 80 83 /** Last opened image in the chain. 81 * The same as pBase if only one image is used or the last opened diff image. */82 PV BOXHDDIMAGEDESCpLast;84 * The same as pBase if only one image is used. */ 85 PVDIMAGE pLast; 83 86 84 87 /** Flags representing the modification state. */ … … 126 129 * internal: issue early error message. 127 130 */ 128 static int vdEarlyError(PFNVDERROR pfnError, void *pvErrorUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...) 131 static int vdEarlyError(PFNVDERROR pfnError, void *pvErrorUser, int rc, 132 RT_SRC_POS_DECL, const char *pszFormat, ...) 129 133 { 130 134 va_list va; … … 138 142 * internal: issue error message. 139 143 */ 140 static int vdError(PVBOXHDD pDisk, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...) 144 static int vdError(PVBOXHDD pDisk, int rc, RT_SRC_POS_DECL, 145 const char *pszFormat, ...) 141 146 { 142 147 va_list va; … … 150 155 * internal: add image structure to the end of images list. 151 156 */ 152 static void vdAddImageToList(PVBOXHDD pDisk, PV BOXHDDIMAGEDESCpImage)157 static void vdAddImageToList(PVBOXHDD pDisk, PVDIMAGE pImage) 153 158 { 154 159 pImage->pPrev = NULL; … … 175 180 * internal: remove image structure from the images list. 176 181 */ 177 static void vdRemoveImageFromList(PVBOXHDD pDisk, PV BOXHDDIMAGEDESCpImage)182 static void vdRemoveImageFromList(PVBOXHDD pDisk, PVDIMAGE pImage) 178 183 { 179 184 Assert(pDisk->cImages > 0); … … 198 203 * internal: find image by index into the images list. 199 204 */ 200 static PV BOXHDDIMAGEDESCvdGetImageByNumber(PVBOXHDD pDisk, unsigned nImage)201 { 202 PV BOXHDDIMAGEDESCpImage = pDisk->pBase;205 static PVDIMAGE vdGetImageByNumber(PVBOXHDD pDisk, unsigned nImage) 206 { 207 PVDIMAGE pImage = pDisk->pBase; 203 208 while (pImage && nImage) 204 209 { … … 213 218 * will give us. 214 219 */ 215 static int vdReadHelper(PVBOXHDD pDisk, PVBOXHDDIMAGEDESC pImage, uint64_t uOffset, void *pvBuf, size_t cbRead) 220 static int vdReadHelper(PVBOXHDD pDisk, PVDIMAGE pImage, uint64_t uOffset, 221 void *pvBuf, size_t cbRead) 216 222 { 217 223 int rc; 218 224 size_t cbThisRead; 219 PV BOXHDDIMAGEDESCpCurrImage;225 PVDIMAGE pCurrImage; 220 226 221 227 /* Loop until all read. */ … … 227 233 cbThisRead = cbRead; 228 234 rc = VINF_VDI_BLOCK_FREE; 229 for (pCurrImage = pImage; pCurrImage != NULL && rc == VINF_VDI_BLOCK_FREE; pCurrImage = pCurrImage->pPrev) 235 for (pCurrImage = pImage; 236 pCurrImage != NULL && rc == VINF_VDI_BLOCK_FREE; 237 pCurrImage = pCurrImage->pPrev) 230 238 { 231 rc = pDisk->Backend->pfnRead(pCurrImage->pvBackendData, uOffset, pvBuf, cbThisRead, &cbThisRead); 239 rc = pDisk->Backend->pfnRead(pCurrImage->pvBackendData, uOffset, 240 pvBuf, cbThisRead, &cbThisRead); 232 241 } 233 242 … … 260 269 261 270 RTUuidCreate(&Uuid); 262 pDisk->Backend->pfnSetModificationUuid(pDisk->pLast->pvBackendData, &Uuid); 271 pDisk->Backend->pfnSetModificationUuid(pDisk->pLast->pvBackendData, 272 &Uuid); 263 273 } 264 274 … … 283 293 pDisk->Backend->pfnFlush(pDisk->pLast->pvBackendData); 284 294 } 295 } 296 297 /** 298 * internal: write a complete block (only used for diff images), taking the 299 * remaining data from parent images. This implementation does not optimize 300 * anything (except that it tries to read only that portions from parent 301 * images that are really needed). 302 */ 303 static int vdWriteHelperStandard(PVBOXHDD pDisk, PVDIMAGE pImage, 304 uint64_t uOffset, size_t cbWrite, 305 size_t cbThisWrite, size_t cbPreRead, 306 size_t cbPostRead, const void *pvBuf, 307 void *pvTmp) 308 { 309 int rc; 310 311 /* Read the data that goes before the write to fill the block. */ 312 if (cbPreRead) 313 { 314 rc = vdReadHelper(pDisk, pImage->pPrev, uOffset - cbPreRead, 315 pvTmp, cbPreRead); 316 if (VBOX_FAILURE(rc)) 317 return rc; 318 } 319 320 /* Copy the data to the right place in the buffer. */ 321 memcpy((char *)pvTmp + cbPreRead, pvBuf, cbThisWrite); 322 323 /* Read the data that goes after the write to fill the block. */ 324 if (cbPostRead) 325 { 326 /* If we have data to be written, use that instead of reading 327 * data from the image. */ 328 size_t cbWriteCopy; 329 if (cbWrite > cbThisWrite) 330 cbWriteCopy = RT_MIN(cbWrite - cbThisWrite, cbPostRead); 331 else 332 cbWriteCopy = 0; 333 /* Figure out how much we cannnot read from the image, because 334 * the last block to write might exceed the nominal size of the 335 * image for technical reasons. */ 336 size_t cbFill; 337 if (uOffset + cbThisWrite + cbPostRead > pDisk->cbSize) 338 cbFill = uOffset + cbThisWrite + cbPostRead - pDisk->cbSize; 339 else 340 cbFill = 0; 341 /* The rest must be read from the image. */ 342 size_t cbReadImage = cbPostRead - cbWriteCopy - cbFill; 343 344 /* Now assemble the remaining data. */ 345 if (cbWriteCopy) 346 memcpy((char *)pvTmp + cbPreRead + cbThisWrite, 347 (char *)pvBuf + cbThisWrite, cbWriteCopy); 348 if (cbReadImage) 349 rc = vdReadHelper(pDisk, pImage->pPrev, 350 uOffset + cbThisWrite + cbWriteCopy, 351 (char *)pvTmp + cbPreRead + cbThisWrite + cbWriteCopy, 352 cbReadImage); 353 if (VBOX_FAILURE(rc)) 354 return rc; 355 /* Zero out the remainder of this block. Will never be visible, as this 356 * is beyond the limit of the image. */ 357 if (cbFill) 358 memset((char *)pvTmp + cbPreRead + cbThisWrite + cbWriteCopy + cbReadImage, 359 '\0', cbFill); 360 } 361 362 /* Write the full block to the virtual disk. */ 363 rc = pDisk->Backend->pfnWrite(pImage->pvBackendData, 364 uOffset - cbPreRead, pvTmp, 365 cbPreRead + cbThisWrite + cbPostRead, 366 NULL, 367 &cbPreRead, &cbPostRead); 368 Assert(rc != VINF_VDI_BLOCK_FREE); 369 Assert(cbPreRead == 0); 370 Assert(cbPostRead == 0); 371 372 return rc; 373 } 374 375 /** 376 * internal: write a complete block (only used for diff images), taking the 377 * remaining data from parent images. This implementation optimized out writes 378 * that do not change the data relative to the state as of the parent images. 379 * All backends which support differential/growing images support this. 380 */ 381 static int vdWriteHelperOptimized(PVBOXHDD pDisk, PVDIMAGE pImage, 382 uint64_t uOffset, size_t cbWrite, 383 size_t cbThisWrite, size_t cbPreRead, 384 size_t cbPostRead, const void *pvBuf, 385 void *pvTmp) 386 { 387 size_t cbFill = 0; 388 size_t cbWriteCopy = 0; 389 size_t cbReadImage = 0; 390 int rc; 391 392 if (cbPostRead) 393 { 394 /* Figure out how much we cannnot read from the image, because 395 * the last block to write might exceed the nominal size of the 396 * image for technical reasons. */ 397 if (uOffset + cbThisWrite + cbPostRead > pDisk->cbSize) 398 cbFill = uOffset + cbThisWrite + cbPostRead - pDisk->cbSize; 399 400 /* If we have data to be written, use that instead of reading 401 * data from the image. */ 402 if (cbWrite > cbThisWrite) 403 cbWriteCopy = RT_MIN(cbWrite - cbThisWrite, cbPostRead); 404 405 /* The rest must be read from the image. */ 406 cbReadImage = cbPostRead - cbWriteCopy - cbFill; 407 } 408 409 /* Read the entire data of the block so that we can compare whether it will 410 * be modified by the write or not. */ 411 rc = vdReadHelper(pDisk, pImage->pPrev, uOffset - cbPreRead, 412 pvTmp, cbPreRead + cbThisWrite + cbPostRead - cbFill); 413 if (VBOX_FAILURE(rc)) 414 return rc; 415 416 /* Check if the write would modify anything in this block. */ 417 if ( !memcmp((char *)pvTmp + cbPreRead, pvBuf, cbThisWrite) 418 && (!cbWriteCopy || !memcmp((char *)pvTmp + cbPreRead + cbThisWrite, 419 (char *)pvBuf + cbThisWrite, cbWriteCopy))) 420 { 421 /* Block is completely unchanged, so no need to write anything. */ 422 return VINF_SUCCESS; 423 } 424 425 /* Copy the data to the right place in the buffer. */ 426 memcpy((char *)pvTmp + cbPreRead, pvBuf, cbThisWrite); 427 428 /* Handle the data that goes after the write to fill the block. */ 429 if (cbPostRead) 430 { 431 /* Now assemble the remaining data. */ 432 if (cbWriteCopy) 433 memcpy((char *)pvTmp + cbPreRead + cbThisWrite, 434 (char *)pvBuf + cbThisWrite, cbWriteCopy); 435 /* Zero out the remainder of this block. Will never be visible, as this 436 * is beyond the limit of the image. */ 437 if (cbFill) 438 memset((char *)pvTmp + cbPreRead + cbThisWrite + cbWriteCopy + cbReadImage, 439 '\0', cbFill); 440 } 441 442 /* Write the full block to the virtual disk. */ 443 rc = pDisk->Backend->pfnWrite(pImage->pvBackendData, 444 uOffset - cbPreRead, pvTmp, 445 cbPreRead + cbThisWrite + cbPostRead, 446 NULL, 447 &cbPreRead, &cbPostRead); 448 Assert(rc != VINF_VDI_BLOCK_FREE); 449 Assert(cbPreRead == 0); 450 Assert(cbPostRead == 0); 451 452 return rc; 285 453 } 286 454 … … 295 463 * @param ppDisk Where to store the reference to the VBox HDD container. 296 464 */ 297 VBOXDDU_DECL(int) VDCreate(const char *pszBackend, PFNVDERROR pfnError, void *pvErrorUser, PVBOXHDD *ppDisk) 465 VBOXDDU_DECL(int) VDCreate(const char *pszBackend, PFNVDERROR pfnError, 466 void *pvErrorUser, PVBOXHDD *ppDisk) 298 467 { 299 468 int rc = VINF_SUCCESS; … … 332 501 } 333 502 else 334 rc = vdEarlyError(pfnError, pvErrorUser, VERR_INVALID_PARAMETER, RT_SRC_POS, "VD: unknown backend name '%s'", pszBackend); 503 rc = vdEarlyError(pfnError, pvErrorUser, VERR_INVALID_PARAMETER, 504 RT_SRC_POS, "VD: unknown backend name '%s'", 505 pszBackend); 335 506 336 507 LogFlow(("%s: returns %vrc (pDisk=%#p)\n", __FUNCTION__, rc, pDisk)); … … 376 547 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants. 377 548 */ 378 VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszFilename, unsigned uOpenFlags) 549 VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszFilename, 550 unsigned uOpenFlags) 379 551 { 380 552 int rc = VINF_SUCCESS; 381 LogFlow(("%s: pszFilename=\"%s\" uOpenFlags=%#x\n", __FUNCTION__, pszFilename, uOpenFlags)); 553 LogFlow(("%s: pszFilename=\"%s\" uOpenFlags=%#x\n", __FUNCTION__, 554 pszFilename, uOpenFlags)); 382 555 /* sanity check */ 383 556 Assert(pDisk); … … 394 567 395 568 /* Set up image descriptor. */ 396 PV BOXHDDIMAGEDESC pImage = (PVBOXHDDIMAGEDESC)RTMemAllocZ(sizeof(VBOXHDDIMAGEDESC));569 PVDIMAGE pImage = (PVDIMAGE)RTMemAllocZ(sizeof(VDIMAGE)); 397 570 if (!pImage) 398 571 return VERR_NO_MEMORY; … … 402 575 403 576 if (VBOX_SUCCESS(rc)) 404 rc = pDisk->Backend->pfnOpen(pImage->pszFilename, uOpenFlags, pDisk->pfnError, pDisk->pvErrorUser, &pImage->pvBackendData); 577 { 578 pImage->uOpenFlags = uOpenFlags & VD_OPEN_FLAGS_HONOR_SAME; 579 rc = pDisk->Backend->pfnOpen(pImage->pszFilename, 580 uOpenFlags & ~VD_OPEN_FLAGS_HONOR_SAME, 581 pDisk->pfnError, pDisk->pvErrorUser, 582 &pImage->pvBackendData); 583 } 405 584 /* If the open in read-write mode failed, retry in read-only mode. */ 406 585 if (VBOX_FAILURE(rc)) … … 412 591 || rc == VERR_SHARING_VIOLATION 413 592 || rc == VERR_FILE_LOCK_FAILED)) 414 rc = pDisk->Backend->pfnOpen(pImage->pszFilename, uOpenFlags | VD_OPEN_FLAGS_READONLY, pDisk->pfnError, pDisk->pvErrorUser, &pImage->pvBackendData); 593 rc = pDisk->Backend->pfnOpen(pImage->pszFilename, 594 (uOpenFlags & ~VD_OPEN_FLAGS_HONOR_SAME) 595 | VD_OPEN_FLAGS_READONLY, 596 pDisk->pfnError, pDisk->pvErrorUser, 597 &pImage->pvBackendData); 415 598 if (VBOX_FAILURE(rc)) 416 rc = vdError(pDisk, rc, RT_SRC_POS, N_("VD: error opening image file '%s'"), pszFilename); 599 rc = vdError(pDisk, rc, RT_SRC_POS, 600 N_("VD: error opening image file '%s'"), pszFilename); 417 601 } 418 602 … … 420 604 { 421 605 VDIMAGETYPE enmImageType; 422 rc = pDisk->Backend->pfnGetImageType(pImage->pvBackendData, &enmImageType); 606 rc = pDisk->Backend->pfnGetImageType(pImage->pvBackendData, 607 &enmImageType); 423 608 /* Check image type. As the image itself has no idea whether it's a 424 609 * base image or not, this info is derived here. Image 0 can be fixed … … 535 720 { 536 721 int rc = VINF_SUCCESS; 537 LogFlow(("%s: pszFilename=\"%s\" uOpenFlags=%#x\n", __FUNCTION__, pszFilename, uOpenFlags)); 722 LogFlow(("%s: pszFilename=\"%s\" uOpenFlags=%#x\n", __FUNCTION__, 723 pszFilename, uOpenFlags)); 538 724 /* sanity check */ 539 725 Assert(pDisk); … … 559 745 560 746 /* Set up image descriptor. */ 561 PV BOXHDDIMAGEDESC pImage = (PVBOXHDDIMAGEDESC)RTMemAllocZ(sizeof(VBOXHDDIMAGEDESC));747 PVDIMAGE pImage = (PVDIMAGE)RTMemAllocZ(sizeof(VDIMAGE)); 562 748 if (!pImage) 563 749 return VERR_NO_MEMORY; … … 615 801 * @param pvUser User argument for the progress callback. 616 802 */ 617 VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom, unsigned nImageTo, 618 PFNVMPROGRESS pfnProgress, void *pvUser) 803 VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom, 804 unsigned nImageTo, PFNVMPROGRESS pfnProgress, 805 void *pvUser) 619 806 { 620 807 return VERR_NOT_IMPLEMENTED; … … 711 898 AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 712 899 713 PV BOXHDDIMAGEDESCpImage = pDisk->pLast;900 PVDIMAGE pImage = pDisk->pLast; 714 901 int rc = VINF_SUCCESS; 715 902 while (pImage) 716 903 { 717 PV BOXHDDIMAGEDESCpPrev = pImage->pPrev;904 PVDIMAGE pPrev = pImage->pPrev; 718 905 /* Remove image from list of opened images. */ 719 906 vdRemoveImageFromList(pDisk, pImage); … … 749 936 750 937 int rc = VINF_SUCCESS; 751 PV BOXHDDIMAGEDESCpImage = pDisk->pLast;938 PVDIMAGE pImage = pDisk->pLast; 752 939 if (RT_UNLIKELY(!pImage)) 753 940 { … … 788 975 size_t cbThisWrite; 789 976 size_t cbPreRead, cbPostRead; 790 PV BOXHDDIMAGEDESCpImage = pDisk->pLast;977 PVDIMAGE pImage = pDisk->pLast; 791 978 if (RT_UNLIKELY(!pImage)) 792 979 { … … 814 1001 * block if needed. */ 815 1002 cbThisWrite = cbWrite; 816 rc = pDisk->Backend->pfnWrite(pImage->pvBackendData, uOffset, pvBuf, cbThisWrite, &cbThisWrite, &cbPreRead, &cbPostRead); 1003 rc = pDisk->Backend->pfnWrite(pImage->pvBackendData, uOffset, pvBuf, 1004 cbThisWrite, &cbThisWrite, 1005 &cbPreRead, &cbPostRead); 817 1006 if (rc == VINF_VDI_BLOCK_FREE) 818 1007 { 819 /* Partial block write to an unallocated block. Read the rest of820 * this block and then do a full-block (allocating) write. */821 1008 void *pvTmp = RTMemTmpAlloc(cbPreRead + cbThisWrite + cbPostRead); 822 1009 if (!pvBuf) … … 827 1014 } 828 1015 829 /* Read the data that goes before the write to fill the block. */ 830 if (cbPreRead) 1016 if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_HONOR_SAME)) 831 1017 { 832 rc = vdReadHelper(pDisk, pImage->pPrev, uOffset - cbPreRead, 833 pvTmp, cbPreRead); 834 if (VBOX_FAILURE(rc)) 835 break; 1018 /* Optimized write, suppress writing to a so far unallocated 1019 * block when the data is identical than as of the parent. */ 1020 rc = vdWriteHelperOptimized(pDisk, pImage, uOffset, 1021 cbWrite, cbThisWrite, 1022 cbPreRead, cbPostRead, 1023 pvBuf, pvTmp); 836 1024 } 837 838 /* Copy the data to the right place in the buffer. */ 839 memcpy((char *)pvTmp + cbPreRead, pvBuf, cbThisWrite); 840 841 /* Read the data that goes after the write to fill the block. */ 842 if (cbPostRead) 1025 else 843 1026 { 844 /* If we have data to be written, use that instead of reading 845 * data from the image. */ 846 size_t cbWriteCopy; 847 if (cbWrite > cbThisWrite) 848 cbWriteCopy = RT_MIN(cbWrite - cbThisWrite, cbPostRead); 849 else 850 cbWriteCopy = 0; 851 /* Figure out how much we cannnot read from the image, because 852 * the last block to write might exceed the nominal size of the 853 * image for technical reasons. */ 854 size_t cbFill; 855 if (uOffset + cbThisWrite + cbPostRead > pDisk->cbSize) 856 cbFill = uOffset + cbThisWrite + cbPostRead - pDisk->cbSize; 857 else 858 cbFill = 0; 859 /* The rest must be read from the image. */ 860 size_t cbReadImage = cbPostRead - cbWriteCopy - cbFill; 861 862 /* Now assemble the remaining data. */ 863 if (cbWriteCopy) 864 memcpy((char *)pvTmp + cbPreRead + cbThisWrite, (char *)pvBuf + cbThisWrite, cbWriteCopy); 865 if (cbReadImage) 866 rc = vdReadHelper(pDisk, pImage->pPrev, uOffset + cbThisWrite + cbWriteCopy, 867 (void *)((char *)pvTmp + cbPreRead + cbThisWrite + cbWriteCopy), 868 cbReadImage); 869 if (VBOX_FAILURE(rc)) 870 break; 871 if (cbFill) 872 memset((char *)pvTmp + cbPreRead + cbThisWrite + cbWriteCopy + cbReadImage, '\0', cbFill); 1027 /* Normal write, not optimized in any way. The block will be 1028 * written no matter what. This will usually (unless the 1029 * backend has some further optimization enabled) cause the 1030 * block to be allocated. */ 1031 rc = vdWriteHelperStandard(pDisk, pImage, uOffset, 1032 cbWrite, cbThisWrite, 1033 cbPreRead, cbPostRead, 1034 pvBuf, pvTmp); 873 1035 } 874 875 /* Write the full block to the virtual disk. */ 876 rc = pDisk->Backend->pfnWrite(pImage->pvBackendData, 877 uOffset - cbPreRead, pvTmp, 878 cbPreRead + cbThisWrite + cbPostRead, 879 NULL, 880 &cbPreRead, &cbPostRead); 881 Assert(rc != VINF_VDI_BLOCK_FREE); 1036 if (VBOX_FAILURE(rc)) 1037 break; 882 1038 } 883 1039 … … 905 1061 906 1062 int rc = VINF_SUCCESS; 907 PV BOXHDDIMAGEDESCpImage = pDisk->pLast;1063 PVDIMAGE pImage = pDisk->pLast; 908 1064 if (RT_UNLIKELY(!pImage)) 909 1065 { … … 997 1153 * @param pcSectors Where to store the number of sectors. NULL is ok. 998 1154 */ 999 VBOXDDU_DECL(int) VDGetGeometry(PVBOXHDD pDisk, 1000 unsigned *pc Cylinders, unsigned *pcHeads, unsigned *pcSectors)1155 VBOXDDU_DECL(int) VDGetGeometry(PVBOXHDD pDisk, unsigned *pcCylinders, 1156 unsigned *pcHeads, unsigned *pcSectors) 1001 1157 { 1002 1158 /* sanity check */ … … 1005 1161 1006 1162 int rc = VINF_SUCCESS; 1007 PV BOXHDDIMAGEDESCpImage = pDisk->pBase;1163 PVDIMAGE pImage = pDisk->pBase; 1008 1164 if (RT_UNLIKELY(!pImage)) 1009 1165 { … … 1042 1198 * @param cSectors Number of sectors. 1043 1199 */ 1044 VBOXDDU_DECL(int) VDSetGeometry(PVBOXHDD pDisk, 1045 unsigned c Cylinders, unsigned cHeads, unsigned cSectors)1200 VBOXDDU_DECL(int) VDSetGeometry(PVBOXHDD pDisk, unsigned cCylinders, 1201 unsigned cHeads, unsigned cSectors) 1046 1202 { 1047 1203 /* sanity check */ … … 1050 1206 1051 1207 int rc = VINF_SUCCESS; 1052 PV BOXHDDIMAGEDESCpImage = pDisk->pBase;1208 PVDIMAGE pImage = pDisk->pBase; 1053 1209 if (RT_UNLIKELY(!pImage)) 1054 1210 { … … 1104 1260 * @param penmTranslation Where to store the translation mode (see pdm.h). 1105 1261 */ 1106 VBOXDDU_DECL(int) VDGetTranslation(PVBOXHDD pDisk, PPDMBIOSTRANSLATION penmTranslation) 1262 VBOXDDU_DECL(int) VDGetTranslation(PVBOXHDD pDisk, 1263 PPDMBIOSTRANSLATION penmTranslation) 1107 1264 { 1108 1265 /* sanity check */ … … 1111 1268 1112 1269 int rc = VINF_SUCCESS; 1113 PV BOXHDDIMAGEDESCpImage = pDisk->pBase;1270 PVDIMAGE pImage = pDisk->pBase; 1114 1271 if (RT_UNLIKELY(!pImage)) 1115 1272 { … … 1139 1296 * @param enmTranslation Translation mode (see pdm.h). 1140 1297 */ 1141 VBOXDDU_DECL(int) VDSetTranslation(PVBOXHDD pDisk, PDMBIOSTRANSLATION enmTranslation) 1298 VBOXDDU_DECL(int) VDSetTranslation(PVBOXHDD pDisk, 1299 PDMBIOSTRANSLATION enmTranslation) 1142 1300 { 1143 1301 /* sanity check */ … … 1146 1304 1147 1305 int rc = VINF_SUCCESS; 1148 PV BOXHDDIMAGEDESCpImage = pDisk->pBase;1306 PVDIMAGE pImage = pDisk->pBase; 1149 1307 if (RT_UNLIKELY(!pImage)) 1150 1308 { … … 1187 1345 * @param puVersion Where to store the image version. 1188 1346 */ 1189 VBOXDDU_DECL(int) VDGetVersion(PVBOXHDD pDisk, unsigned nImage, unsigned *puVersion) 1347 VBOXDDU_DECL(int) VDGetVersion(PVBOXHDD pDisk, unsigned nImage, 1348 unsigned *puVersion) 1190 1349 { 1191 1350 return VERR_NOT_IMPLEMENTED; … … 1201 1360 * @param penmType Where to store the image type. 1202 1361 */ 1203 VBOXDDU_DECL(int) VDGetImageType(PVBOXHDD pDisk, unsigned nImage, PVDIMAGETYPE penmType) 1362 VBOXDDU_DECL(int) VDGetImageType(PVBOXHDD pDisk, unsigned nImage, 1363 PVDIMAGETYPE penmType) 1204 1364 { 1205 1365 return VERR_NOT_IMPLEMENTED; … … 1215 1375 * @param puImageFlags Where to store the image flags. 1216 1376 */ 1217 VBOXDDU_DECL(int) VDGetImageFlags(PVBOXHDD pDisk, unsigned nImage, unsigned *puImageFlags) 1377 VBOXDDU_DECL(int) VDGetImageFlags(PVBOXHDD pDisk, unsigned nImage, 1378 unsigned *puImageFlags) 1218 1379 { 1219 1380 return VERR_NOT_IMPLEMENTED; … … 1236 1397 unsigned uOpenFlags = 0; 1237 1398 int rc = VINF_SUCCESS; 1238 PV BOXHDDIMAGEDESCpImage = pDisk->pLast;1399 PVDIMAGE pImage = pDisk->pLast; 1239 1400 if (RT_UNLIKELY(!pImage)) 1240 1401 { … … 1269 1430 1270 1431 int rc = VINF_SUCCESS; 1271 PV BOXHDDIMAGEDESCpImage = pDisk->pLast;1432 PVDIMAGE pImage = pDisk->pLast; 1272 1433 if (RT_UNLIKELY(!pImage)) 1273 1434 { … … 1276 1437 } 1277 1438 else 1278 rc = pDisk->Backend->pfnSetOpenFlags(pDisk->pLast->pvBackendData, uOpenFlags); 1439 rc = pDisk->Backend->pfnSetOpenFlags(pDisk->pLast->pvBackendData, 1440 uOpenFlags); 1279 1441 LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc)); 1280 1442 return rc; … … 1294 1456 * @param cbFilename Size of buffer pszFilename points to. 1295 1457 */ 1296 VBOXDDU_DECL(int) VDGetFilename(PVBOXHDD pDisk, unsigned nImage, char *pszFilename, unsigned cbFilename) 1458 VBOXDDU_DECL(int) VDGetFilename(PVBOXHDD pDisk, unsigned nImage, 1459 char *pszFilename, unsigned cbFilename) 1297 1460 { 1298 1461 return VERR_NOT_IMPLEMENTED; … … 1310 1473 * @param cbComment The size of pszComment buffer. 0 is ok. 1311 1474 */ 1312 VBOXDDU_DECL(int) VDGetComment(PVBOXHDD pDisk, unsigned nImage, char *pszComment, unsigned cbComment) 1475 VBOXDDU_DECL(int) VDGetComment(PVBOXHDD pDisk, unsigned nImage, 1476 char *pszComment, unsigned cbComment) 1313 1477 { 1314 1478 return VERR_NOT_IMPLEMENTED; … … 1316 1480 1317 1481 /** 1318 * * Changes the comment line of image in HDD container. 1319 * * 1320 * * @returns VBox status code. 1321 * * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened. 1322 * * @param pDisk Pointer to VBox HDD container. 1323 * * @param nImage Image number, counts from 0. 0 is always base image of container. 1324 * * @param pszComment New comment string (UTF-8). NULL is allowed to reset the comment. 1325 * */ 1326 VBOXDDU_DECL(int) VDSetComment(PVBOXHDD pDisk, unsigned nImage, const char *pszComment) 1482 * Changes the comment line of image in HDD container. 1483 * 1484 * @returns VBox status code. 1485 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened. 1486 * @param pDisk Pointer to VBox HDD container. 1487 * @param nImage Image number, counts from 0. 0 is always base image of container. 1488 * @param pszComment New comment string (UTF-8). NULL is allowed to reset the comment. 1489 */ 1490 VBOXDDU_DECL(int) VDSetComment(PVBOXHDD pDisk, unsigned nImage, 1491 const char *pszComment) 1327 1492 { 1328 1493 return VERR_NOT_IMPLEMENTED; … … 1346 1511 Assert(pUuid); 1347 1512 1348 PV BOXHDDIMAGEDESCpImage = vdGetImageByNumber(pDisk, nImage);1513 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 1349 1514 int rc; 1350 1515 if (pImage) … … 1375 1540 Assert(pUuid); 1376 1541 1377 PV BOXHDDIMAGEDESCpImage = vdGetImageByNumber(pDisk, nImage);1542 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 1378 1543 int rc; 1379 1544 if (pImage) … … 1402 1567 Assert(pUuid); 1403 1568 1404 PV BOXHDDIMAGEDESCpImage = vdGetImageByNumber(pDisk, nImage);1569 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 1405 1570 int rc; 1406 1571 if (pImage) … … 1431 1596 Assert(pUuid); 1432 1597 1433 PV BOXHDDIMAGEDESCpImage = vdGetImageByNumber(pDisk, nImage);1598 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 1434 1599 int rc; 1435 1600 if (pImage) … … 1451 1616 * @param pUuid Where to store the parent image UUID. 1452 1617 */ 1453 VBOXDDU_DECL(int) VDGetParentUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid) 1618 VBOXDDU_DECL(int) VDGetParentUuid(PVBOXHDD pDisk, unsigned nImage, 1619 PRTUUID pUuid) 1454 1620 { 1455 1621 /* sanity check */ … … 1458 1624 Assert(pUuid); 1459 1625 1460 PV BOXHDDIMAGEDESCpImage = vdGetImageByNumber(pDisk, nImage);1626 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 1461 1627 int rc; 1462 1628 if (pImage) … … 1478 1644 * @param pUuid Optional parameter, new parent UUID of the image. 1479 1645 */ 1480 VBOXDDU_DECL(int) VDSetParentUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid) 1646 VBOXDDU_DECL(int) VDSetParentUuid(PVBOXHDD pDisk, unsigned nImage, 1647 PCRTUUID pUuid) 1481 1648 { 1482 1649 LogFlow(("%s: uuid={%Vuuid} nImage=%u\n", __FUNCTION__, pUuid, nImage)); … … 1486 1653 Assert(pUuid); 1487 1654 1488 PV BOXHDDIMAGEDESCpImage = vdGetImageByNumber(pDisk, nImage);1655 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 1489 1656 int rc; 1490 1657 if (pImage) … … 1510 1677 1511 1678 RTLogPrintf("--- Dumping VDI Disk, Images=%u\n", pDisk->cImages); 1512 for (PV BOXHDDIMAGEDESCpImage = pDisk->pBase; pImage; pImage = pImage->pNext)1679 for (PVDIMAGE pImage = pDisk->pBase; pImage; pImage = pImage->pNext) 1513 1680 { 1514 1681 RTLogPrintf("Dumping VDI image \"%s\" file=%#p\n", pImage->pszFilename);
Note:
See TracChangeset
for help on using the changeset viewer.