Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjiezhou committed Sep 2, 2023
1 parent aae7bf9 commit b81f6cf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kernel/src/ipc/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use core::{

use crate::{
arch::asm::current::current_pcb,
filesystem::vfs::{file::{File, FileMode}, fcntl::{FcntlCommand, FD_CLOEXEC}},
filesystem::vfs::{
fcntl::{FcntlCommand, FD_CLOEXEC},
file::{File, FileMode},
},
include::bindings::bindings::{pid_t, verify_area, NULL},
kwarn,
syscall::{Syscall, SystemError},
Expand Down Expand Up @@ -47,14 +50,14 @@ impl Syscall {
///
/// - `fd`: 用于返回文件描述符的数组
/// - `flags`:设置管道的参数
pub fn pipe2(fd: &mut [i32],flags:PipeFlag) -> Result<usize, SystemError> {
pub fn pipe2(fd: &mut [i32], flags: PipeFlag) -> Result<usize, SystemError> {
let pipe_ptr = LockedPipeInode::new(flags);
let read_file = File::new(pipe_ptr.clone(), FileMode::O_RDONLY)?;
let write_file = File::new(pipe_ptr.clone(), FileMode::O_WRONLY)?;

let read_fd = current_pcb().alloc_fd(read_file, None)?;
let write_fd = current_pcb().alloc_fd(write_file, None)?;
if flags.contains(PipeFlag::O_CLOEXEC){
if flags.contains(PipeFlag::O_CLOEXEC) {
Syscall::fcntl(read_fd, FcntlCommand::SetFd, FD_CLOEXEC as i32)?;
Syscall::fcntl(write_fd, FcntlCommand::SetFd, FD_CLOEXEC as i32)?;
}
Expand Down

0 comments on commit b81f6cf

Please sign in to comment.