MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / ensure_supervisor_binary

Function ensure_supervisor_binary

crates/openshell-driver-vm/src/rootfs.rs:814–842  ·  view source on GitHub ↗
(rootfs: &Path)

Source from the content-addressed store, hash-verified

812}
813
814fn ensure_supervisor_binary(rootfs: &Path) -> Result<(), String> {
815 let path = rootfs.join(SANDBOX_SUPERVISOR_PATH.trim_start_matches('/'));
816 if SUPERVISOR.is_empty() {
817 if !path.exists() {
818 return Err(
819 "sandbox supervisor not embedded. Build openshell-driver-vm with OPENSHELL_VM_RUNTIME_COMPRESSED_DIR set and run `mise run vm:setup && mise run vm:supervisor` first"
820 .to_string(),
821 );
822 }
823 } else {
824 if let Some(parent) = path.parent() {
825 fs::create_dir_all(parent).map_err(|e| format!("create {}: {e}", parent.display()))?;
826 }
827
828 let supervisor = zstd::decode_all(Cursor::new(SUPERVISOR))
829 .map_err(|e| format!("decompress supervisor: {e}"))?;
830 fs::write(&path, supervisor).map_err(|e| format!("write {}: {e}", path.display()))?;
831 }
832
833 #[cfg(unix)]
834 {
835 use std::os::unix::fs::PermissionsExt as _;
836
837 fs::set_permissions(&path, fs::Permissions::from_mode(0o755))
838 .map_err(|e| format!("chmod {}: {e}", path.display()))?;
839 }
840
841 Ok(())
842}
843
844fn ensure_umoci_binary(rootfs: &Path) -> Result<(), String> {
845 let path = rootfs.join(SANDBOX_UMOCI_PATH.trim_start_matches('/'));

Callers 1

prepare_sandbox_rootfsFunction · 0.85

Calls 2

existsMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected