Skip to content

Commit c15fe51

Browse files
committedOct 11, 2022
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
1 parent 86f8d42 commit c15fe51

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
 

‎NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ PHP NEWS
1414
- Streams:
1515
. Fixed bug GH-9590 (stream_select does not abort upon exception or empty
1616
valid fd set). (Arnaud)
17+
. Fixed bug GH-9653 (file copy between different filesystems). (David Carlier)
1718

1819
29 Sep 2022, PHP 8.2.0RC3
1920

‎configure.ac

+27-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ PHP_CHECK_FUNC(socketpair, socket, network)
364364
PHP_CHECK_FUNC(htonl, socket, network)
365365
PHP_CHECK_FUNC(gethostname, nsl, network)
366366
PHP_CHECK_FUNC(gethostbyaddr, nsl, network)
367-
PHP_CHECK_FUNC(copy_file_range)
368367
PHP_CHECK_FUNC(dlopen, dl, root)
369368
PHP_CHECK_FUNC(dlsym, dl, root)
370369
if test "$ac_cv_func_dlopen" = "yes"; then
@@ -691,6 +690,33 @@ if test "$ac_cv_func_getaddrinfo" = yes; then
691690
AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function])
692691
fi
693692

693+
AC_CACHE_CHECK([for copy_file_range], ac_cv_copy_file_range,
694+
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
695+
#ifdef __linux__
696+
#ifndef _GNU_SOURCE
697+
#define _GNU_SOURCE
698+
#endif
699+
#include <linux/version.h>
700+
#include <unistd.h>
701+
702+
int main(void) {
703+
(void)copy_file_range(-1, 0, -1, 0, 0, 0);
704+
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,3,0)
705+
#error "kernel too old"
706+
#else
707+
return 0;
708+
#endif
709+
}
710+
#else
711+
#error "unsupported platform"
712+
#endif
713+
]])], [ac_cv_copy_file_range=yes], [ac_cv_copy_file_range=no])
714+
])
715+
716+
if test "$ac_cv_copy_file_range" = yes; then
717+
AC_DEFINE(HAVE_COPY_FILE_RANGE,1,[Define if copy_file_range support])
718+
fi
719+
694720
AC_REPLACE_FUNCS(strlcat strlcpy explicit_bzero getopt)
695721
AC_FUNC_ALLOCA
696722
PHP_TIME_R_TYPE

0 commit comments

Comments
 (0)