From: Christian Goeschel Ndjomouo Date: Thu, 9 Apr 2026 15:08:41 +0000 (-0400) Subject: include: (fileutils.h) add fallback for the copy_file_range syscall X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d6986d4d0c5e6064644cd87c09ee668c9393e8a5;p=thirdparty%2Futil-linux.git include: (fileutils.h) add fallback for the copy_file_range syscall Closes: #4212 Signed-off-by: Christian Goeschel Ndjomouo --- diff --git a/include/fileutils.h b/include/fileutils.h index d6a15fd0b..d1b2ddf08 100644 --- a/include/fileutils.h +++ b/include/fileutils.h @@ -103,6 +103,16 @@ static inline int statx(int fd, const char *restrict path, int flags, # define HAVE_STATX 1 # endif /* SYS_statx */ +# if !defined(HAVE_COPY_FILE_RANGE) && defined(SYS_copy_file_range) +static inline ssize_t copy_file_range(int fd_in, off_t *off_in, + int fd_out, off_t *off_out, size_t size, unsigned int flags) +{ + return syscall(SYS_copy_file_range, fd_in, off_in, fd_out, + off_out, size, flags); +} +# define HAVE_COPY_FILE_RANGE 1 +# endif /* SYS_copy_file_range */ + #endif /* HAVE_SYS_SYSCALL_H */ diff --git a/misc-utils/copyfilerange.c b/misc-utils/copyfilerange.c index 41bf93e2e..00c508fb5 100644 --- a/misc-utils/copyfilerange.c +++ b/misc-utils/copyfilerange.c @@ -32,6 +32,7 @@ #include "nls.h" #include "closestream.h" #include "xalloc.h" +#include "fileutils.h" /* fallback for copy_file_range() */ static int verbose;