Crates.io | proc_getter |
lib.rs | proc_getter |
version | 0.0.3 |
source | src |
created_at | 2019-11-16 11:25:17.277684 |
updated_at | 2019-11-24 17:34:13.414064 |
description | make retriving infomations from /proc/* easier |
homepage | |
repository | https://github.com/pearzl/proc_getter |
max_upload_size | |
id | 181757 |
size | 83,931 |
This crate is longer being maintained on crates.io.
Because it is renamed to (lpfs)[https://github.com/pearzl/lpfs].
You can find these code at proc_getter branch of lpfs.
The goal of this repo is to make retriving system informations reside in proc file system easier.
use proc_getter::cmdline::*;
use proc_getter::pid::cmdline::*;
fn main() {
// /proc/cmdline
println!("{:?}", cmdline());
// /proc/1/cmdline
println!("{:?}", cmdline_of(1));
}
rust 2018 (rustc 1.31.0 +)
I try to make this support any distribution with 3.+ kernel version.
The proc file system is not the same among different version of kernel and distribution. Some code may not works on your system.
Therefore, almost every function return Result for the reason that specified file may not exist in your system. It is possible that specidied file is exist but still return Err. I condider this case as a mistake and should be fix, PR and issue is welcomed.
Majority files listed here shoule be supported. Detail information is listed blow.
/proc/*
file | status | file | status | file | status |
---|---|---|---|---|---|
buddyinfo | ✔ | cmdline | ✔ | consoles | ✔ |
cpuinfo | ✔ | crypto | ✔ | devices | ✔ |
diskstates | ✔ | dma | ✔ | execdomains | ✔ |
fb | ✔ | filesystems | ✔ | interrupts | ✔ |
iomem | ✔ | ioports | ✔ | kcore | ✔ |
kmsg | ❌ | loadavg | ✔ | locks | ✔ |
mdstat | ✔ | meminfo | ✔ | misc | ✔ |
modules | ✔ | mounts | ✔ | mtrr | ✔ |
partitions | ✔ | slabinfo | ✔ | stat | ✔ |
swaps | ✔ | uptime | ✔ | version | ✔ |
self | ✔ | sysrq-trigger | ❌ |
/proc/${pid}/*
file | status | file | status | file | status |
---|---|---|---|---|---|
cmdline | ✔ | cwd | ✔ | environ | ✔ |
exe | ✔ | fd | ❌ | maps | ✔ |
root | ✔ | stat | ✔ | statm | ✔ |
status | ✔ |
The table below lists the implemented files.
directory | file |
---|---|
acpi | wakeup |
driver | rtc |
net | arp, dev, dev_mcast, iptables_name, netstat |
route |
Note: Not fully tested.