1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-26 08:55:18 +03:00

repart: always honour --discard=no

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>
(cherry picked from commit 5113436b05)
(cherry picked from commit 4abc5b2cfe)
This commit is contained in:
Arnaud Ferraris 2022-10-04 18:52:33 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 6d6e6a6be1
commit b1881b45b7

View File

@ -2428,6 +2428,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