-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
Conversation
感谢您的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 (
|
@@ -400,6 +400,14 @@ impl Syscall { | |||
Self::dup2(oldfd, newfd) | |||
} | |||
|
|||
#[cfg(target_arch = "x86_64")] | |||
SYS_DUP3 => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
riscv也有dup3,因此这里不需要加条件编译
kernel/src/filesystem/vfs/syscall.rs
Outdated
@@ -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 { |
There was a problem hiding this comment.
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 ready |
提交代码的时候需要先make fmt进行格式化,并修复clippy报出的error哈。我刚帮你修了。 |
This reverts commit 40348dd.
* feat(fs): add sys_dup3
实现dup3系统调用并给出测试用例。