diff options
author | Florian Weimer <fweimer@redhat.com> | 2017-12-22 10:55:40 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2017-12-22 10:55:40 +0100 |
commit | bad7a0c81f501fbbcc79af9eaa4b8254441c4a1f (patch) | |
tree | 2734074b2ca53301953e238e6ce362bdc94f9604 /sysdeps/unix | |
parent | 6cb86fd21ca6fdfc31042cda8c37f96c46b8a4da (diff) | |
download | glibc-bad7a0c81f501fbbcc79af9eaa4b8254441c4a1f.tar.gz glibc-bad7a0c81f501fbbcc79af9eaa4b8254441c4a1f.tar.xz glibc-bad7a0c81f501fbbcc79af9eaa4b8254441c4a1f.zip |
copy_file_range: New function to copy file data
The semantics are based on the Linux system call, but a very close emulation in user space is provided.
Diffstat (limited to 'sysdeps/unix')
29 files changed, 77 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist index ec0ead15dd..90c9bc84e1 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -2104,6 +2104,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index 5355769974..fd2d81fb68 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -2015,6 +2015,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist index 9bafe71b51..044ec102c2 100644 --- a/sysdeps/unix/sysv/linux/arm/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/libc.abilist @@ -105,6 +105,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/copy_file_range.c b/sysdeps/unix/sysv/linux/copy_file_range.c new file mode 100644 index 0000000000..1ec5f9d8d8 --- /dev/null +++ b/sysdeps/unix/sysv/linux/copy_file_range.c @@ -0,0 +1,46 @@ +/* Linux implementation of copy_file_range. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <sysdep-cancel.h> +#include <unistd.h> + +/* Include the fallback implementation. */ +#ifndef __ASSUME_COPY_FILE_RANGE +#define COPY_FILE_RANGE_DECL static +#define COPY_FILE_RANGE copy_file_range_compat +#include <io/copy_file_range-compat.c> +#endif + +ssize_t +copy_file_range (int infd, __off64_t *pinoff, + int outfd, __off64_t *poutoff, + size_t length, unsigned int flags) +{ +#ifdef __NR_copy_file_range + ssize_t ret = SYSCALL_CANCEL (copy_file_range, infd, pinoff, outfd, poutoff, + length, flags); +# ifndef __ASSUME_COPY_FILE_RANGE + if (ret == -1 && errno == ENOSYS) + ret = copy_file_range_compat (infd, pinoff, outfd, poutoff, length, flags); +# endif + return ret; +#else /* !__NR_copy_file_range */ + return copy_file_range_compat (infd, pinoff, outfd, poutoff, length, flags); +#endif +} diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist index 90aa8d034f..2360130abe 100644 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -1869,6 +1869,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index 4d44c30c64..39c993fd79 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -2034,6 +2034,7 @@ GLIBC_2.26 strtof128_l F GLIBC_2.26 wcstof128 F GLIBC_2.26 wcstof128_l F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist index 112fc57634..68496aa6ac 100644 --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist @@ -1898,6 +1898,7 @@ GLIBC_2.26 strtof128_l F GLIBC_2.26 wcstof128 F GLIBC_2.26 wcstof128_l F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 59b613377f..b9864790c7 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -111,3 +111,7 @@ #if __LINUX_KERNEL_VERSION >= 0x040400 # define __ASSUME_MLOCK2 1 #endif + +#if __LINUX_KERNEL_VERSION >= 0x040500 +# define __ASSUME_COPY_FILE_RANGE 1 +#endif diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index 2e8b6a4586..b676025261 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -106,6 +106,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index 3c33400f67..cdd1df55d0 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -1983,6 +1983,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist index e1b1a579d2..e4265fd74d 100644 --- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist @@ -2104,6 +2104,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index c1550323f3..3a7e0b4c29 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -1958,6 +1958,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist index 3b3a172e4f..5e805924fa 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -1956,6 +1956,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index 101ca7a241..1973fac36d 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -1954,6 +1954,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist index 2d129f7170..5e18ab83b4 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -1949,6 +1949,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist index 8bc350aff8..cc5885ab9b 100644 --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist @@ -2145,6 +2145,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index 127c426e1c..676aa50c81 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -1987,6 +1987,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index a9411318e2..2016c7c1e5 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -1992,6 +1992,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist index d7bf5db601..3d19e38dbd 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist @@ -2199,6 +2199,7 @@ GLIBC_2.26 strtof128_l F GLIBC_2.26 wcstof128 F GLIBC_2.26 wcstof128_l F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist index a3415a72ac..c57ab21b82 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist @@ -106,6 +106,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index 414338f9a2..25903720e3 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -1987,6 +1987,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index f0f7a69b64..5d6800c236 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -1888,6 +1888,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist index 9f95aba898..c04872ca7f 100644 --- a/sysdeps/unix/sysv/linux/sh/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/libc.abilist @@ -1873,6 +1873,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index 83fbdf2d7e..85cbe308d6 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -1980,6 +1980,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index ee84ad10bc..f7a1ab8edb 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -1917,6 +1917,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist index dcbfbc05ac..ab56ecee44 100644 --- a/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist +++ b/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist @@ -2111,6 +2111,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist index 53dc99c45a..f2518c08ff 100644 --- a/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist +++ b/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist @@ -2111,6 +2111,7 @@ GLIBC_2.26 pwritev2 F GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist index ae4dcaa47e..2a3cc40674 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -1875,6 +1875,7 @@ GLIBC_2.26 strtof128_l F GLIBC_2.26 wcstof128 F GLIBC_2.26 wcstof128_l F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index 0dbda14796..8bc16b9004 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -2118,6 +2118,7 @@ GLIBC_2.26 strtof128_l F GLIBC_2.26 wcstof128 F GLIBC_2.26 wcstof128_l F GLIBC_2.27 GLIBC_2.27 A +GLIBC_2.27 copy_file_range F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F |