This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 7d3130c9930 fs/aio: ignore aio_reqprio/aio_offset in aio_fsync()
7d3130c9930 is described below
commit 7d3130c993032aae7755022025a88bbd34793367
Author: yukangzhi <[email protected]>
AuthorDate: Tue Nov 10 11:39:55 2026 +0800
fs/aio: ignore aio_reqprio/aio_offset in aio_fsync()
POSIX says aio_fsync() ignores every aiocb member except aio_fildes and
aio_sigevent, but aio_error() checks aio_reqprio/aio_offset, which only
make sense for aio_read()/aio_write(). A caller that submits an fsync
with, for example, aio_reqprio = -1 and aio_offset = -1 gets EINVAL from
aio_error() instead of the real completion status.
Set aio_reqprio and aio_offset to 0 in aio_fsync() so aio_error()
reports the fsync status correctly. The existing aio_reqprio < 0 check
in aio_error() still makes LTP aio_error/3-1 (un-submitted aiocb with
aio_reqprio = -1) return EINVAL.
Note: aio_fsync() now overwrites the caller's aio_reqprio/aio_offset.
Signed-off-by: yukangzhi <[email protected]>
---
fs/aio/aio_fsync.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fs/aio/aio_fsync.c b/fs/aio/aio_fsync.c
index 766c7b08f76..a67cedc75cd 100644
--- a/fs/aio/aio_fsync.c
+++ b/fs/aio/aio_fsync.c
@@ -205,6 +205,16 @@ int aio_fsync(int op, FAR struct aiocb *aiocbp)
return ERROR;
}
+ /* aio_fsync() ignores every aiocb member except aio_fildes and
+ * aio_sigevent, so the caller may leave aio_reqprio/aio_offset with any
+ * value. Normalize them so that aio_error(), whose aio_reqprio/aio_offset
+ * checks are meant for aio_read()/aio_write(), reports the real fsync
+ * status instead of EINVAL.
+ */
+
+ aiocbp->aio_reqprio = 0;
+ aiocbp->aio_offset = 0;
+
/* The result -EINPROGRESS means that the transfer has not yet completed */
sigwork_init(&aiocbp->aio_sigwork);