Fix GH-9653: does not inconditionally support copy_file_range on older kernels.

As mentioned in its manpage, it had been reworked in the 5.3 line to support cross filesystem interactions.
Closes #GH-9656
This commit is contained in:
David Carlier 2022-10-02 12:55:00 +01:00
parent 86f8d423dd
commit c15fe51918
2 changed files with 28 additions and 1 deletions

1
NEWS
View File

@ -14,6 +14,7 @@ PHP NEWS
- Streams:
. Fixed bug GH-9590 (stream_select does not abort upon exception or empty
valid fd set). (Arnaud)
. Fixed bug GH-9653 (file copy between different filesystems). (David Carlier)
29 Sep 2022, PHP 8.2.0RC3

View File

@ -364,7 +364,6 @@ PHP_CHECK_FUNC(socketpair, socket, network)
PHP_CHECK_FUNC(htonl, socket, network)
PHP_CHECK_FUNC(gethostname, nsl, network)
PHP_CHECK_FUNC(gethostbyaddr, nsl, network)
PHP_CHECK_FUNC(copy_file_range)
PHP_CHECK_FUNC(dlopen, dl, root)
PHP_CHECK_FUNC(dlsym, dl, root)
if test "$ac_cv_func_dlopen" = "yes"; then
@ -691,6 +690,33 @@ if test "$ac_cv_func_getaddrinfo" = yes; then
AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function])
fi
AC_CACHE_CHECK([for copy_file_range], ac_cv_copy_file_range,
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
#ifdef __linux__
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <linux/version.h>
#include <unistd.h>
int main(void) {
(void)copy_file_range(-1, 0, -1, 0, 0, 0);
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,3,0)
#error "kernel too old"
#else
return 0;
#endif
}
#else
#error "unsupported platform"
#endif
]])], [ac_cv_copy_file_range=yes], [ac_cv_copy_file_range=no])
])
if test "$ac_cv_copy_file_range" = yes; then
AC_DEFINE(HAVE_COPY_FILE_RANGE,1,[Define if copy_file_range support])
fi
AC_REPLACE_FUNCS(strlcat strlcpy explicit_bzero getopt)
AC_FUNC_ALLOCA
PHP_TIME_R_TYPE