feat(storage): full file protocol over per-client shared region (badged clients, owned handles, clamped lengths, ReadOnly on unwritable disk); init loads via libkos::fs; drop boot shared buffer

This commit is contained in:
2026-10-27 12:42:37 +01:00
parent 694c675a40
commit 909b3f0503
19 changed files with 827 additions and 506 deletions

View File

@@ -6,4 +6,4 @@ pub mod server;
pub use codec::{Decode, Encode};
pub use executor::block_on;
pub use server::{serve, Server};
pub use server::{MALFORMED, Server, serve};

View File

@@ -18,6 +18,22 @@ pub trait Server {
/// server's device interrupt). `bits` are the signalled bits.
fn signal(&mut self, _bits: usize) {}
/// Handles one message, seeing who sent it (`badge`) and any
/// capability it carried; returns the reply and a capability to send
/// back with it. The default decodes the words and calls `handle`;
/// servers that track clients or pass capabilities override it.
fn handle_call(
&mut self,
_badge: usize,
words: [usize; 4],
_cap: Option<CapSlot>,
) -> ([usize; 4], Option<CapSlot>) {
match Self::Request::decode(words) {
Some(request) => (self.handle(request).encode(), None),
None => ([MALFORMED, 0, 0, 0], None),
}
}
/// Serves `endpoint` until receiving on it fails (it was destroyed or
/// the capability revoked), then returns why. Every `Call` gets a
/// reply, `[MALFORMED, ..]` if it does not decode; a one-way `Send` is
@@ -31,17 +47,12 @@ pub trait Server {
Err(e) => return e,
};
next = match message {
Received::Call { words, .. } => {
let reply = match Self::Request::decode(words) {
Some(request) => self.handle(request).encode(),
None => [MALFORMED, 0, 0, 0],
};
reply_recv(endpoint, reply, None)
Received::Call { badge, words, cap } => {
let (reply, give) = self.handle_call(badge, words, cap);
reply_recv(endpoint, reply, give)
}
Received::Message { words, .. } => {
if let Some(request) = Self::Request::decode(words) {
let _ = self.handle(request);
}
Received::Message { badge, words, cap } => {
let _ = self.handle_call(badge, words, cap);
receive_msg(endpoint)
}
Received::Signal { bits } => {