-
-
Notifications
You must be signed in to change notification settings - Fork 166
feat(vfs): 重构文件系统标志体系,区分打开标志与访问模式 #1414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR performs a comprehensive refactoring of file-related type names in the VFS layer to better align with Linux kernel semantics:
- Renames
FileModetoFileFlags(user-space open flags like O_RDONLY, O_WRONLY, O_RDWR) - Introduces a new
FileModetype representing kernel-internal f_mode flags (FMODE_READ, FMODE_WRITE, etc.) - Renames
ModeTypetoInodeMode(inode permission bits like 0o755) - Fixes pipe poll permission checking logic to use proper helper methods instead of direct flag checks
Key Changes
- New
FileMode::open_fmode()function convertsFileFlagsto internalFileModerepresentation - Enhanced permission checking in
File::readable()andFile::writeable()methods - Pipe poll now uses
is_write_only()andis_read_only()helper methods for clearer access mode checks
Reviewed changes
Copilot reviewed 100 out of 100 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| kernel/src/filesystem/vfs/file.rs | Core refactoring: adds new FileMode type, renames FileMode to FileFlags, implements conversion logic and permission checks |
| kernel/src/ipc/pipe.rs | Renames mode field to file_flags, fixes poll permission check logic using new helper methods |
| kernel/src/filesystem/vfs/syscall/mod.rs | Renames ModeType to InodeMode throughout syscall interfaces |
| kernel/src/filesystem/vfs/mod.rs | Updates IndexNode trait methods to use FileFlags parameter, updates InodeMode conversions |
| All other files | Mechanical renames of FileMode→FileFlags and ModeType→InodeMode across device drivers, filesystems, and system components |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- 新增O_SYNC/O_DSYNC标志处理及数据同步逻辑 - 实现S_APPEND/S_IMMUTABLE标志的权限检查 - 添加datasync()接口支持O_DSYNC语义 - 修复O_APPEND模式下的竞态条件问题
ModeType重命名为InodeMode,明确其为inode权限位FileMode重命名为FileFlags,明确其为文件打开标志(O_RDONLY等)FileMode结构体,对应Linux内核的file.f_mode,表示内核专用访问模式(FMODE_READ/FMODE_WRITE/FMODE_LSEEK等)InodeFlags结构体,支持 S_SYNC、S_APPEND、S_IMMUTABLE 等inode标志poll函数中的标志判断逻辑