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

master
chyyuu 6 years ago
parent 28aaae53b9
commit 19200e40d0

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

@ -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;

Loading…
Cancel
Save