fix(vfs):修复 sys_mknodat 路径解析与 mode 处理,并修复 fatfs中mknod 相关死锁#1346
fix(vfs):修复 sys_mknodat 路径解析与 mode 处理,并修复 fatfs中mknod 相关死锁#1346fslongjin merged 8 commits intoDragonOS-Community:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enables and implements support for the mknod_test in the gvisor syscall test suite. The key changes refactor the sys_mknodat syscall implementation to use proper path resolution utilities and fix a lock scope issue in the FAT filesystem's mknod implementation.
- Refactored
sys_mknodatto useuser_path_atandrsplit_pathutilities for consistent path handling - Fixed lock scope in FAT filesystem
mknodto prevent holding the lock during file creation - Added
mknod_testto whitelist with a blocklist for unimplemented features
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| user/apps/tests/syscall/gvisor/whitelist.txt | Enables mknod_test in the test suite |
| user/apps/tests/syscall/gvisor/blocklists/mknod_test | Documents test cases blocked due to unimplemented features (umask, symlink, socket) |
| kernel/src/filesystem/vfs/syscall/sys_mknodat.rs | Refactors path resolution to use standard utilities and fixes mode handling |
| kernel/src/filesystem/fat/fs.rs | Fixes lock scope to avoid holding lock during create operation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| MknodTest.RegularFilePermissions | ||
| # symlink未实现 | ||
| MknodTest.MknodOnExistingPathFails | ||
| # sys_socket对应功能为实现 |
There was a problem hiding this comment.
Corrected spelling of '为实现' to '未实现' (missing negation character).
| # sys_socket对应功能为实现 | |
| # sys_socket对应功能未实现 |
- 重构FAT文件系统目录检查逻辑,提前释放锁 - 改进mknod系统调用中空路径名检查方式 - 修正测试文件中的注释拼写错误 Signed-off-by: longjin <longjin@DragonOS.org>
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| file.inode().mknod(&path, mode, dev)?; | ||
| if name.is_empty() && dirfd != AtFlags::AT_FDCWD.bits() { | ||
| return Err(SystemError::ENOENT); | ||
| } |
There was a problem hiding this comment.
Bug: Empty Path Handling in dirfd AT_FDCWD Bug
When dirfd equals AT_FDCWD and path is an empty string, the code fails to return ENOENT. Instead, after user_path_at prepends the current working directory (e.g., "/home/user/"), rsplit_path extracts the last component ("user") as the filename and parent path ("home"). This causes mknod to incorrectly attempt creating a node in an unintended location. The condition should check for empty path regardless of dirfd value, or verify that the original path (not just the final name component) was non-empty.
Note
Fixes sys_mknodat path resolution and mode=0 handling, updates FAT mknod locking to avoid deadlock, and enables mknod tests with targeted blocklists.
dirfd-relative paths viauser_path_at, split withrsplit_path, and follow symlinks up toVFS_MAX_FOLLOW_SYMLINK_TIMES.mode == 0asS_IFREG; validate modes viaModeType::from_bits.ENOENTwhen name is empty anddirfd != AT_FDCWD.mknodon the resolved parent inode instead of fd-table direct dir checks.fs.rs):mknodby dropping the directory lock before callingcreate; re-lock only when creating special nodes.SpecialNodeData::Pipeand cache inchildren.mknod_testto gVisor whitelist; blocklist specific cases (RegularFilePermissions,MknodOnExistingPathFails,Socket).Written by Cursor Bugbot for commit 7c255dc. This will update automatically on new commits. Configure here.