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

@@ -19,11 +19,12 @@ use types::address::VirtualAddress;
use types::apps::reply;
use types::bounded::CapSlot;
/// Where init's manifest put them: `uses`, then storage.
/// Where init's manifest put them: `uses`, then storage, then signing out.
const TERMINAL: CapSlot = CapSlot::const_new(0);
const PERMISSION: CapSlot = CapSlot::const_new(1);
/// The owner's files, `/home`: the shell's `/`.
/// The user's files, their `home`: the shell's `/`.
const HOME: CapSlot = CapSlot::const_new(2);
const SESSION: CapSlot = CapSlot::const_new(3);
/// Bits on the shell's notification: the program died (its death watch is
/// unbadged), or Ctrl+C was typed (the terminal's copy).
@@ -227,7 +228,7 @@ fn run(sh: &mut Shell, line: &str) {
match args.first().copied() {
None => {}
Some("help") => {
println!("built-ins: help, echo <text>, clear, cd <dir>, pwd");
println!("built-ins: help, echo <text>, clear, cd <dir>, pwd, logout");
println!("apps: apps, install <folder>, allow|revoke <app id> <capability>");
println!("anything else runs an app: try ls, cat readme.txt, snake");
println!("apps see the current directory, read-only, and only what you allowed");
@@ -244,6 +245,19 @@ fn run(sh: &mut Shell, line: &str) {
Some("pwd") => println!("{}", sh.cwd),
Some("echo") => println!("{}", Joined(&args[1..])),
Some("clear") => libkos::terminal::clear(TERMINAL),
// Init stops this shell and everything it ran, and the lock
// screen comes back.
Some("logout") => {
libkos::terminal::clear(TERMINAL);
if syscall::send_msg(SESSION, [types::spawn::SIGN_OUT, 0, 0, 0], None).is_err() {
println!("logout: cannot sign out");
return;
}
// No prompt over the lock screen: wait to be stopped.
loop {
let _ = syscall::wait(sh.done);
}
}
Some(_) => run_program(sh, args),
}
}