On Mon, Jul 26, 2021 at 06:28:57PM +0100, Richard W.M. Jones wrote: > Although it probably cannot happen on Linux, POSIX allows pread/pwrite > to return or write fewer bytes than requested. The cache and cow > filters didn't handle this situation. Replace the raw > pread(2)/pwrite(2) syscalls with alternate versions which can handle > this.
Short reads and writes are unlikely to happen for regular files, but are a definite possibility on named FIFOs, as well as block and char devices. While our local cache happens to use a regular file, it is indeed always better practice to write robust code. > --- > common/utils/Makefile.am | 1 + > common/utils/utils.h | 2 + > common/utils/full-rw.c | 81 ++++++++++++++++++++++++++++++++++++++++ > filters/cache/blk.c | 10 ++--- > filters/cow/blk.c | 6 +-- > 5 files changed, 92 insertions(+), 8 deletions(-) > -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org _______________________________________________ Libguestfs mailing list [email protected] https://listman.redhat.com/mailman/listinfo/libguestfs
