๐ Executables โ
The executable crate defines the native executable contract and the launcher used across Core.
Role โ
- Defines
ExecutableTraitand typedGET_MAIN_FUNCTIONcommand contract. - Provides
execute(...)orchestration: permission checks, task spawn, and standard stream propagation.
Boundaries โ
- In scope: executable ABI contract, launch permission logic, standard stream helper type.
- Out of scope: executable UI/business logic and shell-specific command parsing.
Internal structure โ
traits.rs:ExecutableTrait,ExecutableWrapper,mount_executables!, command definition.lib.rs: launch path (execute) + execution permission helpers.standard.rs:Standardabstraction (open,duplicate,read_line,close).arguments_parser.rs: argument helper support for executable crates.error.rs: launcher-level error type.
Runtime interaction โ
- Executables are mounted as character devices exposing
GET_MAIN_FUNCTION. execute(path, args, standard, spawner)fetches VFS statistics and checks execute permissions.- It opens executable file and requests main function via control command.
- It spawns a task and calls main with provided
Standardand argument vector. - It returns
task::JoinHandle<isize>to allow join/wait by caller.
Dependency model โ
- Core dependencies: File System, Virtual file system, Task, Users, Shared, Log, Internationalization.
Failure semantics โ
- Permission denial is explicit (
Error::PermissionDenied). - Missing main entrypoint yields
FailedToGetMainFunction. - Task spawn or VFS failures are mapped into crate error variants.
- Executable runtime errors are converted to negative
isizetask return values in spawned task closure.
Extension points โ
- New executable crates implement
ExecutableTraitand mount throughExecutableWrapperormount_executables!. buildingfeature gates additional build-time support without changing runtime core path.
Contract vs implementation โ
- Contract: executable = mounted character device that answers
GET_MAIN_FUNCTIONand receivesStandard + Vec<String>. - Current implementation: launcher uses VFS metadata + users/group checks and task spawn under current task context.
Limitations and trade-offs โ
- Contract is intentionally narrow (
mainonly), simplifying dispatch but leaving richer lifecycle hooks to higher layers. setuid-style override logic is constrained and permission-checked at launch time.