2019-06-07 04:18:11 +00:00
|
|
|
/* Stub for copy_file_range
|
2024-01-02 01:47:10 +00:00
|
|
|
Copyright 2019-2024 Free Software Foundation, Inc.
|
2019-06-07 04:18:11 +00:00
|
|
|
|
Update from Gnulib
Make the following changes by hand, and run 'admin/merge-gnulib'.
* .gitignore: Add lib/malloc/*.gl.h.
* admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h
directly from Gnulib, without worrying about Gnulib modules,
as these files are special cases.
(AVOIDED_MODULES): Remove malloc-posix.
* lib/malloc.c, lib/realloc.c, m4/malloc.m4, m4/realloc.m4:
* m4/year2038.m4: New files, copied from Gnulib.
* lib/malloca.c, lib/malloca.h:
* m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4:
Remove. These are either no longer present in Gnulib, or are no
longer needed by modules that Emacs uses.
* oldXMenu/AddPane.c, oldXmenu/Addsel.c: Include XmenuInt.h first;
needed for new Gnulib.
* src/xmenu.c: Call emacs_abort, not abort.
2021-10-04 19:11:39 +00:00
|
|
|
This file 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.
|
2019-06-07 04:18:11 +00:00
|
|
|
|
Update from Gnulib
Make the following changes by hand, and run 'admin/merge-gnulib'.
* .gitignore: Add lib/malloc/*.gl.h.
* admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h
directly from Gnulib, without worrying about Gnulib modules,
as these files are special cases.
(AVOIDED_MODULES): Remove malloc-posix.
* lib/malloc.c, lib/realloc.c, m4/malloc.m4, m4/realloc.m4:
* m4/year2038.m4: New files, copied from Gnulib.
* lib/malloca.c, lib/malloca.h:
* m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4:
Remove. These are either no longer present in Gnulib, or are no
longer needed by modules that Emacs uses.
* oldXMenu/AddPane.c, oldXmenu/Addsel.c: Include XmenuInt.h first;
needed for new Gnulib.
* src/xmenu.c: Call emacs_abort, not abort.
2021-10-04 19:11:39 +00:00
|
|
|
This file is distributed in the hope that it will be useful,
|
2019-06-07 04:18:11 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Update from Gnulib
Make the following changes by hand, and run 'admin/merge-gnulib'.
* .gitignore: Add lib/malloc/*.gl.h.
* admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h
directly from Gnulib, without worrying about Gnulib modules,
as these files are special cases.
(AVOIDED_MODULES): Remove malloc-posix.
* lib/malloc.c, lib/realloc.c, m4/malloc.m4, m4/realloc.m4:
* m4/year2038.m4: New files, copied from Gnulib.
* lib/malloca.c, lib/malloca.h:
* m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4:
Remove. These are either no longer present in Gnulib, or are no
longer needed by modules that Emacs uses.
* oldXMenu/AddPane.c, oldXmenu/Addsel.c: Include XmenuInt.h first;
needed for new Gnulib.
* src/xmenu.c: Call emacs_abort, not abort.
2021-10-04 19:11:39 +00:00
|
|
|
GNU Lesser General Public License for more details.
|
2019-06-07 04:18:11 +00:00
|
|
|
|
Update from Gnulib
Make the following changes by hand, and run 'admin/merge-gnulib'.
* .gitignore: Add lib/malloc/*.gl.h.
* admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h
directly from Gnulib, without worrying about Gnulib modules,
as these files are special cases.
(AVOIDED_MODULES): Remove malloc-posix.
* lib/malloc.c, lib/realloc.c, m4/malloc.m4, m4/realloc.m4:
* m4/year2038.m4: New files, copied from Gnulib.
* lib/malloca.c, lib/malloca.h:
* m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4:
Remove. These are either no longer present in Gnulib, or are no
longer needed by modules that Emacs uses.
* oldXMenu/AddPane.c, oldXmenu/Addsel.c: Include XmenuInt.h first;
needed for new Gnulib.
* src/xmenu.c: Call emacs_abort, not abort.
2021-10-04 19:11:39 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2019-06-07 04:18:11 +00:00
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
2022-02-23 19:11:52 +00:00
|
|
|
#if defined __linux__ && HAVE_COPY_FILE_RANGE
|
|
|
|
# include <sys/utsname.h>
|
|
|
|
#endif
|
|
|
|
|
2019-06-07 04:18:11 +00:00
|
|
|
ssize_t
|
|
|
|
copy_file_range (int infd, off_t *pinoff,
|
|
|
|
int outfd, off_t *poutoff,
|
|
|
|
size_t length, unsigned int flags)
|
|
|
|
{
|
2022-02-23 19:11:52 +00:00
|
|
|
#undef copy_file_range
|
|
|
|
|
|
|
|
#if defined __linux__ && HAVE_COPY_FILE_RANGE
|
|
|
|
/* The implementation of copy_file_range (which first appeared in
|
|
|
|
Linux kernel release 4.5) had many issues before release 5.3
|
|
|
|
<https://lwn.net/Articles/789527/>, so fail with ENOSYS for Linux
|
|
|
|
kernels 5.2 and earlier.
|
|
|
|
|
|
|
|
This workaround, and the configure-time check for Linux, can be
|
|
|
|
removed when such kernels (released March 2016 through September
|
|
|
|
2019) are no longer a consideration. As of January 2021, the
|
|
|
|
furthest-future planned kernel EOL is December 2024 for kernel
|
|
|
|
release 4.19. */
|
|
|
|
|
|
|
|
static signed char ok;
|
|
|
|
|
|
|
|
if (! ok)
|
|
|
|
{
|
|
|
|
struct utsname name;
|
|
|
|
uname (&name);
|
|
|
|
char *p = name.release;
|
|
|
|
ok = ((p[1] != '.' || '5' < p[0]
|
|
|
|
|| (p[0] == '5' && (p[3] != '.' || '2' < p[2])))
|
|
|
|
? 1 : -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 < ok)
|
|
|
|
return copy_file_range (infd, pinoff, outfd, poutoff, length, flags);
|
|
|
|
#endif
|
|
|
|
|
2019-06-07 04:18:11 +00:00
|
|
|
/* There is little need to emulate copy_file_range with read+write,
|
|
|
|
since programs that use copy_file_range must fall back on
|
|
|
|
read+write anyway. */
|
|
|
|
errno = ENOSYS;
|
|
|
|
return -1;
|
|
|
|
}
|