From 20ac27def64f92a5003e04e2d40d4f9647fc183c Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 25 Jun 2024 20:43:27 -0400 Subject: [PATCH] kernel/fs: Fix readv/writev after the seek-disabled refactor. This fixes a regression introduced in 34fcf3d9ead1371b57e46877071ced38235e789e. That commit correctly adjusted the "pos" checks at the top of these functions, but missed that there was a place in the loop where pos is incremented. After the first increment, we would have a non-zero pos, and so the new checks in the actual read/write routines would return an error, meaning that only the first iovec was ever processed. This fixes WINE following the aforementioned change. --- src/system/kernel/fs/fd.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/fs/fd.cpp b/src/system/kernel/fs/fd.cpp index 9ccb342aaa..f05c6ef528 100644 --- a/src/system/kernel/fs/fd.cpp +++ b/src/system/kernel/fs/fd.cpp @@ -814,7 +814,8 @@ common_user_vector_io(int fd, off_t pos, const iovec* userVecs, size_t count, else bytesTransferred += (ssize_t)length; - pos += length; + if (movePosition) + pos += length; if (length < vecs[i].iov_len) break; @@ -1089,7 +1090,8 @@ _kern_readv(int fd, off_t pos, const iovec* vecs, size_t count) else bytesRead += (ssize_t)length; - pos += vecs[i].iov_len; + if (movePosition) + pos += vecs[i].iov_len; } if (movePosition) @@ -1181,7 +1183,8 @@ _kern_writev(int fd, off_t pos, const iovec* vecs, size_t count) else bytesWritten += (ssize_t)length; - pos += vecs[i].iov_len; + if (movePosition) + pos += vecs[i].iov_len; } if (movePosition)