Can decompress raw files to sparse file

This commit is contained in:
2025-05-29 15:41:08 +02:00
parent 42f22c110c
commit 21fd5de139
2 changed files with 20 additions and 0 deletions

View File

@ -129,3 +129,9 @@ pub const COPY_PROGRAM: &str = "/bin/cp";
/// Gzip program path
pub const GZIP_PROGRAM: &str = "/usr/bin/gzip";
/// Bash program
pub const BASH_PROGRAM: &str = "/usr/bin/bash";
/// DD program
pub const DD_PROGRAM: &str = "/usr/bin/dd";

View File

@ -251,6 +251,20 @@ impl DiskFileInfo {
cmd
}
// Decompress Raw to sparse file
// https://benou.fr/www/ben/decompressing-sparse-files.html
(DiskFileFormat::CompressedRaw, DiskFileFormat::Raw { is_sparse: true }) => {
let mut cmd = Command::new(constants::BASH_PROGRAM);
cmd.arg("-c").arg(format!(
"{} -d -c {} | {} conv=sparse of={}",
constants::GZIP_PROGRAM,
self.file_path.display(),
constants::DD_PROGRAM,
temp_file.display()
));
cmd
}
// Dumb copy of file
(a, b) if a == b => {
let mut cmd = Command::new(constants::COPY_PROGRAM);