mirror of
https://github.com/vhaudiquet/ecrou.git
synced 2026-11-12 22:22:44 +00:00
refactor: drop the dead shell probe and unused engine bindings
utils::detect_shell lost to the image probe; krun_set_root and krun_set_env have had no caller since the root crossed as a block device. Unused FFI bindings rot where they stand.
This commit is contained in:
1 parent
a368a2e7cb
commit
dabe66994b
2 files changed
+2
-48
No files matched your search
@@ -117,18 +117,6 @@ impl Krun {
|
||||
krun_ret(unsafe { f(ctx_id, vcpus, ram_mib) }, "krun_set_vm_config")
|
||||
}
|
||||
|
||||
/// `krun_set_root`: the virtiofs share that becomes the guest root.
|
||||
pub fn set_root(&self, ctx_id: u32, root: &Path) -> Result<()> {
|
||||
let root_c = path_cstring(root)?;
|
||||
let f = symbol!(
|
||||
self.lib,
|
||||
b"krun_set_root\0",
|
||||
unsafe extern "C" fn(u32, *const c_char) -> i32
|
||||
);
|
||||
// Safety: root_c is NUL-terminated and outlives the call.
|
||||
krun_ret(unsafe { f(ctx_id, root_c.as_ptr()) }, "krun_set_root")
|
||||
}
|
||||
|
||||
/// `krun_add_disk`: a raw image as a virtio-blk device. An engine
|
||||
/// built without the blk feature ships no such symbol, and the
|
||||
/// lookup failure names that, not age.
|
||||
@@ -264,18 +252,6 @@ impl Krun {
|
||||
)
|
||||
}
|
||||
|
||||
/// `krun_set_env`: extra environment for the payload.
|
||||
pub fn set_env(&self, ctx_id: u32, envp: &[String]) -> Result<()> {
|
||||
let envp_c = CArgs::build(envp)?;
|
||||
let f = symbol!(
|
||||
self.lib,
|
||||
b"krun_set_env\0",
|
||||
unsafe extern "C" fn(u32, *const *const c_char) -> i32
|
||||
);
|
||||
// Safety: envp_c is NUL-terminated and outlives the call.
|
||||
krun_ret(unsafe { f(ctx_id, envp_c.ptr()) }, "krun_set_env")
|
||||
}
|
||||
|
||||
/// `krun_set_console_output`: redirect the guest console to a file.
|
||||
pub fn set_console_output(&self, ctx_id: u32, path: &Path) -> Result<()> {
|
||||
let path_c = path_cstring(path)?;
|
||||
@@ -437,9 +413,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn krun_ret_maps_negated_errno() {
|
||||
let err = krun_ret(-2, "krun_set_root").unwrap_err();
|
||||
let err = krun_ret(-2, "krun_set_vm_config").unwrap_err();
|
||||
let msg = format!("{err:#}");
|
||||
assert!(msg.contains("krun_set_root failed"), "{msg}");
|
||||
assert!(msg.contains("krun_set_vm_config failed"), "{msg}");
|
||||
assert!(msg.contains("No such file"), "{msg}");
|
||||
}
|
||||
}
|
||||
@@ -160,28 +160,6 @@ pub fn map_oci_arch(arch: &str) -> String {
|
||||
Arch::from_str(arch).oci_name().to_string()
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Shell detection
|
||||
// ============================================================================
|
||||
|
||||
/// Detect the best available shell in a rootfs
|
||||
/// Checks for bash first, falls back to sh
|
||||
/// Returns the path relative to the rootfs (e.g., "/bin/bash")
|
||||
pub fn detect_shell(rootfs: &Path) -> &'static str {
|
||||
// Check for bash first (preferred)
|
||||
if rootfs.join("bin/bash").exists() {
|
||||
"/bin/bash"
|
||||
} else if rootfs.join("bin/sh").exists() {
|
||||
"/bin/sh"
|
||||
} else if rootfs.join("usr/bin/bash").exists() {
|
||||
"/usr/bin/bash"
|
||||
} else if rootfs.join("usr/bin/sh").exists() {
|
||||
"/usr/bin/sh"
|
||||
} else {
|
||||
"/bin/sh" // Will fail with clear error if not present
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in new issue
Block a user