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

Function run_debugfs

crates/openshell-driver-vm/src/rootfs.rs:706–739  ·  view source on GitHub ↗
(image_path: &Path, command: &str)

Source from the content-addressed store, hash-verified

704}
705
706fn run_debugfs(image_path: &Path, command: &str) -> Result<(), String> {
707 let mut last_error = None;
708 for candidate in e2fs_tool_candidates("debugfs") {
709 let label = candidate.display().to_string();
710 let output = Command::new(&candidate)
711 .arg("-w")
712 .arg("-R")
713 .arg(command)
714 .arg(image_path)
715 .output();
716 match output {
717 Ok(output) if output.status.success() => return Ok(()),
718 Ok(output) => {
719 last_error = Some(format!(
720 "{label} failed with status {}\nstdout: {}\nstderr: {}",
721 output.status,
722 String::from_utf8_lossy(&output.stdout),
723 String::from_utf8_lossy(&output.stderr)
724 ));
725 }
726 Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
727 last_error = Some(format!("{label} not found"));
728 }
729 Err(err) => {
730 last_error = Some(format!("run {label}: {err}"));
731 }
732 }
733 }
734 Err(format!(
735 "debugfs command '{command}' failed for {}: {}. Install e2fsprogs (debugfs) and retry",
736 image_path.display(),
737 last_error.unwrap_or_else(|| "debugfs not found".to_string())
738 ))
739}
740
741fn e2fs_tool_candidates(tool: &str) -> Vec<PathBuf> {
742 let mut candidates = vec![PathBuf::from(tool)];

Callers 3

write_rootfs_image_fileFunction · 0.85

Calls 2

e2fs_tool_candidatesFunction · 0.85
successMethod · 0.45

Tested by

no test coverage detected