git: c80c9fd9f6bc - stable/13 - linux: Fix ENOTSOCK handling in sendfile(2)

From: Edward Tomasz Napierala <trasz_at_FreeBSD.org>
Date: Thu, 17 Feb 2022 12:54:34 UTC
The branch stable/13 has been updated by trasz:

URL: https://cgit.FreeBSD.org/src/commit/?id=c80c9fd9f6bccd35b6f7817149285c278c12025d

commit c80c9fd9f6bccd35b6f7817149285c278c12025d
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-10-23 08:15:37 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2022-02-13 22:25:12 +0000

    linux: Fix ENOTSOCK handling in sendfile(2)
    
    The Linux way for sendfile(2) to tell the application
    to fallback to another way of copying data is by EINVAL,
    not ENOTSOCK.  This fixes package installation scripts
    for Mono packages from Focal.
    
    Sponsored By:   EPSRC
    Differential Revision:  https://reviews.freebsd.org/D32604
    
    (cherry picked from commit 2c7f7982825442c851e8bb17555a086a232ef4d9)
---
 sys/compat/linux/linux_socket.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index 707426582bbc..e9d9e3f60fcf 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -2057,6 +2057,8 @@ linux_sendfile_common(struct thread *td, l_int out, l_int in,
 	td->td_retval[0] = (ssize_t)bytes_read;
 drop:
 	fdrop(fp, td);
+	if (error == ENOTSOCK)
+		error = EINVAL;
 	return (error);
 }