From 6ed66d03d8ecd4eafc99758d7f6b1ed729a56e55 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Sun, 10 Mar 2019 00:50:28 +0800 Subject: [PATCH] Fix sys_pipe --- kernel/src/syscall/fs.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kernel/src/syscall/fs.rs b/kernel/src/syscall/fs.rs index 7a47dcb..dcac2c5 100644 --- a/kernel/src/syscall/fs.rs +++ b/kernel/src/syscall/fs.rs @@ -3,15 +3,13 @@ use core::mem::size_of; use core::cmp::min; use rcore_fs::vfs::Timespec; -use smoltcp::socket::*; use crate::fs::*; use crate::memory::MemorySet; use crate::sync::Condvar; -use crate::drivers::{NET_DRIVERS, SOCKET_ACTIVITY}; +use crate::drivers::SOCKET_ACTIVITY; use super::*; -use super::net::*; pub fn sys_read(fd: usize, base: *mut u8, len: usize) -> SysResult { info!("read: fd: {}, base: {:?}, len: {:#x}", fd, base, len); @@ -553,6 +551,13 @@ pub fn sys_pipe(fds: *mut u32) -> SysResult { let write_fd = proc.get_free_fd(); proc.files.insert(write_fd, FileLike::File(FileHandle::new(Arc::new(write), OpenOptions { read: false, write: true, append: false }))); + unsafe { + *fds = read_fd as u32; + *(fds.add(1)) = write_fd as u32; + } + + info!("pipe: created rfd: {} wfd: {}", read_fd, write_fd); + Ok(0) }