cubefs/phase3: expose 'open'/'seal' as first-class CLI commands; document startup verification points
- cubesys/src/bin/cube.rs: route known command words (prog/write/run/ls/stat/
seal/open/query/begin/commit/rollback/stats/audit) straight to Session::exec
from argv, making the coordinate-addressed 'open <path> <K.Z.Y.X> <tf>' surface
(Phase 3 'open by CZYX + flags') a real CLI command, not REPL/script-only.
Verified: ./check green; cube open/cube bogus both behave; dispatch reaches
crypto/run layer over in-process and durable daemon (cubec) paths.
- STARTUP-README.md: add verification points per standing directive; mark
Phase 2 FS + durability VERIFIED, Phase 3 surface DONE, boot-substrate IN PROGRESS.
- Guest binaries synced to host HEAD f40b448 + this change; OS state now persists
on the cube store in the VM (/cubefs/c200/...), durable across daemon restart.
This commit is contained in:
@@ -30,11 +30,50 @@ use std::io::BufRead;
|
||||
|
||||
use cubesys::commands::Session;
|
||||
|
||||
/// Command words understood by the shared interpreter. When `cube`'s first
|
||||
/// argument is one of these, it is run as a single command against a fresh
|
||||
/// in-memory store (the same path as `cube repl`), so the OS / a script can
|
||||
/// invoke e.g. `cube open /c001/z001/y001/x001 001.001.001.001 none` directly
|
||||
/// — this is the Phase-3 "open by CZYX + flags" surface made a first-class
|
||||
/// CLI command rather than REPL-only.
|
||||
fn is_command_word(w: &str) -> bool {
|
||||
matches!(
|
||||
w,
|
||||
"prog"
|
||||
| "write"
|
||||
| "run"
|
||||
| "ls"
|
||||
| "stat"
|
||||
| "seal"
|
||||
| "open"
|
||||
| "query"
|
||||
| "begin"
|
||||
| "commit"
|
||||
| "rollback"
|
||||
| "stats"
|
||||
| "audit"
|
||||
)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
match args.get(1).map(|s| s.as_str()) {
|
||||
None => print_help(),
|
||||
Some("demo") => cubesys::demo::run(),
|
||||
// A direct command word (e.g. `cube open <path> <K.Z.Y.X> <tf>`): run it
|
||||
// against a fresh in-memory session and exit with the result. This makes
|
||||
// the coordinate-addressed API a real CLI surface the OS can call.
|
||||
Some(word) if is_command_word(word) => {
|
||||
let line = args[1..].join(" ");
|
||||
let mut session = Session::new();
|
||||
match session.exec(&line) {
|
||||
Ok(out) => println!("{out}"),
|
||||
Err(e) => {
|
||||
eprintln!("error: {e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some("repl") => {
|
||||
let mut session = Session::new();
|
||||
let stdin = std::io::stdin();
|
||||
|
||||
Reference in New Issue
Block a user