]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: always honour `--discard=no`
authorArnaud Ferraris <aferraris@debian.org>
Tue, 4 Oct 2022 16:52:33 +0000 (18:52 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 6 Oct 2022 15:27:47 +0000 (17:27 +0200)
Currently, even if `--discard=no` is passed to `systemd-repart`, the
`context_discard_gap_after()` function still runs normally, discarding
e.g. all blocks between the GPT and the start of the first partition.

This can lead to issues on some embedded devices, where this space
holds the bootloader and shouldn't be modified (creating a protective
partition there is not always possible due to the specifics of the boot
process of some ARM-based SoC's).

This commit ensures passing `--discard=no` would be enough to ensure
the bootloader isn't wiped in such cases.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@gmail.com>
src/partition/repart.c

index 92aa9a25eb29533885b3c6d497a8d59b7bf2a917..721a196a9a6b26e49fa8b88118badc07a11c6aae 100644 (file)
@@ -2843,6 +2843,9 @@ static int context_discard_gap_after(Context *context, Partition *p) {
         assert(context);
         assert(!p || (p->offset != UINT64_MAX && p->new_size != UINT64_MAX));
 
+        if (!arg_discard)
+                return 0;
+
         if (p)
                 gap = p->offset + p->new_size;
         else