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 fa7820b commit f5bf317
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/platform/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,32 @@ 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 {
for proc in processes {
println!("P: {process:?}");
let stat = rustix::fs::openat(
&process.fd,
&proc.fd,
"stat",
OFlags::RDONLY | OFlags::CLOEXEC,
Mode::empty(),
)
.unwrap();
let dir_fd = rustix::fs::openat(
&process.fd,
&proc.fd,
"fd",
OFlags::RDONLY | OFlags::DIRECTORY | OFlags::CLOEXEC,
Mode::empty(),
)
.unwrap();
println!("dir_fd: {:?}", dir_fd);
let mut dir = rustix::fs::Dir::read_from(&dir_fd).unwrap();
println!("dir: {:?}", dir);
let mut socket_inodes = Vec::new();
if let Some(Ok(entry)) = dir.next() {
let name = entry.file_name().to_string_lossy();
if let Ok(fd) = RawFd::from_str(&name) {
println!("\t Found valid!! With name {:?}", name);
if let Some(socket_inode) =
get_socket_inodes(process.root, dir_fd.as_fd(), name.as_ref(), fd)
get_socket_inodes(proc.root, dir_fd.as_fd(), name.as_ref(), fd)
{
socket_inodes.push(socket_inode);
}
Expand Down

0 comments on commit f5bf317

Please sign in to comment.