Changeset 67188 in vbox for trunk/src/VBox/Runtime/common/checksum
- Timestamp:
- Jun 1, 2017 7:40:58 AM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 115865
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/checksum/manifest3.cpp
r62477 r67188 43 43 #include <iprt/vfs.h> 44 44 #include <iprt/vfslowlevel.h> 45 #include <iprt/zero.h> 45 46 46 47 … … 411 412 { 412 413 PRTMANIFESTPTIOS pThis = (PRTMANIFESTPTIOS)pvThis; 413 AssertReturn(off == -1 || off == pThis->offCurPos, VERR_WRONG_ORDER);414 414 Assert(RTVfsIoStrmTell(pThis->hVfsIos) == pThis->offCurPos); 415 415 416 /* 417 * Validate the offset. 418 */ 419 if (off < 0 || off == pThis->offCurPos) 420 { /* likely */ } 421 else 422 { 423 /* We cannot go back and rewrite stuff. Sorry. */ 424 AssertReturn(off > pThis->offCurPos, VERR_WRONG_ORDER); 425 426 /* 427 * We've got a gap between the current and new position. 428 * Fill it with zeros and hope for the best. 429 */ 430 uint64_t cbZeroGap = off - pThis->offCurPos; 431 do 432 { 433 size_t cbToZero = cbZeroGap >= sizeof(g_abRTZero64K) ? sizeof(g_abRTZero64K) : (size_t)cbZeroGap; 434 size_t cbZeroed = 0; 435 int rc = RTVfsIoStrmWrite(pThis->hVfsIos, g_abRTZero64K, cbToZero, true /*fBlocking*/, &cbZeroed); 436 if (RT_FAILURE(rc)) 437 return rc; 438 pThis->offCurPos += cbZeroed; 439 rtManifestHashesUpdate(pThis->pHashes, g_abRTZero64K, cbZeroed); 440 cbZeroGap -= cbZeroed; 441 } while (cbZeroGap > 0); 442 Assert(off == pThis->offCurPos); 443 } 444 445 /* 446 * Do the writing. 447 */ 416 448 int rc = RTVfsIoStrmSgWrite(pThis->hVfsIos, -1 /*off*/, pSgBuf, fBlocking, pcbWritten); 417 449 if (RT_SUCCESS(rc))
Note:
See TracChangeset
for help on using the changeset viewer.