#proc #linux #info #sys #procfs

archived lpfs

Retriving infomations from linux proc filesystem

2 unstable releases

0.2.0 Feb 2, 2020
0.1.0 Nov 24, 2019

#10 in #procfs

Download history 129/week @ 2022-03-10 97/week @ 2022-03-17 213/week @ 2022-03-24 78/week @ 2022-03-31 150/week @ 2022-04-07 204/week @ 2022-04-14 255/week @ 2022-04-21 116/week @ 2022-04-28 292/week @ 2022-05-05 213/week @ 2022-05-12 215/week @ 2022-05-19 297/week @ 2022-05-26 265/week @ 2022-06-02 399/week @ 2022-06-09 373/week @ 2022-06-16 501/week @ 2022-06-23

1,620 downloads per month
Used in perf_monitor

MIT license

205KB
3K SLoC

docs.rs crates.io license

The goal of this repo is to make retriving system informations reside in proc file system easier.

Example

use lpfs::proc::*;
use lpfs::pid::*;

fn main() {
    //  /proc/stat
    println!("{:?}", stat().unwrap());

    //  /proc/1/stat
    println!("{:?}", stat_of(1).unwrap());
}

Interface Design

eminence/procfs is a similar crate with different interface design.

Top-Level Files

Each file is retrived by a function reside in lpfs::proc with same name. For example, lpfs::proc::cmdline retrive from /proc/cmdline.

Process Directories

It's similar with top-level files, here is an example with stat.

function file
stat_of(pid) /proc/[pid]/stat
stat_self() /proc/self/stat
stat_of_task(pid, tid) /proc/[pid]/task/[tid]/stat
stat_self_task(tid) /proc/self/task/[tid]/stat

These functions reside in lpfs::pid

Minial Requirement

rust 2018 (rustc 1.31.0 +)

Supported

all linux distribution with 3.+ kernel version.

LICENSE

MIT

No runtime deps