]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/missing: add copy_file_range
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 15 Mar 2016 23:26:30 +0000 (19:26 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 17 Mar 2016 17:02:18 +0000 (13:02 -0400)
syscall numbers based on:
https://fedora.juszkiewicz.com.pl/syscalls.html

configure.ac
src/basic/missing.h

index 79340bcca956df1001220758e42d6a7befd9277e..cb14abda05cc9d3f7316f79d6a995f579b95967c 100644 (file)
@@ -296,8 +296,19 @@ LIBS="$save_LIBS"
 AC_SUBST(CAP_LIBS)
 
 AC_CHECK_FUNCS([__secure_getenv secure_getenv])
-AC_CHECK_DECLS([memfd_create, gettid, pivot_root, name_to_handle_at, setns, getrandom, renameat2, kcmp, keyctl, LO_FLAGS_PARTSCAN],
-               [], [], [[
+AC_CHECK_DECLS([
+        memfd_create,
+        gettid,
+        pivot_root,
+        name_to_handle_at,
+        setns,
+        getrandom,
+        renameat2,
+        kcmp,
+        keyctl,
+        LO_FLAGS_PARTSCAN,
+        copy_file_range],
+        [], [], [[
 #include <sys/types.h>
 #include <unistd.h>
 #include <sys/mount.h>
index 417604aa649a9c7b1a6cf0f0ef61efd0734658ac..bdea7606e6896f8a5f8a45789032dde2ab1f8d95 100644 (file)
@@ -1177,3 +1177,33 @@ static inline key_serial_t request_key(const char *type, const char *description
 #endif
 
 #endif
+
+#ifndef __NR_copy_file_range
+#  if defined(__x86_64__)
+#    define __NR_copy_file_range 326
+#  elif defined(__i386__)
+#    define __NR_copy_file_range 377
+#  elif defined __s390__
+#    define __NR_copy_file_range 375
+#  elif defined __arm__
+#    define __NR_copy_file_range 391
+#  elif defined __aarch64__
+#    define __NR_copy_file_range 285
+#  else
+#    warning "__NR_copy_file_range not defined for your architecture"
+#  endif
+#endif
+
+#if !HAVE_DECL_COPY_FILE_RANGE
+static inline ssize_t copy_file_range(int fd_in, loff_t *off_in,
+                                      int fd_out, loff_t *off_out,
+                                      size_t len,
+                                      unsigned int flags) {
+#ifdef __NR_copy_file_range
+        return syscall(__NR_copy_file_range, fd_in, off_in, fd_out, off_out, len, flags);
+#else
+        errno = ENOSYS;
+        return -1;
+#endif
+}
+#endif