From 0fc2c934d9e65f3f977a3d48c03a914db166af96 Mon Sep 17 00:00:00 2001 From: Szymon Walter Date: Mon, 19 Mar 2018 19:33:20 +0100 Subject: [PATCH] add offset argument to BlockGroupDescriptor::find_... --- src/sys/block_group.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sys/block_group.rs b/src/sys/block_group.rs index cf7445b..05e0a95 100644 --- a/src/sys/block_group.rs +++ b/src/sys/block_group.rs @@ -56,14 +56,14 @@ impl BlockGroupDescriptor { Ok(descr) } - pub fn find_descriptor_table<'a, E>( + pub unsafe fn find_descriptor_table<'a, E>( haystack: &'a Buffer, + offset: usize, count: usize, ) -> Result<(Vec, usize), Error> where Error: From, { - let offset = 2048; // TODO: this assumes a block size let end = offset + count * mem::size_of::(); if haystack.len() < end { return Err(Error::OutOfBounds(end)); @@ -88,7 +88,8 @@ mod tests { #[test] fn find() { let buffer = vec![0_u8; 4096]; - let table = BlockGroupDescriptor::find_descriptor_table(&buffer, 8); + let table = + BlockGroupDescriptor::find_descriptor_table(&buffer, 2048, 8); assert!( table.is_ok(), "Err({:?})",