feat(users): per-user sealed folders users/<id>/{home,apps,data,permissions}; storage SET_USER/LOCK/PURGE; init sign-in/sign-out loop (purge fresh/removed/guest, seed from factory, session start/stop); shell logout; pm user+system app shelves; terminal SIGNED_OUT; per-program stack (gatekeeper 12p); 128K load scratch

This commit is contained in:
2026-10-28 01:08:50 +01:00
parent 29a25bd8c2
commit 91f7d28834
38 changed files with 1156 additions and 378 deletions

View File

@@ -141,6 +141,30 @@ impl Storage {
self.with_path(op::RMDIR, path, reply::OK).map(|_| ())
}
/// Init only, while nobody is signed in: removes the tree at `path`
/// (in `users/`) without its key.
pub fn purge(&mut self, path: &[u8]) -> Result<()> {
self.with_path(op::PURGE, path, reply::OK).map(|_| ())
}
/// Init only: whose areas the key about to be sent opens (see
/// `types::user`).
pub fn set_user(&mut self, id: u64, guest: bool) -> Result<()> {
self.expect([op::SET_USER, id as usize, usize::from(guest), 0], reply::OK).map(|_| ())
}
/// Init only: half (`half` 0 or 1) of the master key, or with `seed` of
/// the seed for storage's randomness.
pub fn set_half(&mut self, seed: bool, half: usize, words: [usize; 2]) -> Result<()> {
let opcode = if seed { op::SET_SEED } else { op::SET_KEY };
self.expect([opcode, half, words[0], words[1]], reply::OK).map(|_| ())
}
/// Init only: the user signed out; every grant and file is gone.
pub fn lock(&mut self) -> Result<()> {
self.expect([op::LOCK, 0, 0, 0], reply::OK).map(|_| ())
}
pub fn close(&mut self, handle: FileHandle) -> Result<()> {
self.expect([op::CLOSE, handle.0 as usize, 0, 0], reply::OK).map(|_| ())
}