From 8d1d01717552c3384e9cf02b7b0daf79ac734bfd Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Sat, 18 Jul 2020 11:28:40 +0000 Subject: [PATCH] Add a trivial linux(4) splice(2) implementation, which simply returns EINVAL. Fixes grep (grep-3.1-2build1). PR: kern/218699 Reported by: avos Reviewed by: emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25636 --- sys/amd64/linux/linux_dummy.c | 1 - sys/amd64/linux/syscalls.master | 9 ++++++++- sys/amd64/linux32/linux32_dummy.c | 1 - sys/amd64/linux32/syscalls.master | 9 ++++++++- sys/arm64/linux/linux_dummy.c | 1 - sys/arm64/linux/syscalls.master | 9 ++++++++- sys/compat/linux/linux_file.c | 14 ++++++++++++++ sys/i386/linux/linux_dummy.c | 1 - sys/i386/linux/syscalls.master | 9 ++++++++- 9 files changed, 46 insertions(+), 8 deletions(-) diff --git a/sys/amd64/linux/linux_dummy.c b/sys/amd64/linux/linux_dummy.c index 0e8c39b993b3..d8bd0d997244 100644 --- a/sys/amd64/linux/linux_dummy.c +++ b/sys/amd64/linux/linux_dummy.c @@ -105,7 +105,6 @@ DUMMY(inotify_rm_watch); DUMMY(migrate_pages); DUMMY(unshare); /* Linux 2.6.17: */ -DUMMY(splice); DUMMY(tee); DUMMY(vmsplice); /* Linux 2.6.18: */ diff --git a/sys/amd64/linux/syscalls.master b/sys/amd64/linux/syscalls.master index 91da10676669..e7dfd77a522b 100644 --- a/sys/amd64/linux/syscalls.master +++ b/sys/amd64/linux/syscalls.master @@ -1612,7 +1612,14 @@ ); } 275 AUE_NULL STD { - int linux_splice(void); + int linux_splice( + int fd_in, + l_loff_t *off_in, + int fd_out, + l_loff_t *off_out, + l_size_t len, + l_uint flags + ); } 276 AUE_NULL STD { int linux_tee(void); diff --git a/sys/amd64/linux32/linux32_dummy.c b/sys/amd64/linux32/linux32_dummy.c index 98037ad09b4a..7cf7cb593b8d 100644 --- a/sys/amd64/linux32/linux32_dummy.c +++ b/sys/amd64/linux32/linux32_dummy.c @@ -102,7 +102,6 @@ DUMMY(inotify_rm_watch); DUMMY(migrate_pages); DUMMY(unshare); /* Linux 2.6.17: */ -DUMMY(splice); DUMMY(tee); DUMMY(vmsplice); /* Linux 2.6.18: */ diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master index fa10fbfb9369..97d448f8d9c3 100644 --- a/sys/amd64/linux32/syscalls.master +++ b/sys/amd64/linux32/syscalls.master @@ -1731,7 +1731,14 @@ ); } 313 AUE_NULL STD { - int linux_splice(void); + int linux_splice( + int fd_in, + l_loff_t *off_in, + int fd_out, + l_loff_t *off_out, + l_size_t len, + l_uint flags + ); } 314 AUE_NULL STD { int linux_sync_file_range( diff --git a/sys/arm64/linux/linux_dummy.c b/sys/arm64/linux/linux_dummy.c index bbae98f919a9..ad56a0eec4e9 100644 --- a/sys/arm64/linux/linux_dummy.c +++ b/sys/arm64/linux/linux_dummy.c @@ -98,7 +98,6 @@ DUMMY(inotify_rm_watch); DUMMY(migrate_pages); DUMMY(unshare); /* Linux 2.6.17: */ -DUMMY(splice); DUMMY(tee); DUMMY(vmsplice); /* Linux 2.6.18: */ diff --git a/sys/arm64/linux/syscalls.master b/sys/arm64/linux/syscalls.master index 9a259c02ad45..81d888e44492 100644 --- a/sys/arm64/linux/syscalls.master +++ b/sys/arm64/linux/syscalls.master @@ -467,7 +467,14 @@ int linux_vmsplice(void); } 76 AUE_NULL STD { - int linux_splice(void); + int linux_splice( + int fd_in, + l_loff_t *off_in, + int fd_out, + l_loff_t *off_out, + l_size_t len, + l_uint flags + ); } 77 AUE_NULL STD { int linux_tee(void); diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 377e0ef4d34a..3267bf2313ef 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -1766,3 +1766,17 @@ linux_memfd_create(struct thread *td, struct linux_memfd_create_args *args) return (kern_shm_open2(td, SHM_ANON, oflags, 0, shmflags, NULL, memfd_name)); } + +int +linux_splice(struct thread *td, struct linux_splice_args *args) +{ + + linux_msg(td, "syscall splice not really implemented"); + + /* + * splice(2) is documented to return EINVAL in various circumstances; + * returning it instead of ENOSYS should hint the caller to use fallback + * instead. + */ + return (EINVAL); +} diff --git a/sys/i386/linux/linux_dummy.c b/sys/i386/linux/linux_dummy.c index b014f9e38561..3ede71769f12 100644 --- a/sys/i386/linux/linux_dummy.c +++ b/sys/i386/linux/linux_dummy.c @@ -98,7 +98,6 @@ DUMMY(inotify_rm_watch); DUMMY(migrate_pages); DUMMY(unshare); /* Linux 2.6.17: */ -DUMMY(splice); DUMMY(tee); DUMMY(vmsplice); /* Linux 2.6.18: */ diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master index 1c7deecd8b58..7f7c124d2d14 100644 --- a/sys/i386/linux/syscalls.master +++ b/sys/i386/linux/syscalls.master @@ -1753,7 +1753,14 @@ ); } 313 AUE_NULL STD { - int linux_splice(void); + int linux_splice( + int fd_in, + l_loff_t *off_in, + int fd_out, + l_loff_t *off_out, + l_size_t len, + l_uint flags + ); } 314 AUE_NULL STD { int linux_sync_file_range(