Skip to content

Commit

Permalink
Check even if udev does not know about the device
Browse files Browse the repository at this point in the history
When gathering udev info on a device if that failed it
would short circuit the checks.  This should prevent that
  • Loading branch information
cholcombe973 committed Sep 20, 2017
1 parent 87291d2 commit eb67aa9
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/test_disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ fn run_checks(device_info: &Device) -> Result<Status> {
match device.exists() {
true => {
debug!("udev Probing device {:?}", device);
let info = block_utils::get_device_info(&device).map_err(|e| {
Error::new(ErrorKind::Other, e)
})?;

let info = block_utils::get_device_info(&device);
let corrupted = match check_writable(&s) {
Ok(_) => false,
Err(e) => {
Expand All @@ -114,10 +111,21 @@ fn run_checks(device_info: &Device) -> Result<Status> {
}
};
if corrupted {
let check_result = check_filesystem(&info.fs_type, &device);
debug!("check_filesystem result: {:?}", check_result);
let repair_result = repair_filesystem(&info.fs_type, &device);
debug!("repair_result result: {:?}", repair_result);
// If udev doesn't know about the disk we can't repair it right?
if let Ok(udev_info) = info {
let check_result =
check_filesystem(&udev_info.fs_type, &device);
debug!("check_filesystem result: {:?}", check_result);
let repair_result =
repair_filesystem(&udev_info.fs_type, &device);
debug!("repair_result result: {:?}", repair_result);
} else {
error!(
"Failed to gather udev info on {:?}. error: {:?}",
device,
info
);
}
}
}
false => {
Expand Down

0 comments on commit eb67aa9

Please sign in to comment.