aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2019-06-06 21:18:11 -0700
committerPaul Eggert2019-06-07 00:44:45 -0700
commit486a81f387bb59b2fbbc6aff7b41adbe1621394e (patch)
tree7b61ed0a44666f10e4da54ef3e0905974c861944 /lib
parent111408a0e9eb3a9492c4057ac7d6ddbb8b365aa9 (diff)
downloademacs-486a81f387bb59b2fbbc6aff7b41adbe1621394e.tar.gz
emacs-486a81f387bb59b2fbbc6aff7b41adbe1621394e.zip
Use copy_file_range to copy files
The copy_file_range syscall (introduced in Linux kernel version 4.5) can copy files more efficiently via server-side copy etc. * admin/merge-gnulib (GNULIB_MODULES): Add copy-file-range. * lib/copy-file-range.c, m4/copy-file-range.m4: New files, copied from Gnulib. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * src/fileio.c (Fcopy_file): Try copy_file_range first, falling back on read+write only if copy_file_range failed or if the input is empty and so could be a /proc file.
Diffstat (limited to 'lib')
-rw-r--r--lib/copy-file-range.c33
-rw-r--r--lib/gnulib.mk.in12
2 files changed, 45 insertions, 0 deletions
diff --git a/lib/copy-file-range.c b/lib/copy-file-range.c
new file mode 100644
index 00000000000..39b5efbc1cc
--- /dev/null
+++ b/lib/copy-file-range.c
@@ -0,0 +1,33 @@
1/* Stub for copy_file_range
2 Copyright 2019 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#include <unistd.h>
20
21#include <errno.h>
22
23ssize_t
24copy_file_range (int infd, off_t *pinoff,
25 int outfd, off_t *poutoff,
26 size_t length, unsigned int flags)
27{
28 /* There is little need to emulate copy_file_range with read+write,
29 since programs that use copy_file_range must fall back on
30 read+write anyway. */
31 errno = ENOSYS;
32 return -1;
33}
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 403d83829cd..6e817fa6897 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -74,6 +74,7 @@
74# c-strcase \ 74# c-strcase \
75# careadlinkat \ 75# careadlinkat \
76# close-stream \ 76# close-stream \
77# copy-file-range \
77# count-leading-zeros \ 78# count-leading-zeros \
78# count-one-bits \ 79# count-one-bits \
79# count-trailing-zeros \ 80# count-trailing-zeros \
@@ -1274,6 +1275,17 @@ EXTRA_DIST += close-stream.h
1274endif 1275endif
1275## end gnulib module close-stream 1276## end gnulib module close-stream
1276 1277
1278## begin gnulib module copy-file-range
1279ifeq (,$(OMIT_GNULIB_MODULE_copy-file-range))
1280
1281
1282EXTRA_DIST += copy-file-range.c
1283
1284EXTRA_libgnu_a_SOURCES += copy-file-range.c
1285
1286endif
1287## end gnulib module copy-file-range
1288
1277## begin gnulib module count-leading-zeros 1289## begin gnulib module count-leading-zeros
1278ifeq (,$(OMIT_GNULIB_MODULE_count-leading-zeros)) 1290ifeq (,$(OMIT_GNULIB_MODULE_count-leading-zeros))
1279 1291