Kaben123 opened a new pull request, #22575:
URL: https://github.com/apache/nuttx/pull/22575

   ## Summary
   
   POSIX says `aio_fsync()` ignores every aiocb member except `aio_fildes` and
   `aio_sigevent`. `aio_error()` however rejects `aio_reqprio < 0` and treats
   `aio_offset < 0` specially, checks that only make sense for
   `aio_read()`/`aio_write()`. A caller that submits an fsync with
   `aio_reqprio = -1` therefore gets `EINVAL` from `aio_error()` instead of the
   real completion status.
   
   `aio_fsync()` now sets `aio_reqprio` and `aio_offset` to 0 before queuing
   the request. The `aio_reqprio < 0` check in `aio_error()` is kept, so LTP
   `aio_error/3-1` (un-submitted aiocb with `aio_reqprio = -1`) still returns
   `EINVAL`.
   
   ## Impact
   
   Only `CONFIG_FS_AIO`. `aio_fsync()` now overwrites the caller's
   `aio_reqprio`/`aio_offset`, which POSIX says it ignores. No API or Kconfig
   change.
   
   ## Testing
   
   Host: Ubuntu 22.04.5 x86_64, GCC 13.1.0, arm-none-eabi-gcc 13.2.1. Base: 
apache/nuttx master 75b4dc85275, apache/nuttx-apps master 9a2c68962.
   
   `sim:nsh` + `CONFIG_FS_AIO=y` + `CONFIG_FS_TMPFS=y`, with a small test
   program: open a file on /tmp, set `aio_reqprio = -1`, `aio_offset = -1`,
   call `aio_fsync(O_SYNC, &cb)`, poll `aio_error()` until it is not
   `EINPROGRESS`.
   
   Before (master):
   ```
   AIOTEST aio_fsync ret=0 aio_error=22 (Unknown error 22) aio_return=0
   ```
   After:
   ```
   AIOTEST aio_fsync ret=0 aio_error=0 (Unknown error 0) aio_return=0
   ```
   
   `sim:nsh` builds with Make and CMake without warnings;
   `tools/checkpatch.sh -c -u -m -g` passes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to