From a55a3604bd65a6d42f41ce09a36ac295a90c7b28 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 23 Apr 2023 21:04:31 +0200 Subject: [PATCH] Fallback from sendfile64() in case of ENOSYS as well As suggested on https://man7.org/linux/man-pages/man2/sendfile.2.html. --- io/copy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/io/copy.h b/io/copy.h index d8441fb..dba0ec2 100644 --- a/io/copy.h +++ b/io/copy.h @@ -114,7 +114,7 @@ template void CopyHelper::copy(NativeFileSt while (count) { const auto bytesCopied = ::sendfile64(output.fileDescriptor(), input.fileDescriptor(), nullptr, count); if (bytesCopied < 0) { - if (errno == EINVAL && static_cast(totalBytes) == count) { + if ((errno == EINVAL || errno == ENOSYS) && static_cast(totalBytes) == count) { // try again the unoptimized version, maybe the filesystem doesn't support sendfile goto unoptimized_version; } @@ -163,7 +163,7 @@ void CopyHelper::callbackCopy(NativeFileStream &input, NativeFileStr const auto bytesToCopy = static_cast(std::min(count, static_cast(bufferSize))); const auto bytesCopied = ::sendfile64(output.fileDescriptor(), input.fileDescriptor(), nullptr, bytesToCopy); if (bytesCopied < 0) { - if (errno == EINVAL && static_cast(totalBytes) == count) { + if ((errno == EINVAL || errno == ENOSYS) && static_cast(totalBytes) == count) { // try again the unoptimized version, maybe the filesystem doesn't support sendfile goto unoptimized_version; }