summaryrefslogtreecommitdiffstats
path: root/src/partition/repart.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-09-05 14:57:38 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-09-08 22:49:00 +0200
commitcdbcc3395207190824dda545032ab9216892fdbf (patch)
treef1b375ac89db86e3de0e5481d79e583d31a5ea4c /src/partition/repart.c
parentrepart: split out free_area_{current,min}_end() from free_area_available_for_... (diff)
downloadsystemd-cdbcc3395207190824dda545032ab9216892fdbf.tar.xz
systemd-cdbcc3395207190824dda545032ab9216892fdbf.zip
repart: check if existing partitions can grow
Fixes #24553.
Diffstat (limited to '')
-rw-r--r--src/partition/repart.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c
index 004022f6da..ae3c0bdb26 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -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;