]> git.ipfire.org Git - thirdparty/systemd.git/commit
repart: Fix growing the partition preceding a FreeArea from leftover space
authorJonas Dreßler <verdre@v0yd.nl>
Mon, 13 Jul 2026 11:56:03 +0000 (13:56 +0200)
committerJonas Dreßler <verdre@v0yd.nl>
Mon, 13 Jul 2026 16:24:25 +0000 (18:24 +0200)
commit0ea9bdfec8fb898fcd9db15383e041aec2306d62
tree7637bb99dd282656523bdba8be09131bbe400245
parent2e1c8bc3d779f3d3ba90c640d771a619d1f86bd1
repart: Fix growing the partition preceding a FreeArea from leftover space

The "Donate to preceding partition" logic is dead code since commit
19903a4 ("repart: split out context_grow_partition_one()").
context_grow_partition_one() gets passed a free area and a partition, and it has
an early-return check to ensure the partition it got passed belongs to the free
area it got passed. That means we compare the FreeArea a to the FreeArea
a->after->allocated_to_area, which always yields FALSE.

Fix the behavior of donating any left over space to the preceding partition
by adding that partition to the loop below (and relying on the partitions list
being ordered according to physical partition offsets).

Since this behavior is not that easy to trigger, mention how to trigger it in a
comment, and add a test for it as well.
src/repart/repart.c
test/units/TEST-58-REPART.sh