Quellcode durchsuchen

add copy_file_range syscall wrapper

Waldemar Brodkorb vor 2 Wochen
Ursprung
Commit
64de3d95ca

+ 4 - 0
include/unistd.h

@@ -1263,6 +1263,10 @@ extern int getentropy(void *__buf, size_t __len) __nonnull ((1)) __wur;
 extern __pid_t gettid(void);
 #endif
 
+#ifdef _GNU_SOURCE
+ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);
+#endif
+
 __END_DECLS
 
 

+ 1 - 0
libc/sysdeps/linux/common/Makefile.in

@@ -20,6 +20,7 @@ CSRC-$(UCLIBC_LINUX_SPECIFIC) += \
 	bdflush.c \
 	capget.c \
 	capset.c \
+	copy_file_range.c \
 	dup3.c \
 	euidaccess.c \
 	eventfd.c \

+ 36 - 0
libc/sysdeps/linux/common/copy_file_range.c

@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2005-2026 Rich Felker, et al.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Imported from musl C library, adapted to uClibc-ng
+ */
+
+#include <sys/syscall.h>
+
+#ifdef __NR_copy_file_range
+#include <fcntl.h>
+int copy_file_range(int fd_in, off_t *off_in, int fd_out, off_t *off_out,
+	size_t len, unsigned flags)
+{
+	return INLINE_SYSCALL(copy_file_range, 6, fd_in, off_in, fd_out,
+			      off_out, len, flags);
+}
+#endif