170 lines
4.4 KiB
Rust
170 lines
4.4 KiB
Rust
#![allow(dead_code, unused_imports, unused_variables)]
|
|
use crate::cli::Method;
|
|
use crate::device::inspect::DeviceInfo;
|
|
use crate::mount::discover::MountInfo;
|
|
|
|
pub fn print_warning(info: &DeviceInfo, method: Method, passes: u32) {
|
|
eprintln!("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
|
eprintln!("WARNING");
|
|
eprintln!("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
|
eprintln!();
|
|
eprintln!("ALL DATA on this device will be permanently destroyed.");
|
|
eprintln!();
|
|
eprintln!("Device:");
|
|
eprintln!(" {}", info.path.display());
|
|
eprintln!();
|
|
if let Some(model) = &info.model {
|
|
if !model.is_empty() {
|
|
eprintln!("Model:");
|
|
eprintln!(" {model}");
|
|
eprintln!();
|
|
}
|
|
}
|
|
if let Some(serial) = &info.serial {
|
|
if !serial.is_empty() {
|
|
eprintln!("Serial:");
|
|
eprintln!(" {serial}");
|
|
eprintln!();
|
|
}
|
|
}
|
|
if let Some(size) = info.size_bytes {
|
|
eprintln!("Size:");
|
|
// Use format from inspect
|
|
let human = crate::device::inspect::format_human_size(size);
|
|
eprintln!(" {human} ({size} bytes)");
|
|
eprintln!();
|
|
}
|
|
eprintln!("Method:");
|
|
eprintln!(" {method}");
|
|
eprintln!();
|
|
eprintln!("Passes:");
|
|
eprintln!(" {passes}");
|
|
eprintln!();
|
|
eprintln!("This operation cannot be undone.");
|
|
eprintln!();
|
|
}
|
|
|
|
pub fn print_dry_run(
|
|
info: &DeviceInfo,
|
|
mounts: &[MountInfo],
|
|
method: Method,
|
|
passes: u32,
|
|
buffer_size: usize,
|
|
will_unmount: bool,
|
|
) {
|
|
println!("Device");
|
|
println!(" Path {}", info.path.display());
|
|
println!(
|
|
" Type {}",
|
|
if info.rota == Some(true) {
|
|
"HDD"
|
|
} else if info.rota == Some(false) {
|
|
"SSD/NVMe"
|
|
} else {
|
|
"unknown"
|
|
}
|
|
);
|
|
if let Some(size) = info.size_bytes {
|
|
println!(
|
|
" Size {}",
|
|
crate::device::inspect::format_human_size(size)
|
|
);
|
|
}
|
|
if let Some(model) = &info.model {
|
|
if !model.is_empty() {
|
|
println!(" Model {model}");
|
|
}
|
|
}
|
|
if let Some(serial) = &info.serial {
|
|
if !serial.is_empty() {
|
|
println!(" Serial {serial}");
|
|
}
|
|
}
|
|
println!(
|
|
" Rotational {}",
|
|
info.rota
|
|
.map(|v| if v { "yes" } else { "no" })
|
|
.unwrap_or("unknown")
|
|
);
|
|
if let Some(tran) = &info.tran {
|
|
println!(" Transport {tran}");
|
|
}
|
|
println!();
|
|
println!("Partitions");
|
|
if info.partitions.is_empty() {
|
|
println!(" (none)");
|
|
} else {
|
|
for p in &info.partitions {
|
|
let mp = if p.mountpoints.is_empty() {
|
|
String::new()
|
|
} else {
|
|
format!(" -> {}", p.mountpoints.join(", "))
|
|
};
|
|
println!(" {}{}", p.path.display(), mp);
|
|
}
|
|
}
|
|
println!();
|
|
println!("Mounted");
|
|
if mounts.is_empty() {
|
|
println!(" (none)");
|
|
} else {
|
|
for m in mounts {
|
|
println!(" {} -> {}", m.source, m.target);
|
|
}
|
|
}
|
|
if will_unmount && !mounts.is_empty() {
|
|
println!();
|
|
println!("Action");
|
|
for m in mounts {
|
|
if m.target == "[SWAP]" {
|
|
println!(" swapoff {}", m.source);
|
|
} else {
|
|
println!(" unmount {}", m.target);
|
|
}
|
|
}
|
|
}
|
|
println!();
|
|
println!("Method");
|
|
println!(" {method}");
|
|
println!();
|
|
println!("Passes");
|
|
println!(" {passes}");
|
|
println!();
|
|
println!("Buffer");
|
|
println!(
|
|
" {}",
|
|
crate::device::inspect::format_human_size(buffer_size as u64)
|
|
);
|
|
println!();
|
|
println!("Estimated operation");
|
|
println!(" destructive: YES");
|
|
println!();
|
|
println!("DRY RUN");
|
|
println!("No data will be modified.");
|
|
}
|
|
|
|
pub fn print_result_human(
|
|
success: bool,
|
|
device: &str,
|
|
method: &str,
|
|
passes: u32,
|
|
verification: bool,
|
|
verified: bool,
|
|
) {
|
|
if success {
|
|
println!("Wipe completed successfully");
|
|
println!(" Device: {device}");
|
|
println!(" Method: {method}");
|
|
println!(" Passes: {passes}");
|
|
if verification {
|
|
if verified {
|
|
println!(" Verification: OVERWRITE_VERIFIED");
|
|
} else {
|
|
println!(" Verification: FAILED");
|
|
}
|
|
}
|
|
} else {
|
|
eprintln!("Wipe failed");
|
|
}
|
|
}
|