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

Function run_debugfs_batch_file

crates/openshell-driver-vm/src/rootfs.rs:670–704  ·  view source on GitHub ↗
(image_path: &Path, command_path: &Path)

Source from the content-addressed store, hash-verified

668}
669
670fn run_debugfs_batch_file(image_path: &Path, command_path: &Path) -> Result<(), String> {
671 let mut last_error = None;
672 for candidate in e2fs_tool_candidates("debugfs") {
673 let label = candidate.display().to_string();
674 let output = Command::new(&candidate)
675 .arg("-w")
676 .arg("-f")
677 .arg(command_path)
678 .arg(image_path)
679 .output();
680 match output {
681 Ok(output) if output.status.success() => return Ok(()),
682 Ok(output) => {
683 last_error = Some(format!(
684 "{label} failed with status {}\nstdout: {}\nstderr: {}",
685 output.status,
686 String::from_utf8_lossy(&output.stdout),
687 String::from_utf8_lossy(&output.stderr)
688 ));
689 }
690 Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
691 last_error = Some(format!("{label} not found"));
692 }
693 Err(err) => {
694 last_error = Some(format!("run {label}: {err}"));
695 }
696 }
697 }
698 Err(format!(
699 "debugfs batch {} failed for {}: {}. Install e2fsprogs (debugfs) and retry",
700 command_path.display(),
701 image_path.display(),
702 last_error.unwrap_or_else(|| "debugfs not found".to_string())
703 ))
704}
705
706fn run_debugfs(image_path: &Path, command: &str) -> Result<(), String> {
707 let mut last_error = None;

Callers 1

run_debugfs_batchFunction · 0.85

Calls 2

e2fs_tool_candidatesFunction · 0.85
successMethod · 0.45

Tested by

no test coverage detected