git: 2c7f79828254 - main - linux: Fix ENOTSOCK handling in sendfile(2)

From: Edward Tomasz Napierala <trasz_at_FreeBSD.org>
Date: Sat, 23 Oct 2021 08:27:00 UTC
The branch main has been updated by trasz:

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

commit 2c7f7982825442c851e8bb17555a086a232ef4d9
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-10-23 08:15:37 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2021-10-23 08:15:58 +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
---
 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 9ae44b909d80..a2b45edf7bdc 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -2101,6 +2101,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);
 }