Jackapyun opened a new pull request, #22388:
URL: https://github.com/apache/nuttx/pull/22388
## Summary
`O_RSYNC` is currently defined as an alias of `O_SYNC`, so it has neither a
value of its own that `open()` can store nor a bit that `fcntl()` can report
back. In particular `aio_fsync(O_RSYNC)` is indistinguishable from the
valid `aio_fsync(O_SYNC)` call, so the `EINVAL` that POSIX requires for an
operation that is neither `O_DSYNC` nor `O_SYNC` can never be produced.
This change gives `O_RSYNC` bit 23 (`_O_MAXBIT` is bumped accordingly). A
build with a 16-bit `int` has no spare bit, so there it keeps the `O_SYNC`
alias. `FRSYNC` is added to `FFCNTL` so that `F_SETFL` can still set the
flag (bits outside `FFCNTL` are ignored by `fcntl()`), and the sim hostfs
maps `O_RSYNC` to its own `O_RSYNC`, which equals its `O_SYNC`.
## Impact
* New or changed features: **YES** - `O_RSYNC` is no longer equal to
`O_SYNC` on platforms with a 32-bit `int`, so `open()` stores it and
`fcntl(F_GETFL)` reports it as a separate flag.
* Impact on users: **NO** - code that passes `O_RSYNC` to `open()` keeps
working; only code that relied on `O_RSYNC == O_SYNC` could notice.
* Build process changes: **NO**
* Hardware or driver impact: **NO**
* Documentation: **NO**
* Security: **NO**
* Compatibility: **NO** - the flag value is internal to NuttX; on a 16-bit
`int` build the previous alias is kept.
## Testing
I confirm that changes are verified on local setup and works as intended:
* Build Host(s): Ubuntu 22.04, x86_64, gcc 13.4.0
* Target(s): `sim:nsh` with `CONFIG_FS_AIO=y`
* Steps: build `sim:nsh`, run a small program from nsh that prints the flag
values, opens a file with `O_RSYNC` and checks `F_GETFL`, sets the flag
with `F_SETFL`, and calls `aio_fsync()` with `O_RSYNC`.
Testing logs before change (upstream master `d96cceb4462`):
```
O_RSYNC=0x101000 O_SYNC=0x101000 O_DSYNC=0x1000 distinct=0
open: F_GETFL has O_RSYNC=1 O_SYNC=1
setfl: ret=0 F_GETFL has O_RSYNC=1
aio_fsync(O_RSYNC): skipped, O_RSYNC aliases O_SYNC
```
Testing logs after change (this PR, `fe86a86e578`):
```
O_RSYNC=0x800000 O_SYNC=0x101000 O_DSYNC=0x1000 distinct=1
open: F_GETFL has O_RSYNC=1 O_SYNC=0
setfl: ret=0 F_GETFL has O_RSYNC=1
aio_fsync(O_RSYNC): ret=-1 errno=22
```
The same run keeps the other flags unchanged (`O_SYNC` and `O_DSYNC` keep
their values), and `ostest` passes.
## PR verification Self-Check
* [x] This PR introduces only one functional change.
* [x] I have updated all required description fields above.
* [x] My PR adheres to Contributing Guidelines and Documentation (git commit
title and message, coding standard, etc).
* [ ] My PR is still work in progress (not ready for review).
* [x] My PR is ready for review and can be safely merged into a codebase.
--
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]