Support mmap in initfs

This commit is contained in:
bjorn3
2025-12-12 21:45:10 +01:00
parent a7047c3f28
commit d5ff91f248
8 changed files with 58 additions and 11 deletions
+7 -1
View File
@@ -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.
+1
View File
@@ -73,6 +73,7 @@ pub struct Header {
pub inode_count: U16,
pub bootstrap_entry: U64,
pub initfs_size: U64,
pub page_size: U16,
}
const _: () = {