Skip to content

Commit 65fe601

Browse files
committed
Return IO in unmount.
1 parent 84286ee commit 65fe601

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/fs.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use alloc::string::String;
33
use core::borrow::BorrowMut;
44
use core::cell::{Cell, RefCell};
5-
use core::char;
5+
use core::{char, mem, ptr};
66
use core::cmp;
77
use core::convert::TryFrom;
88
use core::fmt::Debug;
@@ -597,8 +597,13 @@ impl<IO: Read + Write + Seek, TP, OCC> FileSystem<IO, TP, OCC> {
597597
/// # Errors
598598
///
599599
/// `Error::Io` will be returned if the underlying storage object returned an I/O error.
600-
pub fn unmount(mut self) -> Result<(), Error<IO::Error>> {
601-
self.flush()
600+
pub fn unmount(mut self) -> Result<IO, Error<IO::Error>> {
601+
self.flush()?;
602+
603+
let mut disk = unsafe { ptr::read(self.disk.get_mut()) };
604+
mem::forget(self);
605+
disk.seek(SeekFrom::Start(0))?;
606+
Ok(disk)
602607
}
603608

604609
pub fn flush(&mut self) -> Result<(), Error<IO::Error>> {

0 commit comments

Comments
 (0)