Changeset 77632 in vbox for trunk/src/VBox
- Timestamp:
- Mar 10, 2019 1:33:52 PM (6 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r77545 r77632 816 816 generic/RTDirSetTimes-generic.cpp \ 817 817 generic/fileio-sg-generic.cpp \ 818 generic/fileio-sg-at-generic.cpp \ 818 819 generic/RTFileExists-generic.cpp \ 819 820 generic/RTFileSetAllocationSize-generic.cpp \ … … 955 956 r3/posix/fileio-at-posix.cpp \ 956 957 r3/posix/fileio-sg-posix.cpp \ 958 r3/posix/fileio-sg-at-posix.cpp \ 957 959 r3/posix/filelock-posix.cpp \ 958 960 r3/posix/fs-posix.cpp \ … … 1009 1011 generic/fileio-at-generic.cpp \ 1010 1012 generic/fileio-sg-generic.cpp \ 1013 generic/fileio-sg-at-generic.cpp \ 1011 1014 generic/RTFileMove-generic.cpp \ 1012 1015 generic/RTFileSetAllocationSize-generic.cpp \ … … 1142 1145 r3/posix/fileio-at-posix.cpp \ 1143 1146 r3/posix/fileio-sg-posix.cpp \ 1147 r3/posix/fileio-sg-at-posix.cpp \ 1144 1148 r3/posix/fs-posix.cpp \ 1145 1149 r3/posix/fs2-posix.cpp \ … … 1222 1226 r3/posix/fileio-at-posix.cpp \ 1223 1227 r3/posix/fileio-sg-posix.cpp \ 1228 r3/posix/fileio-sg-at-posix.cpp \ 1224 1229 r3/posix/filelock-posix.cpp \ 1225 1230 r3/posix/fs-posix.cpp \ … … 1302 1307 r3/posix/fileio-at-posix.cpp \ 1303 1308 r3/posix/fileio-sg-posix.cpp \ 1309 r3/posix/fileio-sg-at-posix.cpp \ 1304 1310 r3/posix/filelock-posix.cpp \ 1305 1311 r3/posix/fs-posix.cpp \ … … 1373 1379 r3/posix/fileio-at-posix.cpp \ 1374 1380 r3/posix/fileio-sg-posix.cpp \ 1381 r3/posix/fileio-sg-at-posix.cpp \ 1375 1382 r3/posix/filelock-posix.cpp \ 1376 1383 r3/posix/fs-posix.cpp \ … … 1429 1436 generic/fileio-at-generic.cpp \ 1430 1437 generic/fileio-sg-generic.cpp \ 1438 generic/fileio-sg-at-generic.cpp \ 1431 1439 generic/RTFileMove-generic.cpp \ 1432 1440 generic/RTFileSetAllocationSize-generic.cpp \ -
trunk/src/VBox/Runtime/generic/fileio-sg-generic.cpp
r77235 r77632 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - File I/O, RTFileSgRead At & RTFileSgWriteAt, generic.3 * IPRT - File I/O, RTFileSgRead & RTFileSgWrite, generic. 4 4 */ 5 5 … … 36 36 37 37 38 RTDECL(int) RTFileSgRead At(RTFILE hFile, RTFOFF off, PRTSGBUF pSgBuf, size_t cbToRead, size_t *pcbRead)38 RTDECL(int) RTFileSgRead(RTFILE hFile, PRTSGBUF pSgBuf, size_t cbToRead, size_t *pcbRead) 39 39 { 40 40 int rc = VINF_SUCCESS; … … 46 46 47 47 size_t cbThisRead = cbBuf; 48 rc = RTFileRead At(hFile, off, pvBuf, cbBuf, pcbRead ? &cbThisRead : NULL);48 rc = RTFileRead(hFile, pvBuf, cbBuf, pcbRead ? &cbThisRead : NULL); 49 49 if (RT_SUCCESS(rc)) 50 50 cbRead += cbThisRead; … … 59 59 60 60 cbToRead -= cbBuf; 61 off += cbBuf;62 61 } 63 62 … … 69 68 70 69 71 RTDECL(int) RTFileSgWrite At(RTFILE hFile, RTFOFF off, PRTSGBUF pSgBuf, size_t cbToWrite, size_t *pcbWritten)70 RTDECL(int) RTFileSgWrite(RTFILE hFile, PRTSGBUF pSgBuf, size_t cbToWrite, size_t *pcbWritten) 72 71 { 73 72 int rc = VINF_SUCCESS; … … 79 78 80 79 size_t cbThisWritten = cbBuf; 81 rc = RTFileWrite At(hFile, off, pvBuf, cbBuf, pcbWritten ? &cbThisWritten : NULL);80 rc = RTFileWrite(hFile, pvBuf, cbBuf, pcbWritten ? &cbThisWritten : NULL); 82 81 if (RT_SUCCESS(rc)) 83 82 cbWritten += cbThisWritten; … … 92 91 Assert(cbBuf == cbThisWritten); 93 92 cbToWrite -= cbBuf; 94 off += cbBuf;95 93 } 96 94 -
trunk/src/VBox/Runtime/r3/posix/fileio-sg-posix.cpp
r77244 r77632 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - File I/O, RTFileSgRead At & RTFileSgWriteAt, posixy.3 * IPRT - File I/O, RTFileSgRead & RTFileSgWrite, posixy. 4 4 */ 5 5 … … 29 29 * Header Files * 30 30 *********************************************************************************************************************************/ 31 /*32 * Determin whether we've got preadv and pwritev.33 */34 31 #include <iprt/cdefs.h> 35 #ifdef RT_OS_LINUX 36 /* Linux has these since glibc 2.10 and Linux 2.6.30: */ 37 # include <features.h> 38 # ifdef __GLIBC_PREREQ 39 # if __GLIBC_PREREQ(2,10) 40 # define HAVE_PREADV_AND_PWRITEV 1 41 #else 42 # endif 43 # endif 44 45 #elif defined(RT_OS_FREEBSD) 46 /* FreeBSD has these since 6.0: */ 47 # include <osreldate.h> 48 # ifdef __FreeBSD_version 49 # if __FreeBSD_version >= 600000 50 # define HAVE_PREADV_AND_PWRITEV 1 51 # endif 52 # endif 53 32 #include <errno.h> 33 #include <sys/types.h> 34 #include <sys/uio.h> 35 #include <unistd.h> 36 37 #include "internal/iprt.h" 38 #include <iprt/file.h> 39 40 #include <iprt/assert.h> 41 #include <iprt/err.h> 42 #include <iprt/log.h> 43 44 #ifndef UIO_MAXIOV 45 # error "UIO_MAXIOV is undefined" 54 46 #endif 55 56 #ifndef HAVE_PREADV_AND_PWRITEV57 58 # include "../../generic/fileio-sg-generic.cpp"59 60 #else /* HAVE_PREADV_AND_PWRITEV - rest of the file */61 62 # include <errno.h>63 # include <sys/types.h>64 # include <sys/uio.h>65 # include <unistd.h>66 67 # include "internal/iprt.h"68 # include <iprt/file.h>69 70 # include <iprt/assert.h>71 # include <iprt/err.h>72 # include <iprt/log.h>73 74 # ifndef UIO_MAXIOV75 # error "UIO_MAXIOV is undefined"76 # endif77 47 78 48 … … 82 52 83 53 84 RTDECL(int) RTFileSgRead At(RTFILE hFile, RTFOFF off, PRTSGBUF pSgBuf, size_t cbToRead, size_t *pcbRead)54 RTDECL(int) RTFileSgRead(RTFILE hFile, PRTSGBUF pSgBuf, size_t cbToRead, size_t *pcbRead) 85 55 { 86 56 /* … … 91 61 92 62 /* 93 * Special case: Zero read == seek.63 * Special case: Zero read == nop. 94 64 */ 95 65 if (cbToRead == 0) 96 return RTFileSeek(hFile, off, RTFILE_SEEK_BEGIN, NULL);66 return VINF_SUCCESS; 97 67 98 68 /* … … 109 79 { 110 80 size_t const cSegsLeft = pSgBuf->cSegs - pSgBuf->idxSeg; 111 ssize_t cbThisRead = preadv(RTFileToNative(hFile), (const struct iovec *)&pSgBuf->paSegs[pSgBuf->idxSeg],112 RT_MIN(cSegsLeft, UIO_MAXIOV), off);81 ssize_t cbThisRead = readv(RTFileToNative(hFile), (const struct iovec *)&pSgBuf->paSegs[pSgBuf->idxSeg], 82 RT_MIN(cSegsLeft, UIO_MAXIOV)); 113 83 if (cbThisRead >= 0) 114 84 { … … 134 104 if (cbThisRead == 0) 135 105 return VERR_EOF; 136 137 off += cbThisRead;138 106 } 139 107 else if (cbTotalRead > 0 && pcbRead) … … 156 124 void *pvSeg = RTSgBufGetCurrentSegment(pSgBuf, cbToRead, &cbSeg); 157 125 size_t cbThisRead = cbSeg; 158 rc = RTFileRead At(hFile, off, pvSeg, cbSeg, pcbRead ? &cbThisRead : NULL);126 rc = RTFileRead(hFile, pvSeg, cbSeg, pcbRead ? &cbThisRead : NULL); 159 127 if (RT_SUCCESS(rc)) 160 128 { … … 172 140 Assert(cbSeg == cbThisRead); 173 141 cbToRead -= cbSeg; 174 off += cbSeg;175 142 } 176 143 if (pcbRead) … … 180 147 181 148 182 RTDECL(int) RTFileSgWrite At(RTFILE hFile, RTFOFF off, PRTSGBUF pSgBuf, size_t cbToWrite, size_t *pcbWritten)149 RTDECL(int) RTFileSgWrite(RTFILE hFile, PRTSGBUF pSgBuf, size_t cbToWrite, size_t *pcbWritten) 183 150 { 184 151 /* … … 189 156 190 157 /* 191 * Special case: Zero write == seek.158 * Special case: Zero write == nop. 192 159 */ 193 160 if (cbToWrite == 0) 194 return RTFileSeek(hFile, off, RTFILE_SEEK_BEGIN, NULL);161 return VINF_SUCCESS; 195 162 196 163 /* … … 207 174 { 208 175 size_t const cSegsLeft = pSgBuf->cSegs - pSgBuf->idxSeg; 209 ssize_t cbThisWritten = pwritev(RTFileToNative(hFile), (const struct iovec *)&pSgBuf->paSegs[pSgBuf->idxSeg],210 RT_MIN(cSegsLeft, UIO_MAXIOV), off);176 ssize_t cbThisWritten = writev(RTFileToNative(hFile), (const struct iovec *)&pSgBuf->paSegs[pSgBuf->idxSeg], 177 RT_MIN(cSegsLeft, UIO_MAXIOV)); 211 178 if (cbThisWritten >= 0) 212 179 { … … 232 199 if (cbThisWritten == 0) 233 200 return VERR_TRY_AGAIN; 234 235 off += cbThisWritten;236 201 } 237 202 else if (cbTotalWritten > 0 && pcbWritten) … … 254 219 void *pvSeg = RTSgBufGetCurrentSegment(pSgBuf, cbToWrite, &cbSeg); 255 220 size_t cbThisWritten = cbSeg; 256 rc = RTFileWrite At(hFile, off, pvSeg, cbSeg, pcbWritten ? &cbThisWritten : NULL);221 rc = RTFileWrite(hFile, pvSeg, cbSeg, pcbWritten ? &cbThisWritten : NULL); 257 222 if (RT_SUCCESS(rc)) 258 223 { … … 270 235 Assert(cbSeg == cbThisWritten); 271 236 cbToWrite -= cbSeg; 272 off += cbSeg;273 237 } 274 238 if (pcbWritten) … … 277 241 } 278 242 279 #endif /* HAVE_PREADV_AND_PWRITEV */280
Note:
See TracChangeset
for help on using the changeset viewer.