Add progress callback to clone function

This commit is contained in:
Jeremy Soller
2025-09-26 10:08:54 -06:00
parent 74582a0917
commit f37afb04bb
2 changed files with 42 additions and 15 deletions
+20 -8
View File
@@ -112,7 +112,17 @@ fn main() {
}
};
match clone(&mut fs_old, &mut fs) {
let size_old = fs_old.header.size();
let free_old = fs_old.allocator().free() * redoxfs::BLOCK_SIZE;
let used_old = size_old - free_old;
match clone(&mut fs_old, &mut fs, |used| {
eprint!(
"{}%: {}/{}\r",
(used * 100) / used_old,
used / 1000 / 1000,
used_old / 1000 / 1000
);
}) {
Ok(()) => (),
Err(err) => {
println!(
@@ -124,11 +134,13 @@ fn main() {
}
let uuid = Uuid::from_bytes(fs.header.uuid());
println!(
"redoxfs-clone: created filesystem on {}, reserved {} blocks, size {} MB, uuid {}",
disk_path,
fs.block,
fs.header.size() / 1000 / 1000,
uuid.hyphenated()
);
let size = fs.header.size();
let free = fs.allocator().free() * redoxfs::BLOCK_SIZE;
let used = size - free;
println!("redoxfs-clone: created filesystem on {}", disk_path,);
println!("\treserved: {} blocks", fs.block);
println!("\tuuid: {}", uuid.hyphenated());
println!("\tsize: {} MB", size / 1000 / 1000);
println!("\tused: {} MB", used / 1000 / 1000);
println!("\tfree: {} MB", free / 1000 / 1000);
}