mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-11-28 17:45:10 +01:00
hmmmm
This commit is contained in:
parent
5a74cf91ae
commit
73edcd9b29
44
src/collection/processes/linux/gpu.rs
Normal file
44
src/collection/processes/linux/gpu.rs
Normal file
@ -0,0 +1,44 @@
|
||||
//! Extract GPU process information on Linux.
|
||||
|
||||
use std::{os::fd::BorrowedFd, path::Path};
|
||||
|
||||
use hashbrown::HashSet;
|
||||
use rustix::fs::{Mode, OFlags};
|
||||
|
||||
use crate::collection::processes::Pid;
|
||||
|
||||
fn is_drm_fd(fd: &BorrowedFd<'_>) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Get fdinfo for a process given the PID.
|
||||
///
|
||||
/// Based on the method from nvtop [here](https://github.com/Syllo/nvtop/blob/339ee0b10a64ec51f43d27357b0068a40f16e9e4/src/extract_processinfo_fdinfo.c#L101).
|
||||
pub(crate) fn get_fdinfo(pid: Pid, seen_fds: &mut HashSet<u32>) {
|
||||
let fdinfo_path = format!("/proc/{pid}/fdinfo");
|
||||
let fdinfo_path = Path::new(&fdinfo_path);
|
||||
|
||||
let Ok(fd_entries) = std::fs::read_dir(fdinfo_path) else {
|
||||
return;
|
||||
};
|
||||
|
||||
for fd_entry in fd_entries.flatten() {
|
||||
let path = fd_entry.path();
|
||||
|
||||
if !path.is_file() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if !(path.to_string_lossy().chars().all(|c| c.is_ascii_digit())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let Ok(fd) = rustix::fs::openat(
|
||||
pid_path.as_path(),
|
||||
OFlags::PATH | OFlags::DIRECTORY | OFlags::CLOEXEC,
|
||||
Mode::empty(),
|
||||
) else {
|
||||
continue;
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
//! Process data collection for Linux.
|
||||
|
||||
mod gpu;
|
||||
mod process;
|
||||
|
||||
use std::{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user