Skip to content
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

feat(fs): add sys_dup3 #755

Merged
merged 3 commits into from
Apr 23, 2024
Merged

feat(fs): add sys_dup3 #755

merged 3 commits into from
Apr 23, 2024

Conversation

zwb0x00
Copy link
Contributor

@zwb0x00 zwb0x00 commented Apr 22, 2024

实现dup3系统调用并给出测试用例。

@dragonosbot
Copy link

感谢您的pull request,欢迎加入!🎉 DragonOS社区很兴奋地期待审核您的更改,您将在接下来的两周内收到 @fslongjin (or someone else) 的回复。💬😊

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-等待审查 and S-等待作者修改) stays updated, invoking these commands when appropriate:

  • @dragonosbot author: 审查结束后,PR的作者应检查评论并采取相应行动
  • @dragonosbot review: 作者已完成修改,将此PR提交给reviewer进行审阅,此PR将再次在审阅者队列中排队

@dragonosbot dragonosbot added A-fs Area: 文件系统 S-等待审查 Status: 等待assignee以及相关方的审查。 labels Apr 22, 2024
@github-actions github-actions bot added ambiguous The title of PR/issue doesn't match the format documentation Improvements or additions to documentation labels Apr 22, 2024
@@ -400,6 +400,14 @@ impl Syscall {
Self::dup2(oldfd, newfd)
}

#[cfg(target_arch = "x86_64")]
SYS_DUP3 => {
Copy link
Member

Choose a reason for hiding this comment

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

riscv也有dup3,因此这里不需要加条件编译

@@ -1020,6 +1020,16 @@ impl Syscall {
return Self::do_dup2(oldfd, newfd, &mut fd_table_guard);
}

pub fn dup3(oldfd: i32, newfd: i32, flags: u32) -> Result<usize, SystemError> {
let flags: FileMode = FileMode::from_bits(flags).ok_or(SystemError::EINVAL)?;
if flags != FileMode::O_CLOEXEC {
Copy link
Member

Choose a reason for hiding this comment

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

这里的实现逻辑不正确。
参考dup3的含义:
https://man7.org/linux/man-pages/man2/dup.2.html

dup3()
dup3() is the same as dup2(), except that:

   •  The caller can force the close-on-exec flag to be set for the
      new file descriptor by specifying O_CLOEXEC in flags.  See the
      description of the same flag in open(2) for reasons why this
      may be useful.

   •  If oldfd equals newfd, then dup3() fails with the error
      EINVAL.

@dragonosbot dragonosbot added S-等待作者修改 Status: 这正在等待作者的一些操作(例如代码更改或更多信息)。 and removed S-等待审查 Status: 等待assignee以及相关方的审查。 labels Apr 22, 2024
@fslongjin
Copy link
Member

然后,pr的名字麻烦参考文档改一下:

https://docs.dragonos.org/zh-cn/latest/community/code_contribution/conventional-commit.html

@zwb0x00 zwb0x00 changed the title 实现dup3系统调用 feat(fs): add sys_dup3 Apr 23, 2024
@github-actions github-actions bot added enhancement New feature or request and removed documentation Improvements or additions to documentation ambiguous The title of PR/issue doesn't match the format labels Apr 23, 2024
@zwb0x00
Copy link
Contributor Author

zwb0x00 commented Apr 23, 2024

@dragonosbot ready

@dragonosbot dragonosbot added S-等待审查 Status: 等待assignee以及相关方的审查。 and removed S-等待作者修改 Status: 这正在等待作者的一些操作(例如代码更改或更多信息)。 labels Apr 23, 2024
@fslongjin
Copy link
Member

提交代码的时候需要先make fmt进行格式化,并修复clippy报出的error哈。我刚帮你修了。

@fslongjin fslongjin merged commit 40348dd into DragonOS-Community:master Apr 23, 2024
7 checks passed
zwb0x00 added a commit to zwb0x00/DragonOS that referenced this pull request Apr 23, 2024
BrahmaMantra pushed a commit to BrahmaMantra/DragonOS that referenced this pull request Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-fs Area: 文件系统 enhancement New feature or request S-等待审查 Status: 等待assignee以及相关方的审查。
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants