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

Function ensure_umoci_binary

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

Source from the content-addressed store, hash-verified

842}
843
844fn ensure_umoci_binary(rootfs: &Path) -> Result<(), String> {
845 let path = rootfs.join(SANDBOX_UMOCI_PATH.trim_start_matches('/'));
846 if UMOCI.is_empty() {
847 if !path.exists() {
848 return Err(
849 "umoci not embedded. Build openshell-driver-vm with OPENSHELL_VM_RUNTIME_COMPRESSED_DIR set and run `mise run vm:setup` first"
850 .to_string(),
851 );
852 }
853 } else {
854 if let Some(parent) = path.parent() {
855 fs::create_dir_all(parent).map_err(|e| format!("create {}: {e}", parent.display()))?;
856 }
857
858 let umoci =
859 zstd::decode_all(Cursor::new(UMOCI)).map_err(|e| format!("decompress umoci: {e}"))?;
860 fs::write(&path, umoci).map_err(|e| format!("write {}: {e}", path.display()))?;
861 }
862
863 #[cfg(unix)]
864 {
865 use std::os::unix::fs::PermissionsExt as _;
866
867 fs::set_permissions(&path, fs::Permissions::from_mode(0o755))
868 .map_err(|e| format!("chmod {}: {e}", path.display()))?;
869 }
870
871 Ok(())
872}
873
874fn require_rootfs_path(rootfs: &Path, relative: &str) -> Result<(), String> {
875 let candidate = rootfs.join(relative.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