in below/procfs/src/lib.rs [395:418]
fn read_mount_info_map(&self) -> Result<HashMap<String, MountInfo>> {
// Map contains a MountInfo object corresponding to the first
// mount of each mount source. The first mount is what shows in
// the 'df' command and reflects the usage of the device.
let path = self.path.join("self/mountinfo");
let file = File::open(&path).map_err(|e| Error::IoError(path.clone(), e))?;
let buf_reader = BufReader::new(file);
let mut mount_info_map: HashMap<String, MountInfo> = HashMap::new();
for line in buf_reader.lines() {
let line = line.map_err(|e| Error::IoError(path.clone(), e))?;
if let Ok(mount_info) = self.process_mount_info(&path, &line) {
if let Some(mount_source) = mount_info.mount_source.clone() {
mount_info_map.entry(mount_source).or_insert(mount_info);
}
}
}
if mount_info_map.is_empty() {
Err(Error::InvalidFileFormat(path))
} else {
Ok(mount_info_map)
}
}