]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: split out that disarms automatic artifact removal
authorLennart Poettering <lennart@poettering.net>
Mon, 20 Oct 2025 14:09:52 +0000 (16:09 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 22 Oct 2025 20:56:01 +0000 (22:56 +0200)
src/repart/repart.c

index b74d9bb552bfb1ca7fe94c77989063e1f71c975f..0af92eea61c8b4ce6feda76165c443e2bfc530cf 100644 (file)
@@ -855,6 +855,16 @@ static Context* context_free(Context *context) {
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(Context*, context_free);
 
+static void context_disarm_auto_removal(Context *context) {
+        assert(context);
+
+        /* Make sure automatic removal of half-written artifacts is disarmed */
+        context->node = mfree(context->node);
+
+        LIST_FOREACH(partitions, p, context->partitions)
+                p->split_path = mfree(p->split_path);
+}
+
 static int context_add_free_area(
                 Context *context,
                 uint64_t size,
@@ -10177,10 +10187,7 @@ static int run(int argc, char *argv[]) {
 
         (void) context_dump(context, /*late=*/ true);
 
-        context->node = mfree(context->node);
-
-        LIST_FOREACH(partitions, p, context->partitions)
-                p->split_path = mfree(p->split_path);
+        context_disarm_auto_removal(context);
 
         return 0;
 }