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