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 6bc28fe commit b9a17fd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/platform/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ static KERNEL: Lazy<Option<String>> = Lazy::new(|| {

pub(crate) fn hi() {
let processes = get_all_processes();
for p in processes.iter() {
println!("P: {:?}", p);
}
println!();

let socket_inode_process_map = build_inode_process_map(processes);
for (inode, process) in socket_inode_process_map {
println!("{inode} {process:?}");
println!("I: {inode} P: {process:?}");
}
println!();
}

fn get_all_processes() -> Vec<Process> {
Expand Down Expand Up @@ -94,21 +99,17 @@ 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();
if let Some(Ok(entry)) = dir.next() {
println!("A");
let name = entry.file_name().to_string_lossy();
println!("name: {:?}", name);
println!("\tfile name: {:?}", name);
if let Ok(fd) = RawFd::from_str(&name) {
println!("B");
if let Some(socket_inode) =
get_socket_inodes(process.root, dir_fd.as_fd(), name.as_ref(), fd)
{
println!("C");
socket_inodes.push(socket_inode);
}
}
}
if let Some(pid_name) = PidName::from_read(File::from(read)) {
println!("D");
for inode in socket_inodes {
map.insert(inode, pid_name.clone());
}
Expand All @@ -117,6 +118,7 @@ fn build_inode_process_map(processes: Vec<Process>) -> HashMap<u64, PidName> {
map
}

#[derive(Debug)]
struct Process {
pid: i32,
fd: OwnedFd,
Expand Down

0 comments on commit b9a17fd

Please sign in to comment.