Support mmap in initfs
This commit is contained in:
+7
-1
@@ -182,7 +182,7 @@ impl<'initfs> InodeStruct<'initfs> {
|
||||
}
|
||||
|
||||
impl<'initfs> InitFs<'initfs> {
|
||||
pub fn new(base: &'initfs [u8]) -> Result<Self> {
|
||||
pub fn new(base: &'initfs [u8], required_page_size: Option<u16>) -> Result<Self> {
|
||||
let this = Self { base };
|
||||
|
||||
if base.len() < core::mem::size_of::<Header>() {
|
||||
@@ -214,6 +214,12 @@ impl<'initfs> InitFs<'initfs> {
|
||||
return Err(Error);
|
||||
}
|
||||
|
||||
if let Some(required_page_size) = required_page_size
|
||||
&& header.page_size.get() != required_page_size
|
||||
{
|
||||
return Err(Error);
|
||||
}
|
||||
|
||||
// From now on, we can be completely sure that the header and inode tables offsets are
|
||||
// valid, and thus continue based on that assumption.
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ pub struct Header {
|
||||
pub inode_count: U16,
|
||||
pub bootstrap_entry: U64,
|
||||
pub initfs_size: U64,
|
||||
pub page_size: U16,
|
||||
}
|
||||
|
||||
const _: () = {
|
||||
|
||||
Reference in New Issue
Block a user