feat(storage): ext4-only disk via mkfs.ext4 -d; drop FAT16; feature-gated mount (ro on unknown ro_compat); ext4 read spans blocks, delete clears inode, mkdir counts dir; virtio-blk writes; test-qemu e2fsck gate
This commit is contained in:
@@ -12,9 +12,15 @@ use libkos::syscall;
|
||||
use types::bounded::CapSlot;
|
||||
use types::budget::Limits;
|
||||
|
||||
/// Where init put them (see init's manifest: spawn endpoint, then control).
|
||||
const INIT: CapSlot = CapSlot::const_new(0);
|
||||
const CONTROL: CapSlot = CapSlot::const_new(1);
|
||||
/// Where init put them (see init's manifest: `uses`, the spawn endpoint,
|
||||
/// then control).
|
||||
const STORAGE: CapSlot = CapSlot::const_new(0);
|
||||
const INIT: CapSlot = CapSlot::const_new(1);
|
||||
const CONTROL: CapSlot = CapSlot::const_new(2);
|
||||
/// Where storage's buffer is mapped.
|
||||
const STORAGE_BUF_VA: usize = 0x0180_0000;
|
||||
/// Read back from the disk image by scripts/test-qemu.sh.
|
||||
const NOTE: &[u8] = b"written by k-os on ext4\n";
|
||||
|
||||
/// Over half the allowance (128 pages), so a second one fits only after
|
||||
/// the first has died and its limits came back.
|
||||
@@ -31,7 +37,28 @@ fn run_hello(died: CapSlot) -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// A file written through storage, which the host then checks with e2fsck.
|
||||
fn write_a_file() -> Result<(), &'static str> {
|
||||
let mut fs = libkos::fs::Storage::attach(STORAGE, STORAGE_BUF_VA).map_err(|_| "cannot attach to storage")?;
|
||||
let h = fs.create(b"selftest.txt").map_err(|_| "cannot create a file")?;
|
||||
if fs.write(h, NOTE) != Ok(NOTE.len()) {
|
||||
return Err("short write");
|
||||
}
|
||||
fs.close(h).map_err(|_| "close failed")?;
|
||||
let h = fs.open(b"selftest.txt").map_err(|_| "cannot reopen the file")?;
|
||||
let mut back = [0u8; 64];
|
||||
let n = fs.read(h, &mut back).map_err(|_| "read failed")?;
|
||||
fs.close(h).map_err(|_| "close failed")?;
|
||||
if &back[..n] != NOTE {
|
||||
return Err("read back something else");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn check() -> Result<(), &'static str> {
|
||||
write_a_file()?;
|
||||
libkos::println!("spawntest: a file written to ext4 reads back: ok");
|
||||
|
||||
let died = syscall::create_notification().map_err(|_| "no notification")?;
|
||||
run_hello(died)?;
|
||||
libkos::println!("spawntest: spawned program runs and its death is heard: ok");
|
||||
|
||||
Reference in New Issue
Block a user