From 7757fdd491862fa5c33f1f894503346b89898a01 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 13 May 2024 12:02:30 +0200 Subject: daemon: Loop over ‘copy_file_range’ upon short writes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes . * nix/libutil/util.cc (copyFile): Loop over ‘copy_file_range’ instead of throwing upon short write. Reported-by: Ricardo Wurmus Change-Id: Id7b8a65ea59006c2d91bc23732309a68665b9ca0 --- nix/libutil/util.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc index 578d657293..3206dea11b 100644 --- a/nix/libutil/util.cc +++ b/nix/libutil/util.cc @@ -397,9 +397,14 @@ static void copyFile(int sourceFd, int destinationFd) } else { if (result < 0) throw SysError(format("copy_file_range `%1%' to `%2%'") % sourceFd % destinationFd); - if (result < st.st_size) - throw SysError(format("short write in copy_file_range `%1%' to `%2%'") - % sourceFd % destinationFd); + + /* If 'copy_file_range' copied less than requested, try again. */ + for (ssize_t copied = result; copied < st.st_size; copied += result) { + result = copy_file_range(sourceFd, NULL, destinationFd, NULL, + st.st_size - copied, 0); + if (result < 0) + throw SysError(format("copy_file_range `%1%' to `%2%'") % sourceFd % destinationFd); + } } } -- cgit v1.2.3 diff/nix/local.mk?id=bc3896db25c788c181c7bcd65754e7cd378e9d9f'>diff
AgeCommit message (Expand)Author
2020-10-27maint: Add 'etc/gnu-store.mount.in' to the distribution....Ludovic Courtès
2020-09-17guix-install.sh: Support OpenRC....Morgan Smith
2020-06-27daemon: Remove OpenSSL hash compatibility wrappers....Ludovic Courtès
2020-05-23build: Add a comment above the sysvinit section....Vincent Legoll
2020-05-17etc: Install mount unit only if it exists....Tobias Geerinckx-Rice
2020-05-16etc: Add a systemd unit to bind-mount @storedir@ read-only....Tobias Geerinckx-Rice
2020-03-11Add system start-up files for guix-daemon....Danny Milosavljevic