Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
GyulyVGC committed Mar 4, 2024
1 parent 9225dd9 commit 4735d68
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/platform/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn get_all_processes() -> Vec<Process> {
fn build_inode_process_map(processes: Vec<Process>) -> HashMap<u64, PidName> {
let mut map: HashMap<u64, PidName> = HashMap::new();
for process in processes {
let read = rustix::fs::openat(
let stat = rustix::fs::openat(
&process.fd,
"stat",
OFlags::RDONLY | OFlags::CLOEXEC,
Expand All @@ -99,6 +99,7 @@ fn build_inode_process_map(processes: Vec<Process>) -> HashMap<u64, PidName> {
let mut dir = rustix::fs::Dir::read_from(&dir_fd).unwrap();
let mut socket_inodes = Vec::new();
println!("dir_fd: {:?}", dir_fd);
println!("dir: {:?}", dir);
if let Some(Ok(entry)) = dir.next() {
let name = entry.file_name().to_string_lossy();
println!("\tfile name: {:?}", name);
Expand All @@ -110,7 +111,7 @@ fn build_inode_process_map(processes: Vec<Process>) -> HashMap<u64, PidName> {
}
}
}
if let Some(pid_name) = PidName::from_read(File::from(read)) {
if let Some(pid_name) = PidName::from_file(File::from(stat)) {
println!("pid_name: {:?}", pid_name);
for inode in socket_inodes {
map.insert(inode, pid_name.clone());
Expand Down Expand Up @@ -140,7 +141,7 @@ struct PidName {
}

impl PidName {
fn from_read<R: Read>(mut r: R) -> Option<Self> {
fn from_file<R: Read>(mut r: R) -> Option<Self> {
// read in entire thing, this is only going to be 1 line
let mut buf = Vec::with_capacity(512);
r.read_to_end(&mut buf).unwrap();
Expand Down

0 comments on commit 4735d68

Please sign in to comment.