checksum: avoid mmap'ing potentially huge files
checksum: avoid mmap'ing potentially huge files

An update of a rootfs may easily measure several 100 MB, maybe more in
some cases. On an embedded device with perhaps only 512 or 1024 MB of
memory, mmap'ing such a huge file is problematic in several ways:
There's no guarantee we even have sufficient address space (on a 32 bit
machine), the update bundle may be placed in tmpfs, so we're already
tight on memory (and, being squashfs, the kernel can't reuse page cache
between the bundle file in tmpfs and the file from inside the bundle
we're reading), and despite the pages being clean, so the kernel could
theoretically just drop them at any time, the fact that they're mapped
into a (root-owned) process makes the kernel a little more reluctant to
discard them.

It's not much more code to just do a standard read-till-EOF loop, and
that may even be more efficient (since we read the file explicitly
instead of relying on page faults). We can adjust 4096, or allocate a
larger heap buffer (say, 64K or something) if need be.

Signed-off-by: Rasmus Villemoes <4a950b3c050761f138a737fe02e762ea6e8a2378@prevas.dk>

ejoerns/rauc,rauc/rauc,rauc/rauc,jluebbe/rauc,rauc/rauc,ejoerns/rauc,jluebbe/rauc,jluebbe/rauc,ejoerns/rauc