1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-22 08:06:17 +04:00

impl pseudo INode '/proc/self/fd/FD_NUM' for rustc app

This commit is contained in:
chyyuu 2019-05-03 13:06:18 +08:00
parent 28aaae53b9
commit 19200e40d0
2 changed files with 19 additions and 2 deletions

View File

@ -10,7 +10,7 @@ pub struct FileHandle {
inode: Arc<INode>,
offset: u64,
options: OpenOptions,
path: String,
pub path: String,
}
#[derive(Debug, Clone)]

View File

@ -776,12 +776,29 @@ impl Process {
dirfd as isize, self.cwd, path, follow
);
// hard code special path
let (fd_dir_path, fd_name) = split_path(&path);
match path {
"/proc/self/exe" => {
return Ok(Arc::new(Pseudo::new(&self.exec_path, FileType::SymLink)));
}
_ => {}
}
match fd_dir_path {
"/proc/self/fd" =>{
let fd:u32= fd_name.parse::<u32>().unwrap();
let fd_path= match self.files.get(&(fd as usize)).unwrap() {
FileLike::File(file) => Some(&file.path),
_ => None,
};
info!("lookup_inode_at:BEG /proc/sefl/fd {}, path {}", fd, fd_path.unwrap());
if(fd_path.is_some()) {
return Ok(Arc::new(Pseudo::new(fd_path.unwrap(), FileType::SymLink)));
} else {
{}
}
}
_ => {}
}
let follow_max_depth = if follow { FOLLOW_MAX_DEPTH } else { 0 };
if dirfd == AT_FDCWD {
@ -1392,5 +1409,5 @@ impl FdSet {
}
}
}
//pathname is interpreted relative to the current working directory(CWD)
const AT_FDCWD: usize = -100isize as usize;