jingfei195887 opened a new pull request, #21692: URL: https://github.com/apache/nuttx/pull/21692
## Summary `O_CREAT`, `O_EXCL`, `O_NOCTTY` and `O_TRUNC` only affect the `open()` call itself, but `file_vopen()` keeps them in `f_oflags`, so `fcntl(F_GETFL)` reports them. POSIX defines `F_GETFL` to return the file status flags and the access mode, which do not include these flags. Clear them once the open has succeeded. ## Impact `fcntl(F_GETFL)` no longer reports `O_CREAT`, `O_EXCL`, `O_NOCTTY` or `O_TRUNC`. The access mode and the status flags such as `O_APPEND` and `O_NONBLOCK` are unchanged. I found no code in the tree that tests these four flags in `f_oflags` after the open. ## Testing Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, master 03aea78639 (rebased onto 6f47a1c3d6; the one new commit does not touch fs/), `sim:nsh`. A small test program opens a file with `O_CREAT | O_TRUNC | O_RDWR | O_APPEND` and reads `fcntl(fd, F_GETFL)`: | | master | this PR | |---|---|---| | `F_GETFL` | 0x642 | 0x402 | | `O_CREAT` / `O_TRUNC` | set | clear | | `O_APPEND`, access mode | set, `O_RDWR` | set, `O_RDWR` | - `./tools/checkpatch.sh -g master..HEAD`: all checks pass. - Make and CMake builds pass; `ostest` exits with status 0. -- 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]
