From 077d51909d3d7bc2d52afd47c9be1de8ee4f0756 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 11 Dec 2024 14:02:28 -0800 Subject: internal/poll: in SendFile treat ENOTSUP like EOPNOTSUPP Fixes #70763 Change-Id: Ifb79b5b0529f7977df0fe1b59d224b8b31df2c9b Reviewed-on: https://go-review.googlesource.com/c/go/+/635396 Reviewed-by: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Damien Neil Auto-Submit: Ian Lance Taylor --- src/internal/poll/sendfile_unix.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/internal/poll') diff --git a/src/internal/poll/sendfile_unix.go b/src/internal/poll/sendfile_unix.go index f5aee38a05..1105e05691 100644 --- a/src/internal/poll/sendfile_unix.go +++ b/src/internal/poll/sendfile_unix.go @@ -110,12 +110,20 @@ func sendFile(dstFD *FD, src int, offset *int64, size int64) (written int64, err // Retry. case syscall.ENOSYS, syscall.EOPNOTSUPP, syscall.EINVAL: // ENOSYS indicates no kernel support for sendfile. - // EINVAL indicates a FD type which does not support sendfile. + // EINVAL indicates a FD type that does not support sendfile. // // On Linux, copy_file_range can return EOPNOTSUPP when copying // to a NFS file (issue #40731); check for it here just in case. return written, err, written > 0 default: + // We want to handle ENOTSUP like EOPNOTSUPP. + // It's a pain to put it as a switch case + // because on Linux systems ENOTSUP == EOPNOTSUPP, + // so the compiler complains about a duplicate case. + if err == syscall.ENOTSUP { + return written, err, written > 0 + } + // Not a retryable error. return written, err, true } -- cgit v1.3-6-g1900