Skip to content

Conversation

@oeasy1412
Copy link
Contributor

  1. 新增: sys_umask 系统调用:

    • 实现了进程文件模式创建屏蔽字(file mode creation mask)的设置功能。
    • 严格遵循 Linux 语义,在设置新 mask 的同时正确返回旧的 mask 值,完善了文件系统的权限控制机制。
  2. 修复: do_mkdir_at 权限模式截断问题:

    • 修正了 do_mkdir_at 错误使用 FileMode(通常用于 open flags)来接收权限参数的问题。
    • 改为使用 ModeType 接收参数,解决了因 FileMode 定义不包含中间权限位(Group/Other)导致传入的 0777 被错误截断为 0703 的 Bug。
  3. 修复: inode_permission 权限位运算逻辑:

    • 修正了 DAC 权限检查时的位运算优先级与逻辑,例如 (file_mode & ModeType::S_IRWXU.bits()) >> 6
    • 确保先进行按位与(Masking)再进行移位(Shifting),准确提取 Owner/Group/Other 的权限位,修复了因运算顺序导致的权限误判问题。
  4. 修复: mkdir 边界条件与错误码(Test: MkdirAtEmptyPath / DirAlreadyExists):

    • 修复了路径解析逻辑,当路径为空时正确返回 ENOENT
    • 修复了目标检查逻辑,当目标路径已存在时,严格遵循 Linux 标准返回 EEXIST,而非错误地返回成功或覆盖。
  5. 修复: sys_mknod 行为:

  6. 修复: 使用 ModeType 代替硬编码文件权限,如 0o777

@github-actions github-actions bot added the test Unitest/User space test label Nov 28, 2025
@oeasy1412 oeasy1412 changed the title fix(sys_mkdir): 修复sys_mkdir行为 fix(mkdir): 修复sys_mkdir逻辑错误和权限截断问题,并添加sys_umask Nov 29, 2025
@github-actions github-actions bot added the Bug fix A bug is fixed in this pull request label Nov 29, 2025
Comment on lines 54 to 62
pub fn umask(&self) -> u32 {
self.umask.load(Ordering::SeqCst)
}

/// Linux: xchg(&current->fs->umask, mask & S_IRWXUGO)
pub fn set_umask(&self, mask: u32) -> u32 {
self.umask
.swap(mask & ModeType::S_IRWXUGO.bits(), Ordering::SeqCst)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里最好直接返回ModeType,并且set的时候传入ModeType

@oeasy1412 oeasy1412 requested a review from fslongjin December 1, 2025 10:29
@fslongjin fslongjin merged commit cd45a99 into DragonOS-Community:master Dec 1, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug fix A bug is fixed in this pull request test Unitest/User space test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants