Merge branch 'fix_virtio_blkd_empty_disk' into 'master'
virtio-blkd: Do not crash when the disk is empty See merge request redox-os/drivers!164
This commit is contained in:
@@ -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};
|
||||
|
||||
@@ -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<Option<usize>> {
|
||||
todo!()
|
||||
fn fstat(&mut self, id: usize, _stat: &mut syscall::Stat) -> syscall::Result<Option<usize>> {
|
||||
match self.handles.get_mut(&id).ok_or(Error::new(EBADF))? {
|
||||
Handle::List { .. } => Ok(Some(0)),
|
||||
Handle::Disk { .. } | Handle::Partition { .. } => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn dup(&mut self, _old_id: usize, _buf: &[u8]) -> Result<Option<usize>> {
|
||||
|
||||
Reference in New Issue
Block a user