Debian Codegraph @

debian/rust-vendor/procfs/examples/mountinfo.rs

raw
1 use procfs::process::Process;
2 use std::collections::HashSet;
3
4 fn main() {
5 for mount in Process::myself().unwrap().mountinfo().unwrap() {
6 let (a, b): (HashSet<_>, HashSet<_>) = mount
7 .mount_options
8 .into_iter()
9 .chain(mount.super_options)
10 .partition(|&(_, ref m)| m.is_none());
11
12 println!(
13 "{} on {} type {} ({})",
14 mount.mount_source.unwrap_or_else(|| "None".to_string()),
15 mount.mount_point.display(),
16 mount.fs_type,
17 a.into_iter().map(|(k, _)| k).collect::<Vec<_>>().join(",")
18 );
19
20 for (opt, val) in b {
21 if let Some(val) = val {
22 println!(" {} = {}", opt, val);
23 } else {
24 println!(" {}", opt);
25 }
26 }
27 }
28 }