Changeset 69955 in vbox for trunk/src/VBox/Runtime/common/vfs
- Timestamp:
- Dec 6, 2017 12:26:37 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 119457
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp
r69942 r69955 81 81 Assert((a_pSetOps)->uVersion == RTVFSOBJSETOPS_VERSION); \ 82 82 Assert((a_pSetOps)->offObjOps == (a_offObjOps)); \ 83 AssertPtr ((a_pSetOps)->pfnSetMode); \84 AssertPtr ((a_pSetOps)->pfnSetTimes); \85 AssertPtr ((a_pSetOps)->pfnSetOwner); \83 AssertPtrNull((a_pSetOps)->pfnSetMode); \ 84 AssertPtrNull((a_pSetOps)->pfnSetTimes); \ 85 AssertPtrNull((a_pSetOps)->pfnSetOwner); \ 86 86 Assert((a_pSetOps)->uEndMarker == RTVFSOBJSETOPS_VERSION); \ 87 87 } while (0) … … 113 113 Assert(!((pIoStreamOps)->fFeatures & ~RTVFSIOSTREAMOPS_FEAT_VALID_MASK)); \ 114 114 AssertPtr((pIoStreamOps)->pfnRead); \ 115 AssertPtr ((pIoStreamOps)->pfnWrite); \115 AssertPtrNull((pIoStreamOps)->pfnWrite); \ 116 116 AssertPtr((pIoStreamOps)->pfnFlush); \ 117 117 AssertPtrNull((pIoStreamOps)->pfnPollOne); \ … … 126 126 do { \ 127 127 RTVFSOBJ_ASSERT_OPS(&(pSymlinkOps)->Obj, a_enmType); \ 128 RTVFSOBJSET_ASSERT_OPS(&(pSymlinkOps)->ObjSet, \ 129 RT_OFFSETOF(RTVFSSYMLINKOPS, Obj) - RT_OFFSETOF(RTVFSSYMLINKOPS, ObjSet)); \ 128 RTVFSOBJSET_ASSERT_OPS(&(pSymlinkOps)->ObjSet, RT_OFFSETOF(RTVFSSYMLINKOPS, Obj) - RT_OFFSETOF(RTVFSSYMLINKOPS, ObjSet)); \ 130 129 Assert((pSymlinkOps)->uVersion == RTVFSSYMLINKOPS_VERSION); \ 131 130 Assert(!(pSymlinkOps)->fReserved); \ … … 1317 1316 AssertReturn(pObjSetOps, VERR_INVALID_FUNCTION); 1318 1317 1319 RTVfsLockAcquireWrite(pThis->hLock); 1320 int rc = pObjSetOps->pfnSetMode(pThis->pvThis, fMode, fMask); 1321 RTVfsLockReleaseWrite(pThis->hLock); 1318 int rc; 1319 if (pObjSetOps->pfnSetMode) 1320 { 1321 RTVfsLockAcquireWrite(pThis->hLock); 1322 rc = pObjSetOps->pfnSetMode(pThis->pvThis, fMode, fMask); 1323 RTVfsLockReleaseWrite(pThis->hLock); 1324 } 1325 else 1326 rc = VERR_WRITE_PROTECT; 1322 1327 return rc; 1323 1328 } … … 1339 1344 AssertReturn(pObjSetOps, VERR_INVALID_FUNCTION); 1340 1345 1341 RTVfsLockAcquireWrite(pThis->hLock); 1342 int rc = pObjSetOps->pfnSetTimes(pThis->pvThis, pAccessTime, pModificationTime, pChangeTime, pBirthTime); 1343 RTVfsLockReleaseWrite(pThis->hLock); 1346 int rc; 1347 if (pObjSetOps->pfnSetTimes) 1348 { 1349 RTVfsLockAcquireWrite(pThis->hLock); 1350 rc = pObjSetOps->pfnSetTimes(pThis->pvThis, pAccessTime, pModificationTime, pChangeTime, pBirthTime); 1351 RTVfsLockReleaseWrite(pThis->hLock); 1352 } 1353 else 1354 rc = VERR_WRITE_PROTECT; 1344 1355 return rc; 1345 1356 } … … 1355 1366 AssertReturn(pObjSetOps, VERR_INVALID_FUNCTION); 1356 1367 1357 RTVfsLockAcquireWrite(pThis->hLock); 1358 int rc = pObjSetOps->pfnSetOwner(pThis->pvThis, uid, gid); 1359 RTVfsLockReleaseWrite(pThis->hLock); 1368 int rc; 1369 if (pObjSetOps->pfnSetOwner) 1370 { 1371 RTVfsLockAcquireWrite(pThis->hLock); 1372 rc = pObjSetOps->pfnSetOwner(pThis->pvThis, uid, gid); 1373 RTVfsLockReleaseWrite(pThis->hLock); 1374 } 1375 else 1376 rc = VERR_WRITE_PROTECT; 1360 1377 return rc; 1361 1378 } … … 3499 3516 AssertReturn(pThis->fFlags & RTFILE_O_WRITE, VERR_ACCESS_DENIED); 3500 3517 3501 RTSGSEG Seg = { (void *)pvBuf, cbToWrite }; 3502 RTSGBUF SgBuf; 3503 RTSgBufInit(&SgBuf, &Seg, 1); 3504 3505 RTVfsLockAcquireWrite(pThis->Base.hLock); 3506 int rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, -1 /*off*/, &SgBuf, fBlocking, pcbWritten); 3507 RTVfsLockReleaseWrite(pThis->Base.hLock); 3518 int rc; 3519 if (pThis->pOps->pfnWrite) 3520 { 3521 RTSGSEG Seg = { (void *)pvBuf, cbToWrite }; 3522 RTSGBUF SgBuf; 3523 RTSgBufInit(&SgBuf, &Seg, 1); 3524 3525 RTVfsLockAcquireWrite(pThis->Base.hLock); 3526 rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, -1 /*off*/, &SgBuf, fBlocking, pcbWritten); 3527 RTVfsLockReleaseWrite(pThis->Base.hLock); 3528 } 3529 else 3530 rc = VERR_WRITE_PROTECT; 3508 3531 return rc; 3509 3532 } … … 3522 3545 AssertReturn(pThis->fFlags & RTFILE_O_WRITE, VERR_ACCESS_DENIED); 3523 3546 3524 RTSGSEG Seg = { (void *)pvBuf, cbToWrite }; 3525 RTSGBUF SgBuf; 3526 RTSgBufInit(&SgBuf, &Seg, 1); 3527 3528 RTVfsLockAcquireWrite(pThis->Base.hLock); 3529 int rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, off, &SgBuf, fBlocking, pcbWritten); 3530 RTVfsLockReleaseWrite(pThis->Base.hLock); 3547 int rc; 3548 if (pThis->pOps->pfnWrite) 3549 { 3550 RTSGSEG Seg = { (void *)pvBuf, cbToWrite }; 3551 RTSGBUF SgBuf; 3552 RTSgBufInit(&SgBuf, &Seg, 1); 3553 3554 RTVfsLockAcquireWrite(pThis->Base.hLock); 3555 rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, off, &SgBuf, fBlocking, pcbWritten); 3556 RTVfsLockReleaseWrite(pThis->Base.hLock); 3557 } 3558 else 3559 rc = VERR_WRITE_PROTECT; 3531 3560 return rc; 3532 3561 } … … 3590 3619 AssertReturn(pThis->fFlags & RTFILE_O_WRITE, VERR_ACCESS_DENIED); 3591 3620 3592 RTVfsLockAcquireWrite(pThis->Base.hLock);3593 3621 int rc; 3594 if (!(pThis->pOps->fFeatures & RTVFSIOSTREAMOPS_FEAT_NO_SG)) 3595 rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, off, pSgBuf, fBlocking, pcbWritten); 3622 if (pThis->pOps->pfnWrite) 3623 { 3624 RTVfsLockAcquireWrite(pThis->Base.hLock); 3625 if (!(pThis->pOps->fFeatures & RTVFSIOSTREAMOPS_FEAT_NO_SG)) 3626 rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, off, pSgBuf, fBlocking, pcbWritten); 3627 else 3628 { 3629 size_t cbWritten = 0; 3630 rc = VINF_SUCCESS; 3631 3632 for (uint32_t iSeg = 0; iSeg < pSgBuf->cSegs; iSeg++) 3633 { 3634 RTSGBUF SgBuf; 3635 RTSgBufInit(&SgBuf, &pSgBuf->paSegs[iSeg], 1); 3636 3637 size_t cbWrittenSeg = 0; 3638 rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, off, &SgBuf, fBlocking, pcbWritten ? &cbWrittenSeg : NULL); 3639 if (RT_FAILURE(rc)) 3640 break; 3641 if (pcbWritten) 3642 { 3643 cbWritten += cbWrittenSeg; 3644 if (cbWrittenSeg != SgBuf.paSegs[0].cbSeg) 3645 break; 3646 if (off != -1) 3647 off += cbWrittenSeg; 3648 } 3649 else if (off != -1) 3650 off += pSgBuf->paSegs[iSeg].cbSeg; 3651 } 3652 3653 if (pcbWritten) 3654 *pcbWritten = cbWritten; 3655 } 3656 RTVfsLockReleaseWrite(pThis->Base.hLock); 3657 } 3596 3658 else 3597 { 3598 size_t cbWritten = 0; 3599 rc = VINF_SUCCESS; 3600 3601 for (uint32_t iSeg = 0; iSeg < pSgBuf->cSegs; iSeg++) 3602 { 3603 RTSGBUF SgBuf; 3604 RTSgBufInit(&SgBuf, &pSgBuf->paSegs[iSeg], 1); 3605 3606 size_t cbWrittenSeg = 0; 3607 rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, off, &SgBuf, fBlocking, pcbWritten ? &cbWrittenSeg : NULL); 3608 if (RT_FAILURE(rc)) 3609 break; 3610 if (pcbWritten) 3611 { 3612 cbWritten += cbWrittenSeg; 3613 if (cbWrittenSeg != SgBuf.paSegs[0].cbSeg) 3614 break; 3615 if (off != -1) 3616 off += cbWrittenSeg; 3617 } 3618 else if (off != -1) 3619 off += pSgBuf->paSegs[iSeg].cbSeg; 3620 } 3621 3622 if (pcbWritten) 3623 *pcbWritten = cbWritten; 3624 } 3625 RTVfsLockReleaseWrite(pThis->Base.hLock); 3659 rc = VERR_WRITE_PROTECT; 3626 3660 return rc; 3627 3661 }
Note:
See TracChangeset
for help on using the changeset viewer.