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

   ## Summary
   
   Align the NuttX `open(2)` flag constants (`O_RDONLY`/`O_WRONLY`/`O_RDWR`) 
with the Linux asm-generic values (`0`/`1`/`2` instead of `1`/`2`/`3`) so that 
the FUSE wire protocol and other cross-platform interfaces work without 
conversion.
   
   *   Realign the access-mode flags and the remaining open flags (`O_CREAT`, 
`O_EXCL`, `O_APPEND`, `O_TRUNC`, `O_NONBLOCK`, `O_SYNC`, `O_DSYNC`, `O_DIRECT`, 
`O_DIRECTORY`, `O_NOFOLLOW`, `O_NOATIME`, `O_CLOEXEC`, `O_PATH`, `O_TMPFILE`, 
etc.) with the Linux `asm-generic` values.
   *   Update all code that used `(flags & O_RDONLY)` as a bitmask check (which 
is always `0` now that `O_RDONLY == 0`) to use `(flags & O_ACCMODE)` 
comparisons instead, across `fs/`, `drivers/`, `libs/`, `arch/`, `sched/`, 
`net/`, and `graphics/`.
   *   Update the `NUTTX_O_*` constants in `include/nuttx/fs/hostfs.h` to 
match, and fix the sim hostfs open-flag mapping.
   
   ## Impact
   
   *   **Compatibility:** The new flag values match Linux, so FUSE and other 
wire protocols that pass open flags directly no longer need translation. This 
is the primary motivation.
   *   **Behavior:** Existing code that performed `(flags & O_RDONLY)` would 
silently break (`O_RDONLY` is now `0`), so every such site has been audited and 
converted to `(flags & O_ACCMODE)`.
   *   **No new APIs:** No public API signatures change; only the numeric 
values of existing `#define`s change.
   *   **Build:** No build-system changes required.
   
   ## Testing
   
   Tested on the `sim:nsh` target (Linux x86_64 host, gcc).
   
   **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 0x7766a5a003f0 0x7766a5a00470
       2     0     0 224 FIFO     Kthread   - Waiting  Semaphore 
0000000000000000 0
   067472 hpwork 0x40159080 0x40159100
       4     4     0 100 FIFO     Task      - Running            
0000000000000000 0
   067496 nsh_main
   nsh> mount
     /bin type binfs
     /data type hostfs
     /etc type romfs
     /proc type procfs
   nsh> cat /proc/version
   NuttX version 10.4.0 6bb526f459a Jun 29 2026 23:37:06 sim:nsh
   ```
   
   **OSTest:** ran `ostest` from the NSH prompt — all tests passed with no 
failures or panics. Final summary:
   
   ```
   waitpid_last: PASS: PID 10 waitpid failed with ECHILD.  That may be
   waitpid_last: PASS: PID 13 waitpid failed with ECHILD.  That may be
   waitpid_last: PASS: PID 19 waitpid failed with ECHILD.  That may be
   waitpid_last: PASS: PID 25 waitpid failed with ECHILD.  That may be
   ```


-- 
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