src/tools/disks.rs: new helper disk_by_name()

This commit is contained in:
Dietmar Maurer 2020-06-06 12:22:38 +02:00
parent ff30caeaf8
commit 042afd6e52
1 changed files with 6 additions and 0 deletions

View File

@ -106,6 +106,12 @@ impl DiskManage {
})
}
/// Get a `Disk` for a name in `/sys/block/<name>`.
pub fn disk_by_name(self: Arc<Self>, name: &str) -> io::Result<Disk> {
let syspath = format!("/sys/block/{}", name);
self.disk_by_sys_path(&syspath)
}
/// Gather information about mounted disks:
fn mounted_devices(&self) -> Result<&HashSet<dev_t>, Error> {
use std::os::unix::fs::MetadataExt;