1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-21 23:56:18 +04:00

Fix /proc/self/fd not found panic

This commit is contained in:
Jiajie Chen 2019-05-03 15:00:45 +08:00
parent 6d14fbf3db
commit 7331404fc7
7 changed files with 19 additions and 15 deletions

View File

@ -1,11 +1,11 @@
use core::fmt; use core::fmt;
use super::ioctl::*;
use super::FileHandle; use super::FileHandle;
use crate::net::Socket; use crate::net::Socket;
use crate::syscall::{SysError, SysResult}; use crate::syscall::{SysError, SysResult};
use alloc::boxed::Box; use alloc::boxed::Box;
use rcore_fs::vfs::PollStatus; use rcore_fs::vfs::PollStatus;
use super::ioctl::*;
// TODO: merge FileLike to FileHandle ? // TODO: merge FileLike to FileHandle ?
// TODO: fix dup and remove Clone // TODO: fix dup and remove Clone

View File

@ -1,7 +1,7 @@
use alloc::{sync::Arc, vec::Vec}; use alloc::{sync::Arc, vec::Vec};
use rcore_fs::vfs::*;
use rcore_fs::dev::block_cache::BlockCache; use rcore_fs::dev::block_cache::BlockCache;
use rcore_fs::vfs::*;
use rcore_fs_sfs::SimpleFileSystem; use rcore_fs_sfs::SimpleFileSystem;
use crate::drivers::BlockDriver; use crate::drivers::BlockDriver;
@ -15,10 +15,10 @@ pub use self::stdio::{STDIN, STDOUT};
mod device; mod device;
mod file; mod file;
mod file_like; mod file_like;
mod ioctl;
mod pipe; mod pipe;
mod pseudo; mod pseudo;
mod stdio; mod stdio;
mod ioctl;
/// Hard link user programs /// Hard link user programs
#[cfg(feature = "link_user")] #[cfg(feature = "link_user")]

View File

@ -5,9 +5,9 @@ use core::any::Any;
use rcore_fs::vfs::*; use rcore_fs::vfs::*;
use super::ioctl::*;
use crate::sync::Condvar; use crate::sync::Condvar;
use crate::sync::SpinNoIrqLock as Mutex; use crate::sync::SpinNoIrqLock as Mutex;
use super::ioctl::*;
#[derive(Default)] #[derive(Default)]
pub struct Stdin { pub struct Stdin {

View File

@ -1,10 +1,10 @@
//! Kernel shell //! Kernel shell
use crate::arch::io;
use crate::fs::ROOT_INODE; use crate::fs::ROOT_INODE;
use crate::process::*; use crate::process::*;
use alloc::string::String; use alloc::string::String;
use alloc::vec::Vec; use alloc::vec::Vec;
use crate::arch::io;
#[cfg(not(feature = "run_cmdline"))] #[cfg(not(feature = "run_cmdline"))]
pub fn add_user_shell() { pub fn add_user_shell() {
@ -47,7 +47,7 @@ pub fn add_user_shell() {
&inode, &inode,
cmdline.split(' ').map(|s| s.into()).collect(), cmdline.split(' ').map(|s| s.into()).collect(),
Vec::new(), Vec::new(),
Vec::new() Vec::new(),
)); ));
} }

View File

@ -784,14 +784,18 @@ impl Process {
_ => {} _ => {}
} }
match fd_dir_path { match fd_dir_path {
"/proc/self/fd" =>{ "/proc/self/fd" => {
let fd:u32= fd_name.parse::<u32>().unwrap(); let fd: u32 = fd_name.parse::<u32>().unwrap();
let fd_path= match self.files.get(&(fd as usize)).unwrap() { let fd_path = match self.files.get(&(fd as usize)) {
FileLike::File(file) => Some(&file.path), Some(FileLike::File(file)) => Some(&file.path),
_ => None, _ => return Err(SysError::ENOENT),
}; };
info!("lookup_inode_at:BEG /proc/sefl/fd {}, path {}", fd, fd_path.unwrap()); info!(
if(fd_path.is_some()) { "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))); return Ok(Arc::new(Pseudo::new(fd_path.unwrap(), FileType::SymLink)));
} else { } else {
{} {}

2
user

@ -1 +1 @@
Subproject commit b6a347750531be125583107b6d0fc307366fdcc9 Subproject commit bb73d6ecce1ab0e6fae692c51e4335772b0335d4