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

@@ -170,3 +170,16 @@ fn one_read_fills_the_buffer_across_blocks() {
assert_eq!(fs.read(h, &mut buf), Some(total - 10_000));
assert_eq!(fs.read(h, &mut buf), Some(0));
}
#[test]
fn holes_read_as_zeros() {
let dir = scratch("sparse");
// Data, then a zero block mkfs stores as a hole, then data again.
let mut data = std::vec![b'x'; 4096];
data.extend(std::vec![0u8; 4096]);
data.extend(b"end");
std::fs::write(dir.join("root/sparse.bin"), &data).unwrap();
let Some(img) = mkfs(&dir, MKFS_FEATURES) else { return };
let mut fs = Ext4::mount(FileDisk(img)).expect("mount");
assert_eq!(read_all(&mut fs, b"sparse.bin"), data);
}

View File

@@ -67,10 +67,14 @@ fn nothing_works_before_attaching() {
}
#[test]
fn a_client_attaches_once() {
fn attaching_again_hands_back_the_same_buffer() {
let mut s = server();
Client::attach(&mut s, 0);
assert_eq!(call(&mut s, 0, StorageRequest::Attach).0, StorageResponse::Error);
let (first, cap) = call(&mut s, 0, StorageRequest::Attach);
assert_eq!(call(&mut s, 0, StorageRequest::Attach), (first, cap));
// Not a new client: the other seven places are still free.
for badge in 1..8 {
assert!(matches!(call(&mut s, badge, StorageRequest::Attach).0, StorageResponse::Attached { .. }));
}
}
#[test]