virtio-blkd: Do not crash when the disk is empty

This commit is contained in:
bjorn3
2024-06-13 17:22:23 +02:00
parent 75a9a3b48a
commit 32bcf25f99
2 changed files with 3 additions and 5 deletions
-2
View File
@@ -1,8 +1,6 @@
#![deny(trivial_numeric_casts, unused_allocation)]
#![feature(int_roundings)]
// TODO(andypython): driver panic with an empty disk.
use std::fs::File;
use std::io::{Read, Write};
use std::os::fd::{FromRawFd, RawFd};
+3 -3
View File
@@ -184,10 +184,10 @@ impl<'a> DiskScheme<'a> {
};
let part_table = partitionlib::get_partitions(&mut shim, LogicalBlockSize::Lb512)
.unwrap()
.expect("virtiod: no partitions found");
.ok()
.flatten();
this.part_table = Some(part_table);
this.part_table = part_table;
this
}
}