Changeset 63784 in vbox for trunk/src/VBox/Storage/RAW.cpp
- Timestamp:
- Sep 9, 2016 9:47:15 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/RAW.cpp
r63781 r63784 144 144 uint64_t uOff; 145 145 void *pvBuf = RTMemTmpAllocZ(RAW_FILL_SIZE); 146 if (!pvBuf) 147 goto out; 148 149 uOff = pImage->offAccess; 150 /* Write data to all image blocks. */ 151 while (uOff < pImage->cbSize) 146 if (RT_LIKELY(pvBuf)) 152 147 { 153 unsigned cbChunk = (unsigned)RT_MIN(pImage->cbSize - uOff, 154 RAW_FILL_SIZE); 155 156 rc = vdIfIoIntFileWriteSync(pImage->pIfIo, pImage->pStorage, 157 uOff, pvBuf, cbChunk); 158 if (RT_FAILURE(rc)) 159 goto out; 160 161 uOff += cbChunk; 148 uOff = pImage->offAccess; 149 /* Write data to all image blocks. */ 150 while (uOff < pImage->cbSize) 151 { 152 unsigned cbChunk = (unsigned)RT_MIN(pImage->cbSize - uOff, 153 RAW_FILL_SIZE); 154 155 rc = vdIfIoIntFileWriteSync(pImage->pIfIo, pImage->pStorage, 156 uOff, pvBuf, cbChunk); 157 if (RT_FAILURE(rc)) 158 break; 159 160 uOff += cbChunk; 161 } 162 163 RTMemTmpFree(pvBuf); 162 164 } 163 out: 164 if (pvBuf) 165 RTMemTmpFree(pvBuf); 165 else 166 rc = VERR_NO_MEMORY; 166 167 } 167 168 rawFlushImage(pImage); … … 185 186 static int rawOpenImage(PRAWIMAGE pImage, unsigned uOpenFlags) 186 187 { 187 int rc;188 189 188 pImage->uOpenFlags = uOpenFlags; 190 189 pImage->fCreate = false; … … 194 193 AssertPtrReturn(pImage->pIfIo, VERR_INVALID_PARAMETER); 195 194 196 /* 197 * Open the image. 198 */ 199 rc = vdIfIoIntFileOpen(pImage->pIfIo, pImage->pszFilename, 200 VDOpenFlagsToFileOpenFlags(uOpenFlags, 201 false /* fCreate */), 202 &pImage->pStorage); 203 if (RT_FAILURE(rc)) 204 { 205 /* Do NOT signal an appropriate error here, as the VD layer has the 206 * choice of retrying the open if it failed. */ 207 goto out; 208 } 209 210 rc = vdIfIoIntFileGetSize(pImage->pIfIo, pImage->pStorage, &pImage->cbSize); 211 if (RT_FAILURE(rc)) 212 goto out; 213 if (pImage->cbSize % 512) 214 { 215 rc = VERR_VD_RAW_SIZE_MODULO_512; 216 goto out; 217 } 218 pImage->uImageFlags |= VD_IMAGE_FLAGS_FIXED; 219 220 out: 195 /* Open the image. */ 196 int rc = vdIfIoIntFileOpen(pImage->pIfIo, pImage->pszFilename, 197 VDOpenFlagsToFileOpenFlags(uOpenFlags, 198 false /* fCreate */), 199 &pImage->pStorage); 200 if (RT_SUCCESS(rc)) 201 { 202 rc = vdIfIoIntFileGetSize(pImage->pIfIo, pImage->pStorage, &pImage->cbSize); 203 if ( RT_SUCCESS(rc) 204 && !(pImage->cbSize % 512)) 205 pImage->uImageFlags |= VD_IMAGE_FLAGS_FIXED; 206 else if (RT_SUCCESS(rc)) 207 rc = VERR_VD_RAW_SIZE_MODULO_512; 208 } 209 /* else: Do NOT signal an appropriate error here, as the VD layer has the 210 * choice of retrying the open if it failed. */ 211 221 212 if (RT_FAILURE(rc)) 222 213 rawFreeImage(pImage, false); … … 231 222 PCVDGEOMETRY pPCHSGeometry, 232 223 PCVDGEOMETRY pLCHSGeometry, unsigned uOpenFlags, 233 P FNVDPROGRESS pfnProgress, void *pvUser,224 PVDINTERFACEPROGRESS pIfProgress, 234 225 unsigned uPercentStart, unsigned uPercentSpan) 235 226 { 236 227 RT_NOREF1(pszComment); 237 int rc; 238 RTFOFF cbFree = 0; 239 int32_t fOpen; 240 241 uImageFlags |= VD_IMAGE_FLAGS_FIXED; 242 243 pImage->uOpenFlags = uOpenFlags & ~VD_OPEN_FLAGS_READONLY; 244 245 pImage->uImageFlags = uImageFlags; 246 pImage->fCreate = true; 228 int rc = VINF_SUCCESS; 229 230 pImage->fCreate = true; 231 pImage->uOpenFlags = uOpenFlags & ~VD_OPEN_FLAGS_READONLY; 232 pImage->uImageFlags = uImageFlags | VD_IMAGE_FLAGS_FIXED; 247 233 pImage->PCHSGeometry = *pPCHSGeometry; 248 234 pImage->LCHSGeometry = *pLCHSGeometry; 249 250 pImage->pIfError = VDIfErrorGet(pImage->pVDIfsDisk); 251 pImage->pIfIo = VDIfIoIntGet(pImage->pVDIfsImage); 235 pImage->pIfError = VDIfErrorGet(pImage->pVDIfsDisk); 236 pImage->pIfIo = VDIfIoIntGet(pImage->pVDIfsImage); 252 237 AssertPtrReturn(pImage->pIfIo, VERR_INVALID_PARAMETER); 253 238 254 if (uImageFlags & VD_IMAGE_FLAGS_DIFF) 255 { 239 if (!(pImage->uImageFlags & VD_IMAGE_FLAGS_DIFF)) 240 { 241 /* Create image file. */ 242 uint32_t fOpen = VDOpenFlagsToFileOpenFlags(pImage->uOpenFlags, true /* fCreate */); 243 if (uOpenFlags & VD_OPEN_FLAGS_SEQUENTIAL) 244 fOpen &= ~RTFILE_O_READ; 245 rc = vdIfIoIntFileOpen(pImage->pIfIo, pImage->pszFilename, fOpen, &pImage->pStorage); 246 if (RT_SUCCESS(rc)) 247 { 248 if (!(uOpenFlags & VD_OPEN_FLAGS_SEQUENTIAL)) 249 { 250 RTFOFF cbFree = 0; 251 252 /* Check the free space on the disk and leave early if there is not 253 * sufficient space available. */ 254 rc = vdIfIoIntFileGetFreeSpace(pImage->pIfIo, pImage->pszFilename, &cbFree); 255 if (RT_FAILURE(rc) /* ignore errors */ || ((uint64_t)cbFree >= cbSize)) 256 { 257 rc = vdIfIoIntFileSetAllocationSize(pImage->pIfIo, pImage->pStorage, cbSize, 0 /* fFlags */, 258 pIfProgress ? pIfProgress->pfnProgress : NULL, 259 pIfProgress ? pIfProgress->Core.pvUser : NULL, 260 uPercentStart, uPercentSpan); 261 if (RT_SUCCESS(rc)) 262 { 263 vdIfProgress(pIfProgress, uPercentStart + uPercentSpan * 98 / 100); 264 265 pImage->cbSize = cbSize; 266 rc = rawFlushImage(pImage); 267 } 268 } 269 else 270 rc = vdIfError(pImage->pIfError, VERR_DISK_FULL, RT_SRC_POS, N_("Raw: disk would overflow creating image '%s'"), pImage->pszFilename); 271 } 272 } 273 else 274 rc = vdIfError(pImage->pIfError, rc, RT_SRC_POS, N_("Raw: cannot create image '%s'"), pImage->pszFilename); 275 } 276 else 256 277 rc = vdIfError(pImage->pIfError, VERR_VD_RAW_INVALID_TYPE, RT_SRC_POS, N_("Raw: cannot create diff image '%s'"), pImage->pszFilename); 257 goto out; 258 } 259 260 /* Create image file. */ 261 fOpen = VDOpenFlagsToFileOpenFlags(pImage->uOpenFlags, true /* fCreate */); 262 if (uOpenFlags & VD_OPEN_FLAGS_SEQUENTIAL) 263 fOpen &= ~RTFILE_O_READ; 264 rc = vdIfIoIntFileOpen(pImage->pIfIo, pImage->pszFilename, fOpen, &pImage->pStorage); 265 if (RT_FAILURE(rc)) 266 { 267 rc = vdIfError(pImage->pIfError, rc, RT_SRC_POS, N_("Raw: cannot create image '%s'"), pImage->pszFilename); 268 goto out; 269 } 270 271 if (!(uOpenFlags & VD_OPEN_FLAGS_SEQUENTIAL)) 272 { 273 /* Check the free space on the disk and leave early if there is not 274 * sufficient space available. */ 275 rc = vdIfIoIntFileGetFreeSpace(pImage->pIfIo, pImage->pszFilename, &cbFree); 276 if (RT_SUCCESS(rc) /* ignore errors */ && ((uint64_t)cbFree < cbSize)) 277 { 278 rc = vdIfError(pImage->pIfError, VERR_DISK_FULL, RT_SRC_POS, N_("Raw: disk would overflow creating image '%s'"), pImage->pszFilename); 279 goto out; 280 } 281 282 /* Allocate & commit whole file if fixed image, it must be more 283 * effective than expanding file by write operations. */ 284 rc = vdIfIoIntFileSetAllocationSize(pImage->pIfIo, pImage->pStorage, cbSize, 285 0 /* fFlags */, pfnProgress, pvUser, uPercentStart, uPercentSpan); 286 } 287 288 if (RT_SUCCESS(rc) && pfnProgress) 289 pfnProgress(pvUser, uPercentStart + uPercentSpan * 98 / 100); 290 291 pImage->cbSize = cbSize; 292 293 rc = rawFlushImage(pImage); 294 295 out: 296 297 if (RT_SUCCESS(rc) && pfnProgress) 298 pfnProgress(pvUser, uPercentStart + uPercentSpan); 278 279 if (RT_SUCCESS(rc)) 280 vdIfProgress(pIfProgress, uPercentStart + uPercentSpan); 299 281 300 282 if (RT_FAILURE(rc)) … … 304 286 305 287 306 /** @copydoc V BOXHDDBACKEND::pfnCheckIfValid */288 /** @copydoc VDIMAGEBACKEND::pfnCheckIfValid */ 307 289 static DECLCALLBACK(int) rawCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 308 290 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) … … 311 293 LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage)); 312 294 PVDIOSTORAGE pStorage = NULL; 313 uint64_t cbFile;314 int rc = VINF_SUCCESS;315 char *pszSuffix = NULL;316 317 295 PVDINTERFACEIOINT pIfIo = VDIfIoIntGet(pVDIfsImage); 296 318 297 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 319 320 if ( !VALID_PTR(pszFilename) 321 || !*pszFilename) 322 { 323 rc = VERR_INVALID_PARAMETER; 324 goto out; 325 } 326 327 pszSuffix = RTPathSuffix(pszFilename); 298 AssertReturn((VALID_PTR(pszFilename) && *pszFilename), VERR_INVALID_PARAMETER); 328 299 329 300 /* 330 301 * Open the file and read the footer. 331 302 */ 332 rc = vdIfIoIntFileOpen(pIfIo, pszFilename,333 VDOpenFlagsToFileOpenFlags(VD_OPEN_FLAGS_READONLY,334 false /* fCreate */),335 &pStorage);303 int rc = vdIfIoIntFileOpen(pIfIo, pszFilename, 304 VDOpenFlagsToFileOpenFlags(VD_OPEN_FLAGS_READONLY, 305 false /* fCreate */), 306 &pStorage); 336 307 if (RT_SUCCESS(rc)) 337 308 { 309 uint64_t cbFile; 310 const char *pszSuffix = RTPathSuffix(pszFilename); 338 311 rc = vdIfIoIntFileGetSize(pIfIo, pStorage, &cbFile); 339 312 … … 385 358 vdIfIoIntFileClose(pIfIo, pStorage); 386 359 387 out: 388 LogFlowFunc(("returns %Rrc\n", rc)); 389 return rc; 390 } 391 392 /** @copydoc VBOXHDDBACKEND::pfnOpen */ 360 LogFlowFunc(("returns %Rrc\n", rc)); 361 return rc; 362 } 363 364 /** @copydoc VDIMAGEBACKEND::pfnOpen */ 393 365 static DECLCALLBACK(int) rawOpen(const char *pszFilename, unsigned uOpenFlags, 394 366 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 395 367 VDTYPE enmType, void **ppBackendData) 396 368 { 397 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p enmType=%u ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, enmType, ppBackendData)); 369 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p enmType=%u ppBackendData=%#p\n", 370 pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, enmType, ppBackendData)); 398 371 int rc; 399 372 PRAWIMAGE pImage; … … 402 375 403 376 /* Check open flags. All valid flags are supported. */ 404 if (uOpenFlags & ~VD_OPEN_FLAGS_MASK) 405 { 406 rc = VERR_INVALID_PARAMETER; 407 goto out; 408 } 409 410 /* Check remaining arguments. */ 411 if ( !VALID_PTR(pszFilename) 412 || !*pszFilename) 413 { 414 rc = VERR_INVALID_PARAMETER; 415 goto out; 416 } 417 377 AssertReturn(!(uOpenFlags & ~VD_OPEN_FLAGS_MASK), VERR_INVALID_PARAMETER); 378 AssertReturn((VALID_PTR(pszFilename) && *pszFilename), VERR_INVALID_PARAMETER); 418 379 419 380 pImage = (PRAWIMAGE)RTMemAllocZ(sizeof(RAWIMAGE)); 420 if (!pImage) 421 { 381 if (RT_LIKELY(pImage)) 382 { 383 pImage->pszFilename = pszFilename; 384 pImage->pStorage = NULL; 385 pImage->pVDIfsDisk = pVDIfsDisk; 386 pImage->pVDIfsImage = pVDIfsImage; 387 388 rc = rawOpenImage(pImage, uOpenFlags); 389 if (RT_SUCCESS(rc)) 390 { 391 if (enmType == VDTYPE_DVD) 392 pImage->cbSector = 2048; 393 else 394 pImage->cbSector = 512; 395 *ppBackendData = pImage; 396 } 397 else 398 RTMemFree(pImage); 399 } 400 else 422 401 rc = VERR_NO_MEMORY; 423 goto out; 424 } 425 pImage->pszFilename = pszFilename; 426 pImage->pStorage = NULL; 427 pImage->pVDIfsDisk = pVDIfsDisk; 428 pImage->pVDIfsImage = pVDIfsImage; 429 430 rc = rawOpenImage(pImage, uOpenFlags); 431 if (RT_SUCCESS(rc)) 432 { 433 if (enmType == VDTYPE_DVD) 434 pImage->cbSector = 2048; 435 else 436 pImage->cbSector = 512; 437 *ppBackendData = pImage; 438 } 439 else 440 RTMemFree(pImage); 441 442 out: 402 443 403 LogFlowFunc(("returns %Rrc (pBackendData=%#p)\n", rc, *ppBackendData)); 444 404 return rc; 445 405 } 446 406 447 /** @copydoc V BOXHDDBACKEND::pfnCreate */407 /** @copydoc VDIMAGEBACKEND::pfnCreate */ 448 408 static DECLCALLBACK(int) rawCreate(const char *pszFilename, uint64_t cbSize, 449 409 unsigned uImageFlags, const char *pszComment, … … 458 418 LogFlowFunc(("pszFilename=\"%s\" cbSize=%llu uImageFlags=%#x pszComment=\"%s\" pPCHSGeometry=%#p pLCHSGeometry=%#p Uuid=%RTuuid uOpenFlags=%#x uPercentStart=%u uPercentSpan=%u pVDIfsDisk=%#p pVDIfsImage=%#p pVDIfsOperation=%#p enmType=%u ppBackendData=%#p", 459 419 pszFilename, cbSize, uImageFlags, pszComment, pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags, uPercentStart, uPercentSpan, pVDIfsDisk, pVDIfsImage, pVDIfsOperation, enmType, ppBackendData)); 460 int rc;461 PRAWIMAGE pImage;462 463 PFNVDPROGRESS pfnProgress = NULL;464 void *pvUser = NULL;465 PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation);466 if (pIfProgress)467 {468 pfnProgress = pIfProgress->pfnProgress;469 pvUser = pIfProgress->Core.pvUser;470 }471 420 472 421 /* Check the VD container type. Yes, hard disk must be allowed, otherwise 473 422 * various tools using this backend for hard disk images will fail. */ 474 423 if (enmType != VDTYPE_HDD && enmType != VDTYPE_DVD && enmType != VDTYPE_FLOPPY) 475 { 476 rc = VERR_VD_INVALID_TYPE; 477 goto out; 478 } 479 480 /* Check open flags. All valid flags are supported. */ 481 if (uOpenFlags & ~VD_OPEN_FLAGS_MASK) 482 { 483 rc = VERR_INVALID_PARAMETER; 484 goto out; 485 } 486 487 /* Check remaining arguments. */ 488 if ( !VALID_PTR(pszFilename) 489 || !*pszFilename 490 || !VALID_PTR(pPCHSGeometry) 491 || !VALID_PTR(pLCHSGeometry)) 492 { 493 rc = VERR_INVALID_PARAMETER; 494 goto out; 495 } 496 497 pImage = (PRAWIMAGE)RTMemAllocZ(sizeof(RAWIMAGE)); 498 if (!pImage) 499 { 424 return VERR_VD_INVALID_TYPE; 425 426 int rc = VINF_SUCCESS; 427 PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation); 428 429 /* Check arguments. */ 430 AssertReturn(!(uOpenFlags & ~VD_OPEN_FLAGS_MASK), VERR_INVALID_PARAMETER); 431 AssertReturn( VALID_PTR(pszFilename) 432 && *pszFilename 433 && VALID_PTR(pPCHSGeometry) 434 && VALID_PTR(pLCHSGeometry), VERR_INVALID_PARAMETER); 435 436 PRAWIMAGE pImage = (PRAWIMAGE)RTMemAllocZ(sizeof(RAWIMAGE)); 437 if (RT_LIKELY(pImage)) 438 { 439 pImage->pszFilename = pszFilename; 440 pImage->pStorage = NULL; 441 pImage->pVDIfsDisk = pVDIfsDisk; 442 pImage->pVDIfsImage = pVDIfsImage; 443 444 rc = rawCreateImage(pImage, cbSize, uImageFlags, pszComment, 445 pPCHSGeometry, pLCHSGeometry, uOpenFlags, 446 pIfProgress, uPercentStart, uPercentSpan); 447 if (RT_SUCCESS(rc)) 448 { 449 /* So far the image is opened in read/write mode. Make sure the 450 * image is opened in read-only mode if the caller requested that. */ 451 if (uOpenFlags & VD_OPEN_FLAGS_READONLY) 452 { 453 rawFreeImage(pImage, false); 454 rc = rawOpenImage(pImage, uOpenFlags); 455 } 456 457 if (RT_SUCCESS(rc)) 458 *ppBackendData = pImage; 459 } 460 461 if (RT_FAILURE(rc)) 462 RTMemFree(pImage); 463 } 464 else 500 465 rc = VERR_NO_MEMORY; 501 goto out; 502 } 503 pImage->pszFilename = pszFilename; 504 pImage->pStorage = NULL; 505 pImage->pVDIfsDisk = pVDIfsDisk; 506 pImage->pVDIfsImage = pVDIfsImage; 507 508 rc = rawCreateImage(pImage, cbSize, uImageFlags, pszComment, 509 pPCHSGeometry, pLCHSGeometry, uOpenFlags, 510 pfnProgress, pvUser, uPercentStart, uPercentSpan); 466 467 LogFlowFunc(("returns %Rrc (pBackendData=%#p)\n", rc, *ppBackendData)); 468 return rc; 469 } 470 471 /** @copydoc VDIMAGEBACKEND::pfnRename */ 472 static DECLCALLBACK(int) rawRename(void *pBackendData, const char *pszFilename) 473 { 474 LogFlowFunc(("pBackendData=%#p pszFilename=%#p\n", pBackendData, pszFilename)); 475 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 476 477 AssertReturn((pImage && pszFilename && *pszFilename), VERR_INVALID_PARAMETER); 478 479 /* Close the image. */ 480 int rc = rawFreeImage(pImage, false); 511 481 if (RT_SUCCESS(rc)) 512 482 { 513 /* So far the image is opened in read/write mode. Make sure the514 * image is opened in read-only mode if the caller requested that. */515 if ( uOpenFlags & VD_OPEN_FLAGS_READONLY)483 /* Rename the file. */ 484 rc = vdIfIoIntFileMove(pImage->pIfIo, pImage->pszFilename, pszFilename, 0); 485 if (RT_SUCCESS(rc)) 516 486 { 517 rawFreeImage(pImage, false); 518 rc = rawOpenImage(pImage, uOpenFlags); 519 if (RT_FAILURE(rc)) 520 { 521 RTMemFree(pImage); 522 goto out; 523 } 487 /* Update pImage with the new information. */ 488 pImage->pszFilename = pszFilename; 489 490 /* Open the old image with new name. */ 491 rc = rawOpenImage(pImage, pImage->uOpenFlags); 524 492 } 525 *ppBackendData = pImage; 526 } 527 else 528 RTMemFree(pImage); 529 530 out: 531 LogFlowFunc(("returns %Rrc (pBackendData=%#p)\n", rc, *ppBackendData)); 532 return rc; 533 } 534 535 /** @copydoc VBOXHDDBACKEND::pfnRename */ 536 static DECLCALLBACK(int) rawRename(void *pBackendData, const char *pszFilename) 537 { 538 LogFlowFunc(("pBackendData=%#p pszFilename=%#p\n", pBackendData, pszFilename)); 539 int rc = VINF_SUCCESS; 540 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 541 542 /* Check arguments. */ 543 if ( !pImage 544 || !pszFilename 545 || !*pszFilename) 546 { 547 rc = VERR_INVALID_PARAMETER; 548 goto out; 549 } 550 551 /* Close the image. */ 552 rc = rawFreeImage(pImage, false); 553 if (RT_FAILURE(rc)) 554 goto out; 555 556 /* Rename the file. */ 557 rc = vdIfIoIntFileMove(pImage->pIfIo, pImage->pszFilename, pszFilename, 0); 558 if (RT_FAILURE(rc)) 559 { 560 /* The move failed, try to reopen the original image. */ 561 int rc2 = rawOpenImage(pImage, pImage->uOpenFlags); 562 if (RT_FAILURE(rc2)) 563 rc = rc2; 564 565 goto out; 566 } 567 568 /* Update pImage with the new information. */ 569 pImage->pszFilename = pszFilename; 570 571 /* Open the old image with new name. */ 572 rc = rawOpenImage(pImage, pImage->uOpenFlags); 573 if (RT_FAILURE(rc)) 574 goto out; 575 576 out: 577 LogFlowFunc(("returns %Rrc\n", rc)); 578 return rc; 579 } 580 581 /** @copydoc VBOXHDDBACKEND::pfnClose */ 493 else 494 { 495 /* The move failed, try to reopen the original image. */ 496 int rc2 = rawOpenImage(pImage, pImage->uOpenFlags); 497 if (RT_FAILURE(rc2)) 498 rc = rc2; 499 } 500 } 501 502 LogFlowFunc(("returns %Rrc\n", rc)); 503 return rc; 504 } 505 506 /** @copydoc VDIMAGEBACKEND::pfnClose */ 582 507 static DECLCALLBACK(int) rawClose(void *pBackendData, bool fDelete) 583 508 { 584 509 LogFlowFunc(("pBackendData=%#p fDelete=%d\n", pBackendData, fDelete)); 585 510 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 586 int rc; 587 588 rc = rawFreeImage(pImage, fDelete); 511 int rc = rawFreeImage(pImage, fDelete); 589 512 RTMemFree(pImage); 590 513 … … 593 516 } 594 517 595 /** @copydoc V BOXHDDBACKEND::pfnRead */518 /** @copydoc VDIMAGEBACKEND::pfnRead */ 596 519 static DECLCALLBACK(int) rawRead(void *pBackendData, uint64_t uOffset, size_t cbRead, 597 520 PVDIOCTX pIoCtx, size_t *pcbActuallyRead) … … 619 542 } 620 543 621 /** @copydoc V BOXHDDBACKEND::pfnWrite */544 /** @copydoc VDIMAGEBACKEND::pfnWrite */ 622 545 static DECLCALLBACK(int) rawWrite(void *pBackendData, uint64_t uOffset, size_t cbWrite, 623 546 PVDIOCTX pIoCtx, size_t *pcbWriteProcess, size_t *pcbPreRead, … … 651 574 } 652 575 653 /** @copydoc V BOXHDDBACKEND::pfnFlush */576 /** @copydoc VDIMAGEBACKEND::pfnFlush */ 654 577 static DECLCALLBACK(int) rawFlush(void *pBackendData, PVDIOCTX pIoCtx) 655 578 { … … 664 587 } 665 588 666 /** @copydoc V BOXHDDBACKEND::pfnGetVersion */589 /** @copydoc VDIMAGEBACKEND::pfnGetVersion */ 667 590 static DECLCALLBACK(unsigned) rawGetVersion(void *pBackendData) 668 591 { … … 670 593 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 671 594 672 AssertPtr(pImage); 673 674 if (pImage) 675 return 1; 676 else 677 return 0; 678 } 679 680 /** @copydoc VBOXHDDBACKEND::pfnGetSize */ 595 AssertPtrReturn(pImage, 0); 596 597 return 1; 598 } 599 600 /** @copydoc VDIMAGEBACKEND::pfnGetSize */ 681 601 static DECLCALLBACK(uint32_t) rawGetSectorSize(void *pBackendData) 682 602 { … … 685 605 uint32_t cb = 0; 686 606 687 AssertPtr (pImage);688 689 if (pImage && pImage->pStorage)607 AssertPtrReturn(pImage, 0); 608 609 if (pImage->pStorage) 690 610 cb = pImage->cbSector; 691 611 … … 694 614 } 695 615 696 /** @copydoc V BOXHDDBACKEND::pfnGetSize */616 /** @copydoc VDIMAGEBACKEND::pfnGetSize */ 697 617 static DECLCALLBACK(uint64_t) rawGetSize(void *pBackendData) 698 618 { … … 701 621 uint64_t cb = 0; 702 622 703 AssertPtr (pImage);704 705 if (pImage && pImage->pStorage)623 AssertPtrReturn(pImage, 0); 624 625 if (pImage->pStorage) 706 626 cb = pImage->cbSize; 707 627 … … 710 630 } 711 631 712 /** @copydoc V BOXHDDBACKEND::pfnGetFileSize */632 /** @copydoc VDIMAGEBACKEND::pfnGetFileSize */ 713 633 static DECLCALLBACK(uint64_t) rawGetFileSize(void *pBackendData) 714 634 { 715 635 LogFlowFunc(("pBackendData=%#p\n", pBackendData)); 716 636 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 717 uint64_t cb = 0; 718 719 AssertPtr(pImage); 720 721 if (pImage) 722 { 723 uint64_t cbFile; 724 if (pImage->pStorage) 725 { 726 int rc = vdIfIoIntFileGetSize(pImage->pIfIo, pImage->pStorage, &cbFile); 727 if (RT_SUCCESS(rc)) 728 cb += cbFile; 729 } 730 } 731 732 LogFlowFunc(("returns %lld\n", cb)); 733 return cb; 734 } 735 736 /** @copydoc VBOXHDDBACKEND::pfnGetPCHSGeometry */ 637 638 AssertPtrReturn(pImage, 0); 639 640 uint64_t cbFile = 0; 641 if (pImage->pStorage) 642 { 643 int rc = vdIfIoIntFileGetSize(pImage->pIfIo, pImage->pStorage, &cbFile); 644 if (RT_FAILURE(rc)) 645 cbFile = 0; /* Make sure it is 0 */ 646 } 647 648 LogFlowFunc(("returns %lld\n", cbFile)); 649 return cbFile; 650 } 651 652 /** @copydoc VDIMAGEBACKEND::pfnGetPCHSGeometry */ 737 653 static DECLCALLBACK(int) rawGetPCHSGeometry(void *pBackendData, 738 654 PVDGEOMETRY pPCHSGeometry) … … 740 656 LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p\n", pBackendData, pPCHSGeometry)); 741 657 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 742 int rc; 743 744 AssertPtr(pImage); 745 746 if (pImage) 747 { 748 if (pImage->PCHSGeometry.cCylinders) 749 { 750 *pPCHSGeometry = pImage->PCHSGeometry; 751 rc = VINF_SUCCESS; 752 } 753 else 754 rc = VERR_VD_GEOMETRY_NOT_SET; 755 } 756 else 757 rc = VERR_VD_NOT_OPENED; 658 int rc = VINF_SUCCESS; 659 660 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 661 662 if (pImage->PCHSGeometry.cCylinders) 663 *pPCHSGeometry = pImage->PCHSGeometry; 664 else 665 rc = VERR_VD_GEOMETRY_NOT_SET; 758 666 759 667 LogFlowFunc(("returns %Rrc (PCHS=%u/%u/%u)\n", rc, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors)); … … 761 669 } 762 670 763 /** @copydoc V BOXHDDBACKEND::pfnSetPCHSGeometry */671 /** @copydoc VDIMAGEBACKEND::pfnSetPCHSGeometry */ 764 672 static DECLCALLBACK(int) rawSetPCHSGeometry(void *pBackendData, 765 673 PCVDGEOMETRY pPCHSGeometry) 766 674 { 767 LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p PCHS=%u/%u/%u\n", pBackendData, pPCHSGeometry, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors)); 768 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 769 int rc; 770 771 AssertPtr(pImage); 772 773 if (pImage) 774 { 775 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 776 { 777 rc = VERR_VD_IMAGE_READ_ONLY; 778 goto out; 779 } 780 675 LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p PCHS=%u/%u/%u\n", 676 pBackendData, pPCHSGeometry, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors)); 677 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 678 int rc = VINF_SUCCESS; 679 680 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 681 682 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 683 rc = VERR_VD_IMAGE_READ_ONLY; 684 else 781 685 pImage->PCHSGeometry = *pPCHSGeometry; 782 rc = VINF_SUCCESS; 783 } 784 else 785 rc = VERR_VD_NOT_OPENED; 786 787 out: 788 LogFlowFunc(("returns %Rrc\n", rc)); 789 return rc; 790 } 791 792 /** @copydoc VBOXHDDBACKEND::pfnGetLCHSGeometry */ 686 687 LogFlowFunc(("returns %Rrc\n", rc)); 688 return rc; 689 } 690 691 /** @copydoc VDIMAGEBACKEND::pfnGetLCHSGeometry */ 793 692 static DECLCALLBACK(int) rawGetLCHSGeometry(void *pBackendData, 794 693 PVDGEOMETRY pLCHSGeometry) … … 796 695 LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p\n", pBackendData, pLCHSGeometry)); 797 696 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 798 int rc; 799 800 AssertPtr(pImage); 801 802 if (pImage) 803 { 804 if (pImage->LCHSGeometry.cCylinders) 805 { 806 *pLCHSGeometry = pImage->LCHSGeometry; 807 rc = VINF_SUCCESS; 808 } 809 else 810 rc = VERR_VD_GEOMETRY_NOT_SET; 811 } 812 else 813 rc = VERR_VD_NOT_OPENED; 697 int rc = VINF_SUCCESS; 698 699 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 700 701 if (pImage->LCHSGeometry.cCylinders) 702 *pLCHSGeometry = pImage->LCHSGeometry; 703 else 704 rc = VERR_VD_GEOMETRY_NOT_SET; 814 705 815 706 LogFlowFunc(("returns %Rrc (LCHS=%u/%u/%u)\n", rc, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors)); … … 817 708 } 818 709 819 /** @copydoc V BOXHDDBACKEND::pfnSetLCHSGeometry */710 /** @copydoc VDIMAGEBACKEND::pfnSetLCHSGeometry */ 820 711 static DECLCALLBACK(int) rawSetLCHSGeometry(void *pBackendData, 821 712 PCVDGEOMETRY pLCHSGeometry) 822 713 { 823 LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p LCHS=%u/%u/%u\n", pBackendData, pLCHSGeometry, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors)); 824 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 825 int rc; 826 827 AssertPtr(pImage); 828 829 if (pImage) 830 { 831 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 832 { 833 rc = VERR_VD_IMAGE_READ_ONLY; 834 goto out; 835 } 836 714 LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p LCHS=%u/%u/%u\n", 715 pBackendData, pLCHSGeometry, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors)); 716 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 717 int rc = VINF_SUCCESS; 718 719 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 720 721 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 722 rc = VERR_VD_IMAGE_READ_ONLY; 723 else 837 724 pImage->LCHSGeometry = *pLCHSGeometry; 838 rc = VINF_SUCCESS; 839 } 840 else 841 rc = VERR_VD_NOT_OPENED; 842 843 out: 844 LogFlowFunc(("returns %Rrc\n", rc)); 845 return rc; 846 } 847 848 /** @copydoc VBOXHDDBACKEND::pfnGetImageFlags */ 725 726 LogFlowFunc(("returns %Rrc\n", rc)); 727 return rc; 728 } 729 730 /** @copydoc VDIMAGEBACKEND::pfnGetImageFlags */ 849 731 static DECLCALLBACK(unsigned) rawGetImageFlags(void *pBackendData) 850 732 { 851 733 LogFlowFunc(("pBackendData=%#p\n", pBackendData)); 852 734 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 853 unsigned uImageFlags; 854 855 AssertPtr(pImage); 856 857 if (pImage) 858 uImageFlags = pImage->uImageFlags; 859 else 860 uImageFlags = 0; 861 862 LogFlowFunc(("returns %#x\n", uImageFlags)); 863 return uImageFlags; 864 } 865 866 /** @copydoc VBOXHDDBACKEND::pfnGetOpenFlags */ 735 736 AssertPtrReturn(pImage, 0); 737 738 LogFlowFunc(("returns %#x\n", pImage->uImageFlags)); 739 return pImage->uImageFlags; 740 } 741 742 /** @copydoc VDIMAGEBACKEND::pfnGetOpenFlags */ 867 743 static DECLCALLBACK(unsigned) rawGetOpenFlags(void *pBackendData) 868 744 { 869 745 LogFlowFunc(("pBackendData=%#p\n", pBackendData)); 870 746 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 871 unsigned uOpenFlags; 872 873 AssertPtr(pImage); 874 875 if (pImage) 876 uOpenFlags = pImage->uOpenFlags; 877 else 878 uOpenFlags = 0; 879 880 LogFlowFunc(("returns %#x\n", uOpenFlags)); 881 return uOpenFlags; 882 } 883 884 /** @copydoc VBOXHDDBACKEND::pfnSetOpenFlags */ 747 748 AssertPtrReturn(pImage, 0); 749 750 LogFlowFunc(("returns %#x\n", pImage->uOpenFlags)); 751 return pImage->uOpenFlags; 752 } 753 754 /** @copydoc VDIMAGEBACKEND::pfnSetOpenFlags */ 885 755 static DECLCALLBACK(int) rawSetOpenFlags(void *pBackendData, unsigned uOpenFlags) 886 756 { 887 757 LogFlowFunc(("pBackendData=%#p\n uOpenFlags=%#x", pBackendData, uOpenFlags)); 888 758 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 889 int rc ;759 int rc = VINF_SUCCESS; 890 760 891 761 /* Image must be opened and the new flags must be valid. */ … … 893 763 | VD_OPEN_FLAGS_ASYNC_IO | VD_OPEN_FLAGS_SHAREABLE 894 764 | VD_OPEN_FLAGS_SEQUENTIAL | VD_OPEN_FLAGS_SKIP_CONSISTENCY_CHECKS))) 895 {896 765 rc = VERR_INVALID_PARAMETER; 897 goto out; 898 } 899 900 /* Implement this operation via reopening the image. */ 901 rc = rawFreeImage(pImage, false); 902 if (RT_FAILURE(rc)) 903 goto out; 904 rc = rawOpenImage(pImage, uOpenFlags); 905 906 out: 907 LogFlowFunc(("returns %Rrc\n", rc)); 908 return rc; 909 } 910 911 /** @copydoc VBOXHDDBACKEND::pfnGetComment */ 766 else 767 { 768 /* Implement this operation via reopening the image. */ 769 rc = rawFreeImage(pImage, false); 770 if (RT_SUCCESS(rc)) 771 rc = rawOpenImage(pImage, uOpenFlags); 772 } 773 774 LogFlowFunc(("returns %Rrc\n", rc)); 775 return rc; 776 } 777 778 /** @copydoc VDIMAGEBACKEND::pfnGetComment */ 912 779 static DECLCALLBACK(int) rawGetComment(void *pBackendData, char *pszComment, 913 780 size_t cbComment) … … 916 783 LogFlowFunc(("pBackendData=%#p pszComment=%#p cbComment=%zu\n", pBackendData, pszComment, cbComment)); 917 784 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 918 int rc; 919 920 AssertPtr(pImage); 921 922 if (pImage) 923 rc = VERR_NOT_SUPPORTED; 924 else 925 rc = VERR_VD_NOT_OPENED; 926 927 LogFlowFunc(("returns %Rrc comment='%s'\n", rc, pszComment)); 928 return rc; 929 } 930 931 /** @copydoc VBOXHDDBACKEND::pfnSetComment */ 785 786 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 787 788 LogFlowFunc(("returns %Rrc comment='%s'\n", VERR_NOT_SUPPORTED, pszComment)); 789 return VERR_NOT_SUPPORTED; 790 } 791 792 /** @copydoc VDIMAGEBACKEND::pfnSetComment */ 932 793 static DECLCALLBACK(int) rawSetComment(void *pBackendData, const char *pszComment) 933 794 { … … 935 796 LogFlowFunc(("pBackendData=%#p pszComment=\"%s\"\n", pBackendData, pszComment)); 936 797 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 798 799 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 800 937 801 int rc; 938 939 AssertPtr(pImage); 940 941 if (pImage) 942 { 943 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 944 rc = VERR_VD_IMAGE_READ_ONLY; 945 else 946 rc = VERR_NOT_SUPPORTED; 947 } 948 else 949 rc = VERR_VD_NOT_OPENED; 950 951 LogFlowFunc(("returns %Rrc\n", rc)); 952 return rc; 953 } 954 955 /** @copydoc VBOXHDDBACKEND::pfnGetUuid */ 802 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 803 rc = VERR_VD_IMAGE_READ_ONLY; 804 else 805 rc = VERR_NOT_SUPPORTED; 806 807 LogFlowFunc(("returns %Rrc\n", rc)); 808 return rc; 809 } 810 811 /** @copydoc VDIMAGEBACKEND::pfnGetUuid */ 956 812 static DECLCALLBACK(int) rawGetUuid(void *pBackendData, PRTUUID pUuid) 957 813 { … … 959 815 LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid)); 960 816 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 961 int rc; 962 963 AssertPtr(pImage); 964 965 if (pImage) 966 rc = VERR_NOT_SUPPORTED; 967 else 968 rc = VERR_VD_NOT_OPENED; 969 970 LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid)); 971 return rc; 972 } 973 974 /** @copydoc VBOXHDDBACKEND::pfnSetUuid */ 817 818 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 819 820 LogFlowFunc(("returns %Rrc (%RTuuid)\n", VERR_NOT_SUPPORTED, pUuid)); 821 return VERR_NOT_SUPPORTED; 822 } 823 824 /** @copydoc VDIMAGEBACKEND::pfnSetUuid */ 975 825 static DECLCALLBACK(int) rawSetUuid(void *pBackendData, PCRTUUID pUuid) 976 826 { … … 978 828 LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid)); 979 829 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 830 831 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 832 980 833 int rc; 981 982 LogFlowFunc(("%RTuuid\n", pUuid)); 983 AssertPtr(pImage); 984 985 if (pImage) 986 { 987 if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)) 988 rc = VERR_NOT_SUPPORTED; 989 else 990 rc = VERR_VD_IMAGE_READ_ONLY; 991 } 992 else 993 rc = VERR_VD_NOT_OPENED; 994 995 LogFlowFunc(("returns %Rrc\n", rc)); 996 return rc; 997 } 998 999 /** @copydoc VBOXHDDBACKEND::pfnGetModificationUuid */ 834 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 835 rc = VERR_VD_IMAGE_READ_ONLY; 836 else 837 rc = VERR_NOT_SUPPORTED; 838 839 LogFlowFunc(("returns %Rrc\n", rc)); 840 return rc; 841 } 842 843 /** @copydoc VDIMAGEBACKEND::pfnGetModificationUuid */ 1000 844 static DECLCALLBACK(int) rawGetModificationUuid(void *pBackendData, PRTUUID pUuid) 1001 845 { … … 1003 847 LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid)); 1004 848 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 1005 int rc; 1006 1007 AssertPtr(pImage); 1008 1009 if (pImage) 1010 rc = VERR_NOT_SUPPORTED; 1011 else 1012 rc = VERR_VD_NOT_OPENED; 1013 1014 LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid)); 1015 return rc; 1016 } 1017 1018 /** @copydoc VBOXHDDBACKEND::pfnSetModificationUuid */ 849 850 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 851 852 LogFlowFunc(("returns %Rrc (%RTuuid)\n", VERR_NOT_SUPPORTED, pUuid)); 853 return VERR_NOT_SUPPORTED; 854 } 855 856 /** @copydoc VDIMAGEBACKEND::pfnSetModificationUuid */ 1019 857 static DECLCALLBACK(int) rawSetModificationUuid(void *pBackendData, PCRTUUID pUuid) 1020 858 { … … 1022 860 LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid)); 1023 861 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 862 863 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 864 1024 865 int rc; 1025 1026 AssertPtr(pImage); 1027 1028 if (pImage) 1029 { 1030 if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)) 1031 rc = VERR_NOT_SUPPORTED; 1032 else 1033 rc = VERR_VD_IMAGE_READ_ONLY; 1034 } 1035 else 1036 rc = VERR_VD_NOT_OPENED; 1037 1038 LogFlowFunc(("returns %Rrc\n", rc)); 1039 return rc; 1040 } 1041 1042 /** @copydoc VBOXHDDBACKEND::pfnGetParentUuid */ 866 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 867 rc = VERR_VD_IMAGE_READ_ONLY; 868 else 869 rc = VERR_NOT_SUPPORTED; 870 871 LogFlowFunc(("returns %Rrc\n", rc)); 872 return rc; 873 } 874 875 /** @copydoc VDIMAGEBACKEND::pfnGetParentUuid */ 1043 876 static DECLCALLBACK(int) rawGetParentUuid(void *pBackendData, PRTUUID pUuid) 1044 877 { … … 1046 879 LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid)); 1047 880 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 1048 int rc; 1049 1050 AssertPtr(pImage); 1051 1052 if (pImage) 1053 rc = VERR_NOT_SUPPORTED; 1054 else 1055 rc = VERR_VD_NOT_OPENED; 1056 1057 LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid)); 1058 return rc; 1059 } 1060 1061 /** @copydoc VBOXHDDBACKEND::pfnSetParentUuid */ 881 882 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 883 884 LogFlowFunc(("returns %Rrc (%RTuuid)\n", VERR_NOT_SUPPORTED, pUuid)); 885 return VERR_NOT_SUPPORTED; 886 } 887 888 /** @copydoc VDIMAGEBACKEND::pfnSetParentUuid */ 1062 889 static DECLCALLBACK(int) rawSetParentUuid(void *pBackendData, PCRTUUID pUuid) 1063 890 { … … 1065 892 LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid)); 1066 893 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 894 895 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 896 1067 897 int rc; 1068 1069 AssertPtr(pImage); 1070 1071 if (pImage) 1072 { 1073 if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)) 1074 rc = VERR_NOT_SUPPORTED; 1075 else 1076 rc = VERR_VD_IMAGE_READ_ONLY; 1077 } 1078 else 1079 rc = VERR_VD_NOT_OPENED; 1080 1081 LogFlowFunc(("returns %Rrc\n", rc)); 1082 return rc; 1083 } 1084 1085 /** @copydoc VBOXHDDBACKEND::pfnGetParentModificationUuid */ 898 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 899 rc = VERR_VD_IMAGE_READ_ONLY; 900 else 901 rc = VERR_NOT_SUPPORTED; 902 903 LogFlowFunc(("returns %Rrc\n", rc)); 904 return rc; 905 } 906 907 /** @copydoc VDIMAGEBACKEND::pfnGetParentModificationUuid */ 1086 908 static DECLCALLBACK(int) rawGetParentModificationUuid(void *pBackendData, PRTUUID pUuid) 1087 909 { … … 1089 911 LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid)); 1090 912 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 913 914 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 915 1091 916 int rc; 1092 1093 AssertPtr(pImage); 1094 1095 if (pImage) 917 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 918 rc = VERR_VD_IMAGE_READ_ONLY; 919 else 1096 920 rc = VERR_NOT_SUPPORTED; 1097 else1098 rc = VERR_VD_NOT_OPENED;1099 921 1100 922 LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid)); … … 1102 924 } 1103 925 1104 /** @copydoc V BOXHDDBACKEND::pfnSetParentModificationUuid */926 /** @copydoc VDIMAGEBACKEND::pfnSetParentModificationUuid */ 1105 927 static DECLCALLBACK(int) rawSetParentModificationUuid(void *pBackendData, PCRTUUID pUuid) 1106 928 { … … 1108 930 LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid)); 1109 931 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 932 933 AssertPtrReturn(pImage, VERR_VD_NOT_OPENED); 934 1110 935 int rc; 1111 1112 AssertPtr(pImage); 1113 1114 if (pImage) 1115 { 1116 if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)) 1117 rc = VERR_NOT_SUPPORTED; 1118 else 1119 rc = VERR_VD_IMAGE_READ_ONLY; 1120 } 1121 else 1122 rc = VERR_VD_NOT_OPENED; 1123 1124 LogFlowFunc(("returns %Rrc\n", rc)); 1125 return rc; 1126 } 1127 1128 /** @copydoc VBOXHDDBACKEND::pfnDump */ 936 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 937 rc = VERR_VD_IMAGE_READ_ONLY; 938 else 939 rc = VERR_NOT_SUPPORTED; 940 941 LogFlowFunc(("returns %Rrc\n", rc)); 942 return rc; 943 } 944 945 /** @copydoc VDIMAGEBACKEND::pfnDump */ 1129 946 static DECLCALLBACK(void) rawDump(void *pBackendData) 1130 947 { 1131 948 PRAWIMAGE pImage = (PRAWIMAGE)pBackendData; 1132 949 1133 AssertPtr(pImage); 1134 if (pImage) 1135 { 1136 vdIfErrorMessage(pImage->pIfError, "Header: Geometry PCHS=%u/%u/%u LCHS=%u/%u/%u cbSector=%llu\n", 1137 pImage->PCHSGeometry.cCylinders, pImage->PCHSGeometry.cHeads, pImage->PCHSGeometry.cSectors, 1138 pImage->LCHSGeometry.cCylinders, pImage->LCHSGeometry.cHeads, pImage->LCHSGeometry.cSectors, 1139 pImage->cbSize / 512); 1140 } 950 AssertPtrReturnVoid(pImage); 951 vdIfErrorMessage(pImage->pIfError, "Header: Geometry PCHS=%u/%u/%u LCHS=%u/%u/%u cbSector=%llu\n", 952 pImage->PCHSGeometry.cCylinders, pImage->PCHSGeometry.cHeads, pImage->PCHSGeometry.cSectors, 953 pImage->LCHSGeometry.cCylinders, pImage->LCHSGeometry.cHeads, pImage->LCHSGeometry.cSectors, 954 pImage->cbSize / 512); 1141 955 } 1142 956
Note:
See TracChangeset
for help on using the changeset viewer.