summaryrefslogtreecommitdiff
path: root/src/basic/missing.h
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-03-15 19:26:30 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-03-17 13:02:18 -0400
commit1d4b557d1b5cd200b27562808c690653658ffadf (patch)
tree0f49973729ab79de05e5522a2c8e88af26d5fbf1 /src/basic/missing.h
parent7a827fcb115b6e03e351599db76f247e199d6351 (diff)
basic/missing: add copy_file_range
syscall numbers based on: https://fedora.juszkiewicz.com.pl/syscalls.html
Diffstat (limited to 'src/basic/missing.h')
-rw-r--r--src/basic/missing.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/basic/missing.h b/src/basic/missing.h
index 417604aa64..bdea7606e6 100644
--- a/src/basic/missing.h
+++ b/src/basic/missing.h
@@ -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