From a08267faaf5d6fdb2d4387399c762f1ceebce82e Mon Sep 17 00:00:00 2001 From: Alex Lyn Date: Tue, 26 May 2026 14:37:01 +0800 Subject: [PATCH] runtime-rs: Track GPT partition padding files for cleanup When a GPT-partitioned VMDK is split into individual partition images, padding files may be generated between partitions to maintain correct byte offsets. These were not tracked for cleanup, leading to stale temporary files after container removal. Iterate over the partition layout and check for pad-{idx}.img files alongside the head image; add any that exist to gpt_metadata_paths so they are removed during teardown. Signed-off-by: Alex Lyn --- .../crates/resource/src/rootfs/erofs_rootfs.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/runtime-rs/crates/resource/src/rootfs/erofs_rootfs.rs b/src/runtime-rs/crates/resource/src/rootfs/erofs_rootfs.rs index c31185ae1e..9d47e5f321 100644 --- a/src/runtime-rs/crates/resource/src/rootfs/erofs_rootfs.rs +++ b/src/runtime-rs/crates/resource/src/rootfs/erofs_rootfs.rs @@ -730,6 +730,19 @@ impl ErofsMultiLayerRootfs { // Track GPT metadata files (head + padding) for cleanup gpt_metadata_paths.push(gpt_files.head_path.clone()); gpt_metadata_paths.extend(gpt_files.pad_paths.iter().cloned()); + for idx in 0..layout.partitions.len() { + if idx > 0 { + // Check for padding files (only created when there are gaps) + let pad_path = gpt_files + .head_path + .parent() + .unwrap() + .join(format!("pad-{}.img", idx)); + if pad_path.exists() { + gpt_metadata_paths.push(pad_path); + } + } + } info!( sl!(),