Skip to content

{bp-19238} !include/fcntl.h: align open flags with Linux values#19267

Merged
xiaoxiang781216 merged 5 commits into
apache:releases/13.0from
jerpelea:bp-19238
Jul 3, 2026
Merged

{bp-19238} !include/fcntl.h: align open flags with Linux values#19267
xiaoxiang781216 merged 5 commits into
apache:releases/13.0from
jerpelea:bp-19238

Conversation

@jerpelea

@jerpelea jerpelea commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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.

Access-mode flag values across major operating systems
Constant NuttX (before) NuttX (after) Linux glibc FreeBSD macOS
O_RDONLY 1 0 0 0 0 0
O_WRONLY 2 1 1 1 1 1
O_RDWR 3 2 2 2 2 2
O_ACCMODE 3 3 3 3 3 3

Before this change NuttX was the only major OS using 1/2/3 for the access-mode flags; every other platform (Linux, glibc, FreeBSD, macOS) uses the 0/1/2 convention. After this change NuttX matches the de-facto standard, so interfaces that pass open flags directly across the kernel/userspace or host/guest boundary (e.g. FUSE) work without conversion.

Includes
#18902
#19162
#19231

Impact

RELEASE

Testing

CI

@github-actions github-actions Bot added Arch: arm Issues related to ARM (32-bit) architecture Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: simulator Issues related to the SIMulator Arch: x86_64 Issues related to the x86_64 architecture Area: Drivers Drivers issues Size: L The size of the change in this PR is large Board: arm labels Jul 2, 2026
Abhishekmishra2808 and others added 5 commits July 2, 2026 17:24
Add pseudoFS permission enforcement for unlink(), mkdir(), and rename() VFS mutation operations.

This change validates parent-directory permissions before modifying pseudoFS inode topology and returns -EACCES for unauthorized operations.

The implementation preserves mountpoint filesystem behavior and fixes multiple inode lifetime/search-state issues in the rename path.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
Add fs_checkmode() and fs_checkopenperm() for reuse across filesystems.
Enforce pseudoFS mode bits in inode_checkperm() and allow world-readable
open of passwd/group entries so getpwnam() works after seteuid().

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
O_RDOK and O_WROK are non-standard aliases for O_RDONLY and O_WRONLY
respectively.  Having two names for the same flag creates confusion,
especially when aligning the flag values with Linux.  Remove the
aliases and replace all uses with the standard O_RDONLY/O_WRONLY.

No functional change — O_RDOK was defined as O_RDONLY and O_WROK as
O_WRONLY, so the replacement is a pure text substitution.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
to pass PSE52 test suite

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Align the NuttX open(2) flag constants with the Linux asm-generic
values so that the FUSE wire protocol and other cross-platform
interfaces work without conversion.

All code that used '(flags & O_RDONLY)' as a bitmask check (always 0
now that O_RDONLY=0) has been updated to use '(flags & O_ACCMODE)'
comparisons.

The NUTTX_O_* constants in include/nuttx/fs/hostfs.h are updated to
match, and the sim hostfs open flag mapping is fixed.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
@xiaoxiang781216 xiaoxiang781216 merged commit a0357b3 into apache:releases/13.0 Jul 3, 2026
20 of 41 checks passed
@jerpelea jerpelea deleted the bp-19238 branch July 3, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: simulator Issues related to the SIMulator Arch: x86_64 Issues related to the x86_64 architecture Area: Drivers Drivers issues Board: arm Size: L The size of the change in this PR is large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants