Changeset 100908 in vbox for trunk/src/VBox/Storage/VDIfVfs.cpp
- Timestamp:
- Aug 19, 2023 2:57:05 AM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/VDIfVfs.cpp
r98103 r100908 95 95 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnRead} 96 96 */ 97 static DECLCALLBACK(int) vdIfVfsIos_Read(void *pvThis, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead)97 static DECLCALLBACK(int) vdIfVfsIos_Read(void *pvThis, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead) 98 98 { 99 99 PVDIFVFSIOSFILE pThis = (PVDIFVFSIOSFILE)pvThis; 100 100 Assert(pSgBuf->cSegs == 1); NOREF(fBlocking); 101 101 Assert(off >= -1); 102 103 size_t cbSeg = 0; 104 void * const pvSeg = RTSgBufGetCurrentSegment(pSgBuf, ~(size_t)0, &cbSeg); 102 105 103 106 /* … … 108 111 int rc; 109 112 if (pThis->pVDIfsIo) 110 rc = vdIfIoFileReadSync(pThis->pVDIfsIo, pThis->pStorage, off, p SgBuf[0].pvSegCur, pSgBuf->paSegs[0].cbSeg, pcbRead);113 rc = vdIfIoFileReadSync(pThis->pVDIfsIo, pThis->pStorage, off, pvSeg, cbSeg, pcbRead); 111 114 else 112 115 { 113 rc = vdIfIoIntFileReadSync(pThis->pVDIfsIoInt, (PVDIOSTORAGE)pThis->pStorage, off, p SgBuf[0].pvSegCur, pSgBuf->paSegs[0].cbSeg);116 rc = vdIfIoIntFileReadSync(pThis->pVDIfsIoInt, (PVDIOSTORAGE)pThis->pStorage, off, pvSeg, cbSeg); 114 117 if (pcbRead) 115 *pcbRead = RT_SUCCESS(rc) ? pSgBuf->paSegs[0].cbSeg : 0;118 *pcbRead = RT_SUCCESS(rc) ? cbSeg : 0; 116 119 } 117 120 if (RT_SUCCESS(rc)) 118 121 { 119 size_t c bAdvance = pcbRead ? *pcbRead : pSgBuf->paSegs[0].cbSeg;122 size_t const cbAdvance = pcbRead ? *pcbRead : cbSeg; 120 123 pThis->offCurPos = off + cbAdvance; 124 RTSgBufAdvance(pSgBuf, cbAdvance); 121 125 if (pcbRead && !cbAdvance) 122 126 rc = VINF_EOF; … … 129 133 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnWrite} 130 134 */ 131 static DECLCALLBACK(int) vdIfVfsIos_Write(void *pvThis, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten)135 static DECLCALLBACK(int) vdIfVfsIos_Write(void *pvThis, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten) 132 136 { 133 137 PVDIFVFSIOSFILE pThis = (PVDIFVFSIOSFILE)pvThis; … … 135 139 Assert(off >= -1); 136 140 141 size_t cbSeg = 0; 142 void const * const pvSeg = RTSgBufGetCurrentSegment(pSgBuf, ~(size_t)0, &cbSeg); 143 137 144 /* 138 * This may end up being a little more complicated, esp. wrt VERR_EOF.145 * Do the writing. 139 146 */ 140 147 if (off == -1) … … 142 149 int rc; 143 150 if (pThis->pVDIfsIo) 144 rc = vdIfIoFileWriteSync(pThis->pVDIfsIo, pThis->pStorage, off, p SgBuf[0].pvSegCur, pSgBuf->paSegs[0].cbSeg, pcbWritten);151 rc = vdIfIoFileWriteSync(pThis->pVDIfsIo, pThis->pStorage, off, pvSeg, cbSeg, pcbWritten); 145 152 else 146 153 { 147 rc = vdIfIoIntFileWriteSync(pThis->pVDIfsIoInt, pThis->pStorage, off, p SgBuf[0].pvSegCur, pSgBuf->paSegs[0].cbSeg);154 rc = vdIfIoIntFileWriteSync(pThis->pVDIfsIoInt, pThis->pStorage, off, pvSeg, cbSeg); 148 155 if (pcbWritten) 149 *pcbWritten = RT_SUCCESS(rc) ? pSgBuf->paSegs[0].cbSeg : 0;156 *pcbWritten = RT_SUCCESS(rc) ? cbSeg : 0; 150 157 } 151 158 if (RT_SUCCESS(rc)) 152 pThis->offCurPos = off + (pcbWritten ? *pcbWritten : pSgBuf->paSegs[0].cbSeg); 159 { 160 size_t const cbAdvance = pcbWritten ? *pcbWritten : cbSeg; 161 pThis->offCurPos = off + cbAdvance; 162 RTSgBufAdvance(pSgBuf, cbAdvance); 163 } 153 164 return rc; 154 165 }
Note:
See TracChangeset
for help on using the changeset viewer.