1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-29 21:55:36 +03:00

repart: check if existing partitions can grow

Fixes #24553.
This commit is contained in:
Yu Watanabe 2022-09-05 21:57:38 +09:00
parent 58b06ac1ab
commit cdbcc33952

View File

@ -645,6 +645,12 @@ static bool context_allocate_partitions(Context *context, uint64_t *ret_largest_
context->n_free_areas == 0 ? 0 :
free_area_available_for_new_partitions(context, context->free_areas[context->n_free_areas-1]);
/* Check that each existing partition can fit its area. */
for (size_t i = 0; i < context->n_free_areas; i++)
if (free_area_current_end(context, context->free_areas[i]) <
free_area_min_end(context, context->free_areas[i]))
return false;
/* A simple first-fit algorithm. We return true if we can fit the partitions in, otherwise false. */
LIST_FOREACH(partitions, p, context->partitions) {
bool fits = false;