diff --git a/storage/virtio-blkd/src/main.rs b/storage/virtio-blkd/src/main.rs
index 1c13166341..9d71b3a8d1 100644
--- a/storage/virtio-blkd/src/main.rs
+++ b/storage/virtio-blkd/src/main.rs
@@ -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};
diff --git a/storage/virtio-blkd/src/scheme.rs b/storage/virtio-blkd/src/scheme.rs
index e981de0369..3b37b547ff 100644
--- a/storage/virtio-blkd/src/scheme.rs
+++ b/storage/virtio-blkd/src/scheme.rs
@@ -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
}
}
@@ -210,10 +210,10 @@ impl<'a> SchemeBlockMut for DiskScheme<'a> {
// to the namespace id).
write!(list, "{}\n", 0).unwrap();
- let part_table = self.part_table.as_ref().unwrap();
-
- for part_num in 0..part_table.partitions.len() {
- write!(list, "{}p{}\n", 0, part_num).unwrap();
+ if let Some(part_table) = &self.part_table {
+ for part_num in 0..part_table.partitions.len() {
+ write!(list, "{}p{}\n", 0, part_num).unwrap();
+ }
}
let id = self.next_id;
@@ -389,8 +389,11 @@ impl<'a> SchemeBlockMut for DiskScheme<'a> {
todo!()
}
- fn fstat(&mut self, _id: usize, _stat: &mut syscall::Stat) -> syscall::Result