diff --git a/kernel/src/fs/file_like.rs b/kernel/src/fs/file_like.rs index dbbdbe46..ae5ae6b6 100644 --- a/kernel/src/fs/file_like.rs +++ b/kernel/src/fs/file_like.rs @@ -1,11 +1,11 @@ use core::fmt; +use super::ioctl::*; use super::FileHandle; use crate::net::Socket; use crate::syscall::{SysError, SysResult}; use alloc::boxed::Box; use rcore_fs::vfs::PollStatus; -use super::ioctl::*; // TODO: merge FileLike to FileHandle ? // TODO: fix dup and remove Clone diff --git a/kernel/src/fs/ioctl.rs b/kernel/src/fs/ioctl.rs index dc3d9970..3eb3509e 100644 --- a/kernel/src/fs/ioctl.rs +++ b/kernel/src/fs/ioctl.rs @@ -33,4 +33,4 @@ pub const FIONCLEX: usize = 0x6602; #[cfg(not(target_arch = "mips"))] pub const FIOCLEX: usize = 0x5451; #[cfg(target_arch = "mips")] -pub const FIOCLEX: usize = 0x6601; \ No newline at end of file +pub const FIOCLEX: usize = 0x6601; diff --git a/kernel/src/fs/mod.rs b/kernel/src/fs/mod.rs index a5e56a1c..0c47c8f6 100644 --- a/kernel/src/fs/mod.rs +++ b/kernel/src/fs/mod.rs @@ -1,7 +1,7 @@ use alloc::{sync::Arc, vec::Vec}; -use rcore_fs::vfs::*; use rcore_fs::dev::block_cache::BlockCache; +use rcore_fs::vfs::*; use rcore_fs_sfs::SimpleFileSystem; use crate::drivers::BlockDriver; @@ -15,10 +15,10 @@ pub use self::stdio::{STDIN, STDOUT}; mod device; mod file; mod file_like; +mod ioctl; mod pipe; mod pseudo; mod stdio; -mod ioctl; /// Hard link user programs #[cfg(feature = "link_user")] diff --git a/kernel/src/fs/stdio.rs b/kernel/src/fs/stdio.rs index 6a73c28f..d13520ae 100644 --- a/kernel/src/fs/stdio.rs +++ b/kernel/src/fs/stdio.rs @@ -5,9 +5,9 @@ use core::any::Any; use rcore_fs::vfs::*; +use super::ioctl::*; use crate::sync::Condvar; use crate::sync::SpinNoIrqLock as Mutex; -use super::ioctl::*; #[derive(Default)] pub struct Stdin { diff --git a/kernel/src/shell.rs b/kernel/src/shell.rs index 48b7608d..c26b176c 100644 --- a/kernel/src/shell.rs +++ b/kernel/src/shell.rs @@ -1,10 +1,10 @@ //! Kernel shell +use crate::arch::io; use crate::fs::ROOT_INODE; use crate::process::*; use alloc::string::String; use alloc::vec::Vec; -use crate::arch::io; #[cfg(not(feature = "run_cmdline"))] pub fn add_user_shell() { @@ -47,7 +47,7 @@ pub fn add_user_shell() { &inode, cmdline.split(' ').map(|s| s.into()).collect(), Vec::new(), - Vec::new() + Vec::new(), )); } diff --git a/kernel/src/syscall/fs.rs b/kernel/src/syscall/fs.rs index 895252c5..977529d3 100644 --- a/kernel/src/syscall/fs.rs +++ b/kernel/src/syscall/fs.rs @@ -784,14 +784,18 @@ impl Process { _ => {} } match fd_dir_path { - "/proc/self/fd" =>{ - let fd:u32= fd_name.parse::().unwrap(); - let fd_path= match self.files.get(&(fd as usize)).unwrap() { - FileLike::File(file) => Some(&file.path), - _ => None, + "/proc/self/fd" => { + let fd: u32 = fd_name.parse::().unwrap(); + let fd_path = match self.files.get(&(fd as usize)) { + Some(FileLike::File(file)) => Some(&file.path), + _ => return Err(SysError::ENOENT), }; - info!("lookup_inode_at:BEG /proc/sefl/fd {}, path {}", fd, fd_path.unwrap()); - if(fd_path.is_some()) { + info!( + "lookup_inode_at:BEG /proc/self/fd {}, path {}", + fd, + fd_path.unwrap() + ); + if (fd_path.is_some()) { return Ok(Arc::new(Pseudo::new(fd_path.unwrap(), FileType::SymLink))); } else { {} diff --git a/user b/user index b6a34775..bb73d6ec 160000 --- a/user +++ b/user @@ -1 +1 @@ -Subproject commit b6a347750531be125583107b6d0fc307366fdcc9 +Subproject commit bb73d6ecce1ab0e6fae692c51e4335772b0335d4