🏃 Executables
The executables crate provides a set of utilities to define and launch native executables within the system.
Xila has two types of executables:
- Native executables: These are compiled directly for the target architecture, statically linked against Xila's binary.
- WASM executables: These are WebAssembly modules that run within a WASM runtime environment, providing portability across different architectures. These are handled by the WASM native executable.
Features
Key features include:
- Executable definition: Easily define native executables and their properties.
Dependencies
This crate relies on several core modules:
- Virtual file system: Access and manage executable files.
- Task: Create and manage tasks for running executables.
- Users: Handle permissions and ownership.
- Log: Log launch events and errors.
- Shared: Common utilities and types used across Xila.
Architecture
To launch a native executable, follow these steps:
- Define the Executable: Implement the executable either as a raw
file_system::CharacterDeviceor by using theexecutable::ExecutableTrait. - Mount the Executable: Attach the executable to the virtual file system as a character device.
- Launch the Executable: Call the
executable::execute()with the following parameters:- Path to the executable in the virtual file system
- Arguments to pass (as an owned slice of strings)
- Standard input, output, and error files (opened and wrapped in
executable::Standard; file duplicates can be used for redirection) - (Optional) Executable spawner identifier
The executable::execute() performs these steps:
- Retrieves task metadata (owner, group, etc.).
- Obtains the executable file's metadata from the virtual file system.
- Checks permissions for the executable file.
- Locates the executable entry point (
mainfunction) usingexecutable::GET_MAIN_FUNCTION. - Creates a new task to run the executable.
- Invokes the executable's
mainfunction with the provided arguments and standard streams in the new task context. - Returns a
task::JoinHandlefor the created task.
Known limitations
Currently, the executables crate doesn't have any known limitations except those inherited from the underlying modules it depends on.
Future improvements
No specific future improvements are planned for the executables crate at this time. However, general enhancements to the underlying modules may indirectly benefit this crate.