From: Vincent Fu Date: Thu, 8 May 2025 17:02:57 +0000 (-0700) Subject: windows: fix pread/pwrite X-Git-Tag: fio-3.40~15 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=3a2b42b355fa206c794b2e3640a128ff9b59f118;p=fio.git windows: fix pread/pwrite The pread and pwrite functions for Windows posix emulation never actually seek to the requested offset. Fix this so that the psync ioengine works correctly on Windows. Signed-off-by: Vincent Fu --- diff --git a/os/windows/posix.c b/os/windows/posix.c index e3abf383..3e48c3ff 100644 --- a/os/windows/posix.c +++ b/os/windows/posix.c @@ -830,18 +830,24 @@ ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset) { int64_t pos = _telli64(fildes); - ssize_t len = _write(fildes, buf, nbyte); + ssize_t len; + _lseeki64(fildes, offset, SEEK_SET); + len = _write(fildes, buf, nbyte); _lseeki64(fildes, pos, SEEK_SET); + return len; } ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset) { int64_t pos = _telli64(fildes); - ssize_t len = read(fildes, buf, nbyte); + ssize_t len; + _lseeki64(fildes, offset, SEEK_SET); + len = read(fildes, buf, nbyte); _lseeki64(fildes, pos, SEEK_SET); + return len; }