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 <alex.lyn@antgroup.com>
This commit is contained in:
Alex Lyn
2026-05-26 14:37:01 +08:00
parent 51e8310ef3
commit a08267faaf

View File

@@ -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!(),