]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include: (fileutils.h) add fallback for the copy_file_range syscall
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Thu, 9 Apr 2026 15:08:41 +0000 (11:08 -0400)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Wed, 15 Apr 2026 12:18:26 +0000 (08:18 -0400)
Closes: #4212
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
include/fileutils.h
misc-utils/copyfilerange.c

index d6a15fd0ba23941821f13910d58f13f8d0ff30d9..d1b2ddf08f2a8fdced7c49ce2f0554e05cfd8a24 100644 (file)
@@ -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 */
 
 
index 41bf93e2e9484a24f24350bb5299e4a2a4d9c6f3..00c508fb548425e314fc58a82c4bcf0eb6ea4516 100644 (file)
@@ -32,6 +32,7 @@
 #include "nls.h"
 #include "closestream.h"
 #include "xalloc.h"
+#include "fileutils.h" /* fallback for copy_file_range() */
 
 static int verbose;