{bp-19238} !include/fcntl.h: align open flags with Linux values#19267
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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