Currently the loader uses int as the return type for various APIs
that deal with file sizes, which leads to an error if the file
size is >=2GB, as it ends up being interpreted as a negative error
code. Furthermore, we do not tolerate short reads, which are possible
at least on Linux when attempting to read such large files in one
syscall.
Fix the first problem by switching to 64-bit types for file sizes,
and fix the second by introducing a loop around the read syscall.
Signed-off-by: Peter Collingbourne<pcc@google.com>
---
hw/core/generic-loader.c | 2 +-
hw/core/loader.c | 44 ++++++++++++++++++++++++----------------
include/hw/loader.h | 13 ++++++------
3 files changed, 34 insertions(+), 25 deletions(-)