File: mountinfo.rs

package info (click to toggle)
rust-procfs 0.17.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 652 kB
  • sloc: makefile: 2
file content (28 lines) | stat: -rw-r--r-- 823 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use procfs::process::Process;
use std::collections::HashSet;

fn main() {
    for mount in Process::myself().unwrap().mountinfo().unwrap() {
        let (a, b): (HashSet<_>, HashSet<_>) = mount
            .mount_options
            .into_iter()
            .chain(mount.super_options)
            .partition(|&(_, ref m)| m.is_none());

        println!(
            "{} on {} type {} ({})",
            mount.mount_source.unwrap_or_else(|| "None".to_string()),
            mount.mount_point.display(),
            mount.fs_type,
            a.into_iter().map(|(k, _)| k).collect::<Vec<_>>().join(",")
        );

        for (opt, val) in b {
            if let Some(val) = val {
                println!("  {} = {}", opt, val);
            } else {
                println!("  {}", opt);
            }
        }
    }
}