1use linux_info::storage::{MountPoints, MountPoint};
6
7
8fn main() {
9 let mt = MountPoints::read().expect("could not read /proc/self/mountinfo");
10 println!("{:<15} {:>10} {:>10} {:>10} {}", "Filesystem", "Size", "Used", "Avail", "Mounted on");
11 for point in mt.points() {
12 let _ = print_point(point);
13 }
14}
15
16fn print_point(point: MountPoint) -> Option<()> {
18 let stat = point.stats().ok()?;
19
20 if !stat.has_blocks() {
21 return None
22 }
23
24 println!(
25 "{:<15} {:>10} {:>10} {:>10} {}",
26 point.mount_source()?,
27 format!("{:.1}", stat.total()?),
28 format!("{:.1}", stat.available()?),
29 format!("{:.1}", stat.used()?),
30 point.mount_point()?
31 );
32
33 Some(())
34}