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:
@@ -23,6 +23,8 @@ pub trait Buffers {
|
||||
struct Client {
|
||||
badge: usize,
|
||||
buf: &'static mut [u8],
|
||||
/// What maps `buf`, sent again when the same client attaches again.
|
||||
cap: Option<CapSlot>,
|
||||
}
|
||||
|
||||
pub struct StorageServer<F: FileSystem, B: Buffers> {
|
||||
@@ -77,9 +79,11 @@ impl<F: FileSystem, B: Buffers> StorageServer<F, B> {
|
||||
self.clients.iter_mut().flatten().find(|c| c.badge == badge)
|
||||
}
|
||||
|
||||
/// A client attaching again gets its buffer again: the programs a shell
|
||||
/// runs one after another share its badge.
|
||||
fn attach(&mut self, badge: usize) -> (StorageResponse, Option<CapSlot>) {
|
||||
if self.client(badge).is_some() {
|
||||
return (StorageResponse::Error, None);
|
||||
if let Some(c) = self.client(badge) {
|
||||
return (StorageResponse::Attached { size: c.buf.len() }, c.cap);
|
||||
}
|
||||
let Some(index) = self.clients.iter().position(Option::is_none) else {
|
||||
return (StorageResponse::Error, None);
|
||||
@@ -89,7 +93,7 @@ impl<F: FileSystem, B: Buffers> StorageServer<F, B> {
|
||||
};
|
||||
let size = buf.len();
|
||||
if let Some(slot) = self.clients.get_mut(index) {
|
||||
*slot = Some(Client { badge, buf });
|
||||
*slot = Some(Client { badge, buf, cap });
|
||||
}
|
||||
(StorageResponse::Attached { size }, cap)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user