fix(vfs): 修复 utimensat/futimesat 系统调用边界情况以兼容 gVisor 测试#1431
Merged
fslongjin merged 6 commits intoDragonOS-Community:masterfrom Dec 5, 2025
Merged
fix(vfs): 修复 utimensat/futimesat 系统调用边界情况以兼容 gVisor 测试#1431fslongjin merged 6 commits intoDragonOS-Community:masterfrom
fslongjin merged 6 commits intoDragonOS-Community:masterfrom
Conversation
a22b5cb to
5ee7040
Compare
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.
描述
本PR修复了utimensat和futimesat系统调用实现中的若干边界情况,使其符合Linux语义并通过gVisor系统调用兼容性测试。
主要变更
1.添加tv_nsec参数校验(utimensat.rs)
验证tv_nsec必须在[0,1e9)范围内,或者等于UTIME_NOW/UTIME_OMIT特殊值
对于无效的纳秒值返回EINVAL错误
修复测试:UtimensatTest.InvalidNsec
2.添加UTIME_OMIT提前返回(open.rs)
当两个时间戳都是UTIME_OMIT时,立即返回成功而不访问文件
符合Linux行为,此时不会进行任何实际的文件操作
修复测试:UtimensatTest.OmitNoop
3.添加AT_FDCWD+NULLpathname处理(open.rs)
当pathname为NULL且dirfd为AT_FDCWD时,返回EFAULT(而不是EBADF)
符合Linux对这种无效组合的特定错误处理
修复测试:FutimesatTest.OnNullPathWithCWD
4.添加O_PATH文件描述符拒绝(open.rs)
当操作使用O_PATH打开的文件描述符时,返回EBADF
O_PATH描述符只能用于元数据操作,不能用于更新时间戳
修复测试:FutimesatTest.OnNullPathWithOPath
修复的测试
✅UtimensatTest.InvalidNsec-无效纳秒值校验
✅UtimensatTest.OmitNoop-UTIME_OMIT无操作行为
✅FutimesatTest.OnNullPathWithCWD-AT_FDCWD+NULL路径错误处理
✅FutimesatTest.OnNullPathWithOPath-O_PATH文件描述符拒绝
技术细节
UTIME_NOW和UTIME_OMIT常量:
UTIME_NOW=(1<<30)-1=0x3FFFFFFF-使用当前时间
UTIME_OMIT=(1<<30)-2=0x3FFFFFFE-不修改该时间戳
错误码语义:
EINVAL:tv_nsec超出有效范围
EFAULT:AT_FDCWD+NULLpathname的无效组合
EBADF:O_PATH文件描述符不支持时间戳修改操作