JFLib

plat/boot.rs#

Source: lib/plat/boot.rs

boot -- what build_rs.py builds into every program of an app, set up before the program's
own code runs (docs/PERMISSIONS.md, docs/VFS.md)

  start(&rt::boot::Boot) -> Result<(), exit code>   console programs (rt::main!): the
                          process entry registers it with rt::boot; name, app://, manifest
  name_and_assets(app, assets) -> Result<(), i32>    vfs::set_app_id, the JFA1 bundle as app://
  permissions(manifest) -> Result<Option<Key>, i32>  install the manifest; with fs.user the
                          paths on the command line are the user's (read + write, folders
                          with everything below; a local file:// URI as its path; not the
                          values of the library's VALUE_OPTS but --theme-file, --shot, --script); without
                          a manifest the process's key (policy::take_key: it answers the
                          questions of agent actions).  A `sandbox` line then hands the
                          manifest to the OS as well (sandbox::apply)

ui::main! calls name_and_assets and permissions itself (ui::boot, with the user's languages
in between) and keeps the key; rt::main! programs drop it, so their code cannot widen the
rules.  A refused bundle or manifest is reported on stderr: exit code 2.
  • fn start(b: &rt::boot::Boot) -> Result<(), i32> (rt::main!, through rt::boot) set a console program up: name, assets, permissions

  • fn name_and_assets(app: Option<&str>, assets: &'static [u8]) -> Result<(), i32> the app's name for its folders and its assets as app:// (Err: a damaged bundle)

  • fn permissions(manifest: Option<&str>) -> Result<Option<Key>, i32> install the app's manifest (None: the app has none, everything stays allowed) and grant the command line's paths; Some(key) for the caller to keep or drop (also without a manifest: policy::take_key)

  • fn grant_user(key: &Key, path: &str) a path the user handed over: a folder with everything below, else the file (with fs.user)

Source: docs/API.md in the JFLib repository.