feat(userspace): shell runs programs (ls, cat) via spawn w/ terminal+storage+args page; ext4 holes read as zeros; storage re-attach same buffer

This commit is contained in:
2026-10-27 17:22:08 +01:00
parent 0fd568cdad
commit c603a578c0
22 changed files with 396 additions and 66 deletions

View File

@@ -106,9 +106,15 @@ impl<B: BlockDevice> FileSystem for Ext4<B> {
let mut block_buf = [0u8; 4096];
while done < to_read {
let offset = file.offset + done;
let phys_block = self.map_logical_block(&inode, (offset / bs) as u32)?;
if !read_block(&mut self.device, phys_block, self.sb.sectors_per_block(), &mut block_buf) {
return None;
// A block no extent maps is a hole (mkfs leaves zero blocks
// out): it reads as zeros.
match self.map_logical_block(&inode, (offset / bs) as u32) {
Some(phys_block) => {
if !read_block(&mut self.device, phys_block, self.sb.sectors_per_block(), &mut block_buf) {
return None;
}
}
None => block_buf.fill(0),
}
let byte_in_block = offset % bs;
let chunk = (to_read - done).min(bs - byte_in_block);