src/tools/disks.rs; use correct subdir to check holders

This commit is contained in:
Dietmar Maurer 2020-06-05 09:27:48 +02:00
parent 4c1e8855cc
commit f03a0e509e
1 changed files with 13 additions and 11 deletions

View File

@ -436,17 +436,19 @@ impl Disk {
/// another kernel driver like the device mapper. /// another kernel driver like the device mapper.
pub fn has_holders(&self) -> io::Result<bool> { pub fn has_holders(&self) -> io::Result<bool> {
Ok(*self Ok(*self
.info .info
.has_holders .has_holders
.get_or_try_init(|| -> io::Result<bool> { .get_or_try_init(|| -> io::Result<bool> {
for entry in std::fs::read_dir(self.syspath())? { let mut subdir = self.syspath().to_owned();
match entry?.file_name().as_bytes() { subdir.push("holders");
b"." | b".." => (), for entry in std::fs::read_dir(subdir)? {
_ => return Ok(true), match entry?.file_name().as_bytes() {
} b"." | b".." => (),
} _ => return Ok(true),
Ok(false) }
})?) }
Ok(false)
})?)
} }
/// Check if this disk is mounted. /// Check if this disk is mounted.