coredump: correctly take tmpfs size into account for compression
authorLuca Boccassi <bluca@debian.org>
Tue, 2 Jul 2024 14:28:47 +0000 (15:28 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 2 Jul 2024 23:15:03 +0000 (01:15 +0200)
commite6b2508275aac2951aedfc842735d8ebc29850bb
tree06b18e341b1e440596e87dcaa4512d50b4115ce6
parent4b7249111a4c1d366f476bdbd6e03f7893eb9d42
coredump: correctly take tmpfs size into account for compression

We calculate the amount of uncompressed data we can write by taking the limits
into account and halving it to ensure there's room for switching to compression
on the fly when storing cores on a tmpfs (eg: due read-only rootfs).

But the logic is flawed, as taking into account the size of the tmpfs storage
was applied after the halving, so in practice when an uncompressed core file
was larger than the tmpfs, we fill it and then fail.

Rearrange the logic so that the halving is done after taking into account
the tmpfs size.
src/coredump/coredump.c