diff --git a/src/fs.rs b/src/fs.rs new file mode 100644 index 0000000..2d80417 --- /dev/null +++ b/src/fs.rs @@ -0,0 +1,26 @@ +use error::Error; +use buffer::Buffer; +use sys::superblock::Superblock; + +/// Safe wrapper for raw sys structs +pub struct Ext2> { + buffer: B, + superblock: Option<(Superblock, usize)>, +} + +impl> Ext2 { + pub fn new(buffer: B) -> Ext2 { + Ext2 { + buffer, + superblock: None, + } + } + + pub fn init(&mut self) -> Result<(), Error> { + let superblock = Superblock::find(&self.buffer); + match superblock { + Ok(sb) => Ok(self.superblock = Some(sb)), + Err(err) => Err(err), + } + } +}