fix(vfs): 修复truncate系统调用,添加截断时的页缓存截断,修复边界条件#1444
fix(vfs): 修复truncate系统调用,添加截断时的页缓存截断,修复边界条件#1444fslongjin merged 12 commits intoDragonOS-Community:masterfrom
Conversation
|
https://github.com/DragonOS-Community/DragonOS/actions/runs/20005297190 这里拉到底有个CR报告。 |
可以 |
|
改进空间:
次要问题:
|
9582167 to
45d5e08
Compare
|
主线中OpenTest.AppendConcurrentWrite 测试不稳定,有时会失败 https://github.com/DragonOS-Community/DragonOS/blob/master/kernel/src/filesystem/fat/entry.rs#L203
|
|
@claude review this PR in Chinese |
|
Claude finished @fslongjin's task in 4m 16s —— View job PR #1444 代码审查我正在审查PR #1444 "fix(vfs): 修复truncate系统调用,添加截断时的页缓存截断,修复边界条件"。让我分析变更并提供反馈。 <分析>
<关键发现>
<审查计划>
待办事项列表
代码审查反馈总体评价这个PR很好地修复了truncate/ftruncate系统调用的语义对齐问题,增加了必要的边界检查和错误处理,实现了页缓存截断功能,并启用了gVisor测试。代码质量整体较好,但存在一些可改进的地方。 主要变更分析1. 系统调用语义对齐 ✓
2. 页缓存截断 ✓
3. FAT文件系统改进 ✓
4. 测试配置 ✓
代码质量问题1. 常量定义不一致
|
PR Summary
Align truncate/ftruncate semantics: reject负长度,要求常规文件,非可写/非可写能力返回EINVAL,O_PATH返回EBADF,超出RLIMIT_FSIZE发送SIGXFSZ并报EFBIG。
移除在 FAT resize 中意外的文件大小限制,恢复正常扩展能力。
Testing
Note
Aligns truncate/ftruncate with proper checks/signals, truncates page cache on resize, chunks zero-fills to cap memory, enforces FAT limits, and enables gVisor truncate tests.
ftruncate/truncatesemantics aligned:len <= isize::MAX).O_PATH->EBADF; non-writable ->EINVAL.RLIMIT_FSIZE: sendSIGXFSZ, returnEFBIG.vfs_truncateand add DAC write permission check intruncate.FATInode::resize: enforceMAX_FILE_SIZEwithEFBIG; truncate page cache viatruncate_inode_pages; expand using fixed zero buffer chunks; sync metadata.FATFile::zero_range: switch to 512KB chunked zero-writes to avoid large allocations.truncate_testinuser/apps/tests/syscall/gvisor/whitelist.txtand blocklistTruncateTest.FtruncateVirtualTmp.Written by Cursor Bugbot for commit 4f76c1e. This will update automatically on new commits. Configure here.