xiaoxiang781216 opened a new pull request, #3572:
URL: https://github.com/apache/nuttx-apps/pull/3572
## Summary
Companion to apache/nuttx#19238 ("include/fcntl.h: align open flags with
Linux values").
After aligning the NuttX `open()` flag constants with Linux (`O_RDONLY=0`,
`O_WRONLY=1`, `O_RDWR=2`), code that used `(flags & O_RDONLY)` or `(flags &
O_WRONLY)` as a bitmask check is broken because `O_RDONLY` is now `0`. This PR
fixes all such sites in `apps/` by using `(flags & O_ACCMODE)` comparisons
instead.
* **usrsocktest** (`examples/usrsocktest/`): replace `flags & O_RDWR` with
`flags & O_ACCMODE` in `fcntl(F_GETFL)` assertions across 5 test files.
* **dd** (`system/dd/dd_main.c`): verify mode used `(oflags & O_RDONLY)`
to detect verify; replace with `(oflags & O_ACCMODE) == O_RDWR`.
* **dpopen** (`system/popen/dpopen.c`): replace `(oflag & O_RDWR) ==
O_RDWR` with `(oflag & O_ACCMODE) == O_RDWR`.
* **usbmsc** (`system/usbmsc/usbmsc_main.c`): replace `flags & O_WRONLY`
with `(flags & O_ACCMODE) == O_RDONLY`.
* **fcntl_test** (`testing/testsuites/kernel/syscall/cases/fcntl_test.c`):
replace `(flags & O_WRONLY) == 0` with `(flags & O_ACCMODE) == O_RDONLY`.
## Impact
* **Correctness:** Without these fixes, the affected code silently
misbehaves when `O_RDONLY == 0` (e.g. `dd verify` never triggers, dpopen
bidirectional detection fails, usbmsc read-only detection is wrong).
* **Dependency:** Must be merged together with (or after)
apache/nuttx#19238. Standalone this PR has no effect since apache/nuttx still
uses the old flag values.
## Testing
Tested on the `sim:nsh` target (Linux x86_64 host, gcc) together with
apache/nuttx#19238.
**Boot log:**
```
NuttShell (NSH) NuttX-10.4.0
nsh> uname -a
NuttX 10.4.0 6bb526f459a Jun 29 2026 23:37:06 sim sim
nsh> ps
TID PID PPID PRI POLICY TYPE NPX STATE EVENT SIGMASK
STACK COMMAND
0 0 0 0 FIFO Kthread - Ready
0000000000000000 0
069584 Idle_Task
1 0 0 224 FIFO Kthread - Waiting Semaphore
0000000000000000 0
067456 sim_loop_wq
2 0 0 224 FIFO Kthread - Waiting Semaphore
0000000000000000 0
067472 hpwork
4 4 0 100 FIFO Task - Running
0000000000000000 0
067496 nsh_main
```
**OSTest:** ran `ostest` from the NSH prompt — all tests passed with no
failures or panics.
--
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]