All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] windows: fix pread/pwrite
@ 2025-05-08 17:14 Vincent Fu
  2025-05-08 17:18 ` Jens Axboe
  2025-05-08 17:49 ` fio CI test result fiotestbot
  0 siblings, 2 replies; 8+ messages in thread
From: Vincent Fu @ 2025-05-08 17:14 UTC (permalink / raw)
  To: fio, axboe; +Cc: Vincent Fu

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 <vincent.fu@samsung.com>
---
 os/windows/posix.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

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;
 }
 
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-05-09  0:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-08 17:14 [PATCH] windows: fix pread/pwrite Vincent Fu
2025-05-08 17:18 ` Jens Axboe
2025-05-08 17:31   ` Vincent Fu
2025-05-08 17:35     ` Jens Axboe
2025-05-08 18:00       ` Vincent Fu
2025-05-08 21:28     ` Sitsofe Wheeler
2025-05-09  0:43       ` Vincent Fu
2025-05-08 17:49 ` fio CI test result fiotestbot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.